MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference page 1008

Actionscript 2.0 language reference
Table of Contents

Advertisement

The
Object.watch()
operate through lazy evaluation-- the value of the property is not determined until the
property is actually queried. Lazy evaluation is often efficient because the property is not
constantly updated; it is, rather, evaluated when needed. However,
evaluate a property to determine whether to invoke the
getter/setter property,
inefficient.
Generally, predefined ActionScript properties, such as
getter/setter properties and cannot be watched with
Availability: ActionScript 1.0; Flash Player 6
Parameters
- A string; the name of the object property to watch.
name:String
callback:Function
parameter is a function object, not a function name as a string. The form of
callback(prop, oldVal, newVal, userData)
[optional] - An arbitrary piece of ActionScript data that is passed to the
userData:Object
method. If the
callback
method.
Returns
- A Boolean value:
Boolean
Example
The following example uses
limit:
// Create a new object
var myObject:Object = new Object();
// Add a property that tracks speed
myObject.speed = 0;
// Write the callback function to be executed if the speed property changes
var speedWatcher:Function = function(prop, oldVal, newVal, speedLimit) {
// Check whether speed is above the limit
if (newVal > speedLimit) {
trace ("You are speeding.");
}
else {
trace ("You are not speeding.");
}
1008 ActionScript classes
method cannot watch getter/setter properties. Getter/setter properties
needs to evaluate the property constantly, which is
Object.watch()
- The function to invoke when the watched property changes. This
parameter is omitted,
userData
if the watchpoint is created successfully,
true
to check whether the
watch()
Object.watch()
function. To work with a
callback
,
,
, and
_x
_y
_width
.
Object.watch()
.
is passed to the callback
undefined
property exceeds the speed
speed
needs to
, are
_height
is
callback
otherwise.
false

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents