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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creates a getter/setter property. When Flash reads a getter/setter property, it invokes the get<br />

function, <strong>and</strong> the function's return value becomes the value of name. When Flash writes a<br />

getter/setter property, it invokes the set function <strong>and</strong> passes it the new value as a parameter. If<br />

a property with the given name already exists, the new property overwrites it.<br />

A "get" function is a function with no parameters. Its return value can be of any type. Its type<br />

can change between invocations. The return value is treated as the current value of the<br />

property.<br />

A "set" function is a function that takes one parameter, which is the new value of the property.<br />

For example, if property x is assigned by the statement x = 1, the set function is passed the<br />

parameter 1 of type number. The return value of the set function is ignored.<br />

You can add getter/setter properties to prototype objects. If you add a getter/setter property to<br />

a prototype object, all object instances that inherit the prototype object inherit the getter/<br />

setter property. This makes it possible to add a getter/setter property in one location, the<br />

prototype object, <strong>and</strong> have it propagate to all instances of a class (similar to adding methods to<br />

prototype objects). If a get/set function is invoked for a getter/setter property in an inherited<br />

prototype object, the reference passed to the get/set function is the originally referenced<br />

object--not the prototype object.<br />

If invoked incorrectly, Object.addProperty() can fail with an error. The following table<br />

describes errors that can occur:<br />

Error condition What happens<br />

name is not a valid property name; for<br />

example, an empty string.<br />

Returns false <strong>and</strong> the property is not added.<br />

getter is not a valid function object. Returns false <strong>and</strong> the property is not added.<br />

setter is not a valid function object. Returns false <strong>and</strong> the property is not added.<br />

Parameters<br />

name:String - A string; the name of the object property to create.<br />

getter:Function - The function that is invoked to retrieve the value of the property; this<br />

parameter is a Function object.<br />

setter:Function - The function that is invoked to set the value of the property; this<br />

parameter is a Function object. If you pass the value null for this parameter, the property is<br />

read-only.<br />

Returns<br />

Boolean - A Boolean value: true if the property is successfully created; false otherwise.<br />

Object 521

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

Saved successfully!

Ooh no, something went wrong!