I want to write code where I have arrays of objects.
I want to write a for loop and have something like:
[size=2][size=2]myObject1 = new Object();
[/size][/size][size=2][size=2]myObject2 = new Object();
[/size][/size][size=2][size=2]myObject3 = new Object();
[/size][/size][size=2][size=2]myObject4 = new Object();
etc…
[/size][/size]
How can I do this?
I’ve tried using square brackets… it doesn’t work and looks wrong to do anyway.
//declaring a new Array
var aValues:Array = new Array();
//adding the data to the Array with array access notation method
aValues[0] = myObject1;
aValues[1] = myObject2;
aValues[2] = myObject3;
//returning every index in the array from zero (the first object) to the length of the array, so we don’t have to hardcode the length of the array in the for statement.
for (var i:Number = 0; i < aValues.length; i++);
trace(aValues*);
myObject = new Array();
myObject[0] = new Object(); // arrays start on 0
myObject[1] = new Object();
myObject[2] = new Object();
myObject[3] = new Object();
I have a similar question…
Would it at all be possible to do something like this?
var i = 0;
while (i <=10) {
myTextField*.text = "Textfield:" +i+"";
i++;
}
The part I can’t get working is “myTextField*.text” and I don’t even know if this kind of thing is possible. Anyone know if it is? And what you should use instead of “*”?