Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
GR

How to stop a tween without creating a tween object?

Recommended Posts

Hey,

in my code i generate n number of items and assign tween to them. below is the sample code:

for(var i=0; i<myArr.length; i++){
var item:myObj = new myObj();
TweenLite.to(item, 30, {x:1200});
}

 

Now, on clicking on one item, i want to remove its tween. how can i achieve this?

Link to post
Share on other sites

instead of "TweenLite.to" if I create object of the tween:

var myTween:TweenLite = new TweenLite.....

 

how will i get the tween of the clicked item?

Link to post
Share on other sites

If you want to remove it's tween:

function killEm(e:MouseEvent):void

{

TweenLite.killTweensOf(e.currentTarget)

}

myObj.addEventListener(MouseEvent.CLICK, killEm);

----------------------------------------

If you want to pause its tween:

// Create tween using var

var myTween:TweenLite = new TweenLite.....

//Assign the tween as a property of the object:

myObject.tween = myTween;

// Setup eventListener and function

myObj.addEventListener(MouseEvent.CLICK, pauseTween);

 

function pauseTween(e:MouseEvent):void

{

e.currentTarget.myTween.pause();

}

  • Like 3
Link to post
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.

×