这些问题是随机的,但它们显示了我的需要。正如您在 answer[0] 中看到的那样,我必须指定三个可能的答案。如果“bill”写在他们答案的任何地方,我希望能够说明答案是正确的。但这行不通
for (var i = 0; i < answer[index].length; i++)
{
for (answer[index][i] in answer_input.text.toLowerCase())
{
correct = true;
}
answer = new Array();
answer[0] = ["your name is bill","bill's your name","your name's bill"]
answer[1] = ["john", "sean", "greg"]
question = new Array();
question[0] = "whats my name?"
question[1] = "whats not my name?"
index = 0;
onEnterFrame = function ()
{
question_txt.text = question[index];
};
enter1.onRelease = function()
{
question_txt.text = question[index];
var correct = false;
for (var i = 0; i < answer[index].length; i++)
{
if (answer[index][i] == answer_input.text.toLowerCase())
{
correct = true;
}
}
if (correct)
{
index++;
answer_input.text = "";
}
else
{
answer_input.text = "Incorrect";
}
};