Jump to content
Search Community

daniel_siq

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by daniel_siq

  1. well, not quite.

    for example, using this demo http://hulting.homedns.org/takers_us/li ... D_Demo.swf

    if you first tween rotationX to 90, and then rotationZ to 90, it will rotate the movieclip clockwise in the screen, pointing up and down.

    The correct behaviour for local coordinate (not parent/child coordinate) would be for the image to remain a horizontal sliver and rotate around it's new Z axis, which now points "up and down"

     

    I've been able to achieve the rotation in the local axis, but as you can see by the code, it's far from an elegant solution and having relative values does not help a bit for what I need.

    I was hoping you would have something like this somewhere.

     

    var mc:MovieClip = new MovieClip();
    mc.graphics.beginFill(0xff0000);
    mc.graphics.drawRect(-stage.stageWidth*.25,-stage.stageHeight*.25,stage.stageWidth*.5,stage.stageHeight*.5);
    mc.graphics.endFill();
    mc.x=stage.stageWidth*.5;
    mc.y=stage.stageHeight*.5;
    mc.z=0;
    addChild(mc);
    
    
    //rotationGlobal(80); rotationGlobal(0,0,45); //Uncomment this for Global rotation
    //rotationLocal(80); rotationLocal(0,0,45); //Uncomment this for Local rotation
    
    function rotationGlobal(x:int=0, y:int=0, z:int=0):void{ //Absolute Values
    if (x) mc.rotationX=x;
    if (y) mc.rotationZ=y;
    if (z) mc.rotationZ=z;
    }
    
    function rotationLocal(x:int=0, y:int=0, z:int=0):void{ //Relative values
    var raw:Vector. = mc.transform.matrix3D.rawData;
    var right:Vector3D = new Vector3D(raw[0], raw[1], raw[2]);
    var up:Vector3D = new Vector3D(raw[4], raw[5], raw[6]);
    var out:Vector3D = new Vector3D(raw[8], raw[9], raw[10]);
    var pivot:Vector3D = new Vector3D(mc.x, mc.y, mc.z);
    
    mc.transform.matrix3D.appendRotation(x, right, pivot);
    mc.transform.matrix3D.appendRotation(y, up, pivot);
    mc.transform.matrix3D.appendRotation(z, out, pivot);
    
    }
    

×
×
  • Create New...