Yes, you could do
 
var o:Object = {};
var i:int = 1;
o["image" + i] = new Image();
i++;
 
But you don't want to! Using an Object to store name/value pairs where
the name acts as a sequential index is less efficient than using an
Array:
 
var a:Array = [];
var i:int = 1;
a[i] = new Image();
i++;
 
- Gordon

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of donvoltz
Sent: Wednesday, September 19, 2007 10:31 AM
To: [email protected]
Subject: [flexcoders] Re: access a component name using array variable



I have a related question to this from the creation side of things. Is 
it possible to create an object using this type of notation??

For example, if you did not know how many images you would be adding, 
how can I sequentially name the images that are added to the app

Can I do something like this
var i:int = 1;
"image" + i = new Image();
i++;

Thanks

Don



 

Reply via email to