Jump to content
Search Community

How to stop a tween without creating a tween object?

GR test
Moderator Tag

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