我是一名正在学习的学生,我知道成千上万的问题,关于陈述是否已经得到答复,但我找不到与我能理解的场景有关的问题。我试图以我所知道的所有方式来操纵此代码,但无法弄清楚为什么它不起作用。我正在使用Animate CC actionscript3.0,并正在为幼儿园的孩子创建一个交互式测验。此功能是测验的最后一帧,显示最终分数,并带有一条说明该分数是否合格的语句。但是,if语句不起作用。有人可以告诉我我做错了什么吗,或者我的简单代码是否有可能告诉我。
这是分数开始的第一帧-
import flash.events.KeyboardEvent;
stop();
var rightAnswer = "cow";
var blankAnswer = " ";
var points:Number = 0;
txt_answer.text = "";
txt_result.text = "";
btn_submit1.addEventListener(MouseEvent.CLICK, submitAnswer);
function submitAnswer(event):void {
if (txt_answer.text.toLowerCase() == rightAnswer ) {
txt_result.text = "You Rock!";
points = points + 10;
} else {
txt_result.text = "Oops!";
points = points - 5;
}
if (txt_answer.text.toLowerCase() == blankAnswer ) {
txt_result.text = "Oops!";
points = points - 5;
}
txt_score.text = points.toString();
btn_submit1.visible = false;
stage.focus = txt_result;
txt_answer.type = TextFieldType.DYNAMIC;
}
这是从最后一帧开始的>
var finalScore = txt_score.text = points.toString();
var zoo = txt_summary.text = "Wow " + userName + " , you did an
awesome job! Your final score is " + finalScore + " . As a
reward, we would like to invite you to our petting zoo to see all
of the animals you named in the quiz and some you may have
missed!";
var retry = txt_summary.text = "Good try " + userName + " , your
final score is " + finalScore + ". Let's practice a little more.
You still have a chance to come to our petting zoo if you retry
the quiz and improve your score. Give it a try, you can do it!";
function scoreCal() {
if (finalScore > 70) {
zoo;
btn_zoo.visible = true;
}
else {
retry;
btn_zoo.visible = false;
};
}