Global Functions
97
interval
:Number
- The time in milliseconds between calls to the
functionReference
or
methodName
function passed in.
If
interval
is less than the SWF file's frame rate (for example, 10 frames per second [fps] is
equal to 100 millisecond intervals), the interval function is called as close in time to the value
of
interval
as possible. Executing long, memory-intensive scripts during an interval causes
delays. If the function being called initiates a change to visual elements, you should 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 called only after
interval
has expired
and
the playhead has entered the next frame; this minimizes the impact
each time the screen is refreshed.
param
:Object
[optional] - Parameters passed to the function that was sent to
functionReference
or
methodName
. Multiple parameters should be separated by commas:
param1
,
param2
, ...,
paramN
objectReference
:Object
- An object that contains the method specified by
methodName
.
methodName
:String
- A method that exists in the scope of the object specified by
objectReference
.
Returns
Number
- An integer that identifies the interval (the interval ID), which you can pass to
clearInterval()
to cancel the interval.
Example
Example 1: The following example traces a message at an interval of 20 milliseconds, up to 10
times, and then clears the interval. The object scope,
this
, is passed in as the first parameter,
and the method name,
executeCallback
, as the second. This ensures that
executeCallback()
is executed from the same scope as the calling script.
var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 10;
var duration:Number = 20;
function executeCallback():Void {
trace("executeCallback intervalId: " + inte " count: " + count);
if(count >= maxCount) {
clearInterval(intervalId);
}
count++;
}
intervalId = setInterval(this, "executeCallback", duration);
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...