Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Call a Numbered MovieClip Dynamically

Contributor ,
Feb 10, 2014 Feb 10, 2014

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;;

          }

}

TOPICS
ActionScript
509
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 10, 2014 Feb 10, 2014

I figured it out:

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 10, 2014 Feb 10, 2014
LATEST

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines