3 Replies Latest reply on Apr 5, 2007 1:04 PM by Rothrock

    attaching MovieClip to stage

      Instead of attaching movie clips to the stage spacing them with a set variable how can I space them 10px more than the bottom of the last MovieClip attached?

      I am creating a menu and some of the text in the menu items has to wrap which increases the height of the menu so I need the next menu item to space evenly and not on top of the next one. I also can't increase the set variable because the rest of the menu items will not visually look correct. Too much spacing.

      Here is my code:
        • 1. Re: attaching MovieClip to stage
          Rothrock Level 5
          Well, how big is the last movie attached?

          I'm guessing you could find that with lastMovieAttached._height, right?

          So add 10 to that and there you go.

          If you have a bunch of them to do you can just keep adding like this:

          curYpos += lastClipAttached._height +myMenuPad;

          Make sure that in this case you start somewhere (outside of any loops) with

          var curYpos:Number=0;
          var myMenuPad:Number=10;

          Trust me on defining that menu pad as a variable. Later you will need to change it and this way there is only one place too look. You won't have to go hunting through lines of code and wondering if any 10 you see is for that or for something else.
          • 2. attaching MovieClip to stage
            arandlett Level 1
            Thanks for the point in the right direction. That didn't work all the way because when the text would wrap it was still reading the btn height with text on one line. So what I did was determin if the length of the button title was past a certain # of characters then return a number to use for extra padding. Now all is working.

            Here is the solution below:

            • 3. Re: attaching MovieClip to stage
              Rothrock Level 5
              You might want to look at getTextExtent() method of the TextFormat class. It will tell you how big text is or how big it will be.