Master Volume Control in AS3.0

Applied to a single button. Frame 1 shows that sound is on, and frame 2 shows that it’s off.

sound_mc.buttonMode = true
sound_mc.addEventListener(MouseEvent.CLICK,toggleSound)

function toggleSound(e:MouseEvent){
	var tempMC:MovieClip = e.currentTarget as MovieClip
	var sTransform:SoundTransform = new SoundTransform(1,0);
	if(tempMC.currentFrame == 1){
		tempMC.gotoAndStop(2)
		sTransform.volume = 0;
	}else if(tempMC.currentFrame == 2){
		tempMC.gotoAndStop(1)
		sTransform.volume = 1;
	}
	SoundMixer.soundTransform = sTransform;
}

If this post helped you in any way, help me in return by clicking on the ad below:

One Response to “Master Volume Control in AS3.0”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>