Little tricks to rotate images in Flex

My last project is an Image manipulator made with Flex and AIR, so I guide a user to manipulate (rotation, resizing…) an image, choosen from own computer, with a wizard.
When I was at Rotation step, I said: “and now?!”.

Infact if you use rotation property of an Image component it rotates in 0,0, but there is a little trick to rotate an image or component with origin in the middle.
If you use Rotate effect, you can decide which is the origin point, so if you write:

var rotEff:Rotate = new Rotate();
//img is the ID of Image component in MXML file rotEff.target = img; rotEff.originX = img.width/2; rotEff.originY = img.height/2; rotEff.duration = 1500; rotEff.angleFrom = img.rotation; rotEff.angleTo = img.rotation + 90; rotEff.play();

With those script you can rotate an image or component in the middle.
That’s a little trick!
Enjoy

Advertisements