Posted By

kajyr on 05/19/10


Tagged

flip horizontal vertical actionscript3 DisplayObject


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

socialflasher
alptugan


Flipping DisplayObjects


 / Published in: ActionScript 3
 

URL: http://www.nightdrops.com/2010/quickreference-flipping-displayobjects/

  1. public static function flipHorizontal(obj:DisplayObject):void {
  2. var m:Matrix = obj.transform.matrix;
  3. m.transformPoint(new Point(obj.width * .5, obj.height * .5));
  4. m.tx = (m.a > 0)?obj.width + obj.x:obj.x - obj.width;
  5. m.a = -1 * m.a;
  6. obj.transform.matrix = m;
  7. }
  8.  
  9. public static function flipVertical(obj:DisplayObject):void {
  10. var m:Matrix = obj.transform.matrix;
  11. m.transformPoint(new Point(obj.width * .5, obj.height * .5));
  12. m.ty = (m.d > 0)?obj.y + obj.height:obj.y - obj.height;
  13. m.d = -1 * m.d;
  14. obj.transform.matrix = m;
  15. }

Report this snippet  

You need to login to post a comment.