# Accessing an MC created dynamically

**URL:** <https://forum.kirupa.com/t/accessing-an-mc-created-dynamically/185981>\
**Category:** Uncategorized\
**Created:** [April 18, 2006, 6:58am UTC](https://forum.kirupa.com/t/accessing-an-mc-created-dynamically/185981 "2006-04-18T06:58:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bulletz](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bulletz](https://forum.kirupa.com/u/bulletz)\
**Post date:** [April 18, 2006, 6:58am UTC](https://forum.kirupa.com/t/accessing-an-mc-created-dynamically/185981/1 "2006-04-18T06:58:26Z")

</div>

hello:  
i have a problem accessing an MC inside another MC created dynamically.  
can someone help me on this?  
here is my code:

```auto

first frame of _root:
for (var i=0;i<5;i++) {
var newname:String = "newnavboxmc"+i;
  _root.navboxmc.duplicateMovieClip(newname,i);
_root[newname].holder_mc.bandname = "Bastard Dogs";
}

```

and getting the value of “bandname” using a button event:

```auto

on (release) {
trace (_root.newnavboxmc0.holder_mc.bandname);
}

```

it always shows an “undefined” error.

any help is very much appreciated.  
thanks in advance.

---

<div class="post-metadata">

**Author:** ![SmoothDime](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@SmoothDime](https://forum.kirupa.com/u/SmoothDime)\
**Post date:** [April 18, 2006, 8:15am UTC](https://forum.kirupa.com/t/accessing-an-mc-created-dynamically/185981/2 "2006-04-18T08:15:12Z")

</div>

use attachMovie() instead.

---

<div class="post-metadata">

**Author:** ![theflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/theflash/32/1221_2.png) [@theflash](https://forum.kirupa.com/u/theflash)\
**Post date:** [April 18, 2006, 9:04am UTC](https://forum.kirupa.com/t/accessing-an-mc-created-dynamically/185981/3 "2006-04-18T09:04:00Z")

</div>

duplicate movie and attachMovie both functions return instance of newly created movieclip you can store the references in variables  
OR  
for your case this will work too  
[FONT=Courier New][LEFT][COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]navboxmc[/COLOR][COLOR=#000000][[/COLOR][COLOR=#ff0000]“newnavboxmc”[/COLOR]+i[COLOR=#000000]][/COLOR]  
[/LEFT]  
[/FONT]  
i will be the numbers you used to create them
