views:

12

answers:

2

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