Flash: How to Mute or control volume of sounds embedded on the timeline

by troy on April 13, 2009

How the mute a clip on the timeline?!! With all the of the classes in the AS3 Sound Arsenal (SoundMixer, SoundChannel, Sound, SoundTransform..oh my!), this is simple but not as self evident so here it is.

In AS2 it looked like this

//AS2------------
var sound21:Sound = new Sound(someSpriteOrMovieClass);
sound21.setVolume(0);

Every Sprite based displayobject has a soundTransform. Counter-intuitively, setting the soundTransform.volume does nothing. To control volume you HAVE to set it to a new SoundTransform with the desired values.

AS3:

 //AS3-----------
someSpriteOrMovieClass.soundTransform = new SoundTransform(0);

{ 3 comments… read them below or add one }

Yanith January 27, 2010 at 9:44 pm

cool
hope u can help me, how can i the audio if i have a mp3playerMC playing throughout 5 sections and i only need to mute the audio in one, so they can listen to other audio clips or movies.

thanks

Usman March 10, 2012 at 6:59 am

Thanks, its Works

arun August 12, 2012 at 9:41 am

Thank you so much for this As2

Leave a Comment

 

{ 1 trackback }

Previous post:

Next post: