Flipping DisplayObjects


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.