MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual page 59

Developing flex components and themes in flash authoring
Table of Contents

Advertisement

To define getter and setter methods, precede the method name with
space and the property name. Macromedia recommends that you use initial capital letters for the
second word and each word that follows. For example:
public function get initialColorStyle(): Number
The variable that stores the property's value cannot have the same name as the getter or setter. By
convention, precede the name of the getter and setter variables with two underscores (__). In
addition, Macromedia recommends that you declare the variable as private.
The following example shows the declaration of
that get and set the value of this property:
...
private var __initialColor:Color = 42;
...
public function get initialColor():Number {
return __initialColor;
}
public function set initialColor(newColor:Number) {
__initialColor = newColor;
}
You commonly use getters and setters in conjunction with metadata keywords to define properties
that are visible, are bindable, and have other properties. For more information, see
metadata" on page
Component metadata
The Flash compiler recognizes component metadata statements in your external ActionScript
class files. The metadata tags define component attributes, data binding properties, events, and
other properties of the component. Flash interprets these statements during compilation; they are
never interpreted during runtime in Flex or Flash.
Using metadata keywords
Metadata statements are associated with a class declaration or an individual data field. They are
bound to the next line in the ActionScript file. When defining a component property, add the
metadata tag on the line before the property declaration. When defining component events or
other aspects of a component that affect more than a single property, add the metadata tag outside
the class definition so that the metadata is bound to the entire class.
In the following example, the
, and
colorStr
shapeStr
[Inspectable(defaultValue="strawberry")]
public var flavorStr:String;
[Inspectable(defaultValue="blue")]
public var colorStr:String;
[Inspectable(defaultValue="circular")]
public var shapeStr:String;
59.
Inspectable
properties:
, and getter and setter methods
initialColor
metadata keywords apply to the
Writing the component's ActionScript code
or
, followed by a
get
set
"Component
,
flavorStr
59

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX - DEVELOPING COMPONENTS AND THEMES and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flex

Table of Contents