FLEX里图片绕中心旋转
原文地址:http://rss.9ria.com/?p=1998
package{import flash.display.DisplayObject;import flash.geom.Point;import flash.geom.Matrix;public class TransformWithPoint {public static function transformWithExternalPoint(displayOb:DisplayObject, regPiont:Point, angleDegrees:Number = 0, sx:Number = 1, sy:Number = 1):void{//自身坐标系var m:Matrix = displayOb.transform.matrix;m.tx -= regPiont.x;m.ty -= regPiont.y;if (angleDegrees % 360 != 0) {m.rotate(angleDegrees*(Math.PI/180));}if (sx != 1 || sy != 1) {m.scale(sx,sy);}m.tx += regPiont.x;m.ty += regPiont.y;displayOb.transform.matrix = m;}public static function transformWithInternalPoint(displayOb:DisplayObject, regPiont:Point, angleDegrees:Number = 0, sx:Number = 1, sy:Number = 1):void{//容器坐标系var m:Matrix = displayOb.transform.matrix;regPiont = m.transformPoint(regPiont);m.tx -= regPiont.x;m.ty -= regPiont.y;if (angleDegrees % 360 != 0) {m.rotate(angleDegrees*(Math.PI/180));}if (sx != 1 || sy != 1) {m.scale(sx,sy);}m.tx += regPiont.x;m.ty += regPiont.y;displayOb.transform.matrix = m;}}}//TransformWithPoint.transformWithInternalPoint(sp,new Point(100,100),90)//TransformWithPoint.transformWithExternalPoint(sp,new Point(50,50),90)