Object.watch()
387
Example
The following example shows the return value of valueOf() for a generic object (which does not
have a primitive value) and compares it to the return value of toString():
// Create a generic object
var myObject:Object = new Object();
trace(myObject.valueOf()); // output: [object Object]
trace(myObject.toString()); // output: [object Object]
The following examples show the return values for the built-in classes Date and Array, and
compares them to the return values of
Object.toString()
:
// Create a new Date object set to February 1, 2004, 8:15 AM
// The toString() method returns the current time in human-readable form
// The valueOf() method returns the primitive value in milliseconds
var myDate:Date = new Date(2004,01,01,8,15);
trace(myDate.toString()); // output: Sun Feb 1 08:15:00 GMT-0800 2004
trace(myDate.valueOf()); // output: 1075652100000
// Create a new Array object containing two simple elements
// In this case both toString() and valueOf() return the same value: one,two
var myArray:Array = new Array("one", "two");
trace(myArray.toString()); // output: one,two
trace(myArray.valueOf()); // output: one,two
See the example for
Object.toString()
for an example of the return value of
Object.valueOf()
for a custom class that overrides
toString()
.
Object.watch()
Availability
Flash Player 6.
Usage
myObject
.watch(
prop:String
,
callback:Function
[,
userData:Object
] )
: Boolean
Parameters
prop
A string; the name of the object property to watch.
callback
The function to invoke when the watched property changes. This parameter is a
function object, not a function name as a string. The form of
callback
is
callback(prop,
oldVal, newVal, userData)
.
userData
An arbitrary piece of ActionScript data that is passed to the
callback
method. If
the
userData
parameter is omitted,
undefined
is passed to the callback method. This parameter
is optional.
Returns
A Boolean value:
true
if the watchpoint is created successfully,
false
otherwise.
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...