This is a blog about Flash & AS by betaruce :-)

## Calendar

June 2007
M T W T F S S
« May
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
• Categories
• Archives
• Meta

• ## *My Publications*

• Flash8 Master Show

• ## My Contact

• Brandon Ellis: you could use a little Regular Expression to check: // notice in local links on Windows you have to...
• Mobile: Thanks for your tutorial!
• patrick mantout: thanks a lot for your tutorial. :-) You can see my tutorial in AS3 here...
• Keith H: This post and additional comment was greatly helpful to me. Thanks both of you.

## September 18, 2005

### Flash 8 Tips: Matrix

Filed under: Using Flash — betaruce @ 2:45 am

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).

• • •