setInterval()
731
setInterval()
Availability
Flash Player 6.
Usage
setInterval(
functionName:Function
,
interval:Number
[,
param1:Object
,
param2
,
...,
paramN
])
: Number
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 identifying integer 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 to update a time display.
If
interval
is less than the SWF file’s 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 file’s 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
(1 second).
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()
statement. 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" );
CHAPTER 2
ActionScript Language Reference
Summary of Contents for FLASH MX
Page 1: ...ActionScript Language Reference ...
Page 20: ...20 Contents ...
Page 24: ...24 Chapter 1 Introduction ...
Page 145: ...Button onKeyDown 145 See also Button onKeyUp ...
Page 202: ...202 Chapter 2 ActionScript Language Reference See also break default strict equality switch ...
Page 282: ...282 Chapter 2 ActionScript Language Reference See also break continue while ...
Page 383: ...LoadVars addRequestHeader 383 See also XML addRequestHeader ...
Page 388: ...388 Chapter 2 my_lv load place a valid URL pointing to a text file here ...
Page 463: ...Microphone setRate 463 See also Microphone rate ...
Page 469: ...Microphone silenceLevel 469 See also Microphone gain Microphone setSilenceLevel ...
Page 480: ...480 Chapter 2 ActionScript Language Reference See also Mouse addListener ...
Page 529: ...MovieClip globalToLocal 529 See also MovieClip getBounds MovieClip localToGlobal ...
Page 612: ...612 Chapter 2 ActionScript Language Reference See also MovieClipLoader onLoadStart ...
Page 623: ...NetConnection class 623 See also NetStream class Video attachVideo ...
Page 649: ...Number 649 See also NaN Number class ...
Page 679: ...on 679 on release trace X this _x trace Y this _y stopDrag See also onClipEvent ...
Page 683: ...onUpdate 683 buttonLabel textColor my_mc labelColor ...
Page 788: ...788 Chapter 2 ActionScript Language Reference See also private public ...
Page 1001: ...Video height 1001 my_mc _height my_mc my_video height See also MovieClip _height Video width ...
Page 1022: ...1022 Chapter 2 ActionScript Language Reference See also XML createElement ...
Page 1057: ...XML xmlDecl 1057 See also XML docTypeDecl XML toString ...
Page 1070: ...1070 Chapter 2 ActionScript Language Reference ...
Page 1104: ...1104 Appendix Deprecated Language Elements ...