Share Posted October 15, 2008 Hi Jack, I'm having a problem rotating a selected item when i use the following code. How can i get the rotation right? ( is suck at math ). private function rotateSelected(value:Number) { //value = -1 or 1 var angle:Number = Math.atan2(currentTarget.x,currentTarget.y) manager.rotateSelection(angle+value) } Link to comment Share on other sites More sharing options...
Share Posted October 15, 2008 Sorry, but I have no idea what you're trying to accomplish so I can't help with the Math. Please explain. Link to comment Share on other sites More sharing options...
Author Share Posted October 15, 2008 Hey Jack sorry for my confusing explenation, I have a transformItem on the stage and 2 buttons one for rotating the object left( - ) and one for rotating the object right( + ). When i push one of the buttons the function rotateSelected is fired and i get a variable called "value" Button "Left" gives a value of -1 wich indicates that the transformItem has to rotate counter clockwise. Button "Right" gives a value of 1 wich indicates that the transformItem has to rotate clockwise. In short i want the user to rotate the object with the buttons. I know this is possible by calling TransformManager.rotateSelected("angle") But i have no idea on how to get the right value for the angle. Link to comment Share on other sites More sharing options...
Share Posted October 16, 2008 It should be relatively straightforward as long as you realize that rotateSelection() accepts RADIAN values, not degrees If you want to translate degrees to radians, you'd just do: var radians:Number = degrees * (Math.PI / 180); So if you want it to rotate 5 degrees, have your + button call a function like: function onClickPlus($e:MouseEvent):void { myManager.rotateSelection(5 * (Math.PI / 180)); } And your - button could call something like: function onClickMinus($e:MouseEvent):void { myManager.rotateSelection(-5 * (Math.PI / 180)); } Link to comment Share on other sites More sharing options...
Author Share Posted October 16, 2008 Hey Jack, That's exactly what i was searching for! Thanks! Link to comment Share on other sites More sharing options...
Share Posted February 18, 2011 hey, function onClickMinus($e:MouseEvent):void { myManager.rotateSelection(-5 * (Math.PI / 180)); } flex code ? private function myRotate():void{ ............? } Link to comment Share on other sites More sharing options...
Share Posted February 22, 2011 The Flex code wouldn't really be different. And it depends on what you named your FlexTransformManager instance. private function myRotate():void{ myManager.rotateSelection(-5 * (Math.PI / 180)); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now