I have a quiz where the user has multiple choice options. When the user selects the button, it checks to see if that is the correct answer for that question. If the answer is correct it jumps to a frame that plays a little animation and then tells it to go back to the beginning of the movie. At the beginning there is code that resets all the buttons and all the questions.
First I had simple buttons in my movie that had this code on them
on (release) {
if (!hasAnswered) {
currentQuizItem.checkAnswerNumber(1);
}
hasAnswered = true;
}
Then I decided that I wanted a more complex button, so I decided to replace the simple buttons with movieclips. The code on the movieclips is as follows which is supposed to do exactly what the button did, except I added a little piece that tells the movieclip instance to go to certain frame in the movieclip.
on (release) {
if (!hasAnswered) {
currentQuizItem.checkAnswerNumber(1);
answer2Btn.gotoAndStop("checked")
}
hasAnswered = true;
}
Now, the movieclip button works for the first question of the quiz, but stops working after that. Why? All the buttons would reset properly. Why isn’t the movieclip??
This is the code for resetting everything when it goes back to the beginning. Note: The new questions and answers (being loaded from external xml file) do load, but something in the code that assigns the answer to the button isn’t working, b/c on the second question, the buttons no longer work, although they worked fine as simple buttons
var currentQuizItem = quizItems[currentQuestionNumber-1];
var hasAnswered = false;
question = currentQuizItem.getQuestion();
for (var i = 1; i<=currentQuizItem.getNumOfAnswers(); i++) {
_root["answer"+i] = currentQuizItem.getAnswer(i-1);
_root["answer"+i+"Btn"]._visible = true;
_root["answer"+i+"Btn"].gotoAndStop("notChecked");
_root["answer"+i+"Text"]._visible = true;
}
for (; i<=5; i++) {
_root["answer"+i+"Btn"].gotoAndStop("notChecked");
_root["answer"+i+"Btn"]._visible = false;
_root["answer"+i+"Text"]._visible = false;
}
if (currentQuestionNumber<15) {
questionType = "Knowledge Questions";
} else {
questionType = "Behavior Questions";
}
stop();