You cannot index independent variables and you cannot concatenate variable names to form names of other variables (well, not the way you attempted).
You need to create an array of Sprite
objects. An array is a data structure that stores several things at once. (A one-dimensional array is called a vector.)
To store sprites in a vector, you'd write:
var sprites:Vector.<Sprite> = new Vector.<Sprite> ();
for ( var i:int = 0; i < 200; i++ )
{
sprites.push ( new Sprite () );
}
This loop creates 200 Sprite
instances and stores all of them in the sprites
array (really, Vector
). You can then access individual sprites by simply indexing them:
sprites[n]....
where n
goes from 0 to N-1
if the Vector
has N
total elements.