flash.utils.clearTimeout.as Maven / Gradle / Ivy
package flash.utils {
/**
* Cancels a specified setTimeout()
call.
* @param id The ID of the setTimeout()
call, which you set to a variable, as in the following:
*
* @see #setTimeout
*
* @example The following example uses the setTimeout()
method to call another method following a specified delay period.
* A loop is created to count to one million. If the system can process this request faster than a second can expire, clearTimeout()
will remove the setTimeout()
request, and myDelayedFunction()
will not be called.
*
* package {
* import flash.display.Sprite;
* import flash.utils.*;
*
* public class ClearTimeoutExample extends Sprite {
* private var delay:Number = 1000; // delay before calling myDelayedFunction
* private var intervalId:uint;
* private var count:uint = 1000000;
*
* public function ClearTimeoutExample() {
* intervalId = setTimeout(myDelayedFunction, delay);
* startCounting();
* }
*
* public function startCounting():void {
* var i:uint = 0;
* do {
* if(i == count-1) {
* clearTimeout(intervalId);
* trace("Your computer can count to " + count + " in less than " + delay/1000 + " seconds.");
* }
* i++;
* } while(i < count)
* }
*
* public function myDelayedFunction():void {
* trace("Time expired.");
* }
* }
* }
*
*/
public function clearTimeout(id:uint):void {
window.clearTimeout(id);
}
}