I have a flex application in which multiple sound files are used in various parts of the application. Can i have a single sound handler, which will take care of volume control fo the entire application at once. How can i do that
A:
sure you can. I would use a singleton pattern here.
something like:
SoundManager.getInstance().setVolume(volumeLevel:Number);
SoundManager.getInstance().playSound(soundName:String);
//sounds - class refeance or MP3 path or something else
SoundManager.GONG;
SoundManager.SQUASH
if you have an application needs to play sounds, this is the way I would handle it, it's the best way IMHO.
Avi Tzurel
2010-08-16 13:16:02
A:
In order to control the volume globally , you can use the SoundMixer class.
private function set volume(level:Number ):void
{
var transform:SoundTransform = SoundMixer.soundTransform;
transform.volume = level;
}
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/
A Singleton class may be a little overkill since you only really need the above function to control the volume of the Sound globally.
PatrickS
2010-08-16 13:48:33