[AS3] How do you reference dynamically creatived MCs

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:


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?

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.

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)

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