6 Replies Latest reply on Mar 20, 2007 6:20 PM by MotionMaker

    How would I scale all but text elements in a MC?

    odie11
      I have a movieclip (a grid) which scales up and down with user input. The movieclip has some labels (could be nested text boxes or movieclips) which I do not want to scale in size BUT I do want them to keep their relative positions within the grid movieclip as it scales in size. I'm not really sure the best way to 'attack' this problem...any suggestions?
        • 1. Re: How would I scale all but text elements in a MC?
          MotionMaker Level 1
          Do not reset MC _widths and _heights.
          Redraw the mc grid borders and background and move the children as the resizing is occurring.
          • 2. How would I scale all but text elements in a MC?
            odie11 Level 1
            quote:

            Originally posted by: MotionMaker
            Do not reset MC _widths and _heights.
            Redraw the mc grid borders and background and move the children as the resizing is occurring.



            Thanks MM, but I don't understand your suggestion. I am using ._xscale to change the size of a parent MC but I do not want some of the child MCs (textboxes) to change size. If I remove the child MC's from the parent then they stay constant size like I want but then I need to reposition them in the proper relative position.

            To use an analogy, picture a map with a "dot" to represent a city along with an adjacent label (textbox) containing the city name. Now picutre the user enlarges the map size (zooms in) but the size of the city name remains constant AND stays in the same relative position next to the "dot" representing the city.

            The real problem I am having is with "move the children as the resizing is occurring". I can't seem to get this to actually work correctly. If I scale the parent 110% and move the textbox child MC current ._x + 10% it doesn't line up. It's hard to explain but I think the problem comes down to relative and absolute position references (localtoglobal maybe)?

            • 3. Re: How would I scale all but text elements in a MC?
              MotionMaker Level 1
              Seems like the problem is the container scale changes and then the or some of children scales are changed to negate the change to the container so they appear the same size.

              So you need to recompute the scales for the children.

              For positioning you need to adjust the children _x and _y for the scaling change to container.

              Paste this code to frame one of a new Flash document and see if it helps:
              • 4. Re: How would I scale all but text elements in a MC?
                odie11 Level 1
                Success - A BIG thank you to MM!! Based on your code I was able to eventually get it working. My situation was a bit more convoluted...

                I had to modify and extrapolate the logic of the innerCentredBox repositioning code.
                quote:

                innerCenteredBox_mc._x = ( box_mc._width * box_xScaleFactor - innerCenteredBox_mc._width) / 2;
                The division by "2" represents an x position of half way or 50 percent within the parent MC. I had a number of child text MCs at various scattered x positions so I could not simply divide by 2 - I had to devise a ratio based on their initial location (._x) to the ._width of the parent.

                The other complicating factor I had to deal with was the fact that the parent MC origin was offset from the stage (long story). Anyhow, in the end I did get it working but it took a fair bit of trial and error and the solution was not straight forward. Without your help MM I don't think I could have got it working, so aqain thanks for the help MM.

                Now, just for bonus, I'm going to try optimizing the code by removing the text MCs from the scaling parent so that they avoid being scaled up and down altogether and are simnply just repositioned.
                • 5. Re: How would I scale all but text elements in a MC?
                  odie11 Level 1
                  Success - A BIG thank you to MM!! Based on your code I was able to eventually get it working. My situation was a bit more convoluted...

                  I had to modify and extrapolate the logic of the innerCentredBox repositioning code.
                  quote:

                  innerCenteredBox_mc._x = ( box_mc._width * box_xScaleFactor - innerCenteredBox_mc._width) / 2;
                  The division by "2" represents an x position of half way or 50 percent within the parent MC. I had a number of child text MCs at various scattered x positions so I could not simply divide by 2 - I had to devise a ratio based on their initial location (._x) to the ._width of the parent.

                  The other complicating factor I had to deal with was the fact that the parent MC origin was offset from the stage (long story). Anyhow, in the end I did get it working but it took a fair bit of trial and error and the solution was not straight forward. Without your help MM I don't think I could have got it working, so aqain thanks for the help MM.

                  Now, just for bonus, I'm going to try optimizing the code by removing the text MCs from the scaling parent so that they avoid being scaled up and down altogether and are simnply just repositioned.
                  • 6. Re: How would I scale all but text elements in a MC?
                    MotionMaker Level 1
                    Great! Looks like you are having fun!