Stopping some sounds from dynamic classes, and exlude some others
The sound I开发者_如何学编程 wanted to stop or play are separates into background music and button sound effect. I know you could use SoundMixer.stopAll() to stop all sound, and some how exclude the bg music, IF everything is written in the same class. But what if the sounds are called from others dynamic classes? How could I target them and exclude the bg Music?
if i were you i would set up something like a singleton or static class for music/sound and register all sounds with that, therefore you can run it all in the single class.
a basic Singleton pattern as3 overview
Definitely look into creating a sound manager class that keeps all the sounds together, like shortstick suggested.
And, to stop a sound you would keep an instance of its SoundChannel, like
var mySound:SoundChannel = (new mySoundClass).play();
when you need to stop that sound:
mySound.stop()
精彩评论