Jump to content

Forcing a clockwise rotation always - possible?

Recommended Posts

I searched around the forums but could not find any post that could help me so my apologies if it has been answered before. Basically I have a clock type arm that spins to different positions depending on what the user selects. It spins just like a clock arm, its pivot being at the end of the arm. Everything works fine except that the arm should only rotate clockwise, never counter-clockwise. So on some values the user selects the arm spins in the opposite direction, sometimes oddly enough even if the opposite direction is not the closest distance it will still spin that way.


I just need to always force it to spin clockwise no matter the value. Is there any way I can do this? Let me know thanks.

Share this post

Link to post
Share on other sites

Sure, the key here is to always make sure that the rotational value increases - it can go beyond 360 because visually there's no difference and Flash will adjust it internally anyway (Flash always reports rotational values as between 180 and -180).


For example, let's say your object's current rotation is 170 and your user clicks at a spot that reports as -170. If you do a normal tween from 170 to -170, that'll go backwards. So the key is to make sure the destination is always greater than the current value, so you can simply add 360 degrees if it's not.


if (targetRotation < currentRotation) {
   targetRotation += 360;
TweenLite.to(myObject, 1, {rotation:targetRotation});


See what I mean?

  • Like 1

Share this post

Link to post
Share on other sites

that was so amazingly simple. It works perfectly. lol. thanks!

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.