03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

See the example for Object.toString() for an example of the return value of<br />

Object.valueOf() for a custom class that overrides toString().<br />

See also<br />

toString (Object.toString method)<br />

watch (Object.watch method)<br />

public watch(name:String, callback:Function, [userData:Object]) : Boolean<br />

Registers an event h<strong>and</strong>ler to be invoked when a specified property of an ActionScript object<br />

changes. When the property changes, the event h<strong>and</strong>ler is invoked with myObject as the<br />

containing object.<br />

You can use the return statement in your callback method definition to affect the value of<br />

the property you are watching. The value returned by your callback method is assigned to<br />

the watched object property. The value you choose to return depends on whether you wish to<br />

monitor, modify or prevent changes to the property:<br />

■ If you are merely monitoring the property, return the newVal parameter.<br />

■ If you are modifying the value of the property, return your own value.<br />

■ If you want to prevent changes to the property, return the oldVal parameter.<br />

If the callback method you define does not have a return statement, then the watched<br />

object property is assigned a value of undefined.<br />

A watchpoint can filter (or nullify) the value assignment, by returning a modified newval (or<br />

oldval). If you delete a property for which a watchpoint has been set, that watchpoint does<br />

not disappear. If you later recreate the property, the watchpoint is still in effect. To remove a<br />

watchpoint, use the Object.unwatch method.<br />

Only a single watchpoint can be registered on a property. Subsequent calls to<br />

Object.watch() on the same property replace the original watchpoint.<br />

The Object.watch() method behaves similarly to the Object.watch() function in<br />

JavaScript 1.2 <strong>and</strong> later. The primary difference is the userData parameter, which is a Flash<br />

addition to Object.watch() that Netscape Navigator does not support. You can pass the<br />

userData parameter to the event h<strong>and</strong>ler <strong>and</strong> use it in the event h<strong>and</strong>ler.<br />

Object 535

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!