Overview
I’ve been working with Degrafa for a while now, using it to build new components and skin the old. I’ve fixed a few bugs, and contributed some new features, which will hopefully see light sooner rather than later. There’s a few blog posts and tutorials around the net on skinning various individual components, but nothing really comprehensive.
To address this, I’ll be building a complete Flex skin using Degrafa, one component at a time through my blog. Download the source code from Google code, and I’ll try to get a component a week added until the entire standard Flex 3 component set is thoroughly skinned.
So with that out of the way, let’s begin, with TabNavigator!
TabNavigator
The core of any skin is of course, the CSS file. Here’s a snippet of what we’re interested in:
TabNavigator
{
border-skin:ClassReference("parade.TabNavigatorSkin");
padding-top:0px;
padding-right:0px;
padding-bottom:0px;
padding-left:0px;
tabStyleName:"navigatorTab";
firstTabStyleName:"navigatorTab";
lastTabStyleName:"navigatorTab";
selectedTabTextStyleName:"selectedTabText";
}
Button.navigatorTab
{
skin:ClassReference("parade.TabSkin");
paddingTop:1;
paddingRight:10;
paddingBottom:1;
paddingLeft:10;
}
As you can see, we’re referencing two custom skins: TabNavigatorSkin and TabSkin. One to skin the ViewStack.
The TabNavigator skin source code isn’t particularly exciting, so I won’t reproduce it here. The interesting part that will be new for a lot of readers, is the leveraging of Degrafa’s new states support. Here’s the code in question, taken from TabSkin.mxml:
<degrafa:states>
<!-- Hover -->
<degrafa:State name="overSkin">
<degrafa:SetProperty target="{mainFill}" name="color" value="#dddddd"/>
</degrafa:State>
<!-- Selected -->
<degrafa:State name="selectedUpSkin">
<degrafa:SetProperty target="{outlineShape}" name="top" value="0"/>
<degrafa:SetProperty target="{notch}" name="top" value="1"/>
<degrafa:SetProperty target="{notch}" name="visible" value="true"/>
<degrafa:SetProperty target="{notchOutline}" name="top" value="1"/>
<degrafa:SetProperty target="{notchOutline}" name="visible" value="true"/>
<degrafa:SetProperty target="{fillShape}" name="top" value="1"/>
<degrafa:SetProperty target="{fillShape}" name="bottom" value="-2"/>
<degrafa:SetProperty target="{bling}" name="top" value="1"/>
<degrafa:SetProperty target="{bling}" name="visible" value="false"/>
<degrafa:SetProperty target="{mainFill}" name="color" value="#dddddd"/>
</degrafa:State>
<degrafa:State name="selectedOverSkin" basedOn="selectedUpSkin"/>
<degrafa:State name="selectedDownSkin" basedOn="selectedUpSkin"/>
<degrafa:State name="selectedDisabledSkin" basedOn="selectedUpSkin"/>
</degrafa:states>
If this syntax looks familiar, it’s because it should - it’s based on the existing syntax you’re used to seeing to set up states in regular old MXML components.
A key difference you should pay attention to is that in Degrafa the property that identifies the current selected state is not "currentState", as with regular UIComponents. For Degrafa skins, it’s stored in the "name" field. This is because that’s the way the Halo component model is designed, and in 99% of cases it’s Halo components we’re skinning.
The state names you see above are also just part of Halo’s way of doing things. They’re not consistent across different components, but that’s simply how it is. Adobe have no plans on changing the names to be more sensible, because they’re throwing out the whole thing for Spark, the component model and library that will be in Flash Builder / Flex 4.
To see the skin in action, click the image below (view source enabled):

View the example app
Next week: Checkboxes! Do you have preferences as to which components you’d like to see examples for earlier than others? Email me, [catch me on Twitter], or leave a comment here on my blog.