I'm not quite sure that I completely understood your question. But if i did it right then here is the answer:
import flash.events.MouseEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
var SChannel : SoundChannel;
var sound : Sound;
// your sound managing buttons
sound_1.addEventListener ( MouseEvent.CLICK, handleChangeSound );
sound_2.addEventListener ( MouseEvent.CLICK, handleChangeSound );
sound_3.addEventListener ( MouseEvent.CLICK, handleChangeSound );
// sound off button
turn_off.addEventListener ( MouseEvent.CLICK, turnOffSound );
// sound off managining function
function turnOffSound ( e : MouseEvent ) : void
{
SChannel.stop();
SChannel = null;
sound = null;
}
// are sounds in your library Sound_1 (), Sound_2 (), Sound_3 ()
function handleChangeSound ( e : MouseEvent ) : void
{
// in my situation since the button names were sound_1, .._2, .._3
// i can extract the sound id from names of the button.
// if you have some different approach you just need to adopt it.
var soundID : uint = e.target.name.split ( '_' )[1];
// ifi sound is playing, stop it
if ( SChannel )
{
turnOffSound(null);
}
// create new sound, from ID given
switch ( soundID )
{
case 1 :
sound = new Sound_1 ();
break;
case 2 :
sound = new Sound_2 ();
break;
case 3 :
sound = new Sound_3 ();
break;
}
// if sound was in the list start playing it.
if ( sound )
{
SChannel = sound.play();
}
}
And by the way, use SoundMixer
, only when you are refering to the whole flash page to go silent.