MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference page 568

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

[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.");
}
// Return the value of newVal.
return newVal;
}
// Use watch() to register the event handler, passing as parameters:
// - the name of the property to watch: "speed"
// - a reference to the callback function speedWatcher
// - the speedLimit of 55 as the userData parameter
myObject.watch("speed", speedWatcher, 55);
// set the speed property to 54, then to 57
myObject.speed = 54; // output: You are not speeding
myObject.speed = 57; // output: You are speeding
// unwatch the object
myObject.unwatch("speed");
myObject.speed = 54; // there should be no output
See also
addProperty (Object.addProperty method)
568
ActionScript classes
parameter is omitted,
userData
if the watchpoint is created successfully,
true
to check whether the
watch()
undefined
property exceeds the speed
speed
,
unwatch (Object.unwatch method)
is passed to the callback
otherwise.
false

Advertisement

Table of Contents
loading

Table of Contents