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

3 9607
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
weirdlike
offline
weirdlike
1,299 posts
Prince

This question would be good to ask @Tasselfoot
I myself have never tried this but I can suggest

swf_loader.unloadAndStop();
removeChild(swf_loader);
swf_loader = null;

Tasselfoot
offline
Tasselfoot
795 posts
Chamberlain

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.

Quells
offline
Quells
2 posts
Nomad

Thanks weirdlike! swf_loader.unloadAndStop() was exactly what was needed.

Yeah, I thought the preloader issue was weird too. I figured it was something really simple that was missing. Anywho, glad it's over. Thanks again

Showing 1-3 of 3