I am using the following code to mute sound in a flash file - basically turning the volume to 0 or 1.
It works fine until I go to a different scene. Once I load a new scene the button no longer works.
I know it will be something stupid that is causing this, however, I am too stupid to figure it out unfortunately!!
var soundOn:Boolean = true;
onoff_btn.addEventListener(MouseEvent.CLICK,toggleSound);
//onoff_btn.buttonMode = true;
function toggleSound(e:MouseEvent)
{
var s:SoundTransform = new SoundTransform();
if(soundOn)
{
// turn sound off
s.volume=0;
SoundMixer.soundTransform=s;
soundOn=false;
//onoff_btn.gotoAndPlay(1);
}
else // sound is off
{
// turn sound back on
s.volume=1;
SoundMixer.soundTransform=s;
soundOn=true;
//onoff_btn.gotoAndStop(1);
}
}