Detecting if a button is clicked
I am trying to make it so if you click the 5 buttons on my main page frame it will advance you to another frame. The problem I am having is that the buttons that you click take you away from the main page frame. So say the main page frame is on frame 1. buttons 1-5 take you t frames 2-6 (within the main movie frame). I would like to be able to send the user to page 7 once the 5 buttons are clicked, but I am running into problems with detecting if the button was clicked. Here is my code with "main" being the movieclip that everything else is inside.
var clickCount:int = 0;
var clipArray:Array = [main.btn1_mc, main.btn2_mc, main.btn3_mc, main.btn4_mc, main.btn5_mc];
for (var i:int = 0; i < clipArray.length; i++) {
clipArray.buttonMode = true;
clipArray.addEventListener(MouseEvent.CLICK, clickHandler);
clipArray.isClicked = false;
}
function clickHandler(event:MouseEvent):void {
switch (event.currentTarget) {
case main.btn1_mc :
trace("btn1");
break;
case main.btn2_mc :
trace("btn2");
break;
case main.btn3_mc :
trace("btn3");
break;
case main.btn4_mc :
trace("btn4");
break;
case main.btn5_mc :
trace("btn5");
break;
}
clickCount++;
trace(clickCount);
if(event.currentTarget.isClicked == false){
event.currentTarget.isClicked = true;
}
if(clickCount == clipArray.length){
trace("All buttons have been clicked");
}
}
stop();
any help is appreciated as always. Thanks
