Mike Chambers

code = joy

Quick Example : Using COMPC to compile SWCs

with 5 comments

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:

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'

Here is the manifest.xml file:

<?xml version="1.0"?>
<componentPackage>
	<component id="MyWindow" class="mx.containers.MyWindow"/>
</componentPackage>

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 options
mxmlc compiler options
manifest files

Written by mikechambers

May 19th, 2006 at 11:30 am

Posted in General

5 Responses to 'Quick Example : Using COMPC to compile SWCs'

Subscribe to comments with RSS

  1. 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?

    astgtciv

    29 Jun 06 at 4:45 pm

  2. You always have to tell compc what classes you want included. How do I tell it to get all in a directory along with the mxml files? I gave it one class file and it seems to have collected all of the dependencies of that class, but how do I know I got all of them?

    Patrick Liechty

    14 Aug 07 at 12:55 pm

  3. check out the -includes-sources option
    Just my two cents

    Brice Carpentier

    30 Nov 07 at 9:02 am

  4. I have tried to use compc to comiple the files but it didn’t success. I keep getting ” Error: could not find source for class” even though I think the file is right there with correct path.. please help

    csun

    8 Aug 08 at 3:25 pm

  5. I am trying to use your Flickr Authenticate and Login process. I have run into a problem, in that the AuthorizationEvent event was not included in the libraries required by your application. I am commenting here, as I am trying to create a SWC from the AuthorizationEvent event code you posted on another site. My ultimate goal is to get the Flickr Auth-Login process to work. The fundamental error was: 1046: Type was not found or was not a compile-time constant: AuthorizationEvent., FlickrTest/src, FlickrTest.mxml,line 36. So I found your AuthorizationEvent event (http://code.google.com/p/as3flickrlib/source/browse/trunk/src/com/adobe/webapis/flickr/authorization/events/AuthorizationEvent.as?r=33), and decided to try to incorporate it as a custom event in Flex Builder. When that didn’t work, I tried to include the AuthorizationEvent .as file in the build path. Got a conflict with that. So I figured I’d try to create a SWC using your event code. Any help would be great. Thank you. Regards and Happy New Year, Marshall.

    Marshall Goodman

    29 Dec 08 at 3:07 pm

Leave a Reply