The following sections describe common scenarios where you could use the compc command-line compiler. You
can apply the techniques described here to compiling SWC files in Flex Builder with the Flex Library Compiler.
Compiling stand-alone components and classes
In many cases, you have one or more components that you use in your Flex applications, but you do not have them
in a package structure. You want to be able to use them in the generic namespace (“*”) inside your Flex applica-
tions. In these cases, you use the
include-classes option to add the components to your SWC file.
The following command-line example compiles two MXML components, and,
into a single SWC file:
compc -source-path .
-output c:/jrun4/servers/flex2/flex/WEB-INF/flex/user_classes/RotationClasses.swc
-include-classes rotationClasses.Rotation rotationClasses.RotationInstance
The rotationClasses directory is a subdirectory of the current directory, which is in the source path. The SWC file
is output to the user_classes directory, so the new components require no additional configuration to be used in
a server environment.
You use the
include-classes option to add components to the SWC file. You use just the class name of the
component and not the full filename (for example, MyComponent rather than Use dot-
notation to specify the location of the component in the package structure.
You also set the
source-path to the current directory or a directory from which the component directory can be
You can also add the framework.swc and framework_rb.swc files to the library-path option. This addition is
not always required if the compiler can determine the location of these SWC files on its own. However, if you move
the compiler utility out of the default location relative to the frameworks files, you must add it to the library path.
The previous command-line example appears in a configuration file as follows:
Building and Deploying Adobe Flex 3 Applications
To use components that are not in a package in a Flex application, you must declare a namespace that includes the
directory structure of the components. The following example declares a namespace for the components compiled
in the previous example:
<?xml version="1.0"?>
<mx:Application xmlns:mx=""
<local:Rotation id="Rotate75" angleFrom="0" angleTo="75" duration="100"/>
To use the generic namespace of “*” rather than a namespace that includes a components directory structure, you
can include the directory in the
source-path as the following command-line example shows:
compc -source-path . c:/flexdeploy/comps/rotationClasses
-output c:/jrun4/servers/flex2/flex/WEB-INF/flex/user_classes/RotationComps.swc
-include-classes Rotation RotationInstance
Then, you can specify the namespace in your application as:
<mx:Application xmlns:mx="" xmln:local="*">
You are not required to use the directory name in the include-classes option if you add the directory to the
source path.
These options appear in a configuration file, as the following example shows:
This example assumes that the components are not in a named package. For information about compiling
packaged components, see Compiling components in packages” on page 166.

Get ADOBE® FLEX® 3: BUILDING AND DEPLOYING ADOBE FLEX 3 APPLICATIONS now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.