Tip of the Day – Flipping Display Objects

The tip that helped me the most lately is the with flipping objects with the help of matrices.

Here is the code:

function flip( display:DisplayObject, orientation:String ):void {
       var m:Matrix = display.transform.matrix;
       switch (orientation.toUpperCase()) {
               case "HORIZONTAL" :
                       m.a = -1;
                       m.tx = display.width + display.x;
               case "VERTICAL" :
                       m.d = -1;
                       m.ty = display.height + display.y;
       display.transform.matrix = m;
flip(logo, "horizontal");

This tip was provided by Sidney K. Thanks Sidney!

Related Posts

Comments Closed