EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 615

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
setInterval() 615
setInterval()
Availability
Flash Player 6.
Usage
setInterval(functionName, interval [, param1, param2, ..., paramN])
Parameters
functionName
A function name or a reference to an anonymous function.
interval The time in milliseconds between calls to the functionName parameter.
param1, param2, ..., paramN Optional parameters passed to the function or
methodName parameter.
Returns
An interval identifier that you can pass to clearInterval() to cancel the interval.
Description
Function; calls a function or a method or an object at periodic intervals while a SWF file plays.
You can use an interval function to update variables from a database or update a time display.
If
interval is less than the SWF files frame rate (for example, 10 frames per second [fps] is equal
to 100 milliseconds), the interval function is called as close to
interval as possible. You must use
the
updateAfterEvent() function to make sure that the screen refreshes often enough. If
interval is greater than the SWF files frame rate, the interval function is only called each time
the playhead enters a frame; this minimizes the impact each time the screen is refreshed.
Example
Usage 1:The following example calls an anonymous function every 1000 milliseconds (every
1second).
setInterval( function(){ trace("interval called"); }, 1000 );
Usage 2: The following example defines two event handlers and calls each of them. Both calls to
setInterval() send the string "interval called" to the Output panel every 1000
milliseconds. The first call to
setInterval() calls the callback1() function, which contains a
trace() action. The second call to setInterval() passes the "interval called" string to the
function
callback2() as a parameter.
function callback1() {
trace("interval called");
}
function callback2(arg) {
trace(arg);
}
setInterval( callback1, 1000 );
setInterval( callback2, 1000, "interval called" );

Table of Contents

Related product manuals