Reputation: 43
I'm having problems with an actionscript project. I have to ask the user a question 5 times, the user has to answer and when the user clicks a button, the answer has to be validated.
Is there a way to make a for-loop wait for a click event?
What i was thinking of was something like this :
for(teller = 0; teller < 5; teller++){
//show new question
//user answers , and when finished the user clicks the button
buttonNext.addEventListener(MouseEvent.CLICK,checkAnswer);
//it has to wait until the user clicks the button , and then begin all over again
}
Upvotes: 1
Views: 134
Reputation: 7253
Yes, but do it in a different way (not using for loops):
var questionsAnswered = 0; //in class files put this higher up
nextQuestionButton.addEventListener(MouseEvent.CLICK, nextQuestion);
function nextQuestion(e:MouseEvent){
trace(questionsAnswered);
questionsAnswered++;
// Logic here
}
Upvotes: 2