7/2/2010 9:20:09 PM
Title:
canvas size
hi i have one image inside the canvas i want to rotate that image with canvas. rotation working very well but canvas size increased in each rotation.i did not give any size for canvas. once the image reached the normal position canvas also in normal size. here i attached the code which i try,please help me
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundAlpha="0">
<mx:Script>
[Bindable]
public var angle:int=0;
private function rotateImage() : void
{
angle +=90;
rotate.play();
}
</mx:Script>
<mx:Rotate id="rotate" angleFrom="{angle-90}" angleTo="{angle}" target="{img}"/>
<mx:Panel title="Rotate Effect Demo" width="100%" height="100%" horizontalAlign="center">
<mx:Canvas id="canvas" width="100%" height="100%" verticalScrollPolicy="off">
<mx:Image id="img" x="{canvas.width/2 - img.width/2}" y="{canvas.height/2 - img.height/2}"
source="@Embed('autoplay.JPG')"/>
</mx:Canvas>
<mx:ControlBar>
<mx:Button label="Rotate" click="rotateImage()"/>
</mx:ControlBar>
</mx:Panel>
</mx:Application>
7/2/2010 9:50:07 PM
when image is rotated it takes the width and height equal to diagonal distance between one corner to other corner. So you should have that much space to be able to rotate the image .
7/2/2010 9:56:19 PM
you can use fixed width height of canvas and set the vertical and horizontal scrollpolicy to off . by this canvas size will not increase and also there will be no scrollbars , but the image corners will cut during rotation. Use canvas width aqnd height equal to image width and height . Sample
<mx:Canvas id="canvas" width="250" height="250" verticalScrollPolicy="off" horizontalScrollPolicy="off" >
Davis
Points: 780
Posts:0
7/2/2010 9:58:21 PM
first scale the image to decrease its size say( 0.7) and then rotate it , on rotate effect end event set the scaling to 1 means full again to restore the image size .
7/2/2010 10:22:17 PM
thanks for your replies. i m not expecting above solution i tried it already i need something different better and permanent solution. so any one please help me
Davis
Points: 780
Posts:0
7/2/2010 10:35:21 PM
you can do only such solution . Practically its not possible to fit a 200PX image in 150 px. Diagonal width can only be decreased if you decrease the size of image