CHAPTER 8
164
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, Rotation.as and RotationInstance.as,
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 MyComponent.as). 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
determined.
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:
<compiler>
<source-path>
<path-element>.</path-element>
</source-path>
<output>
c:/jrun4/servers/flex2/flex/WEB-INF/flex/user_classes/RotationClasses.swc
</output>
</compiler>
<include-classes>
<class>rotationClasses.Rotation</class>
<class>rotationClasses.RotationInstance</class>
</include-classes>