Flash As3 Mute Button problems
- by Lee
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);