Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual page 108

Migrating applications to flex 2
Table of Contents

Advertisement

The following is a Flex 2 example of a getter/setter pair that uses the
tag:
// Define private variable.
private var _maxFontSize:Number = 15;
[Bindable(event="maxFontSizeChanged")]
// Define public getter method.
public function get maxFontSize():Number {
return _maxFontSize;
}
// Define public setter method.
public function set maxFontSize(value:Number):void {
if (value <= 30) {
_maxFontSize = value;
} else _maxFontSize = 30;
// Create event object.
var eventObj:Event = new Event("maxFontSizeChanged");
dispatchEvent(eventObj);
}
You can omit the event name in the metadata tag, as the following example shows:
// Define private variable.
private var _maxFontSize:Number = 15;
[Bindable]
// Define public getter method.
public function get maxFontSize():Number {
return _maxFontSize;
}
// Define public setter method.
public function set maxFontSize(value:Number):void {
if (value <= 30) {
_maxFontSize = value;
} else _maxFontSize = 30;
}
The Flex compiler automatically generates an event named
specifying the
[Bindable]
[Bindable(event="propertyChange")]
108
Binding
metadata tag with no event is the same as specifying the following:
[Bindable]
. In this case,
propertyChange
metadata

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex 2

Table of Contents