I am a student currently learning and I know millions of questions about if statements have already been answered but I am not able to locate one that related to my scenerio that I can understand. I have tried to manipulate this code all of the ways that I am aware of but cannot figure out why if it not working. I am using Animate CC actionscript3.0 and am creating an interactive quiz for kindergartners. This function is the last frame of the quiz show the final score with a statement appropriate to if the score is passing or failing. However, the if statement is not working. Can someone tell me what I am doing wrong or if it is possible with my simple code.
this is from the first frame where the scores begin-
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;
}
this is from the final frame-
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;
};
}
Aucun commentaire:
Enregistrer un commentaire