# Dynamically creating clips

**URL:** <https://forum.kirupa.com/t/dynamically-creating-clips/151814>\
**Category:** flash\
**Created:** [June 18, 2005, 8:25am UTC](https://forum.kirupa.com/t/dynamically-creating-clips/151814 "2005-06-18T08:25:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skylabel](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@skylabel](https://forum.kirupa.com/u/skylabel)\
**Post date:** [June 18, 2005, 8:25am UTC](https://forum.kirupa.com/t/dynamically-creating-clips/151814/1 "2005-06-18T08:25:49Z")

</div>

Hi,  
I have an Array Object called extData\_arr, that contains data read from a database. Using this data, I’d like to populate my subMenu MovieClips appropriately. I can elaborate on the format of this array if required but basically the problem is this…

Now this line seems to work and displays correctly as I expect

status.text = status.text + n + " : " + i + "  
"; //tracing

but for some reason, on the following line where I try to create empty Clips, flash just doesn’t recognize the value of i and therefore refuses to create the clips. Does anyone know why?

[size=1]function createSubButtons() {  
for (n=0; n \< extData\_arr.length; n++)  
{  
for (i=0; i\<extData\_arr[n][0].length; i++)  
{  
status.text = status.text + n + " : " + i + "  
"; //tracing  
\_root[“subMenu\_mc”+(n+1)].createEmptyMovieClip(“sub\_btn”+(i+1), getNextHighestDepth());  
}

```
 }
 trace(_root.subMenu_mc1.sub_btn1); //yields undefined
 trace(_root.subMenu_mc1) // yields _level0.subMenu_mc1

```

}[/size]
