Reputation: 855
I realise this is very basic but i need a quick way of referencing all my objects in an array, I have a series of movieclips with instance names "block1" "block2"... etc.
I there a quick way to reference these in an array something like "block"+1 ? or even "block" then 1 to 12 ?
Cheers
Upvotes: 1
Views: 273
Reputation: 10510
Not exactly sure what your asking, but if you want to populate an array with references to your movieclips (that are name sequentially), then you can use the getChildByName() method. This method takes an instance name as a string, and gives you back the reference to the displayobject if it finds one. So you could do something like this:
for (var i:int = 1; i <= 12; i++) {
var item:DisplayObject = this.getChildByName('block' + i);
// Use item here. You probably want to make sure item is not null first.
}
Upvotes: 3