Dynamic MC referencing

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):

_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!

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

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

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:

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