# \[AS3\] How do you reference dynamically creatived MCs

**URL:** <https://forum.kirupa.com/t/as3-how-do-you-reference-dynamically-creatived-mcs/266015>\
**Category:** flash\
**Created:** [July 15, 2008, 3:36pm UTC](https://forum.kirupa.com/t/as3-how-do-you-reference-dynamically-creatived-mcs/266015 "2008-07-15T15:36:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thinker2501](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@Thinker2501](https://forum.kirupa.com/u/Thinker2501)\
**Post date:** [July 15, 2008, 3:36pm UTC](https://forum.kirupa.com/t/as3-how-do-you-reference-dynamically-creatived-mcs/266015/1 "2008-07-15T15:36:37Z")

</div>

I have an AS3 project and am creating a bunch of movie clips dynamically. They are mostly from custom classes that extend MC, so I’m adding them to the stage with the standard:

```auto

var myMc:CustomerClass = new CustomClass();
addChild(myMc);

```

The MCs all appear on stage and function properly. The question is: how do I give them a unique name so another MC can reference them later?

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [July 15, 2008, 3:42pm UTC](https://forum.kirupa.com/t/as3-how-do-you-reference-dynamically-creatived-mcs/266015/2 "2008-07-15T15:42:50Z")

</div>

myMc is your unique identifier there. If that is used multiple times for multiple objects, then you could instead use an array or just access the object by its position in the display list, i.e. getChildAt(\<depth\>). Similarly, you can set the name property and use getChildByName(\<name\>); It depends on how many you’re dealing with and how/why you need to access them.

---

<div class="post-metadata">

**Author:** ![saxx](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@saxx](https://forum.kirupa.com/u/saxx)\
**Post date:** [July 15, 2008, 3:48pm UTC](https://forum.kirupa.com/t/as3-how-do-you-reference-dynamically-creatived-mcs/266015/3 "2008-07-15T15:48:47Z")

</div>

Heh i just delt with this on my project

Give myMc a new name each time and add them in separately ( at least i think thats the best way)

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [July 15, 2008, 3:56pm UTC](https://forum.kirupa.com/t/as3-how-do-you-reference-dynamically-creatived-mcs/266015/4 "2008-07-15T15:56:23Z")

</div>

I’d suggest throwing them into an array instead. Accessing array children is faster than using getChildByName and getChildAt.
