Skip to main content
miquael
Inspiring
May 9, 2009
Answered

Dynamic MovieClip reference

  • May 9, 2009
  • 1 reply
  • 784 views

Okay, how does one reference a MovieClip instance dynamically in AS 3.0?

Example, I create a new instance of a "marker" MovieClip class that inherently has within it a series of embedded MovieClips labeled: "m1", "m2", "m3" etc ... and I want to be able to dynamically reference those embedded MCs.  I used to do this all the time in AS 2.0, and can't recall how to do it in AS 3.0.

I know it is something like this:

number = 1;

marker = new StaticMarker();

var thisMarker = this.marker.m[number];

thisMarker.visible = true;

This topic has been closed for replies.
Correct answer Ned Murphy

Try:

var thisMarker:MovieClip = this.marker["m"+number];

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
May 9, 2009

Try:

var thisMarker:MovieClip = this.marker["m"+number];

miquael
miquaelAuthor
Inspiring
May 9, 2009

That's it, THANKS!  So simple, so essential.

Ned Murphy
Legend
May 9, 2009

You're welcome