所以我有那个面板或任何其他mxml组件。我想以某种方式将它旋转,就像你驾驶它的汽车的轮子一样......懒散一个Racing wheel ...播种就像当鼠标按钮向下时捕获组件的pont ...当你移动鼠标组件时根据新的鼠标位置旋转(不移动)...如何将MXML组件像轮子一样围绕其中心旋转到鼠标?
欢迎随时编辑这个问题,因为我知道我已经以糟糕的方式制定了它......
答案 0 :(得分:2)
如果您不想向fl.motion添加依赖项,请将它们添加到实用程序类。*
/**
* Rotates a matrix about a point defined inside the matrix's transformation space.
* This can be used to rotate a movie clip around a transformation point inside itself.
*
* @param m A Matrix instance.
*
* @param x The x coordinate of the point.
*
* @param y The y coordinate of the point.
*
* @param angleDegrees The angle of rotation in degrees.
* @playerversion Flash 9.0.28.0
* @langversion 3.0
* @keyword Matrix, Copy Motion as ActionScript
* @see flash.geom.Matrix
*/
public static function rotateAroundInternalPoint(m:Matrix, x:Number, y:Number, angleDegrees:Number):void
{
var point:Point = new Point(x, y);
point = m.transformPoint(point);
m.tx -= point.x;
m.ty -= point.y;
m.rotate(angleDegrees*(Math.PI/180));
m.tx += point.x;
m.ty += point.y;
}
/**
* Rotates a matrix about a point defined outside the matrix's transformation space.
* This can be used to rotate a movie clip around a transformation point in its parent.
*
* @param m A Matrix instance.
*
* @param x The x coordinate of the point.
*
* @param y The y coordinate of the point.
*
* @param angleDegrees The angle of rotation in degrees.
* @playerversion Flash 9.0.28.0
* @langversion 3.0
* @keyword Matrix, Copy Motion as ActionScript
* @see flash.geom.Matrix
*/
public static function rotateAroundExternalPoint(m:Matrix, x:Number, y:Number, angleDegrees:Number):void
{
m.tx -= x;
m.ty -= y;
m.rotate(angleDegrees*(Math.PI/180));
m.tx += x;
m.ty += y;
}
他们是MatrixTransformer的rotateAroundInternalPoint()和rotateAroundExternalPoint()
那将是2d。对于3d,请参阅transformAround。
不要忘记检查布局兄弟姐妹是否正确更新。
HTH
答案 1 :(得分:0)
我相信你可以使用rotateX,rotateY和rotateZ属性旋转组件:
http://docs.huihoo.com/flex/4/mx/core/UIComponent.html#rotationX
只需点击鼠标即可实现。