Tips for Using the Flex Skin Design Extensions
With Flex 3 there are a lot of great new features to help streamline the implementation of your custom skins into your Flex or AIR application. One of them is the Flex Skin Design Extensions (SDE) for Flash, Illustrator, Photoshop and Fireworks. These were available during the beta releases of Flex 3, so you may already be familiar with it. However, since the full release of Flex 3 there have been some updates to the extensions and I wanted to point out a few tricks that may help streamline your skinning workflow a bit further. Also, if you’re new to skinning Flex apps, check out Narciso Jaramillo’s updated article about creating skins for Flex using Adobe Creative Suite 3.
Naming Conventions
If you look at the skin templates that come with the Flex SDE you’ll notice that each skin is named in a particular way. The naming convention works by specifying the component name, an underscore “_â€, then the component skin part. For example, Button_upSkin, Button_overSkin, etc. They are named this way so when you import the skin through Flex Builder’s Skin Import Wizard the combo boxes that allow you to assign a skin state for each skin are “automagically” assigned to the skin state you specified in the skin template. This is good to know because you can use the same naming conventions when you’re making your own custom skins that may be created without using the templates provided. I typically make a single file with all my skins in it and use this naming convention frequently.
This method will work for a variety of scenarios. For example, if you need to add a background image to a certain container, you could use myVbox_backgroundImage and it will go through the Skin Import Wizard very easily. This will work for other “skinnable†parts, like borderSkin, upIcon, etc. Easy enough, right?
The other nice thing you can do with adhering to these naming conventions is skin “sub-componentsâ€. For example, the DateField component allows you to specify a textInputStyleName. You can assign skins to that text input by specifying the component name, adding a hypen “-†(Illustrator, Fireworks, Illustrator) or dollar sign “$†(Flash) with the sub-component name, then and underscore “_†and the sub-component skin part. So, in the case of the DateField, you could specify the borderSkin for the text input like this:
DateField-textInput_borderSkin (Illustrator, Fireworks, Photoshop) or DateField$textInput_borderSkin (Flash)
Notice I just used “textInput†and not “textInputStyleNameâ€. This is because “StyleName†is appended to the sub-component name during the Skin Import process in Flex. For example, naming a skin asset in Flash “ComboBox$dropdown_backgroundImageâ€, publishing it and importing it using the Skin Import Wizard would produce the following CSS (Note: You’d have to add backgroundSize: ‘100%’ for the image to stretch.):
ComboBox
{
dropdownStyleName: “comboBoxDropdown“;
}
.comboBoxDropdown
{
backgroundImage: Embed(skinClass=“ComboBox$dropdown_backgroundImage“);
}
If you look at the skin template for the application your using you should see this naming convention used for the tab skins. You can use this same naming convention for other sub-components, like dropdown, verticalScrollBar, etc. Just naming your skin assets a certain way can really streamline the the skin production process.
Naming for CSS Design Mode Previews
Another new feature in Flex 3 is CSS Design Mode. While viewing CSS you can click on the “Design†mode button to see what your CSS looks like applied to a particular component. However, if you were to create a style class and switch to CSS Design Mode you won’t get an immediate preview. This is because you have to specify a component to preview the CSS against. A way to forego this step is to add the type of component you want the styling applied to to the class name. For example, if I had a class name of “blueButton†I could preview it as a Button component in CSS Design Mode by adding “Button†to the class name keeping the dot “.†of the class name like this:
Button.myButton
{
fillAlphas: 1.0, 1.0;
fillColors: #84B1F4, #1D4888;
borderColor: #07314F;
color: #FFFFFF;
}
This will work for pretty much any component, provide a quick way to preview the CSS styling on a component without having to specify it in CSS Design Mode and make your CSS a bit more descriptive. If you use the same styling across multiple components you may want to leave class names void of component specifications.
Other Resources
Designing Flex 3 skins and styles using Creative Suite 3 and Flex Builder 3
Flex 3 CSS Design Mode in LiveDocs
March 16th, 2008 at 6:16 pm
[...] Juan Sanchez of ScaleNine, who built the CS3 Flex skin templates, has just posted some great tips and tricks for using the skin templates. Thanks [...]
April 4th, 2008 at 5:16 am
Hi there! thanks for the information..
I just began to do some skining test using Illustrator and I followed the steps from Narciso Jaramillo’s article. It’s been working great for a lot of controls, but I’ve noticed some weird behaviors and can’t find answers for these.
By example, the arrow of my popUpButton is always stretched in height instead of staying centered in the middle, when I modify the popUpButton height.
If I start a new flex skin from the default template with all the controls and that I export it right away, I will be able to reproduce this. I just have to add a popUpButton and modify it’s height.
Would their be any way to control this?
April 4th, 2008 at 9:36 am
Hi Frank,
You’re in luck! In Flex 3 there was a style introduced for PopUpButton called popUpIcon. If you specify an asset for that property that asset will not stretch with the dimensions of the PopUpButton. Cool, huh?
So, you’re probably asking, “Why were the templates set up like that?”. Well, PopUpButton has a popUpIcon property, but ComboBox does not. Bummer I know. To keep consistency between how the two skin templates were set up both icons were “baked into” the skin.
With that said, I think the solution is to pull the icon graphic out from the PopUpButton symbol and make a new Symbol called “PopUpButton_popUpIcon” and publish that. You may need to do some tweaking, but that should get you on the right track.
Hope that helps.
April 4th, 2008 at 11:32 am
Thanks a lot, Juan. I’ve notice that the same occurs also with the comboBox, as you’re saying.
Any luck of having a similar workaround to not have the arrow icon being stretched like that in a comboBox as well?
April 4th, 2008 at 4:04 pm
Since the ComboBox arrow icon is baked into the skin you could try setting the horizontal 9-slice guides both above or below the icon. This can also create some unwanted effects. Or, just make your ComboBox skin the height you want it rather than setting the height in Flex. This will prevent any vertical stretching to happen at all.
As a side note, if you’re just trying to change to the icon color on the default Flex skin, a new property was introduced in Flex 3 to do that. That property is iconColor and you just specify the color you’d like your arrow icon to be.
April 22nd, 2008 at 11:38 pm
Hi guys.
I have a problem using skins so maybe you can give me a little help
I have used flash to create my flex skins and it works fine. Then I have tried to set up a transition inside flash, for the button control:
If I try to change the colour of the button, it works nice, but when I try to enlarge the button from up to over, it doesn t do it in flex…
It seems like flex autoscale my button…..
Do you know what to do?
Thanks.
July 4th, 2008 at 7:05 am
i cant flex autoscale my button too… what can i do?