Jump to content
Search Community

Tween play() and reverse()

FlashDev2007 test
Moderator Tag

Recommended Posts

Hello Jack,

 

I am using a simple TweenMax for tweening something which i need to reverse later on. The problem i get is if the tween is at the start and i call reverse it does not complete, and it its at end and i call play() it does not fire complete. I suspect some folks say this is what you would expect, but my build relies on these events. I have a work around as follows, but I suspect you have some property that handles this that I can't find

 


override public function forward():void
	{
		if(_tween.currentProgress == 1)
		{
			transitionCompleteHandler();
		}
		else
		{
			_tween.play();
		}
	}

override public function reverse():void
	{
		if(_tween.currentProgress == 0)
		{
			transitionReverseCompleteHandler();
		}
		else
		{
			_tween.reverse();
		}
	}

 

Thanks for all your help you give the community.

 

Neil

Link to comment
Share on other sites

Yeah, that would be expected behavior because when you're dealing with tweens, you're dealing with change, so typically you only want the onComplete to fire when the tween ARRIVES at its destination, not if it's already there and the virtual playhead didn't go anywhere. However, there's a way to accommodate your request with an undocumented renderTime() method. Its 3rd parameter is a "force" Boolean that allows you to force it to render even if the playhead didn't move. That should give you what you need. So right after you play() or reverse(), you can render right away, like:

 

override public function forward():void {
    _tween.play();
    _tween.renderTime(_tween.currentTime, false, true);
}

 

But your workaround would be fine too. Just a little more verbose.

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