answer = new Array();
answer[0] = "1997";
answer[1] = "1941";
question = new Array();
question[0] = "What ...?";
question[1] = "Why ...?";
question_txt.text = question;
enter1.onRelease = function()
{
if (answer_input.text == answer)
{
answer++;
question++;
question_txt.text = question;
}
else
{
answer_input.text = "Incorrect";
}
};
There’s 2 text boxes and a button
TextBox1 = question_txt – which is to display the question and is of type [Dynamic]
textBox2 = answer_input – which is to allow users to attempt to answer the question
The values of the answers and questions are just made up, don’t mind them.
So why isn’t it working?
Well, I’m no as2 expert, but it looks like
questionis an array, and you’re trying to setquestion_txt.texttoquestion, which is really the entire array. And then later, you’re trying to add 1 to theanswerandquestionarrays, which won’t work.What you’re really looking to do is access elements of these arrays, and to do that, you need to pass an index to your array. (question[0] = “The first element in the question array”) So what you need is a variable that keeps track of the index of these arrays you’re currently using. Something like this…