1
我要製作一個計數器來計算考試題的正確答案。 計數器只會從每個幀中收集正確答案。創建一個MCQs考試並且在Actionscript 3中的得分計數器出現錯誤
這裏是第一幀:
var counter:Number = 0;
var correctAns:Number;
correctAns = ans1_mc.alpha;
function clicked1(event:MouseEvent):void
{
ans1_mc.alpha = 1;
ans2_mc.alpha = 0;
ans3_mc.alpha = 0;
ans4_mc.alpha = 0;
}
function clicked2(event:MouseEvent):void
{
ans1_mc.alpha = 0;
ans2_mc.alpha = 1;
ans3_mc.alpha = 0;
ans4_mc.alpha = 0;
}
function clicked3(event:MouseEvent):void
{
ans1_mc.alpha = 0;
ans2_mc.alpha = 0;
ans3_mc.alpha = 1;
ans4_mc.alpha = 0;
}
function clicked4(event:MouseEvent):void
{
ans1_mc.alpha = 0;
ans2_mc.alpha = 0;
ans3_mc.alpha = 0;
ans4_mc.alpha = 1;
}
function submit(event:MouseEvent):void
{
if (correctAns == 1)
{
counter++;
}
else
{
counter = counter;
}
trace (counter);
gotoAndStop(currentFrame + 1);
}
ans1_btn.addEventListener(MouseEvent.CLICK, clicked1);
ans2_btn.addEventListener(MouseEvent.CLICK, clicked2);
ans3_btn.addEventListener(MouseEvent.CLICK, clicked3);
ans4_btn.addEventListener(MouseEvent.CLICK, clicked4);
submit_btn.addEventListener(MouseEvent.CLICK, submit);
ans1_mc.alpha = 0;
ans2_mc.alpha = 0;
ans3_mc.alpha = 0;
ans4_mc.alpha = 0;
text1_txt.text = "A";
text2_txt.text = "B";
text3_txt.text = "C";
text4_txt.text = "D";
stop();
第二幀是:
ans1_mc.alpha = 0; ans2_mc.alpha = 0; ans3_mc.alpha = 0; ans4_mc.alpha = 0;
correctAns = ans1_mc.alpha;
text1_txt.text = "E";
text2_txt.text = "F";
text3_txt.text = "G";
text4_txt.text = "H";
stop();
所有其他幀將作爲第二幀。
我想知道錯在哪裏。
非常感謝。我會嘗試你的代碼,並會回來給你一個反饋。 – 2010-10-25 03:44:19
總的來說,這並不是我需要的東西,但這並不意味着你沒有幫助我,你做了一項很好的工作,幫助我用一種很好的方法實現了我的目標。非常感謝 – 2010-10-25 14:50:36