All Downloads are FREE. Search and download functionalities are using the official Maven repository.

flash.utils.setTimeout.as Maven / Gradle / Ivy

There is a newer version: 4.1.8
Show newest version
package flash.utils {

/**
 * Runs a specified function after a specified delay (in milliseconds).
 * 

Instead of using this method, consider creating a Timer object, with the specified interval, using 1 as the repeatCount parameter (which sets the timer to run only once).

*

If you intend to use the clearTimeout() method to cancel the setTimeout() call, be sure to assign the setTimeout() call to a variable (which the clearTimeout() function will later reference). If you do not call the clearTimeout() function to cancel the setTimeout() call, the object containing the set timeout closure function will not be garbage collected.

* @param closure The name of the function to execute. Do not include quotation marks or parentheses, and do not specify parameters of the function to call. For example, use functionName, not functionName() or functionName(param). * @param delay The delay, in milliseconds, until the function is executed. * @param rest An optional list of arguments that are passed to the closure function. * * @return Unique numeric identifier for the timed process. Use this identifier to cancel the process, by calling the clearTimeout() method. * * @see #clearTimeout * * @example * The following example uses the setTimeout() method to call another method following a specified delay period. * * package { * import flash.display.Sprite; * import flash.utils.*; * * public class SetTimeoutExample extends Sprite { * private var delay:Number = 1000; // delay before calling myDelayedFunction * * public function SetTimeoutExample() { * var intervalId:uint = setTimeout(myDelayedFunction, delay, "Hello", "World"); * } * * public function myDelayedFunction():void { * trace(arguments[0] + " " + arguments[1]); * } * } * } * */ public function setTimeout(closure:Function, delay:Number, ...rest):uint { var timeout:* = window.setTimeout(applyWithRestParameters(closure, rest), delay); return timeout; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy