Return to Snippet

Revision: 21291
at December 9, 2009 04:28 by kinski


Initial Code
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);
    }
}

Initial URL

                                

Initial Description

                                

Initial Title
As3 sound toggle

Initial Tags

                                

Initial Language
ActionScript 3