Topic: Game Programming / external swf removeChild not stopping audio
I’ve ran into an issue I’d like a second opinion on. I’m trying to get a cutscene to play for a game intro but when removeChild is called the audio continues.
Basically this code creates a new instance of an swf then stops it at a certain frame
[code]
public function intro(event:Event):void
{
//Reset to begin with in case event called again.
if (timer > 120)
timer = 0;
if (scene_exists == false)
{
scenes0 = new scene1();
scenes0.looping = false;
addChild(cutscenes0);
scene_exists = true;
}
if (timer == 120)
{
scenes0.stop();
SoundMixer.stopAll();
scene_exists = false;
removeChild(cutscenes0);
scenes0 = null;
scenes = 0;
timer = 0;
removeEventListener(Event.ENTER_FRAME, play_intro);
//Do other stuff();
}
timer++;
}
[/code]
I’ve tried .stop with no luck. SoundMixer.stopAll(); stops all sounds but eventually the .swf file loops and the sounds start back. A loader might but one solution but I really need the animation embedded.
Another weird thing is I’ve used code real similar to this for cutscenes before and it works for a different swf with only modifying the frame counter (timer).