Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 95

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

Advertisement

You might use this new method with the
display from long names to short names, as the following example shows:
<?xml version="1.0"?>
<!-- mxmlAdvanced/MainPropWithMethod.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<MyComp:StateComboBoxPropMethod id="myCB" shortNames="false"/>
<mx:Button label="Use Short Names" click="myCB.setShortName(true);"/>
</mx:Application>
Defining properties in MXML
In MXML, you can use an MXML tag to define a property of any type, as long as the type
refers to an ActionScript class name. For example, you can use the
, and
<mx:Number>
<mx:Boolean>
take String, Number, or Boolean values, respectively. When using one of these tags, you must
specify an
, which becomes the property name.
id
Optionally, you can specify an initial value in the body of the tag, or you can use the
property to specify the contents of an external URL or file as the initial property value. If you
use the
property, the body of the tag must be empty. The initial value can be static
source
data or a binding expression.
The following examples show initial properties set as static data and binding expressions;
values are set in the tag bodies and in the
<!-- Boolean property examples: -->
<mx:Boolean id="myBooleanProperty">true</mx:Boolean>
<mx:Boolean id="passwordStatus">{passwordExpired}</mx:Boolean>
<!-- Number property examples: -->
<mx:Number id="myNumberProperty">15</mx:Number>
<mx:Number id="minutes">{numHours * 60}</mx:Number>
<!-- String property examples: -->
<mx:String id="myStringProperty">Welcome, {CustomerName}.</mx:String>
<mx:String id="myStringProperty1" source="./file"/>
All properties defined by using the
public. This means that the component user can access these properties.
event of a
click
tags to define properties in your MXML components that
properties:
source
,
<mx:String>
<mx:Number>
Adding custom properties and methods to a component
Button
control to change the
<mx:String>
, and
<mx:Boolean>
,
source
tags are
95

Advertisement

Table of Contents
loading

Table of Contents