### Flash 8 Tips: Matrix

We can use **Matrix** to do scaling and rotation on MovieClips. However, **if we use the method scale() and rotate() of the Matrix class, the translation of the mc will also be affected**, i.e. the

`tx`

and `ty`

values are also changed.Therefore, I may not use `scale()`

if I want to scale a mc with matrix. Instead I will do the following (assume that there’s a movieclip named “mc” on the stage):

`mat = mc.transform.matrix;`

mat.a += .1;

mat.d += .1;

mc.transform.matrix = mat;

Scaling is done simply by changing the values of `a`

and `d`

.

For rotation, however, since I do not want to do so many sin and cos calculations, I still apply the `rotate()`

method, and afterwards change the `tx`

and `ty`

back to their original values.

`mat = mc.transform.matrix;`

mat2 = mat.clone();

mat.rotate(Math.PI/6);

mat.tx = mat2.tx;

mat.ty = mat2.ty;

mc.transform.matrix = mat;

By using either of these 2 methods, we can do scaling and rotation with the mc remain in the same place (but not moving away).

Interesting read but do you happend to know why when you apply a transform in the matrix to a tween it stops working?

Comment by Svetoslav — September 29, 2005 @ 3:34 pmdo you mean that you apply it to a MC that is undergoing Motion tween?

Comment by betaruce — September 29, 2005 @ 9:11 pm