I was creating a Flash 9 App for a client, the app was working fine. But, the client requested to the app to play a pre existing introduction.swf and then continue as before.
My strategy was to load a separate swf from the Main swf and then remove it when it had reached a certain point, and continue with the Main swf.
To implement this I used the Flash 9 Loader class and the ExternalMovie Class.
The Main Document Class loads the introduction.swf by the calls:
var urlRequest:URLRequest=new URLRequest(“introduction.swf”);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
loader.load(urlRequest);
The onCompleteHandler() Method assigns the clip var and adds it to the DisplayList, and establishes a reference with the swf:Object instance, so the events can be listened to.
clip = loadEvent.currentTarget.content;
addChild(clip);
var loaderInfo:LoaderInfo = loadEvent.target as LoaderInfo;
var swf:Object = loaderInfo.content;
swf.addEventListener(Event.COMPLETE, onIntroCompleteHandler);
}
The swf to be loaded has it’s Document Class set to ExternalMove. When the introduction.swf reaches a certain from it calls a method animationComplete(). The animationComplete() method dispatches an Event.COMPLETE.
This is the Event which the Main Document Class is waiting for, and the onIntroCompleteHandler() Method is called, which removes the introduction.swf and continues with the Main Movie.
removeChild(clip);
loadMcg(); // continues with Main Movie
}