Flash Catalyst project to SWC

Flash Catalyst. Its great isn’t it? Import your layout file and quickly create flex components. Catalyst exports a layout to a flex project file (FXP). In flash builder you can import this file as a new project. However I’ve found it is pretty tricky to import these new components into to an existing project because it requires alot of a refactoring or an additional source path.
I frequently use the export to swc feature within the Flash IDE to export my components into a flash builder project. It seemed strange that Adobe didn’t also include an export to swc feature in the latest flash builder. In order to export to a swc you need to use compc which is only accessible via the command line. Luckily you can use an ANT script to easily automate this task. If you don’t have ant installed for flash builder, follow the steps on this guide. Once installed you can use the script to below to build a SWC out of your flex skin project. You can then you this use this swc in other projects to apply the skin to existing components by using the skinClass property.

<project name="MySkin" default="compileSWC" basedir=".">
<property name="PROJECT_NAME" value="MySkin" />
<!-- change this line if your on a p.c. -->
<property name="FLEX_SDK" location="/Applications/Adobe Flash Builder 4/sdks/4.0.0/"/>
<property name="compc" location="${FLEX_SDK}/bin/compc"/>
<property name="mxmlc" location="${FLEX_SDK}/bin/mxmlc"/>
<property name="asdoc" location="${FLEX_SDK}/bin/asdoc"/>
<property name="SRC_DIR" location="src"/>
<property name="LIBS_DIR" location="libs"/>
<property name="RELEASE_DIR" location="bin-release/"/>
<property name="RELEASE_SWC" location="${RELEASE_DIR}/${PROJECT_NAME}.swc"/>
<property name="flashplayer" value="/SAFlashPlayer" />

<property name="FLEX_SDK_NAME" value="${FLEX_SDK}" />
	<target name="compileSWC">
					 <exec executable="${compc}">
					 	<arg line="-source-path '${SRC_DIR}' -library-path '${LIBS_DIR}' -target-player=10"  />
					 	<arg line="-output '${RELEASE_SWC}'" />
					 	<arg line="-is 'src'" />
					 	<arg line="-include-libraries 'libs'" />
					 	<arg line="-include-libraries '${FLEX_SDK}/frameworks/'" />
					 	<arg line="-include-libraries '${FLEX_SDK}/frameworks/libs/'" />
					 	<arg line="-include-libraries '${FLEX_SDK}/frameworks/locale/en_US/'" />
					 </exec>
			</target>
</project>