EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 582

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
582 Chapter 12: ActionScript Dictionary
Example
This example shows a CheckBox component with methods that set the label or value of each
check box instance:
myCheckBox1.setValue(true);
myCheckBox1.setLabel("new label");
...
It’s convenient to think of the value and label of a check box as properties. Its possible to use
Object.watch() to make accessing the value and label look like property access rather than
method invocation, as in the following:
// Define constructor for (and thus define) CheckBox class
function CheckBox() {
...
this.watch('value', function (id, oldval, newval){
...
});
this.watch('label', function(id, oldval, newval){
...
});
}
When the value or label property is modified, the function specified by the component is invoked
to perform any tasks needed to update the appearance and state of the component. The following
example invokes an
Object.watch() method to notify the component that the variable has
changed, causing the component to update its graphical representation.
myCheckBox1.value = false;
This syntax is more concise than the former syntax:
myCheckBox1.setValue(false);
See also
Object.addProperty(), Object.unwatch()
Object()
Availability
Flash Player 5 .
Usage
Object( [ value ] )
Parameters
value
A number, string, or Boolean value.
Returns
An object.
Description
Conversion function; creates a new, empty object or converts the specified number, string, or
Boolean value to an object. This command is equivalent to creating an object using the Object
constructor (see “Constructor for the Object class” on page 575).

Table of Contents

Related product manuals