How to show and hide a movie clip with one button.
I'm pretty much new to Actionscript 3. I know this question has probably been asked and answered before but I just can't seen to get it right.
What I'm trying to do is when I click this button, this image that I have as a movie clip pops up and if I click the button again it hides, and so on.
This is the code I have written:
comS.alpha = 0;
CButton.addEventListener (MouseEvent.CLICK, FunctionName);
function FunctionName(event:MouseEvent):void
{
if (comS.alpha == 0){
comS.alpha = 1;} else {comS.alpha = 0}
}
It kinda works, but not really because when I click the button the movieclip shows up and hides again by itself after a second. It works if I erase the first line but I need that because I don't want the movie clip visible before clicking the button first.
Please help!
