Wind Chimez
Wind Chimez

Reputation: 1176

flex controlling application sound

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

Upvotes: 1

Views: 158

Answers (2)

PatrickS
PatrickS

Reputation: 9572

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.

Upvotes: 1

KensoDev
KensoDev

Reputation: 3285

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.

Upvotes: 0

Related Questions