我想向数组中添加 200 多个元素。我想从那个数组中访问它的元素:我有 3 个答案。这 3 个答案需要数组中的元素,但我也不需要 2 个答案中的相同元素。
var random: Number;
var answ: Array = [var1, var2, var3];
var elements : Array = [1,2,3,4,5,6,7,8,9,...];
GAME.answer1.addEventListener(MouseEvent.CLICK, randomNumberEvent);
GAME.answer2.addEventListener(MouseEvent.CLICK, randomNumberEvent);
GAME.answer3.addEventListener(MouseEvent.CLICK, randomNumberEvent);
answer1.text = elements[random];
answer2.text = elements[random];
answer3.text = elements[random];
function displayRandomNumber()
{
randomGen = randBetween(2, 120);
GAME.randomNumberText.text = randomGen.toString();
if(myArray.indexOf(randomGen) == -1){
myArray.push(randomGen);
cookie.data.storedmyArray=myArray;
cookie.flush();
levelu = randomGen;
}else{
displayRandomNumber()
}
}
随机访问元素并将它们分配给答案的最佳方法是什么?