1

我在操作脚本项目时遇到问题。我必须向用户询问 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
}
4

1 回答 1

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
}
于 2012-12-29T23:37:07.803 回答