# Referencing dynamically created instances

**URL:** <https://forum.kirupa.com/t/referencing-dynamically-created-instances/227917>\
**Category:** flash\
**Created:** [June 3, 2007, 9:27pm UTC](https://forum.kirupa.com/t/referencing-dynamically-created-instances/227917 "2007-06-03T21:27:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShooterMG](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/shootermg/32/3695_2.png) [@ShooterMG](https://forum.kirupa.com/u/ShooterMG)\
**Post date:** [June 3, 2007, 9:27pm UTC](https://forum.kirupa.com/t/referencing-dynamically-created-instances/227917/1 "2007-06-03T21:27:40Z")

</div>

I’m not even sure if I’ve described this problem correctly. Basically in one of my classes, I have a function that takes an array and generates a tile map from that (tile based game). Anyways, once I create my tiles, the variables used to make them are gone, since they were locally scoped, but the MovieClip instances are still in the display list (which is what I want). Now how can I reference these display objects by name? Here’s the code to generate the map, if it helps:

for(var i:uint = 0; i \< mapHeight; ++i) {  
for(var j:uint = 0; j \< mapWidth; ++j) {  
this[“t\_”+i+"_"+j] = new tile();  
mapContainer.addChild(this["t_"+i+"_"+j]);  
this["t_"+i+"_"+j].x = (j\*tileW);  
this["t_"+i+"_"+j].y = (i\*tileH);  
this["t_"+i+"\_"+j].gotoAndStop(map\*[j]+1);

```
            }

```

}
