User Guide

Example: Creating style properties 193
If you include the <mx:Style> tag, the <mx:Style> tag creates the default style definition, as
the following example shows:
<?xml version="1.0"?>
<!-- skinstyle\MainRectCSSStyles.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<mx:Style>
StyledRectangle {fillColors: #FF00FF, #00FFFF}
</mx:Style>
<MyComp:StyledRectangle/>
</mx:Application>
Defining a style property for a skin
Flex lets you set component skins by using style properties. Your new component might also
support skins and, therefore, support setting skins by using style properties.
The mechanism for creating style properties to support skinning is the same as for creating
other style properties. Setting a style property for a skin that triggers a call to the
styleChanged() method. The styleChanged() method detects the change to the skin, and
performs any updates to the appearance of the component in the
updateDisplayList()
method.
The one difference when defining a style property for a skin is how you specify the
[Style]
metadata tag. When the style property corresponds to a skin, you specify
Class as the value to
the
type property of the metadata tag, as the following example shows:
[Style(name="downSkin", type="Class", inherit="no")]
For more information on creating skins, see Chapter 20, “Using Skins,” in Flex 2 Developer’s
Guide.