var soundOn:Boolean = true;
onoff_btn.addEventListener(MouseEvent.CLICK,toggleSound);
onoff_btn.buttonMode = true;
function toggleSound(e:MouseEvent)
{
if(soundOn)
{
// turn sound off
var s:SoundTransform = new SoundTransform();
s.volume=0;
SoundMixer.soundTransform=s;
onoff_btn.gotoAndPlay(1);
}
else // sound is off
{
// turn sound back on
s.volume=1;
SoundMixer.soundTransform=s;
onoff_btn.gotoAndStop(1);
}
}