Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 98

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

Advertisement

You can also define events to be dispatched when a property changes. This enables you to
signal the change so that an event listener can recognize the change. For more information on
events, see
"Working with events" on page
You can call a component's custom methods and access its properties in ActionScript just as
you would any instance method or component property, as the following application shows:
<?xml version="1.0"?>
<!-- mxmlAdvanced/MainPropSetGet.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<MyComp:StateComboBoxSetGet id="myStateCB" shortNames="true"/>
<mx:Button click="myStateCB.shortNames=!myStateCB.shortNames;"/>
</mx:Application>
In this example, selecting the button toggles the display format of the state name between the
short and long formats.
Defining inspectable properties
You should precede the variable or set function with the
plan to use the component in an authoring tool such as Adobe Flex Builder. The
metadata tag must immediately precede the property's variable declaration or
[Inspectable]
the setter and getter methods to be bound to that property, as the following example shows:
<mx:Script>
<![CDATA[
// Define public variables.
[Inspectable(defaultValue=true)]
public var shortNames:Boolean = true;
]]>
</mx:Script>
For more information on the
Tags in Custom Components," on page
98
Creating Advanced MXML Components
107.
metadata tag, see
[Inspectable]
45.
metadata tag if you
[Inspectable]
Chapter 5, "Using Metadata

Advertisement

Table of Contents
loading

Table of Contents