Answered
How to create objects with names being set "on the fly"?
Hi everyone,
I don't know how to create objects with varying suffixes in their references "constructed" on the fly via "for" loop. What I mean is, the "typical" way of creating few sprites could be:
var sprite1:Sprite = new Sprite();
var sprite2:Sprite = new Sprite();
container.addChild(sprite1);
container.addChild(sprite2);
and what if we want to create 100 such objects using "for" loop so that we don't need to type:
var sprite1:Sprite = new Sprite();
var sprite2:Sprite = new Sprite();
var sprite3:Sprite = new Sprite();
var sprite4:Sprite = new Sprite();
...
var sprite100:Sprite = new Sprite();
the question is how to "incorporate" the number into object's instance name during mass object creation? I remember some old "eval" and/or square brackets '["objectName" + objectId]' magic spells but they don't seem to work in AS3
Greetings
I don't know how to create objects with varying suffixes in their references "constructed" on the fly via "for" loop. What I mean is, the "typical" way of creating few sprites could be:
var sprite1:Sprite = new Sprite();
var sprite2:Sprite = new Sprite();
container.addChild(sprite1);
container.addChild(sprite2);
and what if we want to create 100 such objects using "for" loop so that we don't need to type:
var sprite1:Sprite = new Sprite();
var sprite2:Sprite = new Sprite();
var sprite3:Sprite = new Sprite();
var sprite4:Sprite = new Sprite();
...
var sprite100:Sprite = new Sprite();
the question is how to "incorporate" the number into object's instance name during mass object creation? I remember some old "eval" and/or square brackets '["objectName" + objectId]' magic spells but they don't seem to work in AS3
Greetings