Skip to main content
Participant
May 6, 2008
Question

buttons

  • May 6, 2008
  • 2 replies
  • 280 views
I have a problem - any help would be appreciated

I have five buttons 1,2,3,4,5
and I want a client to press the 5 buttons in a sequence, there is only one sequence that is correct, wen they press the correct sequence then they go to a frame telling them of there success, i would like the answer, 'correct' or 'wrong, try again' to occur after the pressing of the 5th button - any ideas?
This topic has been closed for replies.

2 replies

May 6, 2008
You could also use Strings:

1. Insert 5 buttons called btn1, btn2, btn3, btn4 and btn5
2. Place this script in frame 1 (the correct sequence, "12345", may of course be changed):

var corSeq:String = "12345";
var actSeq:String = "";

for(var i:uint=1;i<6;i++){
this["btn"+i].addEventListener(MouseEvent.CLICK,btnOnClick);
}

function btnOnClick(ev:MouseEvent):void{
actSeq += ev.target.name.substring(3,4);
if(actSeq.length == corSeq.length){
if (actSeq == corSeq){
trace("Correct");
} else {
trace("Incorrect");
}
actSeq = "";
}
}
Inspiring
May 6, 2008
Create an array with the correct sequence of buttons, and another blank array which gets filled with the buttons clicked by the user. After five buttons have been clicked compare the two arrays and do what you have to do accordingly.

Hope this helps.