Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 100

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

When a property is the source of a data binding expression, any changes to the property must
signal an update to the destination property. The way to signal that change is to dispatch an
event, as the following example shows:
<?xml version="1.0"?>
<!-- mxmlAdvanced/myComponents/StateComboBoxSetGetBinding.mxml -->
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import flash.events.Event;
private var stateArrayShort:Array = ["AK", "AL"];
private var stateArrayLong:Array = ["Arkansas", "Alaska"];
private var __shortNames:Boolean = true;
public function set shortNames(val:Boolean):void {
__shortNames = val;
if (__shortNames) {
else {
}
// Include the [Bindable] metadata tag.
[Bindable(event="changeShortNames")]
public function get shortNames():Boolean {
return __shortNames;
}
]]>
</mx:Script>
</mx:ComboBox>
To use a property as the source of a data binding expression:
Define the property as a variable, or by using setter and getter methods.
1.
You must define a setter method and a getter method if you use the
the property.
Insert the
2.
[Bindable]
setter or getter method, and optionally specify the name of the event dispatched by the
property when it changes.
100
Creating Advanced MXML Components
dataProvider=stateArrayShort; }
dataProvider=stateArrayLong; }
// Create and dispatch event.
dispatchEvent(new Event("changeShortNames"));
metadata tag before the property definition, or before either the
tag with
[Bindable]

Advertisement

Table of Contents
loading

Table of Contents