Sunday, November 15, 2009

Objecthandler in flex 3

hi,
Object handler is the best way for image handling..inside that you can rotate,resize and flipping the image without any problem..here i  am writing simple code  for object handle using flex 3.i hope it  will help for  somebody...
Below example , i did vertical flip, rotation and resizing the image using object handles ...
and u can write function for resizing or used resize handle..
code:
?xml version="1.0" encoding="utf-8"?>
mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:oh="com.roguedevelopment.objecthandles.*">

protected var resize_handle:Class;
 [Embed(source="rotate_handle.png")]
protected var rotate_handle:Class;
public function flip(evt:MouseEvent):void
{
var skewMatrix:Matrix =evt.currentTarget.transform.matrix;
if(skewMatrix.a==1)
{
skewMatrix.a=-1;
 skewMatrix.tx=evt.currentTarget.x+evt.currentTarget.width;
 evt.currentTarget.transform.matrix = skewMatrix;
}
 else{
skewMatrix.a=1;
 skewMatrix.tx=evt.currentTarget.x-evt.currentTarget.width;
 evt.currentTarget.transform.matrix = skewMatrix;
}   } ]]>/mx:Script

mx:Canvas id="genericExamples" label="Generic" backgroundColor="0xffffff" backgroundAlpha="1" width="100%" height="100%" >
 oh:ObjectHandles horizontalScrollPolicy="off" verticalScrollPolicy="off" id="oh12" allowRotate="true" resizeHandleImage="{resize_handle}"  rotateHandleImage="{rotate_handle}"  x="10" y="20" width="240" height="130" minHeight="30" minWidth="100" click="flip(event);" >
mx:Image source="oscar_dresses.jpg" width="100%" height="100%"  x="10"/>  /mx:Canvas>/mx:Application>

reference:http://www.rogue-development.com/objectHandles.html.

No comments:

Post a Comment