Master Volume Control in AS3.0

Source code after the jump.

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:

Related Posts

stop all sounds in Flash AS3 Garbage Collector in AS3 New categories Fusekit Tutorial #2 Actionscript 3.0 Basics: The Moving Ball

Related Posts

Popular Posts


Leave Your Response

* Name, Email, Comment are Required

Nuffnang Ad

Advertisement