开发者

Stopping some sounds from dynamic classes, and exlude some others

开发者 https://www.devze.com 2022-12-27 08:09 出处:网络
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 b

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()

0

精彩评论

暂无评论...
验证码 换一张
取 消