Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   Общие вопросы о Flash (не затрагивающие ActionScript) (http://www.flasher.ru/forum/forumdisplay.php?f=60)
-   -   Добавление движения при изменении размера рабочего места (http://www.flasher.ru/forum/showthread.php?t=80373)

Lucero 27.05.2006 13:43

Добавление движения при изменении размера рабочего места
 
Подскажите, пожалуйста, почему при компиляции выдаются ошибки? По идее, здесь должно получиться добавление движения на примере скольжения уголков на свои места. При запуске ролика углы постепенно появляются и скользят на свои позиции каждый раз при изменении размеров окна браузера или проигрывателя Flash.
Код:

fscommand("allowscale", "false");
Stage.scaleMode="showAll";
Stage.originalWidth=Stage.Width;
Stage.originalHeight=Stage.Height;
Stage.scaleMode="noScale"
Stage.onResize=function(){
        this.left=this.getLeft();
        this.top=this.getTop();
        this.right=this.getRight();
        this.bottom=this.getBottom();
};
Stage.getLeft=function(){
        return-1*(this.width-this.originalWidth)/2;
};
Stage.getTop=function(){
        return-1*(this.height-this.originalHeight)/2;
};
Stage.getRight=function(){
        return this.left+this.width;
};
Stage.getBottom=function(){
        return this.top+this.height;
};
Stage.addListener(Stage);
Stage.addListener(tl);
Stage.addListener(tr);
Stage.addListener(bl);
Stage.addListener(br);
MovieClip.prototype.slideTo=function(x, y, speed, callbackObj, callbackFunc){
        var noo
        if (this.slideControl){
                noo=this.slideControl;
                }else{
                        noo=this.createEmptyMovieClip("slideControl",this.depth++);
                }
                noo.tx=x;
                noo.ty=y;
                noo.speed=speed;
                noo.callBackObj=callBackObj;
                noo.callBackFunc=callBackFunc;
                noo.onEnterFrame=function(){
                        this._parent._x+=(this.tx-this._parent._x)/this.speed;
                        this._parent._y+=(this.ty-this._parent._y)/this.speed;
                        if(Math.abs(this.tx-this._parent._x)<0.2&&Math.abs(this.ty-this._parent._y)<0.2){
                                this._parent._x=this.tx;
                                this._parent._y=this.ty;
                                this.callBackObj [this.callBackFunc] (this._parent);
                                this.removeMovieClip();
                        }
                };
};
tl.onResize=function(){
        var x=Stage.left;
        var y=Stage.top;
        this.slideTo(x,y,5);
};
tr.onResize=function(){
        var x=Stage.right-this._width;
        var y=Stage.top;
        this.slideTo(x,y,5);
};
bl.onResize=function(){
        var x=Stage.left;
        var y=Stage.bottom-this._height;
        this.slideTo(x,y,5);
};
br.onResize=function(){
        var x=Stage.right-this._width;
        var y=Stage.bottom-this._height;
        this.slideTo(x,y,5);
};


MIX-er 27.05.2006 16:21

Stage.originalWidth=Stage.Width; <= чо за...???

и не проще ли юзать Tween'ы???

MIX-er 27.05.2006 16:49

моё мнение о вашем уровне знаний флеш... скорее всего прототип который вы используете написан не вами... но это не суть

1. во флеш исчисление координат начинается с левого верхнего угла, поэтому не нада центровать содержимое мувика поцентру!!!

2. советую использовать нормальные имена... так myMC_mc-мувик myTf_txt - текст поле и т.д.

Код:

Stage.showMenu = false;
Stage.align = "TL";
var myListener:Object = new Object();
myListener.onResize = function() {
        br.slideTo(Stage.width-br_mc._width, Stage.height-br_mc._height, 15);
        bl.slideTo(0, Stage.height-br_mc._height, 15);
        tr.slideTo(Stage.width-br_mc._width, 0, 15);
        tl.slideTo(0, 0, 15);
};
Stage.addListener(myListener);
MovieClip.prototype.slideTo = function(x, y, speed, callbackObj, callbackFunc) {
        var noo;
        if (this.slideControl) {
                noo = this.slideControl;
        } else {
                noo = this.createEmptyMovieClip("slideControl", this.depth++);
        }
        noo.tx = x;
        noo.ty = y;
        noo.speed = speed;
        noo.callBackObj = callBackObj;
        noo.callBackFunc = callBackFunc;
        noo.onEnterFrame = function() {
                this._parent._x += (this.tx-this._parent._x)/this.speed;
                this._parent._y += (this.ty-this._parent._y)/this.speed;
                if (Math.abs(this.tx-this._parent._x)<0.2 && Math.abs(this.ty-this._parent._y)<0.2) {
                        this._parent._x = this.tx;
                        this._parent._y = this.ty;
                        this.callBackObj[this.callBackFunc](this._parent);
                        this.removeMovieClip();
                }
        };
};


Lucero 27.05.2006 18:05

Я и не говорила, что этот код мой, просто он у меня не получается, вот и все. этот код из книги Flash MX Справочник профессионала автор Дэнис Болдуин. Кстати, очень жаль, но то, что в итоге должно получиться опять не вышло и с вашим кодом :(


Часовой пояс GMT +4, время: 14:01.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.