Why do I get an ‘undefined’ in my **answerText **Text box when I press Hint_btn but not when I press Show Answers?
Frame 1:
// Setup variables
var quizTitle = "test";
var questionsDone = 0;
Array.prototype.shuffle = function() {
var len = i = this.length;
while (i--) {
var p = Math.floor(Math.random()*len);
var t = this*;
this* = this[p];
this[p] = t;
}
};
var questions = new Array();
// the Question, the Hint and the Answer are stored here
questions[0] = ["Word 1","Hint 1","Answer 1 to be added here"]
questions[1] = ["Word 2","Hint 2","Answer 2 to be added here"]
questions[2] = ["Word 3","Hint 3","Answer 3 to be added here"]
questions[3] = ["Word 4","Hint 4","Answer 4 to be added here"]
questions[4] = ["Word 5","Hint 5""Answer 5 to be added here"]
// randomly sort the array
questions.shuffle();
// find out how many questions there are
var numberQuestions = questions.length
stop();
Then on the Show Hint button (Frame 2) I have this code:
on(click){_parent.userAnswer = _parent.HintText.text
_parent.gotoAndPlay("Showhints");}
On Show Hint Frame 4 have this code:
answerText.text = userAnswer;
HintText.text = questions[questionsDone][1]
stop();
Hope this makes sense…
Yossi