662
Chapter 2: ActionScript Language Reference
Object.addProperty()
Availability
Flash Player 6. In ActionScript 2.0 classes, you can use
get
or
set
instead of this method.
Usage
myObject
.addProperty(
prop:String
,
getFunc:Function
,
setFunc:Function
)
:
Boolean
Parameters
prop
A string; the name of the object property to create.
getFunc
The function that is invoked to retrieve the value of the property; this parameter is a
Function object.
setFunc
The function that is invoked to set the value of the property; this parameter is a
Function object. If you pass the value
null
for this parameter, the property is read-only.
Returns
A Boolean value:
true
if the property is successfully created;
false
otherwise.
Description
Method; creates a getter/setter property. When Flash reads a getter/setter property, it invokes the
get
function, and the function’s return value becomes the value of
prop
. When Flash writes a
getter/setter property, it invokes the
set
function and passes it the new value as a parameter. If a
property with the given name already exists, the new property overwrites it.
A “get” function is a function with no parameters.
Its return value can be of any type. Its type can
change between invocations. The return value is treated as the current value of the property.
A “set” function is a function that takes one parameter, which is the new value of the property. For
example, if property
x
is assigned by the statement
x = 1
, the set function is passed the parameter
1
of type number. The return value of the set function is ignored.
You can add getter/setter properties to prototype objects. If you add a getter/setter property to a
prototype object, all object instances that inherit the prototype object inherit the getter/setter
property. This makes it possible to add a getter/setter property in one location, the prototype
object, and have it propagate to all instances of a class (similar to adding methods to prototype
objects). If a get/set function is invoked for a getter/setter property in an inherited prototype
object, the reference passed to the get/set function is the originally referenced object—not the
prototype object.
If invoked incorrectly,
Object.addProperty()
can fail with an error. The following table
describes errors that can occur:
Error condition
What happens
prop
is not a valid property name; for example, an
empty string.
Returns
false
and the property is not added.
Содержание FLASH MX
Страница 1: ...ActionScript Language Reference ...
Страница 20: ...20 Contents ...
Страница 24: ...24 Chapter 1 Introduction ...
Страница 39: ... logical AND 39 See also logical NOT inequality strict inequality logical OR equality strict equality ...
Страница 145: ...Button onKeyDown 145 See also Button onKeyUp ...
Страница 186: ...186 Chapter 2 ActionScript Language Reference See also Camera onActivity Camera setMotionLevel ...
Страница 202: ...202 Chapter 2 ActionScript Language Reference See also break default strict equality switch ...
Страница 282: ...282 Chapter 2 ActionScript Language Reference See also break continue while ...
Страница 329: ...import 329 For more information on importing see Importing classes and Using packages in Using ActionScript in Flash ...
Страница 383: ...LoadVars addRequestHeader 383 See also XML addRequestHeader ...
Страница 388: ...388 Chapter 2 my_lv load place a valid URL pointing to a text file here ...
Страница 402: ...402 Chapter 2 ActionScript Language Reference See also LocalConnection connect LocalConnection send ...
Страница 463: ...Microphone setRate 463 See also Microphone rate ...
Страница 469: ...Microphone silenceLevel 469 See also Microphone gain Microphone setSilenceLevel ...
Страница 471: ...Microphone silenceTimeOut 471 silenceLevel_pb label Activity level inactive See also Microphone setSilenceLevel ...
Страница 480: ...480 Chapter 2 ActionScript Language Reference See also Mouse addListener ...
Страница 518: ...518 Chapter 2 ActionScript Language Reference See also MovieClip globalToLocal MovieClip localToGlobal ...
Страница 529: ...MovieClip globalToLocal 529 See also MovieClip getBounds MovieClip localToGlobal ...
Страница 535: ...MovieClip hitTest 535 See also MovieClip getBounds MovieClip globalToLocal MovieClip localToGlobal ...
Страница 612: ...612 Chapter 2 ActionScript Language Reference See also MovieClipLoader onLoadStart ...
Страница 623: ...NetConnection class 623 See also NetStream class Video attachVideo ...
Страница 639: ...NetStream play 639 See also MovieClip attachAudio NetStream close NetStream pause Video attachVideo ...
Страница 649: ...Number 649 See also NaN Number class ...
Страница 679: ...on 679 on release trace X this _x trace Y this _y stopDrag See also onClipEvent ...
Страница 683: ...onUpdate 683 buttonLabel textColor my_mc labelColor ...
Страница 788: ...788 Chapter 2 ActionScript Language Reference See also private public ...
Страница 847: ...System security allowInsecureDomain 847 See also System security allowDomain System exactSettings ...
Страница 1001: ...Video height 1001 my_mc _height my_mc my_video height See also MovieClip _height Video width ...
Страница 1022: ...1022 Chapter 2 ActionScript Language Reference See also XML createElement ...
Страница 1057: ...XML xmlDecl 1057 See also XML docTypeDecl XML toString ...
Страница 1070: ...1070 Chapter 2 ActionScript Language Reference ...
Страница 1104: ...1104 Appendix Deprecated Language Elements ...