Search code examples
actionscript-3flashpositionscaleaddchild

as3 addChild into scaled movie clip & keep same scale and position


ATTEMPTING:

Loading a movie clip (NoScale_mc) into a scaled movie clip (Scaled_mc).

ISSUE:

When I load the movie clip NoScale_mc into Scaled_mc it obviously scales too.

QUESTION:


How can I keep the NoScale_mc in THE EXACT SAME POSITION and THE EXACT SAME SCALE but yet still load it into the Scaled_mc using the addChild() method?



Solution

  • You could do a little reverse tirckery with math to try to accomplish this. So get the scaled values of the parent DisplayObject and use those values to inverse-scale the child DisplayObject.

    For instance, the parent DisplayObject is scaled to: scaleX = 1.45 and scaleY = 4.6. So you can set the child DisplayObject to: scaleX = 1/1.45 and scaleY = 1/4.6.

    This may produce odd results though, and will most-likely end up being a headache to maintain. You're probably better off adding the child DisplayObject to the stage on top of the parent, like Marty Wallace said. If you want to keep it looking aligned with the parent DisplayObject, then just set both of their x and y positions to the same thing (or with an offset, if that is what is desired).