Exporting symbols for Flex using Flash CS3
If you have designers sending you Flash SWFs for buttons and other objects in your Flex application you probably have come across Adobe’s tutorial which may not answer all your questions. The simple question my designer had was “How do I export a symbol?”. Read on to find out how…
ActionScript 2.0 vs ActionScript 3.0
For some reason, I wasn’t able to export symbols using AS3 so the first thing I did was switch the publish mode for my designer’s Flash project from AS3 to AS2.
- Select File->Publish Settings…
- Select the Flash Tab
- Change ActionScript version from 3.0 to 2.0
Linkage Options
In order to access the object, it must be exported.
- Right-click the object in your library and choose Properties…
- Make sure Type is set to Movie clip (it should be by default)
- Click Advanced to get more options.
- Under Linkage select “Export for ActionScript” and “Export in first frame”
Scale 9 Slicing
If the object is a button skin or something else that will be resized by a Flex application you need to also configure the scale 9 slicing.
- From the same Properties dialog as above, select “Enable guides for 9-slice scaling”
- This will put some dotted lines over your object. Move the lines around to configure the sections of the object that will stretch.
- If you are creating multiple state skins these lines must be exact for each state. If they are not exact, the items contained within them in the Flex application may appear to move around. For example, text on a button will move from side to side if the scale-9 lines are different for each state of the skin.
Using the Flash SWF in Flex
Once you have the SWF, all you need to do is add a few lines to your Flex stylesheet to start using it in your application.
Button
{
color: #FFFFFF;
textRollOverColor: #FFFFFF;
textSelectedColor: #FFFFFF;
paddingTop: 2;
paddingBottom: 0;
fontWeight: bold;
fontSize: 14pt;
upSkin: Embed(source='/assets/button.swf', symbol='up');
overSkin: Embed(source='/assets/button.swf', symbol='over');
downSkin: Embed(source='/assets/button.swf', symbol='down');
disabledSkin: Embed(source='/assets/button.swf', symbol='disabled');
selectedUpSkin: Embed(source='/assets/button.swf', symbol='selectedUp');
selectedOverSkin: Embed(source='/assets/button.swf', symbol='selectedOver');
selectedDownSkin: Embed(source='/assets/button.swf', symbol='selectedDown');
selectedDisabledSkin: Embed(source='/assets/button.swf', symbol='selectedDisabled');
}
Hi Christopher,
If you’re building a skin for Flex applications, you should check out the Flash CS3 component kit and skin design extension from Adobe:
http://labs.adobe.com/wiki/index.php/Flex_Component_Kit_for_Flash_CS3
It contains template for most flex 3 visual components and exports them to swc file.
If you’re using Flex 3 you can then use the import skin artwork option that automatically imports the skin and generates a CSS code.
Best regards,
Almog Kurtser
Thanks Almog, I’ll be sure to check that out. It will be very useful if we do lots of skinning in Flash.