ForumsProgramming ForumAnyone work with Armor Game's animation swf before?

3 9799
Quells
offline
Quells
2 posts
Nomad

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&quot] 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&quot 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?
  • 3 Replies
Showing 106-105 of 3