# \[AS3\] \_root\["object\_"+i\] approach

**URL:** <https://forum.kirupa.com/t/as3--root-object--i-approach/217145>\
**Category:** flash\
**Created:** [February 23, 2007, 12:56pm UTC](https://forum.kirupa.com/t/as3--root-object--i-approach/217145 "2007-02-23T12:56:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete\_zahut](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@pete\_zahut](https://forum.kirupa.com/u/pete_zahut)\
**Post date:** [February 23, 2007, 12:56pm UTC](https://forum.kirupa.com/t/as3--root-object--i-approach/217145/1 "2007-02-23T12:56:02Z")

</div>

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:
