Applying Styles To Your Custom Component - Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual

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

Advertisement

The root tag of an MXML component cannot contain an
to the object defined by the root tag in the body of the component, you must use the
keyword, as the following example shows:
<?xml version="1.0"?>
<!-- mxml/myComponents/StateComboBoxThis.mxml -->
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml"
close="handleCloseEvent(event);">
<mx:Script>
<![CDATA[
import flash.events.Event;
// Define a property to hold the current index.
public var stateIndex:Number;
private function handleCloseEvent(eventObj:Event):void {
stateIndex = this.selectedIndex;
}
]]>
</mx:Script>
<mx:dataProvider>
<mx:String>AK</mx:String>
<mx:String>AL</mx:String>
</mx:dataProvider>
</mx:ComboBox>
This example defines an event listener for the ComboBox control that updates the
property when the ComboBox control closes.
stateIndex
Applying styles to your custom
component
Along with skins, styles define the look and feel (appearance) of your Flex applications. You
can use styles to change the appearance of a single component, or apply them across all
components.
When working with custom components, you have several options for how you use styles.
You can define your custom components so that they contain no style information at all. That
design allows the application developer who is using your component to apply styles to match
the rest of their application. For example, if you define a custom component to display text,
the application developer can style it to ensure that the font, font size, and font style of your
component match the rest of the application.
84
Creating Simple MXML Components
property. Therefore, if you refer
id
this

Advertisement

Table of Contents
loading

Table of Contents