I'm trying to embed armor game's logo onto my game. It was provided to me as a swf file, and I'm having trouble working with it. My game is made with AS3 and the flashpunk library, and I believe the logo swf is made with AS2.
Here is the code I have so far.
[Embed(source = "graphics/logo.swf", mimeType = "application/octet-stream"] private var LOGO_ANIM:Class; private var swf_loader:Loader; private var child_swfisplayObject; 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 code successfully plays the swf animation. The problem is that after it plays and I remove it, the sound for the logo continues to play & loop indefinitely. Any idea how to stop the sound?
I was the one who told him to ask the community... but I meant the dev framework community, not the Armor community. Such as FGLs forums or Flashpunk's forums.
As someone with 0 programming experience, my understanding is that you need to have it in the 1st frame and then you do something similar (or identical) to what weirdlike mentions. In flash itself (Flash 8; I'm dating myself, I know)... I'm pretty sure you could even just specify it to only run once, instead of looping.
Speaking with some devs I know, you should be able to just call 'stop()'. Sorry that I can't be of more help for you... I do assure you it should be a simple fix, as we rarely/never get issues with the preloader.