Jump to content
GreenSock

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

TweenMax.delayedCall()

TweenMax.delayedCall( delay:Number, callback:Function, params:Array, scope:*, useFrames:Boolean ) : TweenMax

[static] Provides a simple way to call a function after a set amount of time (or frames).

Parameters

delay: Number

Delay in seconds (or frames if useFrames is true) before the function should be called

callback: Function

Function to call

params: Array

(default = null) — An Array of parameters to pass the function (optional).

scope: *

(default = null) — The scope in which the callback should be called (basically, what “this” refers to in the function). NOTE: this parameter only pertains to the JavaScript and AS2 versions; it is omitted in AS3.

useFrames: Boolean

(default = false) — If the delay should be measured in frames instead of seconds, set useFrames to true

Returns : TweenMax

TweenMax instance

Details

Provides a simple way to call a function after a set amount of time (or frames). You can optionally pass any number of parameters to the function too.

Note: - Due to the way JavaScript doesn't maintain scope (what "this" refers to, or the context) in function calls, it can be useful to define the scope specifically. Therefore, the 4th parameter allows you to define the scope.

//calls myFunction after 1 second and passes 2 parameters:
TweenMax.delayedCall(1, myFunction, ["param1", "param2"]);

function myFunction(param1, param2) {
//do stuff
}
Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
×