Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 87

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

Advertisement

Class selectors
Type selectors
The styles that application developers can apply correspond to the styles supported by the root
tag of the MXML component. The following example uses a tag property to set a style for the
custom MXML component:
<?xml version="1.0"?>
<!-- mxml/MainStyleWithPropsOverrideOpenDur.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<MyComp:StateComboBoxWithStyleProps openDuration="1000"/>
</mx:Application>
When you specify styles as tag attributes, those styles override any conflicting styles set in the
definition of the MXML component.
You can use a class selector to define styles. Often you use a class selector to apply styles to
specific instances of a control, as the following example shows:
<?xml version="1.0"?>
<!-- mxml/MainStyleOverrideUsingClassSel.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<mx:Style>
.myStateComboBox {
openDuration : 1000;
}
</mx:Style>
<MyComp:StateComboBoxWithStyleProps styleName="myStateComboBox"/>
<mx:ComboBox>
...
</mx:ComboBox>
</mx:Application>
In this example, you use the
component to apply styles to a specific instance of the MXML component. However, those
styles are not applied to the
would they be applied to any other instances of StateComboBox.mxml unless you also specify
the
property as part of defining those instances of the MXML component.
styleName
When you specify any styles by using a class selector, those styles override all styles that you set
by using a class selector in the MXML file. Those styles do not override styles that you set by
using tag properties in the MXML file.
property in the tag definition of an MXML
styleName
ComboBox
control defined in the main application file, nor
Applying styles to your custom component
87

Advertisement

Table of Contents
loading

Table of Contents