Copy link to clipboard
Copied
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
public class Main extends Sprite
{
private var loader:Loader;
private var mc:MovieClip;
public function Main():void
{
trace("entry point");
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest("some.swf"));
mc = new MovieClip();
mc.addEventListener(Event.ENTER_FRAME, onEnterFrameListener);
}
private function onComplete(e:Event):void
{
trace("onComplete");
loader.removeEventListener(Event.COMPLETE, onComplete);
}
private function onEnterFrameListener(e:Event):void
{
trace("onEnterFrameListener: start");
mc.nextFrame();//prevFrame(); gotoAndStop(); gotoAndPlay();
trace("onEnterFrameListener: end");
}
}
}
result:
...
onEnterFrameListener: start
onComplete
onEnterFrameListener: end
...
Why?
Copy link to clipboard
Copied
It is not clear what you are asking "Why?" about. If you are wondering why the onEnterFrame: start happens first it is probably because the ENTER_FRAME event listener is triggered before the file being loaded has finished being loaded. What are your expectations?
Copy link to clipboard
Copied
The function can not be interrupted during its execution.
If you remove the nextFrame() method, and put in its place anything except the gotoAndStop() gotoAndPlay() or prevFrame(), then the result is as follows:
...
onEnterFrameListener: start
onEnterFrameListener: end
onComplete
...
I can not understand why the function was suspended. No event can not abort the function before it is completed.