# Problemo

**URL:** <https://forum.kirupa.com/t/problemo/320313>\
**Category:** flash\
**Created:** [March 20, 2011, 8:43am UTC](https://forum.kirupa.com/t/problemo/320313 "2011-03-20T08:43:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![WEich1213](https://avatars.discourse-cdn.com/v4/letter/w/ecb155/32.png) [@WEich1213](https://forum.kirupa.com/u/WEich1213)\
**Post date:** [March 20, 2011, 8:43am UTC](https://forum.kirupa.com/t/problemo/320313/1 "2011-03-20T08:43:15Z")

</div>

Hi, I’m trying to use a loop to add some movie clips to the stage, but I want to give each one a different name so I can refer to them in another function, but I don’t know how that is done. I’m trying to learn how to do this so I can create an Isometric game. Here’s my code…

private function buildFloor(){

var y = 0;  
var x = 0;  
var z = 0;  
tiles = [];  
for(var row:Number = 0;row \<=4; row++){  
for (var col = 0; col \<=4; col++){

x = row \* 142;  
z = -col \* 142;

temp = mapToScreen(x,y,z);

groundTile = new Tile;  
groundTile.name = “cell”+row+"\_"+col;  
groundTile.x = temp[0]+200.8;  
groundTile.y = temp[1];  
addChild(groundTile);---------\> here’s where I add the movie clip to the stage.  
}  
}

}

private function arrange(ob1, ob2, ob3):void {--------------\>I want to put the mc’s I added to the stage in this function so I can sort their depths.  
var sortedItems:Array = new Array(ob1, ob2, ob3);

sortedItems.sortOn(“y”, Array.NUMERIC);  
var i:int = sortedItems.length;  
while(i–){  
if (getChildIndex(sortedItems\*) != i) {  
setChildIndex(sortedItems\*, i);  
}  
}  
}

Thanks for your help…
