I wanted to Rotate a button when mouse pointer is hovered over it. But even if I set OrginX & originY to button.width/2 & button.height/2 respectively, it is rotating with top left corner of the button as rotating origin centre.
I will attach the function used for rotating below.
private function rotbut():void
var rot:Rotate = new Rotate();
rot.target = but2;
rot.originX = (but2.width)/2; //need it to rotate around it's center
rot.originY = (but2.height)/2; // -- " --
rot.angleTo = 360;
rot.duration = 1000;
The button is rotating, but its not rotating around its centre. rather its rotating with top left corner of the button as axis centre. Wat is wrong with ma code?
Please Help me
Rotating works well and your function is ok.
I think that the problem is in the positioning of Button. I think that data bindings for x and y position of but2 is working.
For example, if you set that x position should be on the center, it will always be in the center.
Show the code for your Button if you need more help.
This is the code for the button
<mx:Button id="but2" enabled="true" alpha="1.0" cornerRadius="20" fillAlphas="[0.0, 0.0, 0.0, 0.0]" borderColor="#030304" themeColor="#000000" horizontalCenter="0" verticalCenter="72" width="64" height="64" rightClick="rotbut()">
N.B:- rotbut() is the function for rotating
If you remove horizontalCenter and verticalCenter all will work fine.
But I cann't understand why rotating on center doesn't work to it...