我用Array
在我的项目中提出了一系列问题。以下是我使用的编码。我尝试过3个问题的编码,效果很好。对于我的真实项目,我需要提出20个问题,当一切都完成后,我运行项目,它运行不好。我点击下一步,从Q3开始,它将给Q5,然后Q8,然后跳到Q17。为什么会这样?
stop();
var finalString:String = '';
//var finalString2:String = '';
var _list:Array = ["Q1", "Q2", "Q3,"Q4,"Q5 ","Q6","Q7","Q8 ","Q9","Q10","Q11","Q12", "Q13","Q14", "Q15", "Q16","Q17", "Q18", "Q19", "Q20"];
var _marks:Array = [];
var i:int;
var myscore = 0;
////////////////////////////////////////////
buttonA.buttonMode = true;
buttonB.buttonMode = true;
buttonC.buttonMode = true;
buttonD.buttonMode = true;
skip_btn.buttonMode = true;
score_txt.text = myscore;
question_txt.text = _list[0];
buttonA.label_txt.text = "A. ";
buttonB.label_txt.text = "B. ";
buttonC.label_txt.text = "C. ";
buttonD.label_txt.text = "D. ";
skip_btn.label_txt.text = "SKIP";
buttonA.label_txt.mouseEnabled = buttonB.label_txt.mouseEnabled = buttonC.label_txt.mouseEnabled = buttonD.label_txt.mouseEnabled = skip_btn.label_txt.mouseEnabled = false;
buttonA.addEventListener(MouseEvent.CLICK, q1);
buttonB.addEventListener(MouseEvent.CLICK, q1);
buttonC.addEventListener(MouseEvent.CLICK, q1);
buttonD.addEventListener(MouseEvent.CLICK, q1);
skip_btn.addEventListener(MouseEvent.CLICK, q1);
function q1(event:MouseEvent):void
{
if(event.currentTarget == buttonA)
{
_marks.push("Your answer: ");
}
else if(event.currentTarget == buttonB)
{
_marks.push("Your answer:");
}
else if(event.currentTarget == buttonC)
{
_marks.push("Your answer:");
myscore+=5;
}
else if(event.currentTarget == buttonD)
{
_marks.push("Your answer:");
}
else if(event.currentTarget == skip_btn)
{
_marks.push("Skip");
}
buttonA.removeEventListener(MouseEvent.CLICK, q1);
buttonB.removeEventListener(MouseEvent.CLICK, q1);
buttonC.removeEventListener(MouseEvent.CLICK, q1);
buttonD.removeEventListener(MouseEvent.CLICK, q1);
skip_btn.removeEventListener(MouseEvent.CLICK, q1);
nextFrame();
}