Skip to main content
lcg_2012
Inspiring
February 10, 2014
Question

Call a Numbered MovieClip Dynamically

  • February 10, 2014
  • 2 replies
  • 537 views

I have several movieClips on my Stage that are numbered, I don't want to create these dynamically, just call their heights dynamically:

mcText_One1

mcText_One2

mcText_One3

mcText_One4

I want to use the height value of each in a loop.

Here's what I have working except for what is bold. Just need the right syntax to dynamically call the height of that movieClip:

//

var LeadingValue = -2;

var TextAllSameHeight = 28;

//

var TextHeight_One = TextAllSameHeight;

var LinesOfText_One = 4;

var TotalHeight_One = (TextHeight_One * LinesOfText_One) + (LeadingValue * (LinesOfText_One - 1));

var Text_One:Object = {};

for (var Text_One_Count:uint = 0; Text_One_Count < LinesOfText_One; Text_One_Count++)

{

          if (Text_One_Count==0)

          {

                    Text_One['TextOne_EndY_' + (Text_One_Count+1)] =((mcBottomBox.y-TotalHeight_One)/2);

                    Text_One['TextOne_StartY_' + (Text_One_Count+1)] =-(mcText_One(Text_One_Count+1).height);

          }

          else

          {

                    Text_One['TextOne_EndY_' + (Text_One_Count+1)] = Text_One['TextOne_EndY_' + Text_One_Count] + TextHeight_One + LeadingValue;;

          }

}

This topic has been closed for replies.

2 replies

Ned Murphy
Legend
February 10, 2014

Yes, that is better but you should convert the number to a String if you are adding it to a String...

this["mcText_One" + String(Text_One_Count+1)].height;

lcg_2012
lcg_2012Author
Inspiring
February 10, 2014

I figured it out:

-(this["mcText_One" + (Text_One_Count+1)].height);