Skip to content


Actionscript 3 Method to Stop All Sounds within Flash Player

So I have some audio playing on one of my pages within my Flash movie, but I wanted it to stop playing when the user travels away from the audio page. I know in Actionscript 1 and possibly Actionscript 2 the stopAllSounds() method was available. I soon discovered that in Actionscript 3 you can achieve the same results by:

1. Include the SoundMixer class

// make sure you import this class:
import flash.media.SoundMixer;

2. Call the Method within your code:

SoundMixer.stopAll();

Posted in Actionscript 3, Audio.


27 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. MADAWEB says

    Thank you very much. It works.
    Regards.

  2. alp says

    thanks a lot :)
    I have been looking for it.

  3. frulli says

    THAAAAANKSSSS! :D

  4. Bodo says

    thanks a lot too ;-)

  5. Truhgoy says

    Thanks, just what I needed :-)

  6. rlyn says

    thanks!!!.. works perfect.. (^^,)..

    does this apply for video players too?.

  7. Renattto says

    Hey, it really works!
    Thanks! ^^

  8. Seamus says

    Brilliant Thanks :)

  9. raheem says

    how do you start the sounds again after you have stopped them

  10. david says

    Thank you.

  11. Lueran says

    Thank you for the info.

  12. Jayel Draco says

    so simple and so helpful

  13. magda says

    Exactly what I needed. Thank you.

  14. Kary says

    This isn’t working for me. I have several SWF files loading into the UILoader. I have placed SoundMixer.stopAll(); inside the button function. When I click the buttons to load the SWF’s once, it works fine, but when I click a second time, all the sounds start playing. It seems this technique will only work if you have one SWF file that has a sound, but not more than one.

    Are there any tweaks to this that would correct his problem?

  15. admin says

    Kary, I did a little search in regards to your issue. Are all your files within the same security sandbox? Here is some info from Adobe:

    By default, calling the SoundMixer.stopAll() method stops only sounds in the same security sandbox as the object that is calling the method. Any sounds whose playback was not started from the same sandbox as the calling object are not stopped.

    When you load the sound, using the load() method of the Sound class, you can specify a context parameter, which is a SoundLoaderContext object. If you set the checkPolicyFile property of the SoundLoaderContext object to true, Flash Player or Adobe AIR checks for a cross-domain policy file on the server from which the sound is loaded. If the server has a cross-domain policy file, and the file permits the domain of the calling content, then the file can stop the loaded sound by using the SoundMixer.stopAll() method; otherwise it cannot.

  16. Иван says

    Отлично написано. А это все на основе личного опыта?Позвольте полюбопытствовать :)

  17. Rich says

    great tip. exactly what i was looking for, much appreciated.

  18. J says

    nice. simple. functional.

  19. Phil says

    Thank you.

    Your page has a good PageRank, was the first one on Google looking for “Stop all Sounds AS3″ :D

  20. B.Sudhakar Reddy says

    Its very nice. But i am using multiple sounds in my presentation, How to stop a particular sound which are loading from external. Kindly please help me.

  21. maggie says

    I can’t thank you enough. It works beautifully.

  22. Somebody says

    This doesn’t work 100% of the time. If you exit the video frame before it starts loading, the video will sound in the other frame until you call back the function.

  23. noypi says

    wow..i’ve been seeking for this scrip for long time…i love u dude…hahahah…”im a beginner in flash”..tnx

  24. samBrown says

    massive bigups – been banging my head on this for the past couple days, this solution works
    - thank you!

  25. IceCube says

    Thx a lot …

  26. g.simms says

    Great! Spent 2 hours looking for this :/ Works perfectly.

  27. Bruno says

    THANKS!!!!!



Some HTML is OK

or, reply to this post via trackback.