I have an agreement with a flash portal site to create a sitelock version of my game for them. However, their logo animation is an external swf that I believe is an AS2 swf. I’m having problems playing & stopping it. I’ve put together some hacky code to get it to play but when I remove it the sound continues to loop.
[Embed(source = "graphics/logo.swf", mimeType = "application/octet-stream")] private var LOGO_ANIM:Class;
private var swf_loader:Loader;
private var child_swf:DisplayObject;
private var preloader_ld: Loader;
private var preloader_ld_loaded: MovieClip;
private var frame_counter:int = 0;
private function _StartUpAnim():void {
preloader_ld = new Loader();
preloader_ld.loadBytes(new LOGO_ANIM as ByteArray);
preloader_ld.contentLoaderInfo.addEventListener(Event.COMPLETE, _LoadHandler);
}
private function _LoadHandler(e:Event = null):void {
// Note: e.loader.content is an AVM1Movie. I have not had any luck casting this to a MoveClip.
child_swf = (e.target.content as DisplayObject);
swf_loader = e.currentTarget.loader;
addChild(swf_loader);
child_swf.addEventListener(Event.ENTER_FRAME, _EnterFrame);
}
private function _EnterFrame(e:Event):void {
frame_counter += 1;
// Hacky way to stop the swf. Since I am unable to cast to a MoveClip, I do not have access to totalFrames and currFrame properties.
if (frame_counter > 200) {
child_swf.removeEventListener(Event.ENTER_FRAME, _EnterFrame);
removeChild(swf_loader);
// Code to go to game's main menu
var mainClass:Class = getDefinitionByName("Main") as Class;
parent.addChild(new mainClass as DisplayObject);
parent.removeChild(this);
}
}
This hacky method does seem to work. My main problem is that after I removeChild(swfLoader), the sound for their logo continues to play & loop forever. Any idea how to clean out this swf/AVM1 movie?