Search

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:
  1. _mcParent._mcChild.scaleX = 1 / _mcParent.scaleX;
  2. _mcParent._mcChild.scaleY = 1 / _mcParent.scaleY;
  3. _mcParent._mcChild.x = _nChildStartX / _mcParent.scaleX;
  4. _mcParent._mcChild.y = _nChildStartY / _mcParent.scaleY;

And here's a simple demo to illustrate the problem and the solution:

Resizing a Parent Sprite without Resizing the child Sprite

demo | source (.fla)

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.

Something to say?

You must be logged in to post a comment.