有没有办法在 for 循环中创建数组实例?
这是我的代码...
var recArrCon1:Array = new Array(50);
var recArrCon2:Array = new Array(50);
var recArrCon3:Array = new Array(50);
var recArrCon4:Array = new Array(50);
var recArrCon5:Array = new Array(50);
var recArrCon6:Array = new Array(50);
var recArrCon7:Array = new Array(50);
var recArrCon8:Array = new Array(50);
我想通过 for 循环以动态方式进行声明。提前致谢。
顺便说一句,我正在使用 AS3
编辑:答案是(来自 Barış Uşaklı):
var recArrCons:Object = {};
for(var i:int=1; i<=8; i++)
{
recArrCons["recArrCon" + i] = new Array(50);
}
trace(recArrCons.recArrCon4); // 4th array