Jump to content
GreenSock

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

TweenLite used as a Timer?

Recommended Posts

Hi all,

 

I started routinely using Tweenlite.to() static method instead of a Timer by setting a fake target (like 'this') and just putting a onComplete on the tweenvars object.

I dunno if I should, what about the efficiency of that trick?

 

  TweenLite.to(this,2,{onComplete:myFunc});
function myFunc()
{
//My instructions...
}

Link to comment
Share on other sites

TweenLite has a built in method called delayedCall() that is perfect for your situation.

 

TweenLite.delayedCall(2, myFunc); //myFunc will fire after 2 seconds


function myFunc()
{
//My instructions...
}

 

delayedCall also takes an array of parameters for the function that is getting called.

 

http://www.greensock...l#delayedCall()

 

You may find it interesting that delayedCall actually creates a TweenLite instance behind the scenes that works similar to your method. delayedCall() just makes it easier to get the same end result with less code.

Link to comment
Share on other sites

Thank you, that is perfect !

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