[AS3] _root["object_"+i] approach

Hi,

I’m experimenting in AS3 and I stumbled upon this little problem:

[AS]/* --------- Projects are ready to be used! --------- */
for(var i:uint=0;i<projectsArr.length;i++) {

var proj:Project = projectsArr*;
var imgStr:String = proj.getImageFromCategory(0,proj.getCategory(0));
proj.loadImage(imgStr);
		
ref = new UIComponent();
addChild( ref );
		
ref.x = 400 + 120*i;;
ref.y = 450;
ref.scaleX = .3;
ref.scaleY = .3;
	
ref.name = proj.projectName;
		
proj.addEventListener(CustomDispatcher.ACTION,projectComplete);
		
ref.addChild( proj );

}[/AS]

So I’ve filled an array with Project objects that I now want to add to the stage. This works fine and it displays nice.
But I can’t access these projects anymore only the last one, because the ref:UIComponent is always overwritten.
The ref is a public variable, because I need to use it in the projectComplete function (worked fine with one project object).

In my AS1/2 days I would have used something like :
[AS]_root[“project”+i] = new UIComponent();[/AS]

Is there a way to do this in AS3?

Thx, Pete! :h: