0 Replies Latest reply on Mar 3, 2011 3:17 PM by 2009 Matt

    Problem to rotate an image with resizing

    2009 Matt Level 1

      I use Rotate effect on a picture that was taked vertically to rotate the picture 90 deg. The picture should be still in the same sized VBox after rotation.


      <mx:VBox id="vb2" width="520" height="420" horizontalAlign="center" >

           <mx:Image id="image" source="...."  horizontalAlign="center" verticalAlign="middle" height="100%" width="100%" />


      </mx:VBox >


      In the function that triggers the Rotate effect, I set


      rotateEffect.originX = image.width/2;

      rotateEffect.originY = image.height/2;


      rotateEffect.angleFrom = image.rotation;
      rotateEffect.angleTo = image.rotation + 90;


      image.width = orginalImageHeight; // orginalImageHeight is the height of the picture before any rotation.


      The first 90 deg rotation brings the picture to the vertical position and works fine. The size of the picture is correctly reduced and the picture is rotated

      around its center. The picture is at the correct location.


      When I continue rotating another 90 deg that brings the picture to the horizental position, with


      image.width = orginalImageWidth; orginalImageWidth is the width of the picture before any  rotation.


      The picture rotates 90 deg and the size of the picture becomes the original size, but it is not rotated around its center. The location of the picture has be changed.


      I tried to initialize the picture with image.x=0 and image.y=0  before a rotation, but it does not help.


      Any suggestions?