Variables in loooops?


for (var i:Number = 0; i < 4; i++) {

var promotion+i:imageContainer = new imageContainer("images/Promo" +i+ ".swf","loader.swf");
addChild(promotion+i)

};

That’s not possible, I can (sort of) understand why you cannot declare a variable inside a loop, but, can you create it in an array like the following


var Promotion:Array = new Array();
for(var i:int= 0; i< 4; i++){
Promotion* = new Sprite();
Promotion*.graphics.beginFill(0x0000000);
Promotion*.graphics.drawRoundRect(50,50,50,50,50);
Promotion*.graphics.endFill();
addChild(Mask*);
}

In other forums it has been said that arrays are dynamic; you can’t enforce the types of their contents.

So, my question is how would I be able to create 500,000,000 (only joking!) instances of this code:


var Promotion1:imageContainer=new imageContainer(200,200,"images/Promo0.swf","loader.swf");
addChild(Promotion1)