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


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.

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

1 Answer 1


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

There's no negative impact in using the matrix for transforms. I guess it's probably even faster, since you set all transformations at once instead of setting each property individually.

  • \$\begingroup\$ +1 for telling me , manipulating matrices is faster, let me wait for some more days while i (code&re-code) :) before I mark this as the answer \$\endgroup\$
    – Vishnu
    Commented May 13, 2011 at 11:42
  • 1
    \$\begingroup\$ You don't have to re-code everything. Like I said, you can freely mix these things. The marginal performance gain of using matrices isn't worth re-coding everything. \$\endgroup\$
    – bummzack
    Commented May 13, 2011 at 12:15
  • \$\begingroup\$ ok ! Thanks for that too, (this app doesnt let me write just "ok !" :) \$\endgroup\$
    – Vishnu
    Commented May 16, 2011 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .