Copy link to clipboard
Copied
Lets, say I need to show loop for object with different instance. Is it possible ?
var myObj1:Sprite=new Sprite();
var myObj2:Sprite=new Sprite();
var myObj3:Sprite=new Sprite();
1 Correct answer
I would put the intances in a vector (since you are using the same datatype - Sprite):
var arr:Vector.<Sprite> = new Vector.<Sprite>();
for (var i:uint=0;i<3;i++) {
arr.push(new Sprite());
}
Then you can also loop back through the array to access the instances.
Copy link to clipboard
Copied
I would put the intances in a vector (since you are using the same datatype - Sprite):
var arr:Vector.<Sprite> = new Vector.<Sprite>();
for (var i:uint=0;i<3;i++) {
arr.push(new Sprite());
}
Then you can also loop back through the array to access the instances.
Copy link to clipboard
Copied
Your scrips seems. arr is the Vector array, which holds only Sprite object and create 3 objects. But , I do not need this. Let me clear once again
Let, say,
var arr1:Sprite=new Sprite();
this.addChild(arr1);
arr1.x=10;
var arr2:Sprite=new Sprite();
this.addChild(arr2);
arr2.x=20;
var arr3:Sprite=new Sprite();
this.addChild(arr3);
arr3.x=10;
Now I do not want to write manually, I want to set in looping way. for example.
var i:Number;
for(i=1;i<4;i++)
{
var arr
}

