`
jie66989
  • 浏览: 251270 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

FLEX里图片绕中心旋转

    博客分类:
  • 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)



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics