事件驱动的动作脚本

时间:2012-12-29 20:23:18

标签: actionscript-3 flash events flash-builder

我遇到了动作脚本项目的问题。 我必须向用户询问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
}

1 个答案:

答案 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
}