Jump to content
Search Community

rotation behaving like shortRotation

dmb85 test
Moderator Tag

Recommended Posts

I'm trying to make a simple pressure gauge that has a needle that rotates about 220 degrees. I have 2 tweens, one that tweens rotation to 220, and another that tweens it back to 0.

 

My problem is that when the 2nd tween occurs, its acting like shortRotation is enabled - its tweening the needle to 360, so that it appears that the needle is going around the bottom of the gauge. What am I doing wrong here? 

 

This is my entire code:

 

import flash.events.MouseEvent;
import com.greensock.TweenLite;

onBtn.addEventListener(MouseEvent.CLICK, handler);
offBtn.addEventListener(MouseEvent.CLICK, handler);

function handler(evt:MouseEvent):void {
	switch(evt.target){
		case onBtn:
			TweenLite.to(rotator, 1, {rotation: 220});
		break;
		case offBtn:
			TweenLite.to(rotator, 1, {rotation: 0});
		break;
	}
}

 

Thanks in advance for any help!

 

Link to comment
Share on other sites

Yep, that actually has nothing to do with TweenLite - let me explain...

 

Flash always reports rotation values as between 180 and -180. So if you tween to a rotation of 220 and then immediately trace() the rotation, you'll see it reported by Flash as -140. 

 

mc.rotation = 220;
trace(mc.rotation); //-140

So when you're tweening back to zero, TweenLite says "okay, what's the starting value?" and it gets -140 and animates it to 0 from there. 

 

So in your case, you could check to see if rotation is currently less than 0 and if so, animate to -360 instead of 0. That would look the same and it would go in the direction you want. 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...