我遇到了动作脚本项目的问题。 我必须向用户询问5次问题,用户必须回答,当用户点击按钮时,必须验证答案。
有没有办法让for循环等待点击事件?
我在想的是这样的事情:
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
}
答案 0 :(得分:2)
是的,但是以不同的方式(不使用for循环):
var questionsAnswered = 0; //in class files put this higher up
nextQuestionButton.addEventListener(MouseEvent.CLICK, nextQuestion);
function nextQuestion(e:MouseEvent){
trace(questionsAnswered);
questionsAnswered++;
// Logic here
}