Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 94

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

Advertisement

The following MXML application file uses the
configure the control to display long state names:
<?xml version="1.0"?>
<!-- mxmlAdvanced/MainPropAS.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<MyComp:StateComboBoxPropAS shortNames="true"/>
</mx:Application>
The following example modifies the component to add a method that lets you change the
display of the state name at run time. This public method takes a single argument that
specifies the value of the
<?xml version="1.0"?>
<!-- mxmlAdvanced/myComponents/StateComboBoxPropMethod.mxml -->
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="setNameLength();">
<mx:Script>
<![CDATA[
// Define public variables.
public var shortNames:Boolean = true;
// Define private variables.
private var stateArrayShort:Array = ["AK", "AL"];
private var stateArrayLong:Array = ["Arkansas", "Alaska"];
public function setNameLength():void {
if (shortNames) {
else {
}
public function setShortName(val:Boolean):void {
shortNames=val;
if (val) {
else {
}
]]>
</mx:Script>
</mx:ComboBox>
94
Creating Advanced MXML Components
property:
shortNames
this.dataProvider=stateArrayShort; }
this.dataProvider=stateArrayLong; }
dataProvider=stateArrayShort; }
dataProvider=stateArrayLong; }
<MyComp:StateComboBoxPropAS>
tag to

Advertisement

Table of Contents
loading

Table of Contents