# Dynamic MC referencing

**URL:** <https://forum.kirupa.com/t/dynamic-mc-referencing/260997>\
**Category:** flash\
**Created:** [May 21, 2008, 9:40pm UTC](https://forum.kirupa.com/t/dynamic-mc-referencing/260997 "2008-05-21T21:40:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobllama](https://avatars.discourse-cdn.com/v4/letter/b/cc9497/32.png) [@bobllama](https://forum.kirupa.com/u/bobllama)\
**Post date:** [May 21, 2008, 9:40pm UTC](https://forum.kirupa.com/t/dynamic-mc-referencing/260997/1 "2008-05-21T21:40:39Z")

</div>

Howdy all…

Fried and trying to get a fairly simple thing put together, maybe you can help me out.

Very simple:

I have 45 instances of a little animated movieclip on the stage. I’m trying to get them to play at staggered intervals: When one instance reaches frame 14, I want the next one in the sequence to start. They’re all named piece\_1, piece\_2, etc.

I tried something like this (yeah the code is all wrong, but it illustrates what I’m trying to do):

```auto
_parent.i++
next_piece = "parent.piece_"+_parent.i
next_piece.play();

```

But for the life of me I can’t figure out how to reference them from inside the clip.

Oh, and the reason I have them all on stage rather than loading them dynamically (which would make the referencing a breeze) is because placement is very precise and can’t be done dynamically (well, not easily).

Thanks!

---

<div class="post-metadata">

**Author:** ![hasch2o](https://avatars.discourse-cdn.com/v4/letter/h/ba8739/32.png) [@hasch2o](https://forum.kirupa.com/u/hasch2o)\
**Post date:** [May 22, 2008, 6:58am UTC](https://forum.kirupa.com/t/dynamic-mc-referencing/260997/2 "2008-05-22T06:58:51Z")

</div>

You should try and store your movieClips in an array when you are adding them to the stage, that way you have easy access to all their properties. This is a tutorial which helped me a lot: [Array-tutorial](http://www.flepstudio.org/english/tutorials/mix/the-importance-of-an-array-20071029163.html)

this works only when you add the MovieClips with AS.

you could also try getChildByName(“piece\_” + parent.i)

(those work in AS3…not sure which one you use, please state this information in your question)

hope that helps you

---

<div class="post-metadata">

**Author:** ![bobllama](https://avatars.discourse-cdn.com/v4/letter/b/cc9497/32.png) [@bobllama](https://forum.kirupa.com/u/bobllama)\
**Post date:** [May 22, 2008, 7:02am UTC](https://forum.kirupa.com/t/dynamic-mc-referencing/260997/3 "2008-05-22T07:02:34Z")

</div>

Welp, I actually figured it out about 5 minutes ago…

Turns out you can use an alternate naming method that allows for variable naming… Observe:

```auto
_parent.n++;
next_piece = _parent["piece_"+_parent.n];
next_piece.play();

```
