Actionscript 3 事件驱动的动作脚本

Actionscript 3 事件驱动的动作脚本,actionscript-3,flash,events,flash-builder,Actionscript 3,Flash,Events,Flash Builder,我在一个actionscript项目上遇到了问题。 我必须向用户提问5次,用户必须回答,当用户单击按钮时,必须验证答案 有没有办法让for循环等待click事件 我当时的想法是这样的: for(teller = 0; teller < 5; teller++){ //show new question //user answers , and when finished the user clicks the button buttonNext.addEventListe

我在一个actionscript项目上遇到了问题。 我必须向用户提问5次,用户必须回答,当用户单击按钮时,必须验证答案

有没有办法让for循环等待click事件

我当时的想法是这样的:

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
}
for(出纳员=0;出纳员<5;出纳员++){
//提出新问题
//用户回答,完成后,用户单击按钮
buttonNext.addEventListener(MouseEvent.CLICK,checkAnswer);
//它必须等到用户单击按钮,然后重新开始
}

是,但以不同的方式执行(不用于循环):


你问了5次同样的问题吗?不,这是一个测验,当用户点击按钮时问题必须出现,有5个问题我很困惑你写“当用户点击按钮时,答案必须被验证”,现在“当用户点击按钮时问题必须出现”。事件驱动意味着您将为事件编写代码,您的侦听器“checkAnswer”是执行反验证的地方。为什么要创建循环?我更新了代码片段,希望它能告诉你我的意思好吧,我想我现在明白了,你不需要循环,你需要一个全局变量,比如说quizStatus来维护测验的状态,开始时你用0加载它,每次你在处理程序“checkAnswer”中处理事件时当用户通过第二个问题时,您将检查状态并相应地采取行动,然后递增quizStatus变量。你明白我想告诉你什么吗?我的英语很差。
var questionsAnswered = 0; //in class files put this higher up

nextQuestionButton.addEventListener(MouseEvent.CLICK, nextQuestion);
function nextQuestion(e:MouseEvent){
    trace(questionsAnswered);
    questionsAnswered++;
    // Logic here
}