Adobe Flex 3 Help

About compiling

You compile a custom component so that you can use it as part of your application. You can compile the component when you compile the entire application, or you can compile it separately so that you can link it into the application at a later time.

Flex component file types

When you create a Flex component, you can distribute it in one of several different file formats, as the following table shows:

File format

Extension

Description

MXML

.mxml

A component implemented as an MXML file.

ActionScript

.as

A component implemented as an ActionScript class.

SWC

.swc

A component implemented as an MXML or ActionScript file, and then packaged as a SWC file. A SWC file contains components that you package and reuse among multiple applications. The SWC file is then compiled into your application when you create the application's SWF file.

RSL

.swc

A component implemented as an MXML or ActionScript file, and then deployed as an RSL. An RSL is a stand-alone file that is downloaded separately from your application's SWF file, and cached on the client computer for use with multiple application SWF files.

You must take into consideration the file format and file location when you compile an application that uses the component.

About compiling with Flex SDK

Adobe Flex includes two compilers: mxmlc and compc. You use the mxmlc compiler to compile MXML, ActionScript, SWC, and RSL files into a single SWF file. After your application is compiled and deployed on your web or application server, a user can make an HTTP request to download and play the SWF file on their computer.

You use the compc compiler to compile components, classes, and other files into SWC files or into RSLs.

You can use the compc and mxmlc compilers from Adobe® Flex® Builder™ or from a command line. For more information on using the compilers, see Using the Flex Compilers, and Building Projects.

The most basic example of using the mxmlc compiler is one in which the MXML file has no external dependencies (such as components in a SWC file or ActionScript classes). In this case, you open mxmlc and point it to your MXML file:

$ mxmlc c:/myfiles/app.mxml

The default option is the target file to compile into a SWF file, and it must have a value. If you use a space-separated list as part of the options, you can terminate the list with a double hyphen before adding the target file, as in the following example:

$ mxmlc -option arg1 arg2 arg3 -- target_file.mxml

About case sensitivity during a compilation

The Flex compilers use a case-sensitive file lookup on all file systems. On case-insensitive file systems, such as the Macintosh and Windows file systems, the Flex compiler generates a case-mismatch error when you use a component with the incorrect case. On case-sensitive file systems, such as the UNIX file system, the Flex compiler generates a component-not-found error when you use a component with the incorrect case.

About the ActionScript source path

Typically, you put component files in directories that are in the ActionScript source path. These include your application's root directory, its subdirectories, and any directory that you specify to the compiler. To specify a directory, you use the source-path option to the mxmlc compiler, or the Project Properties dialog box in Flex Builder.

The following rules can help you organize your custom components:

  • An application can access MXML and ActionScript components in the same directory and in its subdirectories.
  • An ActionScript component in a subdirectory of the main application directory must define a fully qualified package name that is relative to the location of the application's root directory. For example, if you define a custom component in the dir1/dir2/myControls/PieChart.as file, its fully qualified package name must be dir1.dir2.myControls, assuming dir1 is an immediate subdirectory of the main application directory.
  • An MXML component does not include a package name definition. However, you must declare a namespace definition in the file that references the MXML component that corresponds to the directory location of the MXML component, either in a subdirectory of the application's root directory or in a subdirectory of the source path. For more information, see Simple MXML Components.
  • An application can access MXML and ActionScript components in the directories included in the ActionScript source path. The component search order in the source path is based on the order of the directories listed in the source path.
  • An ActionScript component in a subdirectory of a directory included in the source path must define a fully qualified package name that is relative to the location of the source path directory. For example, if you define a custom component in the file dir1/dir2/myControls/PieChart.as, and dir1 is included in the ActionScript source path, its fully qualified package name must be dir1.dir2.myControls.
  • The <mx:Script> tag in the main MXML file, and in dependent MXML component files, can reference components located in the ActionScript source path.