开发者

flash-as3 code execution order: accessing a flash pro instance after gotoAndStop()

this is a follow up question to this question

i have never actually got the flash-actionscript code execution order.

in flash pro i have an instance of a moveiclip on stage in frame one named tree1 and on frame 3 i have on the stage tree3.

in the document class i have this code:

stop();
var scaleFactor:Number = tree1.scaleX;
gotoAndStop(3);
tree3.scaleX = scaleFactor;

while this works开发者_Go百科 when testing on the desktop, this app will go mobile at the end

is this the correct way to go or should i register for a frameComplete event before accessing instances on a certain frame


So, just dont use the Document Class cause you will need to declare all the scenes from the beginning and will be complicate to manage each scene.

I suggest you to instance a simple MovieClip linked with his own class like the example SceneTree, put it on each Keyframe. You will have more control when you are entering or exiting each frame.

package  {

    import flash.display.MovieClip;
    import flash.events.Event;


    public class SceneTree extends MovieClip {


        public function SceneTree() {
            super();
            this.addEventListener(Event.ADDED_TO_STAGE, Init);
            this.addEventListener(Event.REMOVED_FROM_STAGE, removed);
        }
        protected function Init (event:Event):void{
            trace("added")
        }
        protected function removed (event:Event):void{
            trace("removed")
        }

    }

}


waiting for Event.FRAME_CONSTRUCTED is the correct way whenever accessing assets on a timeline

it insures all assets have been created

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜