Jump to content
Search Community

finish tween before new one starts. [SOLVED]

gareth test
Moderator Tag

Recommended Posts

Hi,

 

Is it possible to have a tween finish before a new one starts? I have some buttons and I would like the roll over effect to always complete before the roll out effect overwrites it. I have tried all of the overwrite properties, but nothing achieves the effect I am after.

 

here is my simple code:

private function buttonRollOver(e:Event):void {
		  TweenLite.to(e.target.buttonTxt, 1, {tint:e.target.txtColorOver,ease:Quad.easeOut});
	}

private function buttonRollOut(e:Event):void {
			  TweenLite.to(e.target.buttonTxt, 1, {tint:e.target.txtColor,ease:Quad.easeOut});
		}
	}

 

thanks,

Gareth

Link to comment
Share on other sites

There are a lot of ways to accomplish it, but here's one:

 

var overTween:TweenLite;

private function buttonRollOver(e:Event):void {
     overTween = new TweenLite(e.target.buttonTxt, 1, {tint:e.target.txtColorOver, ease:Quad.easeOut, overwrite:1});
}

private function buttonRollOut(e:Event):void {
   var timeLeft:Number = overTween.duration - overTween.currentTime;
   TweenLite.to(e.target.buttonTxt, 1, {tint:e.target.txtColor, delay:timeLeft, ease:Quad.easeOut, overwrite:0});
}

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...