Watch (Object.watch Method) - MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference

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

Advertisement

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(). First, create a
generic object. Second, 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. Third, create a new Array object containing two
simple elements. Both toString() and valueOf() return the same value: one,two:
// 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
for an example of the return value of
Object.toString()
for a custom class that overrides
.
Object.valueOf()
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
as the
myObject
containing object.
566
ActionScript classes

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents