Jump to content
Search Community

Check Tweening

koishiikun test
Moderator Tag

Recommended Posts

I have a function that restarts a tween on roll over.

 

My question is -- Is there a way to check if the tween is still tweening so that the roll over does not abruptly restarts the tween?

 

I want it to restart ONLY if its not currently tweening. It just looks bad when the user rolls on and off the mc :(

 

Thank you very much!

Link to comment
Share on other sites

There are a lot of solutions to this:

 

1) Instead of restarting your tween, just create a new tween each time on the rollover (they'll overwrite each other by default anyway). Since tweens will go from whatever the current value is to the destination values, you don't need to worry about it jumping backwards to the beginning.

 

2) Use TweenMax.isTweening()

 

3) The tween's currentTIme will go from 0 all the way to the tween's duration over the course of the tween, so if it's 0, it isn't tweening, and if it's the same as the duration, it's done. You can use that conditional logic to figure it out.

Link to comment
Share on other sites

TweenMax has an isTweening() method that can check if an object is tweening or not.

 

 

in the example below, the roll over listener checks the isTweening value of box_mc.

If isTweening = true, the tween will not restart

 

box_mc.addEventListener(MouseEvent.ROLL_OVER, boxOver);

function boxOver(e:MouseEvent) {
     if (!TweenMax.isTweening(box_mc)) {
	TweenMax.fromTo(box_mc, 5, {scaleX:1}, {scaleX:5});
}

}

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