Jump to content
Search Community

how can you pause/resume a specific tween?

chrisatflash test
Moderator Tag

Recommended Posts

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

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

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