User Guide
Object 1007
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().
See also
toString (Object.toString method)
watch (Object.watch method)
public watch(name:String, callback:Function, [userData:Object]) : Boolean
Registers an event handler to be invoked when a specified property of an ActionScript object
changes. When the property changes, the event handler is invoked with
myObject as the
containing object.
You can use the
return statement in your callback method definition to affect the value of
the property you are watching. The value returned by your
callback method is assigned to
the watched object property. The value you choose to return depends on whether you wish to
monitor, modify or prevent changes to the property:
■ If you are merely monitoring the property, return the newVal parameter.
■ If you are modifying the value of the property, return your own value.
■ If you want to prevent changes to the property, return the oldVal parameter.
If the
callback method you define does not have a return statement, then the watched
object property is assigned a value of
undefined.
A watchpoint can filter (or nullify) the value assignment, by returning a modified newval (or
oldval). If you delete a property for which a watchpoint has been set, that watchpoint does
not disappear. If you later recreate the property, the watchpoint is still in effect. To remove a
watchpoint, use the
Object.unwatch method.
Only a single watchpoint can be registered on a property. Subsequent calls to
Object.watch() on the same property replace the original watchpoint.
The
Object.watch() method behaves similarly to the Object.watch() function in
JavaScript 1.2 and later. The primary difference is the
userData parameter, which is a Flash
addition to
Object.watch() that Netscape Navigator does not support. You can pass the
userData parameter to the event handler and use it in the event handler.