Actionscript 3 removing swf audio does not stop

I'm trying to add an swf for a game cut scene but I have a problem of audio repeating after removeChild and setting the object to null. I'm trying to add the file and remove it after the length of frames in the animation (721) and remove it to move on to other things.

I've also tried cutscenes[0].stop(); and SoundMixer.stopAll(); as suggested by other posts.

removechild() does remove the visual aspect of the file/animation but not the audio, and it repeats after the amount of time of the length of the animation (721 frames) as though it is being reloaded. How can I stop the audio?

    package {
import flash.display.*;
    import flash.media.*;
    import flash.utils.*;
                import flash.events.*;
   [SWF(backgroundColor="#0000ff", frameRate="24", width="640", height="480")]
public class main extends MovieClip
{
    [Embed(source="/Cutscenes/Intro_Scene 1.swf")]
    private var scene1:Class
    public var cutscenes:Array = new Array();
    public var scene_exists:Boolean = false;
    public var scene_timer:Number = 0;
    public function main()
    {
        scene_exists = false;
        addEventListener(Event.ENTER_FRAME, play_intro);
    }

    public function play_intro(event:Event):void
    {
        scene_timer++;
        if (scene_exists == false) //Add cutscene
        {
            cutscenes[0] = new scene1();
            addChild(cutscenes[0]);
            scene_exists = true;
        }

        if (scene_timer == 721) //Remove cutscene
        {
            SoundMixer.stopAll();
            scene_exists = false;
            removeChild(cutscenes[0]);
            cutscenes[0] = null;
            scene_timer = 0;
            removeEventListener(Event.ENTER_FRAME, play_intro);
                            //Do next thing
        }
    }
}

}

Answers


Not sure if this is the issue, but try stopping the cutscene like this :

 cutscenes[0].stop();

Then do the SoundMixer.stopAll(); etc.

My thought is that the timeline of the .swf will keep playing and even repeat if not stopped.

Removing a DisplayObject from the display list does not stop the animation/audio from playing, it's just removing it from the display list.


Need Your Help

Java concurrency & distributed scenario

java concurrency distributed

I'm trying to understand the concurrency requirements for my application. Right now I'm storing in memory a Map with the recent updates for each user. The structure is the following:

Learning to program with Facebook or Foursquare APIs?

facebook api facebook-graph-api foursquare

I would like to know if there are online video resources to help people learn how to program using Facebook or Foursquare APIs?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.