views:

335

answers:

1

Hi all,

Here's something I'm trying to figure out concerning display objects in ActionScript3 / Flex. Let's say you have a display object who's registration point is in the top left and you want to scale it from its center (middle of the display object), How could you easily acheive this with the flash.geom.Matrix class

Thanks for your help

+1  A: 

This is done by translating the object to the desired center of scale/rotation, scale/rotate it and then translate it back.

You can do that with a single matrix by concatenating the matrices to get a single matrix:

var m:Matrix = Matrix.translate(-centerX, -centerY);
m.concat(Matrix.scale(scaleX, scaleY));
m.concat(Matrix.translate(centerX, centerY));
Aaron
Thanks Aaron, much apreciated
just_a_dude
translate() and scale() aren't static methods. You need to call them from a Matrix instance.
picardo
And by the way, the return value on both of those methods is void.
picardo