# Is there a memory read/write or performance difference when applying affine transformations on a movieclip rather basic elementary math

I am using Actionscript 3.0 to make games and I fall into the category of programmers who use ball.x+=5; ball.y+=5; in order to move a ball by 5 pixels horizontally and vertically.

Well, now i seem to have an issue with a game I am making, it has a 3-body vehicle and each has its own translation and rotation. The three bodies: front, back1,back2 exist inside the top movieclip called vehicle. So each of them has a different coordinate system compared to the top movieclip. Well, when the vehicle crashes onto an obstacle in my game, I have to reset the movieclip, this is done by taking apart all the x,y,rotation of each movieclip into an array at the beginning of the game and restoring it to the beginning position after crash.

Well , but ,now I have stumbled upon this

transform.matrix

feature in flash, which allows me to perform mathematical transformations on the movieclip's transformation matrix, and now on applying mathematical transformations on the top level movieclip, all the inside movieclips are affected, It is a huge advantage to me.

But, I would like to know, IF i use this technique by breaking apart my whole code written as of now and re-writing it into using transformation matrices for every single horizontal, vertical or rotation of the vehicle. Will it affect my performance?

Thank you.

• That is some bad design. If you run into something with enough velocity, you will teleport backwards when you crash into something. Commented May 13, 2011 at 17:25

Using matrices for transformation isn't exclusive to using x, y and rotation properties. These actually all map to the same thing. If you update x, y or rotation, the matrix will also change.
So you can freely mix these things. You can store the initial position matrix somewhere, to easily restore it later on, but you can also still do things like ball.x += 5