Как почтительно повернуть компонент MXML вокруг его центра, как колесо, относительно мыши? - PullRequest
1 голос
/ 16 июня 2010

Итак, у меня есть эта панель или любой другой компонент mxml. Я хочу каким-то образом вращать его, как колесо автомобиля, на котором вы его водите ... например, Racing wheel ... сеять, как когда кнопка мыши нажата, она захватывает элемент компонента ... когда вы перемещение компонента мыши вращается (а не двигается) в соответствии с новым положением мыши ... Как вращать компонент MXML вокруг его центра, как колесо, относительно мыши?

Не стесняйтесь редактировать этот вопрос, потому что я знаю, что я сформулировал его неправильно ...

Ответы [ 2 ]

2 голосов
/ 04 июля 2010

Добавьте их в служебный класс, если вы не хотите добавлять зависимость к 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 .

Не забудьте проверить, правильно ли обновляются макеты-братья или сестры.

НТН

0 голосов
/ 16 июня 2010

Полагаю, вы можете вращать компонент, используя свойства rotateX, rotateY и rotateZ:

http://docs.huihoo.com/flex/4/mx/core/UIComponent.html#rotationX

Просто сделайте это в ответ на щелчок мышью.

...