setInterval(function, interval[, p1, ..., pN]) setInterval(object.method, interval[, p1, ..., pN])
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 routine. The setInterval() method returns a unique ID that you can pass to the clearInterval() method to stop the routine.
Flash Communication Server 1
function A Function object.
object.method A method to call on object.
interval A number indicating the time in milliseconds between calls to function.
p1, ..., pN Optional parameters passed to function.
An integer that provides a unique ID for this call. If the interval is not set, returns -1.
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");
The following example uses the second syntax:
var a = new Object();
a.displaying=displaying;
setInterval(a.displaying, 3000);
displaying = function(){
trace("Hello World");
}
The previous example calls the displaying() method every 3 seconds and sends the message "Hello World" to the server log.