Server-Side Communication ActionScript > setInterval |
![]() ![]() ![]() |
setInterval
Availability
Flash Communication Server MX.
Usage
setInterval(function
,interval
[,p1
, ...,pN
]); setInterval(object
,methodName
,interval
[,p1
, ...,pN
]);
Parameters
function
The name of a defined ActionScript function or a reference to an anonymous function.
object
An object derived from the ActionScript Object object.
methodName
The name of the method to call on object
.
interval
The time (interval) between calls to function
, in milliseconds.
p1, ..., pN
Optional parameters passed to function
.
Returns
A unique ID for this call. If the interval is not set, the method returns -1.
Description
Method (global); continually calls a function or method at a specified time interval until the clearInterval
method is called. This method allows a server-side script to run a generic routine. The setInterval
method returns a unique ID that you can pass to the clearInterval
method to stop the routine.
Note: Standard JavaScript supports an additional usage for the setInterval
method, setInterval(stringToEvaluate, timeInterval)
, which is not supported by Server-Side Communication ActionScript.
Example
The following example uses an anonymous function to send the message "interval called" to the server log every second:
setInterval(function(){trace("interval called");}, 1000);
The following example also uses an anonymous function to send the message "interval called" to the server log every second, but it passes the message to the function as a parameter:
setInterval(function(s){trace(s);}, 1000, "interval called");
The following example uses a named function, callback1
, to send the message "interval called" to the server log:
function callback1(){trace("interval called"); } setInterval(callback1, 1000);
The following example also uses a named function, callback2
, to send the message "interval called" to the server log, but it passes the message to the function as a parameter:
function callback2(s){ trace(s);} setInterval(callback2, 1000, "interval called");
![]() ![]() ![]() |