我有5个不同的数组用于一堆练习,如下:
const oef1:Array = ["citroen","schoen","boek"];
const oef2:Array = ["huis","muis","jas"];
const oef3:Array = ["boek","koek","sok"];
const oef4:Array = ["ei","bij","bot"];
const oef5:Array = ["vier","mier","muur"];
现在我要设置当前的游戏。我通过复制数组来实现这一点,如下所示:
var curArr:Array;
var curExc:int = 1;
curArr = ("oef" + curExc) as Array;
我无法说服flash接受字符串(“oef”+ curExc)作为数组。 我该怎么做?
我已经广泛搜索了Stack Overflow,但我认为我根本不知道我正在寻找的正确术语。这是我能想到为什么我在这里找不到答案的唯一可能原因,因为我确信有人必须已经尝试过这个。如果是这种情况,请道歉,请指出正确的问题。
答案 0 :(得分:2)
使用方括号。
curArr = this["oef" + curExc];
答案 1 :(得分:2)
const oef1:Array = ["citroen","schoen","boek"];
const oef2:Array = ["huis","muis","jas"];
const oef3:Array = ["boek","koek","sok"];
const oef4:Array = ["ei","bij","bot"];
const oef5:Array = ["vier","mier","muur"];
const oefArrays:Array = [oef1,oef2,oef3,oef4,oef5];
var curArr:Array;
var curExc:int = 0;
curArr = oefArrays[curExc];
答案 2 :(得分:0)
你可以制作一个二维数组,如下所示:
wrapper => [
0 => oef1,
1 => oef2,
2 => oef3,
3 => oef4,
4 => oef5,
]
只需检索wrapper[curExc]
。
度过美好的一天。