/** * 绕中心点旋转 * * @param mc 元件 * @param angle 角度 */ public function centerRotate(mc:DisplayObject,angle:Number):void { var currentRotation:Number = mc.rotation; //获取mc不旋转时候的尺寸 mc.rotation = 0; var mcWidth:Number = mc.width; var mcHeight:Number = mc.height; mc.rotation = currentRotation; //获取mc当前中心点坐标 var pointO:Point = mc.localToGlobal(new Point(mcWidth / 2, mcHeight / 2)); //旋转mc mc.rotation = angle; //获取mc旋转后中心点坐标 var pointO2:Point = mc.localToGlobal(new Point(mcWidth / 2, mcHeight / 2)); //平移到原来中心点O var p3:Point = pointO.subtract(pointO2); var matrix:Matrix = mc.transform.matrix; matrix.translate(p3.x, p3.y); mc.transform.matrix = matrix; }