Flash & AS3 info, source, & experiments
Resizing a Parent Sprite Without Resizing the Child Sprite
A co-worker approached me with a problem today. He wanted to resize a parent Sprite (or MovieClip, DisplayObject, etc) without resizing the child Sprite. So, in a nutshell, here’s how you do it:
[ActionScript]
_mcParent._mcChild.scaleX = 1 / _mcParent.scaleX;
_mcParent._mcChild.scaleY = 1 / _mcParent.scaleY;
_mcParent._mcChild.x = _nChildStartX / _mcParent.scaleX;
_mcParent._mcChild.y = _nChildStartY / _mcParent.scaleY;
[/ActionScript]
And here’s a simple demo to illustrate the problem and the solution:
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.
| Print article | This entry was posted by Nate Chatellier on March 26, 2009 at 3:31 pm, and is filed under ActionScript, Flash. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |