views:

32

answers:

2

So I have that panel or any other mxml component. I want somehow to rotate it around like a wheel of a car with which you drive it... loke a Racing wheel... sow like when mousebutton is down it captures pont of component... when you move mouse component rotates (not moves) according to new mouse position... How to rotate MXML component round its center like a wheel respectfully to mouse?

welll feel free to edit this question because I know Ive formulated it in a bad way...

A: 

I believe you can rotate the component using the rotateX, rotateY, and rotateZ properties:

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

Just make that happen in response to a mouse click.

www.Flextras.com
but how to change the registry point position (i use Spark framework)
Blender
You mean you want to change the center point for which the item rotates? I don't know if that's possible; you'll have to experiment to find out. IF all else fails, you can go to a framework such as PaperVision3D or Away3D.
www.Flextras.com
+1  A: 

Add these to a utility class if you don't want to add a dependency to 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;
    }

They are MatrixTransformer's rotateAroundInternalPoint() and rotateAroundExternalPoint()

That would be for 2d. For 3d see transformAround.

Don't forget to check if layout siblings are updated properly or not.

HTH

George Profenza
could you give simple mxml example with canvas or group?
Blender
George Profenza