Quick Example : Using COMPC to compile SWCs

I have been using the mxmlc and compc compilers a bunch this week (mxmlc and compc are ActionScript 3 / Flex 2 command line compilers included with the Free Flex 2 SDK). Whenever I start to use a command line compiler it can take me a while to figure out all of the correct arguments I need to pass it, but once I figure it out, it is pretty simple to use, as I just reuse a lot of the same args.

I went through this process this week trying to compile a SWC (containing a Flex Component) with COMPC. I wanted to make a quick post showing how I compiled it, along with a quick explanation, with the hopes of providing a good baseline reference for anyone else who needs to do something similar in the future.

So, here is the entire command:[code]compc -namespace http://www.adobe.com/2006/foo manifest.xml -source-path .-include-namespaces http://www.adobe.com/2006/foo -include-classes mx.containers.MyWindow-include-file MyWindow.png mx/containers/MyWindow.png-output=’MyWindow.swc'[/code]Here is the manifest.xml file:[code][/code]Basically, this compiles a single class / component (mx.containers.MyWindow) places it into the http://www.adobe.com/2006/foo namespace, and puts it all inside of MyWindow.swc (along with an Icon that can be used to show the component in Flex Builder).The SWC can now be easily distributed, making it easy for anyone to use the component and / or library.Here are some useful links in livedocs:compc compiler optionsmxmlc compiler optionsmanifest files

One Response to Quick Example : Using COMPC to compile SWCs

  1. astgtciv says:

    How is it possible to compile an AS3 SWC for use in Flex 2 that has an equivalent of a custom Live Preview in Flash Studio? Obviously, the built-in components in Flex 2 have a preview, but how can we create a custom one?