[COLOR=#333333][FONT=adobe-clean]I would like to know how I can instantiate multiple objects with a for[/FONT][/COLOR]
[COLOR=#333333][FONT=adobe-clean]for example my code I created six squares of different colors and have instantiated with the name “cubeA, B, C, D, E, F”[/FONT][/COLOR]
[COLOR=#333333][FONT=adobe-clean]apart in their xy position attribute I have given a value to each aparesca to me on the stage but in those cordenadas And always add +25 to make aparescan top of each other but can see each one.[/FONT][/COLOR]
[COLOR=#333333][FONT=adobe-clean]Code 1:[/FONT][/COLOR]
var Cube1:CubeA = new CubeA();
Cube1.x = 40
Cube1.y = 140
addChild(Cube1)
var Cube2:CubeB = new CubeB();
Cube2.x = 65
Cube2.y = 140
addChild(Cube2)
var Cube3:CubeC = new CubeC();
Cube3.x = 90
Cube3.y = 140
addChild(Cube3)
var Cube4:CubeD = new CubeD();
Cube4.x = 115
Cube4.y = 140
addChild(Cube4)
var Cube5:CubeE = new CubeE();
Cube5.x = 140
Cube5.y = 140
addChild(Cube5)
var Cube6:CubeF = new CubeF();
Cube6.x = 165
Cube6.y = 140
addChild(Cube6)
[COLOR=#333333][FONT=adobe-clean]I want to achieve is to instantiate all objects with a name but for each class must be contained in an array[/FONT][/COLOR]
[COLOR=#333333][FONT=adobe-clean]something like this:
[/FONT][/COLOR]
var McCubeClassName:Array;
McCubeClassName = [CubeA,CubeB,CubeC,CubeD,CubeE,CubeF]; // Mcs of Cube
for (var i = 0; i<=McCubeClassName.length; i++)
{
cube*.x = 40
cube*.y = (i * 16) + 10;
addChild(Cube*)
}
[COLOR=#333333][FONT=adobe-clean]
what I want is to do the quotas instantiated one by one but this time using a for to make it faster and write fewer lines of code, because I have to do something simimar for a card game but not 54 letters are 100, they know that it is 100 times declare code 1, I’m going crazy![/FONT][/COLOR]