Flash As3 Mute Button problems
Posted
by Lee
on Stack Overflow
See other posts from Stack Overflow
or by Lee
Published on 2010-03-11T16:09:50Z
Indexed on
2010/03/12
7:17 UTC
Read the original article
Hit count: 405
Hey guys,
I am trying to create a UI movie clip that can be used across different scenes. It uses variables from the root scope to determine states.
When i press the mute button is works fine, however when i try to un-mute things go weird. Sometimes it takes 2 clicks to unmute, sometimes more. It seems random. Muting however seems to work first time..
Any ideas?
Main Timeline:
var mute:Boolean = false; var playerName = "Fred";
function setMute(vol) { var sTransform:SoundTransform = new SoundTransform(1,0); sTransform.volume = vol; SoundMixer.soundTransform = sTransform; }
function toggleMuteBtn(event:Event) { if (mute) { // Sound On, Mute Off mute = false; setMute(1); ui_mc.muteCross_mc.visible = false; } else { // Sound Off, Mute On mute = true; setMute(0); ui_mc.muteCross_mc.visible = true; } }
ui_mc Action Script:
if (MovieClip(parent).mute == false) { muteCross_mc.visible = false; }
mute_btn.addEventListener(MouseEvent.CLICK, MovieClip(parent).toggleMuteBtn);
© Stack Overflow or respective owner