Jump to content
GreenSock

chrisatflash

how can you pause/resume a specific tween?

Recommended Posts

Hello,

Is it possible to pause a specific tween by it's diplayobject type?

I noticed TweenMax.pauseAll() , but Is there also something like TweenMax.pause(obj) and TweenMax.resume(obj) ?

Link to comment
Share on other sites

the easist thing to do would be to store a reference to the individual tween you want to pause and resume

 

var boxTween:TweenMax = new TweenMax(box, 1, {x:300});

 

boxTween.pause();

boxTween.play();

 

 

OR use TweenMax.getTweensOf(box) and then loop through the array of tweens and pause/resume them all

http://www.greensock.com/as/docs/tween/ ... tTweensOf()

Link to comment
Share on other sites

thanks for the reply! It's great that this feature is available!

Regards, Chris.

Link to comment
Share on other sites

I created a util for this, so now I can stop all tweens of any displayobject.

 

package com.chris.util 
{
import com.greensock.TweenMax;
import flash.display.DisplayObject;
/**
 * ...
 * @author Chris S
 */
public class TweenMaxUtil 
{

	static public function stopAnimation(obj:DisplayObject):void {
		var tweenArray:Array = TweenMax.getTweensOf(obj);
		for (var i:int = 0; i < tweenArray.length; i++) {
			var tweenref:TweenMax  = tweenArray[i] as TweenMax;
			tweenref.pause();
		}

	}

	static public function startAnimation(obj:DisplayObject):void {
		var tweenArray:Array = TweenMax.getTweensOf(obj);
		for (var i:int = 0; i < tweenArray.length; i++) {
			var tweenref:TweenMax  = tweenArray[i] as TweenMax;
			tweenref.play();
		}

	}

}

}

Link to comment
Share on other sites

that looks useful. thanks for sharing!

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