You can use the Object.watch
method to register a callback function to be invoked when a specified property of an ActionScript object changes. When the property changes, the callback function is invoked with myObject
as the containing object. You must return the new value from the object.watch
callback function; otherwise, the watched object property is assigned a value of undefined
.
For example, in the code that follows, the watch
method specifies a function to be invoked when the value for the label
property of the CheckBox component is changed:
functionCheckBox
() { ... this.watch('label', function (id, oldval, newval){ ... });}
When the label
property is modified, the specified function is invoked to perform any tasks needed to update the appearance and state of the component to reflect its new parameters. Therefore, the following assignment statement uses an Object.watch
handler to notify the component that the variable has changed and causes it to update its graphical representation.
myCheckBox1.value = false;
This syntax is more concise than using a method to update the label
property:
myCheckBox1.setLabel(false);
To remove a watchpoint, use the Object.unwatch
method.
ActionScript DictionaryFor more information, see Object.watch()
and the Object object
entry.