Matrix class and object transformations in ActionScript3

over 3 years ago malczak actionscript comments

AS3 transformation order

For DisplayObject descendant classes we can use transform property to append any transformation. In AS3 (FP9) only affine transformations are possible, with use of Matrix class. Transformation property defines how object is transformed, before it is drawn to its parent canvas. Every object has its own (local) coordinate system, its orgin is used as position of object in parent coordinate system (an it is called registration point).
This is shown in image below.

In this image we defined M to be Object.transform.matrix. This can be used, if we want to transform point from local to parent coordinate system. And vice versa, using inverted matrix.
We can also calculate screen coordinates transform.concatenatedMatrix property. This is a matrix representing the combined transformation matrixes of the display object and all of its parent objects, back to the root level. We will get the same result using localToGlobal() function.

To transform point from screen coordinate system to object coordinates we can use inverted transform.concatenatedMatrix matrix,or (faster way) globalToLocal() function.

Comments

almost 3 years ago RaiulBaztepo #0

Hello!
Very Interesting post! Thank you for such interesting resource!
PS: Sorry for my bad english, I'v just started to learn this language ;)
See you!
Your, Raiul Baztepo

New comment

  1. (with http or https prefix)

  2. (use [code][/code] tags to post a code snippet)

  3. (javascript is required)

Website content premeditately commited by malczak & sobstel.
Layout by mlando. Icons by dryicons.com. All rights reserved.