Flex includes the following application and component compilers:
Application compilers. The application compilers create SWF files from MXML, ActionScript, and other assets such as images, SWF files, and SWC files.
Component compilers. The component compilers create SWC files from the same kinds of files. The application compilers then use the SWC files as component libraries, themes, or RSLs.
The following example shows the input and output of the Flex compilers:
You open the application compiler with the mxmlc command-line tool. You open the component compiler with the compc command-line tool.
The application compilers create SWF files that are run in an Adobe™ Flash® Player client or in an Adobe AIR™ application. The client can be a stand-alone Flash Player or a Flash Player in a browser, which takes the form of an ActiveX control for Microsoft Internet Explorer or a plug-in for Netscape-based browsers.
You open the mxmlc compiler from the command line to create a SWF file that you then deploy to a website. Typically, you pass the name of the application's root MXML file to the compiler. The output is a SWF file. For more information, see Using the mxmlc application compiler.
The mxmlc compiler options are described in About the application compiler options.
You can compile applications that are written entirely in ActionScript and contain no MXML using the mxmlc compiler.
You use the mxmlc command-line compiler to create SWF files from MXML, AS, and other source files. You can open it as a shell script and executable file for use on Windows and UNIX systems. You use this compiler to precompile applications that you deploy later.
The command-line compiler is installed with Flex SDK. It is in the flex_install_dir/bin directory in Flex SDK.
To use the mxmlc utility, you should understand its syntax and how to use configuration files. For more information, see About the command-line compilers.
The basic syntax of the mxmlc utility is as follows:
mxmlc [options] target_file
The default option is the target file to compile into a SWF file, and it is required to 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; for example:
mxmlc -option arg1 arg2 arg3 -- target_file.mxml
To see a list of options for mxmlc, you can use the help list option, as the following example shows:
mxmlc -help list
To see a list of all options available for mxmlc, including advanced options, you use the following command:
mxmlc -help list advanced
The default output of mxmlc is filename.swf, where filename is the name of the root application file. The default output location is in the same directory as the target, unless you specify an output file and location with the output option.
The mxmlc command-line compiler does not generate an HTML wrapper. You must create your own wrapper to deploy a SWF file that the mxmlc compiler produced. The wrapper is used to embed the SWF object in the HTML tag. It includes the <object> and <embed> tags, as well as scripts that support Flash Player version detection and history management. For information about creating an HTML wrapper, see Creating a wrapper.
The mxmlc utility uses the default compiler settings in the flex-config.xml file. This file is in the flex_sdk_dir/frameworks/ directory. You can change the settings in this file or use another custom configuration file. For more information on using configuration files, see About configuration files.
The mxmlc compiler is highly customizable with a large set of options. For information on the compiler options, see About the application compiler options.
You can also open the mxmlc compiler with the java command on the command line. For more information, see Invoking the command-line compilers with Java.
You use the component compiler to generate a SWC file from component source files and other asset files such as images and style sheets. A SWC file is an archive of components and other assets. For more information about SWC files, see About SWC files.
In some ways, the component compiler is similar to the application compiler. The application compiler produces a SWF file from one or more MXML and ActionScript files; the component compiler produces a SWC file from its input files. SWC files are compressed files that contain a SWF file (library.swf), asset files, and a catalog.xml file.
You use the component compiler to create the following kinds of assets:
Component libraries are SWC files that contain one or more components that are used by applications. SWC files also contain the namespace information that describe the contents of the SWC file. For more information about component libraries, see About SWC files.
RSLs are external shared assets that can be separately downloaded and cached on the client. These shared assets are loaded by any number of applications at run time. For more information on RSLs, see Runtime Shared Libraries.
Themes are a combination of skins and Cascading Style Sheets (CSS). You use themes to define the look and feel of an application built with Flex. For more information on themes, see Styles and themes.
You use the component compiler in the following ways:
You open the compc compiler from the command line to create a SWC file. For more information, see Using the compc component compiler.
The component compiler has many of the same options as the application compilers, as described in About the application compiler options. The component compiler has additional options as described in About the component compiler options.
Like the application compiler, you can use the load-config option to point the component compiler to a configuration file, rather than specify command-line options or set the options in the Flex Compiler dialog box.
When you compile a SWC file, store the new file in a location that is not the same as the source files. If both sets of files are accessible by Flex when you compile your application, unexpected behavior can occur.
The SWC files that are produced by the component compilers do not require an HTML wrapper because they are used as themes, RSLs, or component libraries that are input to other compilers to create applications. You never deploy a SWC file that users can request directly.
You use the compc command-line compiler to compile SWC files from MXML, ActionScript, and other source files such as style sheets, images, and SWF files.
You can open the compc compiler as a shell script and executable file for use on Windows and UNIX systems. It is in the flex_install_dir/bin directory in Flex SDK
To use the compc compiler, you should understand how to pass options and use configuration files. For more information, see About the command-line compilers.
The syntax of the compc compiler is as follows:
compc [options] -include-classes class [...]
The default option for compc is include-classes. At least one of the "include-" options is required.
To see a list of supported options for compc, you can use the help list option, as the following example shows:
compc -help list
The compc compiler uses the default compiler settings in the flex-config.xml file. Like the application compiler, you can change these settings or use another custom configuration file. Unlike the application compiler, however, the component compiler does not support the use of default configuration files.
You can also open the compc compiler with the java command on the command line. For more information, see Invoking the command-line compilers with Java.
You use the mxmlc and compc command-line compilers to compile your MXML and AS files into SWF and SWC files. You can use the utilities to precompile applications that you want to deploy on another server or to automate compilation in a testing environment.
To use the command-line compilers, you must have a Java run-time environment in your system path.
For Flex SDK, the command-line compilers are located in the flex_install_dir/bin directory.
When using mxmlc and compc on the command line, you can also use a configuration file to store your options rather than list them on the command line. You can store command-line options as XML blocks in a configuration file. For more information, see About configuration files.
The mxmlc and compc compilers take many options. The options are listed in the help which you can view with the help option, as the following example shows:
mxmlc -help
This displays a menu of choices for getting help. The most common choice is to list the basic configuration options:
mxmlc -help list
To see advanced options, use the list advanced option, as the following example shows:
mxmlc -help list advanced
To see a list of entries whose names or descriptions include a particular String, use the following syntax:
mxmlc -help pattern
The following example returns descriptions for the external-library-path, library-path, and runtime-shared-libraries options:
mxmlc -help list library
For a complete description of mxmlc options, see About the application compiler options. For a complete description of compc options, see About the component compiler options.
Many command-line options, such as show-actionscript-warnings and accessible, have true and false values. You specify these values by using the following syntax:
mxmlc -accessible=true -show-actionscript-warnings=true
Some options, such as source-path, take a list of one or more options. You can see which options take a list by examining the help output. Square brackets ([ ]) that surround options indicate that the option can take a list of one or more parameters.
You can separate each entry in a list with a space or a comma. The syntax is as follows:
-var val1 val2
or
-var=val1, val2
If you do not use commas to separate entries, you terminate a list by using a double hyphen, as the following example shows:
-var val1 val2 -- -next_option
If you use commas to separate entries, you terminate a list by not using a comma after the last entry, as the following example shows:
-var=val1, val2 -next_option
You can append values to an option using the += operator. This adds the new entry to the end of the list of existing entries rather than replacing the existing entries. The following example adds the c:/myfiles directory to the library-path option:
mxmlc -library-path+=c:/myfiles
In some cases, the command-line help shows an option with dot-notation syntax; for example, source-path is shown as compiler.source-path. This notation indicates how you would set this option in a configuration file. On the command line, you can specify the option with only the final node, source-path, as long as that node is unique, as the following example shows:
mxmlc -source-path . c:/myclasses/ -- foo.mxml
For more information about using configuration files to store command-line options, see About configuration files.
Some compiler options have aliases. Aliases provide shortened variations of the option name to make command lines more readable and less verbose. For example, the alias for the output option is o. You can view a list of options by their aliases by using the following command:
mxmlc -help list aliases
or
mxmlc -help list advanced aliases
You can also see the aliases in the verbose help output by using the following command:
mxmlc -help list details
Flex provides a simple interface to the command-line compilers. For UNIX users, there is a shell script. For Windows users, there is an executable file. These files are located in the bin directory. You can also invoke the compilers using Java. This lets you integrate the compilers into Java-based projects (such as Ant) or other utilities.
The shell scripts and executable files for the command-line compilers wrap calls to the mxmlc.jar and compc.jar JAR files. To invoke the compilers from Java, you call the JAR files directly. For Flex SDK, the JAR files are located in the flex_install_dir/lib directory.
To invoke a command in a JAR file, use the java command from the command line and specify the JAR file you want to execute with the jar option. You must also specify the value of the +flexlib option. This advanced option lets you set the root directory that is used by the compiler to locate the flex-config.xml file, among other files. You typically point it to your frameworks directory. From there, the compiler can detect the location of other configuration files.
The following example compiles MyApp.mxml into a SWF file using the JAR file to invoke the mxmlc compiler:
java -jar ../lib/mxmlc.jar +flexlib c:/flex_4_sdk/frameworks c:/flex/MyApp.mxml
You pass all other options as you would when you open the command-line compilers. The following example sets the locale and source path when compiling MyApp:
java -jar ../lib/mxmlc.jar +flexlib c:/flex_4_sdk/frameworks -locale en_US -source-path locale/{locale} c:/flex/MyApp.mxml
Configuration files can be used by the command-line utilities.
Flex includes a default configuration file named flex-config.xml. This configuration file contains most of the default compiler settings for the application and component compilers. You can customize this file or create your own custom configuration file.
Flex SDK includes the flex-config.xml file in the flex_install_dir/frameworks directory.
You can generate a configuration file with the current settings by using the dump-config option, as the following example shows:
mxmlc -dump-config myapp-config.xml
You can specify the location of a configuration file by using the load-config option. The target configuration file can be the default flex-config.xml file, or it can be a custom configuration file. The following example loads a custom configuration file:
compc -load-config=myconfig.xml
If you specify the filename with the += operator, your loaded configuration file is used in addition to and not instead of the flex-config.xml file:
compc -load-config+=myconfig.xml
With the mxmlc compiler, you can also use a local configuration file. A local configuration file does not require you to point to it on the command line. Rather, Flex examines the same directory as the target MXML file for a configuration file with the same name (one that matches the filename-config.xml filename). If it finds a file, it uses it in conjunction with the flex-config.xml file. You can also specify a configuration file by using the load-config option with the += operator.
For example, if your application's top-level file is called MyApp.mxml, the compiler first checks for a MyApp-config.xml file for configuration settings. With this feature, you can easily compile multiple applications using different configuration options without changing your command-line options or your flex-config.xml file.
Options in the local configuration file take precedence over options set in the flex-config.xml file. Options set in a configuration file that the load-config option specify take precedence over the local configuration file. Command-line settings take precedence over all configuration file settings. For more information on the precedence of compiler options, see About option precedence.
You store values in a configuration file in XML blocks, which follow a specific syntax. In general, the tags you use match the command-line options.
The root tag of the default configuration file, flex-config.xml, is <flex-config>. If you write a custom configuration file, it must also have this root tag. Compiler configuration files must also have an XML declaration tag, as the following example shows:
<?xml version="1.0"?> <flex-config>
You must close the <flex-config> tag as you would any other XML tag. All compiler configuration files must be closed with the following tag:
</flex-config>
In general, the second tag in a configuration file is the <compiler> tag. This tag wraps most compiler options. However, not all compiler options are set in the <compiler> block of the configuration file.
Tags that you must wrap in the compiler block are prefixed by compiler in the help output (for example, compiler.services). If the option uses no dot-notation in the help output (for example, include-file), it is a tag at the root level of the configuration file, and the entry appears as follows:
<compiler> ... </compiler> <include-file> <name>logo.gif</name> <path>c:/images/logo/logo1.gif</path> </include-file>
In some cases, options have multiple parent tags, as with the fonts options, such as compiler.fonts.managers and compiler.fonts.languages.language. Other options that require parent tags when added to a configuration file include the frames.frame option and the metadata options. The following sections describe methods for determining the syntax.
Use the help list option of the command-line compilers to get the configuration file syntax of the compiler options; for example:
mxmlc -help list advanced
The following is the entry for the source-path option:
-compiler.source-path [path-element][...]
This indicates that in the configuration file, you can have one or more <path-element> child tags of the <source-path> tag, and that <source-path> is a child of the <compiler> tag. The following example shows how this should appear in the configuration file:
<compiler> <source-path> <path-element>.</path-element> <path-element>c:/myclasses/</path-element> </source-path> </compiler>
The help output uses dot-notation to separate child tags from parent tags, with the right-most entry being known as the leaf node. For example, -tag1.tag2 indicates that <tag2> should be a child tag of <tag1>.
Angle brackets (< >) or square brackets ([ ]) that surround an option indicate that the option is a leaf node.
Square brackets indicate that there can be a list of one or more parameters for that option.
If the leaf node of a tag in the angle bracket is unique, you do not have to specify the parent tags in the configuration file. For example, the help usage shows the following:
compiler.fonts.managers [manager-class][...]
You can specify the value of this option in the configuration file, as the following example shows:
<compiler> <fonts> <managers> <manager-class>flash.fonts.JREFontManager</manager-class> </managers> </fonts> </compiler>
However, the <manager-class> leaf node is unique, so you can set the value without specifying the <fonts> and <managers> parent tags, as the following example shows:
<compiler> <manager-class>flash.fonts.JREFontManager</manager-class> </compiler>
If the help output shows multiple options listed in angle brackets, you set the values of these options at the same level inside the configuration file and do not make them child tags of each other. For example, the usage for default-size (default-size <width> <height>) indicates that the default size of the application is set in a configuration file, as the following example shows:
<default-size> <height>height_value</height> <width>width_value</width> </default-size>
You can pass custom token values to the compiler using the following syntax:
+token_name=value
In the configuration file, you reference that value using the following syntax:
${token_name}
You can use the @Context token in your configuration files to represent the context root of the application. You can also use the ${flexlib} token to represent the frameworks directory. This is useful if you set up your own configuration and are not using the default library-path settings.
The default value of the ${flexlib} token is application_home \frameworks.
In a configuration file, you can specify the append attribute of any tag that takes a list of arguments. Set this attribute to true to indicate that the values should be appended to the option rather than replace it. The default value is false.
Setting the append attribute to true lets you compound the values of options with multiple configuration files. The following example appends two entries to the library-path option:
<library-path append="true"> <path-element>/mylibs</path-element> <path-element>/myotherlibs</path-element> </library-path>
You can set the same options in multiple places and the Flex compilers use the value from the source that has the highest precedence.
If you do not specify an option on the command line, the compilers check for a load-config option and get the value from that file.
When using the mxmlc compiler, Flex checks to see if there is an app_name-config.xml file in the same directory as the target MXML file. This is known as the local configuration file and is described in Locating configuration files. The syntax and structure of local configuration files are the same as with the flex-config.xml file.
If no load-config option is specified, the compilers check for the flex-config.xml file. The compilers look for the flex-config.xml file in the /frameworks directory. The following location is the default:
{flex_root}/frameworks
Most options have a default value that the compilers use if the option is not set in any of the other ways.
The following table shows the possible sources of options for each compiler. The table also shows the order of precedence for each option. The options set using the method described in a lower row take precedence over the options set using the methods described in a higher row.
|
Compiler options |
mxmlc |
compc |
|---|---|---|
|
Default settings |
No |
No |
|
flex-config.xml |
Yes |
Yes |
|
Local configuration file |
Yes |
No |
|
Configuration file specified by load-config option |
Yes |
Yes |
|
Command-line option |
Yes |
Yes |
|
Options panel |
No |
No |
You can mix and match the source of the compiler options. For example, you can specify a custom configuration file with the load-config option, and also set additional options on the command line.
You can also use multiple configuration files. You can chain them by using the += operator with the load-config option. If you specify a configuration file with this option, the compilers also look for the flex-config.xml and local (appname-config.xml) configuration files.
You use the application compiler to compile SWF files from your ActionScript and MXML source files.
The application compiler's options let you define settings such as the library path and whether to include debug information in the resulting SWF file. Also, you can set application-specific settings such as the frame rate at which the SWF file should play and its height and width.
To invoke the application compiler with Flex SDK, you use the mxmlc command-line utility.
The following set of examples use the application compiler.
The following table describes the application compiler options. You invoke the application compiler with the mxmlc command-line utility.
|
Option |
Description |
|---|---|
accessible=true|false |
Enables accessibility features when compiling the application or SWC file. The default value is false. For more information on using the Flex accessibility features, see Accessible applications. |
actionscript-file-encoding string |
Sets the file encoding for ActionScript files. For more information, see Setting the file encoding. |
advanced |
Lists advanced help options when used with the help option, as the following example shows: mxmlc -help advanced This is an advanced option. |
allow-source-path-overlap=true|false |
Checks if a source-path entry is a subdirectory of another source-path entry. It helps make the package names of MXML components unambiguous. This is an advanced option. |
as3=true|false |
Use the ActionScript 3.0 class-based object model for greater performance and better error reporting. In the class-based object model, most built-in functions are implemented as fixed methods of classes. The default value is true. If you set this value to false, you must set the es option to true. This is an advanced option. |
benchmark=true|false |
Prints detailed compile times to the standard output. The default value is true. |
|
compress=true|false |
Enables or disables SWF file compression. The default value is true when debugging is disabled (so that release SWF files are compressed) and false when debugging is enabled (so that debug SWF files are not compressed). |
context-root context-path |
Sets the value of the {context.root} token, which is often used in channel definitions in the flex-services.xml file and other settings in the flex-config.xml file. The default value is null. |
contributor name |
Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. |
creator name |
Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. |
date text |
Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. |
debug=true|false |
Generates a debug SWF file. This file includes line numbers and filenames of all the source files. When a run-time error occurs, the stacktrace shows these line numbers and filenames. This information is used by the command-line debugger. Enabling the debug option generates larger SWF files and also disables compilation optimization. For the mxmlc compiler, the default value is false. For the compc compiler, the default value is true. When generating SWC files, if debug is set to true, then the library.swf file inside the SWC file contains debug information. If you are generating a SWC file for distribution, set this value to false. For information about the command-line debugger, see Command-line debugger. If you set this option to true, Flex also sets the verbose-stacktraces option to true |
debug-password string |
Lets you engage in remote debugging sessions with the Flash IDE. This is an advanced option. |
default-frame-rate int |
Sets the application's frame rate. The default value is 24. This is an advanced option. |
default-script-limits max-recursion-depth max-execution-time |
Defines the application's script execution limits. The max-recursion-depth value specifies the maximum depth of Adobe Flash Player call stack before Flash Player stops. This is essentially the stack overflow limit. The default value is 1000. The max-execution-time value specifies the maximum duration, in seconds, that an ActionScript event handler can execute before Flash Player assumes that it is hung, and aborts it. The default value is 60 seconds. You cannot set this value above 60 seconds. You can override these settings in the application. This is an advanced option. |
default-size width height |
Defines the default application size, in pixels. This is an advanced option. |
defaults-css-files filename [, ...] |
Inserts CSS files into the output the same way that a per-SWC defaults.css file works, but without having to re-archive the SWC file to test each change. CSS files included in the output with this option have a higher precedence than default CSS files in existing SWCs. For example, a CSS file included with this option overrides definitions in framework.swc's defaults.css file, but it has the same overall precedence as other included CSS files inside the SWC file. This option does not actually insert the CSS file into the SWC file; it simulates it. When you finish developing the CSS file, you should rebuild the SWC file with the new integrated CSS file. This option takes one or more files. The precedence for multiple CSS files included with this option is from first to last. This is an advanced option. |
defaults-css-url string |
Defines the location of the default style sheet. Setting this option overrides the implicit use of the defaults.css style sheet in the framework.swc file. For more information on the defaults.css file, see Styles and themes. This is an advanced option. |
define=NAMESPACE::variable,value |
Defines a global constant. The value is evaluated at compile time and exists as a constant within the application. A common use of inline constants is to set values that are used to include or exclude blocks of code, such as debugging or instrumentation code. This is known as conditional compilation. The following example defines the constant debugging in the CONFIG namespace: -define=CONFIG::debugging,true In ActionScript, you can use this value to conditionalize statements; for example: CONFIG::debugging {// Execute debugging code here.}
To set multiple conditionals on the command-line, use the define option more than once. For more information, see Using conditional compilation. |
description text |
Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. |
dump-config filename |
Outputs the compiler options in the flex-config.xml file to the target path; for example: mxmlc -dump-config myapp-config.xml This is an advanced option. |
es=true|false |
Instructs the compiler to use the ECMAScript edition 3 prototype-based object model to allow dynamic overriding of prototype properties. In the prototype-based object model, built-in functions are implemented as dynamic properties of prototype objects. The default value is false. Using the ECMAScript edition 3 prototype-based object model lets you use untyped properties and functions in your application code. As a result, if you set the value of the es compiler option to true, you must set the strict compiler option to false. Otherwise, the compiler will throw errors. If you set this option to true, you must also set the value of the as3 compiler option to false. This is an advanced option. |
externs class_name [...] |
Sets a list of classes to exclude from linking when compiling a SWF file. This option provides compile-time link checking for external references that are dynamically linked. For more information about dynamic linking, see About linking. This is an advanced option. |
external-library-path path-element [...] |
Specifies a list of SWC files or directories to exclude from linking when compiling a SWF file. This option provides compile-time link checking for external components that are dynamically linked. By default, the libs/player/playerglobal.swc file is linked as an external library. This library is built into Flash Player. For more information about dynamic linking, see About linking. You can use the += operator to append the new SWC file to the list of external libraries. |
fonts.advanced-anti-aliasing=true|false |
Sets the default value that determines whether embedded fonts use advanced anti-aliasing information when rendering the font. Setting the value of the advanced-anti-aliasing property in a style sheet overrides this value. The default value is false. For more information about using advanced anti-aliasing, see Fonts. |
fonts.languages.language-range lang range |
Specifies the range of Unicode settings for that language. For more information, see Fonts. This is an advanced option. |
fonts.local-fonts-snapshot path_to_file |
Sets the location of the local font snapshot file. The file contains system font data. This is an advanced option. |
fonts.managers manager-class [...] |
Defines the font manager. The default is flash.fonts.JREFontManager. You can also use the flash.fonts.BatikFontManager. For more information, see Fonts. This is an advanced option. |
fonts.max-cached-fonts string |
Sets the maximum number of fonts to keep in the server cache. |
fonts.max-glyphs-per-face string |
Sets the maximum number of character glyph-outlines to keep in the server cache for each font face. This is an advanced option. |
frames.frame=label,class_name[,...] |
Specifies a SWF file frame label with a
sequence of class names that are linked onto the frame; for example:
-frame=MyLabel,Class1,Class2 This option lets you add asset factories that stream in after the application that then publish their interfaces with the ModuleManager class. The advantage to doing this is that the application starts faster than it would have if the assets had been included in the code, but does not require moving the assets to an external SWF file. This is an advanced option. |
generate-frame-loader=true|false |
Toggles the generation of an IFlexBootstrap-derived loader class. This is an advanced option. |
headless-server=true|false |
Enables the headless implementation of the Flex compiler. This sets the following: System.setProperty("java.awt.headless", "true")
The headless setting (java.awt.headless=true) is required to use fonts and SVG on UNIX systems without X Windows. This is an advanced option. |
help [-list [advanced]] |
Prints usage information to the standard
output. For example:
help -list advanced For more information, see Command-line syntax. |
|
include-inheritance-dependencies-only=false|true |
Include only classes that are inheritance dependencies of classes that are included with the include-classes compiler option. The default value is false. This
is an advanced option. You might use this compiler option if you
are creating a custom RSL and want to externalize as many classes
as possible. For example:
compc -include-classes mx.collections.ListCollectionView -include-inheritance-dependencies-only=true -source-path . -output lcv2 -directory |
include-libraries library [...] |
Links all classes inside a SWC file to the resulting application SWF file, regardless of whether or not they are used. Contrast this option with the library-path option that includes only those classes that are referenced at compile time. To link one or more classes whether or not they are used and not an entire SWC file, use the includes option. This option is commonly used to specify resource bundles. |
include-resource-bundles bundle [...] |
Specifies the resource bundles to link into a resource module. All resource bundles specified with this option must be in the compiler's source path. You specify this using the source-path compiler option. For more information on using resource bundles, see Resource Bundles. |
includes class [...] |
Links one or more classes to the resulting application SWF file, whether or not those classes are required at compile time. To link an entire SWC file rather than individual classes, use the include-libraries option. |
incremental=true|false |
Enables incremental compilation. For more information, see About incremental compilation. For the command-line compiler, the default is false. |
|
isolate-styles=true|false |
Enables per-module styling. The default value is true. This is an advanced option. You typically only use this option if you want to set styles in a module that is loaded into your main application. For more information about modules, see Modular applications. |
keep-as3-metadata=class_name [...] |
Specifies custom metadata that you want to keep. By default, the compiler keeps the following metadata:
If you want to preserve the default metadata, you should use the += operator to append your custom metadata, rather than the = operator which replaces the default metadata. This is an advanced option. For more information, see About metadata tags. |
|
keep-all-type-selectors=true|false |
Instructs the compiler to keep a style sheet's type selector in a SWF file, even if that type (the class) is not used in the application. This is useful when you have a modular application that loads other applications. For example, the loading SWF file might define a type selector for a type used in the loaded (or, target) SWF file. If you set this option to true when compiling the loading SWF file, then the target SWF file will have access to that type selector when it is loaded. If you set this option to false, the compiler will not include that type selector in the loading SWF file at compile time. As a result, the styles will not be available to the target SWF file. This is an advanced option. |
keep-generated-actionscript=true|false |
Determines whether to keep the generated ActionScript class files. The generated class files include stubs and classes that are generated by the compiler and used to build the SWF file. When using the application compiler, the default location of the files is the /generated subdirectory, which is directly below the target MXML file. If the /generated directory does not exist, the compiler creates one. When using the compc component compiler, the default location of the /generated directory is relative to the output of the SWC file. The default names of the primary generated class files are filename-generated.as and filename-interface.as. The default value is false. This is an advanced option. |
language code |
Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. |
library-path path-element [...] |
Links SWC files to the resulting application SWF file. The compiler only links in those classes for the SWC file that are required. You can specify a directory or individual SWC files. The default value of the library-path option includes all SWC files in the libs and libs/player directories, plus the current locale directory. These are required. To point to individual classes or packages rather than entire SWC files, use the source-path option. If you set the value of the library-path as an option of the command-line compiler, you must also explicitly add the framework.swc and locale SWC files. Your new entry is not appended to the library-path but replaces it, unless you use the += operator. On the command line, you use the += operator to append the new argument to the list of existing SWC files. In a configuration file, you can set the append attribute of the library-path tag to true to indicate that the values should be appended to the library path rather than replace existing default entries. |
license product_name license_key |
Defines the license key to use when compiling. |
link-report filename |
Prints linking information to the specified output file. This file is an XML file that contains <def>, <pre>, and <ext> symbols showing linker dependencies in the final SWF file. The output of this command can be used as input to the load-externs option. For more information on the report, see Examining linker dependencies. This is an advanced option. |
load-config filename |
Specifies the location of the configuration file that defines compiler options. If you specify a configuration file, you can override individual options by setting them on the command line. All relative paths in the configuration file are relative to the location of the configuration file itself. Use the += operator to chain this configuration file to other configuration files. For more information on using configuration files to provide options to the command-line compilers, see About configuration files. |
load-externs filename [...] |
Specifies the location of an XML file that contains <def>, <pre>, and <ext> symbols to omit from linking when compiling a SWF file. The XML file uses the same syntax as the one produced by the link-report option. For more information on the report, see Examining linker dependencies. This option provides compile-time link checking for external components that are dynamically linked. For more information about dynamic linking, see About linking. This is an advanced option. |
locale locale[,...] |
Specifies one or more locales to be compiled into the SWF file. If you do not specify a locale, then the compiler uses the default locale from the flex-config.xml file. The default value is en_US. You can append additional locales to the default locale by using the += operator. If you remove the default locale from the flex-config.xml file, and do not specify one on the command line, then the compiler will use the machine's locale. For more information, see Localization. |
localized-description text lang |
Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. |
localized-title text lang |
Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. |
mxml.compatibility-version=version |
Specifies the version of the Flex compiler that the output should be compatible with. This option affects some behavior such as the layout rules, padding and gaps, skins, and other style settings. In addition, it affects the rules for parsing properties files. The following example instructs the application to compile with the Flex 3 rules for these behaviors: -compatibility-version=3.0.0 Possible values for this compiler option are defined as constants in the FlexVersion class. If you set this value to 3.0.0, you must also use a theme in your application that is compatible with version 3 of the SDK. For more information on using this option, see Backward compatibility. |
|
mxml.minimum-supported-version=version_number |
Specifies the minimum version of the SDK that the application uses. This is typically used when generating SWC files. This is an advanced option. |
|
mxml.qualified-type-selectors=true|false |
Determines whether you want the compiler to ensure that type selectors have a qualified namespace in the CSS files. This is an advanced option. The default value is true. |
namespaces.namespace uri manifest |
Specifies a namespace for the MXML file. You must include a URI and the location of the manifest file that defines the contents of this namespace. This path is relative to the MXML file. For more information about manifest files, see About manifest files. |
optimize=true|false |
Enables the ActionScript optimizer. This optimizer reduces file size and increases performance by optimizing the SWF file's bytecode. The default value is true. |
|
omit-trace-statements=false|true |
Enables trace() statements from being written to the flashlog.txt file. The default value is false, which means that by default, trace() statements are written to the flashlog.txt file. |
output filename |
Specifies the output path and filename for the resulting file. If you omit this option, the compiler saves the SWF file to the directory where the target file is located. The default SWF filename matches the target filename, but with a SWF file extension. If you use a relative path to define the filename, it is always relative to the current working directory, not the target MXML application root. The compiler creates extra directories based on the specified filename if those directories are not present. When using this option with the component compiler, the output is a SWC file rather than a SWF file, unless you set the directory option to true. In that case, the output is a directory with the contents of the SWC file. The name of the directory is that value of the ouput option. |
|
preloader class_name |
Specify a download progress bar for your application. The value must be the name of a class that implements the IPreloaderDisplay interface. The default value is "mx.preloaders.SparkDownloadProgressBar" when compatibility-version is 4.0.0 or greater. When compatibility-version is less than 4.0.0, the default value is "mx.preloaders.DownloadProgressBar". For more information, see Showing the download progress of an application. |
publisher name |
Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. |
raw-metadata XML_string |
Defines the metadata for the resulting SWF file. The value of this option overrides any metadata-related compiler options such as contributor, creator, date, and description. This is an advanced option. |
|
remove-unused-rsls=true|false |
Instructs the compiler to only include RSLs that are used by the application. The default value is true. For more information about RSLs, see Runtime Shared Libraries. |
resource-bundle-list filename |
Prints a list of resource bundles that are used by the current application to a file named with the filename argument. You then use this list as input that you specify with the include-resource-bundles option to create a resource module. For more information, see Resource Bundles. |
runtime-shared-libraries rsl-url [...] |
Specifies a list of runtime shared libraries (RSLs) to use for this application. RSLs are dynamically-linked at run time. The compiler externalizes the contents of the application that you are compiling that overlap with the RSL. You specify the location of the SWF file relative to the deployment location of the application. For example, if you store a file named library.swf file in the web_root/libraries directory on the web server, and the application in the web root, you specify libraries/library.swf. This compiler argument is included for backwards compatibility with Flex 3 applications. For Flex 4 applications, use the runtime-shared-library-path option. For more information about RSLs, see Runtime Shared Libraries. |
runtime-shared-library-path=path-element,rsl-url[,policy-file-url,failover-url,...] |
Specifies the location of a runtime shared library (RSL). The compiler externalizes the contents of the application that you are compiling that overlap with the RSL. The path-element argument is the location of the SWC file or open directory to compile against. For example, c:\flexsdk\frameworks\libs\framework.swc. This is the equivalent of the using the external-library-path option when compiling against an RSL using the runtime-shared-libraries option. The rsl-url argument is the URL of the RSL that will be used to load the RSL at runtime. The compiler does not verify the existence of the SWF file at this location at compile time. It does store this string in the application, however, and uses it at run time. As a result, the SWF file must be available at run time but necessarily not at compile time. The policy-file-url is the location of the crossdomain.xml file that gives permission to read the RSL from the server. This might be necessary because the RSL can be on a separate server as the application. For example, http://www.mydomain.com/rsls/crossdomain.xml. The failover-url and second policy-file-url arguments specify the location of the secondary RSL and crossdomain.xml file if the first RSL cannot be loaded. This most commonly happens when the client Player version does not support cross-domain RSLs. You can add any number of failover RSLs, but must include a policy file URL for each one. Do not include spaces between the comma-separated values. The following example shows how to use this option: mxmlc -o=../lib/app.swf -runtime-shared-library-path=../lib/mylib.swc,../bin/myrsl.swf Main.mxml You can specify more than one library file to be used as an RSL. You do this by adding additional runtime-shared-library-path options. You can also use the runtime-shared-libraries command to use RSLs with your applications. However, the runtime-shared-library-path option lets you also specify the location of the policy file and failover RSL. For more information about RSLs, see Runtime Shared Libraries. |
|
runtime-shared-library-settings.application-domain=path-element,application-domain-target |
Controls which domain an RSL is loaded into at runtime. The path-element is the path of the SWC library. To specify an RSL with this option, you must also define it in the runtime-shared-library-path option. The application-domain-target is the domain that the RSL should be loaded into. Valid values for application-domain-target are default, current, parent, and top-level. The default value is default. For more information about modules, see Modular applications. For more information about sub-applications, see Developing and loading sub-applications. For more information about RSLs, see Runtime Shared Libraries. |
|
runtime-shared-library-settings.force-rsls=path-element |
Forces an RSL to be included, regardless of whether it is used by the application. This is useful if all the links to a particular class in an RSL are soft references, or if you anticipate a module or sub-application to need a class that is not used by the main application. The path-element is the path of the SWC library. You can specify more than one path-element by using a comma-delimited list of RSLs. To specify an RSL with this option, you must also define it in the runtime-shared-library-path option. For more information about RSLs, see Runtime Shared Libraries. |
services filename |
Specifies the location of the services-config.xml file. This file is used by LiveCycle Data Services ES. |
show-actionscript-warnings=true|false |
Shows warnings for ActionScript classes. The default value is true. For more information about viewing warnings and errors, see Viewing warnings and errors. |
show-binding-warnings=true|false |
Shows a warning when Flash Player cannot detect changes to a bound property. The default value is true. For more information about viewing warnings and errors, see Viewing warnings and errors. |
|
show-invalid-css-property-warnings=true|false |
Shows a warning when a style property is set in CSS on a component that does not support that property. The warning can be a result of the theme not supporting the style property, the component not declaring it, or the component excluding it. The default value is true. For more information about viewing warnings and errors, see Viewing warnings and errors. |
show-shadowed-device-font-warnings=true|false |
Shows warnings when you try to embed a font with a family name that is the same as the operating system font name. The compiler normally warns you that you are shadowing a system font. Set this option to false to disable the warnings. The default value is true. For more information about viewing warnings and errors, see Viewing warnings and errors. |
show-unused-type-selector-warnings=true|false |
Shows warnings when a type selector in a style sheet or <fx:Style> block is not used by any components in the application. The default value is true. This warning does not detect whether a condition is met for descendant selectors. For more information about viewing warnings and errors, see Viewing warnings and errors. |
|
size-report=filename |
Creates a report that summarizes the size of each type of data within an application SWF file. Types of data include media files, fonts, shapes, and ActionScript. For
example:
mxmlc -size-report=myreport.xml MyApp.mxml The file format of the output is XML. While the format has some similarities to the output of the link-report option, the size report cannot be used as input to the load-externs option. This option is useful if you are optimizing your application and want to see how big areas of your application are. For more information about the size report, see Using the size report. |
source-path path-element [...] |
Adds directories or files to the source path. The Flex compiler searches directories in the source path for MXML, AS, or CSS source files that are used in your applications and includes those that are required at compile time. You can use wildcards to include all files and subdirectories of a directory. To link an entire library SWC file and not individual classes or directories, use the library-path option. The source path is also used as the search path for the component compiler's include-classes and include-resource-bundles options. You can also use the += operator to append the new argument to the list of existing source path entries. This option has the following default behavior:
|
static-link-runtime-shared-libraries=true|false |
Determines whether to compile against libraries statically or use RSLs. Set this option to true to ignore the RSLs specified by the runtime-shared-library-path option. Set this option to false to use the RSLs. The default value is true. This option is useful so that you can quickly switch between a statically and dynamically linked application without having to change the runtime-shared-library-path option, which can be verbose, or edit the configuration files. For more information about RSLs, see Runtime Shared Libraries. |
strict=true|false |
Prints undefined property and function calls; also performs compile-time type checking on assignments and options supplied to method calls.\ The default value is true. For more information about viewing warnings and errors, see Viewing warnings and errors. |
|
swf-version=int |
Specifies the SWF file format version of the output SWF file. Features requiring a later version of the SWF file format are not compiled into the application. This is different from the Player version in that it refers to the SWF specification versioning scheme. For Flex 4.6, the default value of swf-version is 14 (and the default Player version is 11.1). This is an advanced option. For more information, see Targeting Flash Player versions. |
target-player=major_version[.minor_version.revision] |
Specifies the version of Flash Player that you want to target with the application. Features requiring a later version of Flash Player are not compiled into the application. The player_version parameter has the following format: major_version.minor_version.revision The major_version is required while minor_version and revision are optional. For Flex 4.0 and 4.1, the minimum value is 10.0.0. If you do not specify the minor_version or revision , then the compiler uses zeros. For Flex 4.5, the default value is 10.2.0. For Flex 4.6, the default value is 11.1. If you do not explicitly set the value of this option, the compiler uses the default from the flex-config.xml file. The value in flex-config.xml is the version of Flash Player that shipped with the SDK. This option is useful if your application's audience has a specific Player and cannot upgrade. You can use this option to "downgrade" your application for that audience. For more information, see Targeting Flash Player versions |
theme filename [...] |
Specifies a list of theme files to use with this application. Theme files can be SWC files with CSS files inside them or CSS files. For information on compiling a SWC theme file, see Styles and themes. |
title text |
Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. |
|
tools-locale=locale |
Specifies the locale to use when reporting compiler errors and warnings. Valid values are the language code (such as "ja" or "en") or the language code plus country code (such as "ja_JP" or "en_US"), depending on your system's configuration. |
|
use-direct-blit=false|true |
Specifies whether hardware acceleration is used to copy graphics to the screen (if such acceleration is available). This option only applies to applications running in the standalone Flash Player. For applications running in a browser, setting use-direct-blit to true is equivalent to setting wmode to "direct" in the HTML wrapper. For AIR applications, use the renderMode application descriptor tag. The default value is false. This is an advanced option. |
|
use-gpu=false|true |
Specifies whether GPU (Graphics Processing Unit) acceleration is used when drawing graphics (if such acceleration is available). This option only applies to applications running in the standalone Flash Player. For applications running in a browser, setting use-gpu to true is equivalent to setting wmode to "gpu" in the HTML wrapper. For AIR applications, use the renderMode application descriptor tag. The default value is false. This is an advanced option. |
use-network=true|false |
Specifies that the current application uses network services. The default value is true. When the use-network property is set to false, the application can access the local filesystem (for example, use the XML.load() method with file: URLs) but not network services. In most circumstances, the value of this property should be true. For more information about the use-network property, see Security. |
use-resource-bundle-metadata=true|false |
Enables resource bundles. Set to true to instruct the compiler to process the contents of the [ResourceBundle] metadata tag. The default value is true. For more information, see Resource Bundles. This is an advanced option. |
verbose-stacktraces=true|false |
Generates source code that includes line numbers. When a run-time error occurs, the stacktrace shows these line numbers. Enabling this option generates larger SWF files. Enabling this option does not generate a debug SWF file. To do that, you must set the debug option to true. The default value is false. |
verify-digests=true|false |
Instructs the application to check the digest of the RSL SWF file against the digest that was compiled into the application at compile time. This is a security measure that lets you load RSLs from remote domains or different sub-domains. It also lets you enforce versioning of your RSLs by forcing an application's digest to match the RSL's digest. If the digests are out of sync, you must recompile your application or load a different RSL SWF file. For more information about RSLs, see Runtime Shared Libraries. |
version |
Returns the version number of the MXML compiler. If you are using a trial or Beta version of Flex, the version option also returns the number of days remaining in the trial period and the expiration date. |
warn-warning_type=true|false |
Enables specified warnings. For more information, see Viewing warnings and errors. |
warnings=true|false |
Enables all warnings. Set to false to disable all warnings. This option overrides the warn- warning_type options. The default value is true. |
The following sections provide examples of using the mxmlc application compiler options on the command line.
The most basic example is one in which the MXML file has no external dependencies (such as components in a SWC file or ActionScript classes) and no special options. In this case, you invoke the mxmlc compiler and point it to your MXML file as the following example shows:
mxmlc c:/myfiles/app.mxml
The default option is the target file to compile into a SWF file, and it is required to 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; for example:
mxmlc -option arg1 arg2 arg3 -- target_file.mxml
The application compilers support adding metadata to SWF files. This metadata can be used by search engines and other utilities to gather information about the SWF file. This metadata represents a subset of the Dublin Core schema.
You can set the following values:
contributor
creator
date
description
language
localized-description
localized-title
publisher
title
For the mxmlc command-line compiler, the default metadata settings in the flex-config.xml file are as follows:
<metadata> <title>Flex 4 Application</title> <description>http://www.adobe.com/products/flex</description> <publisher>unknown</publisher> <creator>unknown</creator> <language>EN</language> </metadata>
You can also set the metadata values as command-line options. The following example sets some of the metadata values:
mxmlc -language+=klingon -title "checkintest!" -localized-description "it r0x0rs" en-us -localized-description "c'est magnifique!" fr-fr -creator "Flexy Frank" -publisher "Franks Beans" flexstore.mxml
In this example, the following values are compiled into the resulting SWF file:
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <rdf:Description rdf:about='' xmlns:dc='http://purl.org/dc/elements/1.1'> <dc:format>application/x-shockwave-flash</dc:format> <dc:title>checkintest!</dc:title> <dc:description> <rdf:Alt> <rdf:li xml:lang='fr-fr'>c'est magnifique!</rdf:li> <rdf:li xml:lang='x-default'>http://www.adobe.com/products/flex</rdf:li> <rdf:li xml:lang='en-us'>it r0x0rs</rdf:li> </rdf:Alt> </dc:description> <dc:publisher>Franks Beans</dc:publisher> <dc:creator>Flexy Frank</dc:creator> <dc:language>EN</dc:language> <dc:language>klingon</dc:language> <dc:date>Mar 16, 2010</dc:date> </rdf:Description> </rdf:RDF>
You use the actionscript-file-encoding option to set the file encoding so that the application compiler correctly interprets ActionScript files. This tag does not affect MXML files because they are XML files that contain an encoding specification in the xml tag.
You use the actionscript-file-encoding option when your ActionScript files do not contain a Byte Order Mark (BOM), and the files use an encoding that is different from the default encoding of your computer. If your ActionScript files contain a BOM, the compiler uses the information in the BOM to determine the file encoding.
For example, if your ActionScript files use Shift_JIS encoding, have no BOM, and your computer uses ISO-8859-1 as the default encoding, you use the actionscript-file-encoding option, as the following example shows:
actionscript-file-encoding=Shift_JIS
The mxmlc compiler includes options to set the application's frame rate, size, and script limits. By setting them when you compile your application, you do not need to edit the HTML wrapper or the application's MXML file. You can override these settings by using properties of the <s:Application> tag or properties of the <object> and <embed> tags in the HTML wrapper.
The following command-line example sets default application properties:
mxmlc -default-size 240 240 -default-frame-rate=24 -default-script-limits 5000 10 -- c:/myfiles/flex/misc/MainApp.mxml
For more information about the Application class, see Application containers.
For more information about the HTML wrapper, see Creating a wrapper.
Often, you use SWC files when compiling MXML files. SWC files can provide themes, components, or other helper files. You typically specify SWC files used by the application by using the library-path option.
The following example compiles the RotationApplication.mxml file into the RotationApplication.swf file:
mxmlc -library-path+=c:/mylibraries/MyButtonSwc.swc c:/myfiles/comptest/testRotation.mxml
In a configuration file, this appears as follows:
<compiler>
<library-path>
<path-element>libs</path-element>
<path-element>libs/player</path-element>
<path-element>libs/player/{targetPlayerMajorVersion}.{targetPlayerMinorVersion}</path-element>
<path-element>locale/{locale}</path-element>
<path-element>c:/mylibraries/MyButtonSwc.swc</path-element>
</library-path>
</compiler>
You can use incremental compilation to decrease the time it takes to compile an application or component library with the application compilers. When incremental compilation is enabled, the compiler inspects changes to the bytecode between revisions and only recompiles the section of bytecode that has changed. These sections of bytecode are also referred to as compilation units.
You enable incremental compilation by setting the incremental option to true, as the following example shows:
mxmlc -incremental=true MyApp.mxml
Incremental compilation means that the compiler inspects your code, determines which parts of the application are affected by your changes, and only recompiles the newer classes and assets. The Flex compilers generate many compilation units that do not change between compilation cycles. It is possible that when you change one part of your application, the change might not have any effect on the bytecode of another.
As part of the incremental compilation process, the compiler generates a cache file that lists the compilation units of your application and information on your application's structure. This file is located in the same directory as the file that you are compiling. For example, if my application is called MyApp.mxml, the cache file is called MyApp.mxml.cache. This file helps the compiler determine which parts of your application must be recompiled. One way to force a complete recompile is to delete the cache file from the directory.
Incremental compilation can help reduce compile time on small applications, but you achieve the biggest gains on larger applications.
For the mxmlc command-line compiler, the default is false.
To include or exclude blocks of code for certain builds, you can use conditional compilation. The mxmlc compiler lets you pass the values of constants to the application at compile time. Commonly, you pass a Boolean that is used to include or exclude a block of code such as debugging or instrumentation code. The following example conditionalizes a block of code by using an inline constant Boolean:
CONFIG::debugging {
// Execute debugging code here.
}
To pass constants, you use the compiler.define compiler option. The constant can be a Boolean, String, or Number, or an expression that can be evaluated in ActionScript at compile time. This constant is then accessible within the application source code as a global constant.
To use the define option, you define a configuration namespace for the constant, a variable name, and a value using the following syntax:
-define=namespace::variable_name,value
The configuration namespace can be anything you want. The following example defines the constant debugging with a value of true in the CONFIG namespace:
-define=CONFIG::debugging,true
You use the += operator rather than the = operator to append definitions on the command line to the definitions set in the configuration file. Use the = operator to replace the definitions in the configuration file with the definitions on the command line.
To set the values of multiple constants on the command-line, use the define option more than once; for example:
mxmlc -define+=CONFIG::debugging,true -define+=CONFIG::release,false MyApp.mxml
To set the value of these constants in the flex-config.xml file, rather than on the command line, you write this as the following example shows:
<compiler> <define append="true"> <name>CONFIG::debugging</name> <value>true</value> </define> <define append="true"> <name>CONFIG::release</name> <value>false</value> </define> </compiler>
If you set the same definition in a configuration file and on the command line, the value on the command line takes precedence.
In a Flex Ant task, you can set constants with a define element, as the following example shows:
<mxmlc ... > <define name="CONFIG::debugging" value="true"/> <define name="CONFIG::release" value="false"/> </mxmlc>
You can use inline constants in ActionScript. Boolean values can be used to conditionalize top-level definitions of functions, classes, and variables, in much the same way you would use an #IFDEF preprocessor command in C or C++. You cannot use constant Boolean values to conditionalize metadata or import statements.
The following example conditionalizes which class definition the compiler uses when compiling the application:
// compilers/MyButton.as
package {
import mx.controls.Button;
CONFIG::debugging
public class MyButton extends Button {
public function MyButton() {
super();
// Set the label text to blue.
setStyle("color", 0x0000FF);
}
}
CONFIG::release
public class MyButton extends Button {
public function MyButton() {
super();
// Set the label text to red.
setStyle("color", 0xFF0000);
}
}
}
You can also pass Strings and Numbers to the application and use them as inline constants, in the same way you might use a #define directive in C or C++. For example, if you pass a value named NAMES::Company, you replace it with a constant in your application by using an ActionScript statement like the following example shows:
private static const companyName:String = NAMES::Company;
You can pass expressions that can be evaluated at compile time as the value of the constant. The following example evaluates to false:
-define+=CONFIG::myConst,"1 > 2"
The following example evaluates to 3:
-define+=CONFIG::myConst,"4 - 1"
Expressions can contain constants and other configuration values; for example:
-define+=CONFIG::bool2,false -define+=CONFIG::and1,"CONFIG::bool2 && false"
In general, you should wrap all constants with double quotes, so that the mxmlc compiler correctly parses them as a single argument.
When passing Strings, you must add extra quotes to ensure that the compiler parses them correctly.
To define Strings on the command-line, you must surround them with double-quotes, and either escape-quote them ("\"Acme Systems\"" or "\\x\\x) or single-quote them ("'Acme Systems'").
The following example shows both methods of including Strings on the command line:
-define+=NAMES::Company,"'Adobe Systems'" -define+=NAMES::Ticker,"\"ADBE\""
To define Strings in configuration files, you must surround them with single or double quotes; for example:
<define> <name>NAMES::Company</name> <value>'Adobe Systems'</value> </define> <define> <name>NAMES::Ticker</name> <value>"ADBE"</value> </define>
To pass empty Strings on the command line, use single quotes surrounded by double quotes, as the following example shows:
-define+=CONFIG::debugging,"''"
To pass empty Strings in configuration files, use double quotes ("") or single quotes (' ').
You use the component compiler to generate a SWC file from component source files and other asset files such as images and style sheets.
To use the component compiler with Flex SDK, you use the compc command-line utility.
The component compiler options let you define settings such as the classes, resources, and namespaces to include in the resulting SWC file.
The component compiler can take most of the application compiler options, and the options described in this section. For a description of the application compiler options, see About the application compiler options. Application compiler options that do not apply to the component compiler include the metadata options (such as contributor, title, and date), default application options (such as default-frame-rate), locale, debug-password, and theme.
The component compiler has compiler options that the application compilers do not have. The following table describes the component compiler options that are not used by the application compilers:
|
Option |
Description |
|---|---|
compute-digest=true|false |
Writes a digest to the catalog.xml of a library. Use this when the library will be used as a cross-domain RSL or when you want to enforce the versioning of RSLs. The default value is true. For more information about RSLs, see Runtime Shared Libraries. |
directory=false|true |
Outputs the SWC file in an open directory format rather than a SWC file. You use this option with the output option to specify a destination directory, as the following example shows: compc -directory=true -output=destination_directory You typically use this option when you create RSLs because you must extract the library.swf file from the SWC file before deployment. For more information, see Runtime Shared Libraries. The default value is false. |
include-classes class [...] |
Specifies classes to include in the SWC file. You provide the class name (for example, MyClass) rather than the file name (for example, MyClass.as) to the file for this option. As a result, all classes specified with this option must be in the compiler's source path. You specify this by using the source-path compiler option. You can use packaged and unpackaged classes. To use components in namespaces, use the include-namespaces option. If the components are in packages, ensure that you use dot-notation rather than slashes to separate package levels. This is the default option for the component compiler. |
include-file name path [...] |
Adds the file to the SWC file. This option does not embed files inside the library.swf file. This is useful for adding graphics files, where you want to add non-compiled files that can be referenced in a style sheet or embedded as assets in MXML files. If you add a stylesheet that references compiled resources such as programmatic skins, use the include-stylesheet option. If you use the [Embed] syntax to add a resource to your application, you are not required to use this option to also link it into the SWC file. For more information, see Adding nonsource classes. |
include-lookup-only=false|true |
If true, only manifest entries with lookupOnly=true are included in the SWC catalog. The default value is false. This is an advanced option. |
include-namespaces uri [...] |
Specifies namespace-style components in the SWC file. You specify a list of URIs to include in the SWC file. The uri argument must already be defined with the namespace option. To use components in packages, use the include-classes option. |
include-sources path-element |
Specifies classes or directories to add to the SWC file. When specifying classes, you specify the path to the class file (for example, MyClass.as) rather than the class name itself (for example, MyClass). This lets you add classes to the SWC file that are not in the source path. In general, though, use the include-classes option, which lets you add classes that are in the source path. If you specify a directory, this option includes all files with an MXML or AS extension, and ignores all other files. If you use this option to include MXML components that are in a non-default package, you must include the source folder in the source path. |
include-stylesheet name path [...] |
Specifies stylesheets to add to the SWC file. This option compiles classes that are referenced by the stylesheet before including the stylesheet in the SWC file. You do not need to use this option for all stylesheets; only stylesheets that reference assets that need to be compiled such as programmatic skins or other class files. If your stylesheet does not reference compiled assets, you can use the include-file option. This option does not compile the stylesheet into a SWF file before including it in the SWC file. You compile a CSS file into a SWF file when you want to load it at run time. |
On the command line, you cannot point the compc utility to a single directory and have it compile all components and source files in that directory. You must specify each source file to compile.
If you have a large set of components in a namespace to include in a SWC file, you can use a manifest file to avoid having to type an unwieldy compc command. For information on creating manifest files, see About manifest files.
The following sections describe common scenarios where you could use the compc command-line compiler.
In many cases, you have one or more components that you use in your 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 applications. 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/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/flex/WEB-INF/flex/user_classes/RotationClasses.swc </output> </compiler> <include-classes> <class>rotationClasses.Rotation</class> <class>rotationClasses.RotationInstance</class> </include-classes>
To use components that are not in a package in an 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"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmln:local="rotationclasses.*"> ... <local:Rotation id="Rotate75" angleFrom="0" angleTo="75" duration="100"/> ... </s:Application>
To use the generic namespace of "*" rather than a namespace that includes a component's 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/flex/WEB-INF/flex/user_classes/RotationComps.swc -include-classes Rotation RotationInstance
Then, you can specify the namespace in your application as:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/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:
<compiler> <source-path> <path-element>.</path-element> <path-element>c:/flexdeploy/comps/rotationClasses</path-element> </source-path> <output>c:/jrun4/servers/flex/WEB-INF/flex/user_classes/RotationComps.swc</output> </compiler> <include-classes> <class>Rotation</class> <class>RotationInstance</class> <include-classes>
This example assumes that the components are not in a named package. For information about compiling packaged components, see Compiling components in packages.
Some components are created inside packages or directory structures so that they can be logically grouped and separated from application code. As a result, packaged components can have a namespace declaration that includes the package name or a unique namespace identifier that references their location within a package.
You compile packaged components similarly to how you compile components that are not in packages. The only difference is that you must use the package name in the namespace declaration, regardless of how you compiled the SWC file, and that package name uses dot-notation instead of slashes. You must be sure to specify the location of the classes in the source-path.
In the following command-line example, the MyButton component is in the mypackage package:
compc -source-path . c:/flexdeploy/comps/mypackage/ -output c:/jrun4/servers/flex/WEB-INF/flex/user_classes/MyButtonComp.swc -include-classes mypackage.MyButton
These options appear in a configuration file, as the following example shows:
<compiler> <source-path> <path-element>.</path-element> <path-element>c:/flexdeploy/comps/mypackage/</path-element> </source-path> <output> c:/jrun4/servers/flex/WEB-INF/flex/user_classes/MyButtonComp.swc </output> </compiler> <include-classes> <class>mypackage.MyButton</class> <include-classes>
To access the MyButton class in your application, you must declare a namespace that includes its package; for example:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:mine="mypackage.*">
You can use the compc compiler to compile components from multiple packages into a single SWC file. In the following command-line example, the MyButton control is in the mypackage package, and the CustomComboBox control is in the acme package:
compc -source-path . -output c:/jrun4/servers/flex/WEB-INF/flex/user_classes/CustomComps.swc -include-classes mypackage.MyButton acme.CustomComboBox
You then define each package as a separate namespace in your MXML application:
<?xml version="1.0"?> <s:Application <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:mine="mypackage.*" xmlns:acme="acme.*"> <mine:MyButton/> <acme:CustomComboBox/> </s:Application>
When you have many components in one or more packages that you want to add to a SWC file and want to reference from an MXML file through a custom namespace, you can list them in a manifest file, then reference that manifest file on the command line. Also, you can specify a namespace for that component or define multiple manifest files and, therefore, specify multiple namespaces to compile into a single SWC file.
When you use manifest files to define the components in your SWC file, you specify the namespace that the components use in your applications. You can compile all the components from one or more packages into a single SWC file. If you have more than one package, you can set it up so that all packages use a single namespace or so that each package has an individual namespace.
In the manifest file, you define which components are in a namespace. The following sample manifest file defines two components to be included in the namespace:
<?xml version="1.0"?> <!-- SimpleManifest.xml --> <componentPackage> <component id="MyButton" class="MyButton"/> <component id="MyOtherButton" class="MyOtherButton"/> </componentPackage>
The manifest file can contain references to any number of components in a namespace. The class option is the full class name (including package) of the class. The id property is optional, but you can use it to define the MXML tag interface that you use in your applications. If the compiler cannot find one or more files listed in the manifest, it throws an error. For more information on using manifest files, see About manifest files.
On the command line, you define the namespace with the namespace option; for example:
-namespace http://mynamespace SimpleManifest.xml
Next, you target the defined namespace for inclusion in the SWC file with the include-namespaces option; for example:
-include-namespaces http://mynamespace
The namespace option matches a namespace (such as "http://ns.adobe.com/mxml/2009") with a manifest file. The include-namespaces option instructs compc to include all the components listed in that namespace's manifest file in the SWC file.
After you define the manifest file, you can compile the SWC file. The following command-line example compiles the components into the "http://mynamespace" namespace:
compc -source-path . -output c:/jrun4/servers/flex/WEB-INF/flex/user_classes/MyButtons.swc -namespace http://mynamespace SimpleManifest.xml -include-namespaces http://mynamespace
In a configuration file, these options appear as the following example shows:
<compiler> <source-path> <path-element>.</path-element> </source-path> <output>c:/jrun4/servers/flex/WEB-INF/flex/user_classes/ MyButtons.swc</output> <namespaces> <namespace> <uri>http://mynamespace</uri> <manifest>SimpleManifest.xml</manifest> </namespace> </namespaces> </compiler> <include-namespaces> <uri>http://mynamespace</uri> <include-namespaces>
In your application, you can access the components by defining the new namespace in the <s:Application> tag, as the following example shows:
<?xml version="1.0"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:a="http://mynamespace"> <a:MyButton/> <a:MyOtherButton/> </s:Application>
You can use the compc compiler to compile components that use multiple namespaces into a SWC file. Each namespace must have its own manifest file.
The following command-line example compiles components defined in the AcmeManifest.xml and SimpleManifest.xml manifest files:
compc -source-path . -output c:/jrun4/servers/flex/WEB-INF/flex/user_classes/MyButtons.swc -namespace http://acme2009 AcmeManifest.xml -namespace http://mynamespace SimpleManifest.xml -include-namespaces http://acme2009 http://mynamespace
In this case, all components in both the http://mynamespace and http://acme2009 namespaces are targeted and included in the output SWC file.
In a configuration file, these options appear as the following example shows:
<compiler> <source-path> <path-element>.</path-element> </source-path> <output>c:/jrun4/servers/flex/flex/WEB-INF/flex/user_classes/ MyButtons.swc</output> <namespaces> <namespace> <uri>http://acme2009</uri> <manifest>AcmeManifest.xml</manifest> </namespace> <namespace> <uri>http://mynamespace</uri> <manifest>SimpleManifest.xml</manifest> </namespace> </namespaces> </compiler> <include-namespaces> <uri>http://acme2009</uri> <uri>http://mynamespace</uri> <include-namespaces>
In your MXML application, you define both namespaces separately:
<?xml version="1.0"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:simple="http://mynamespace" xmlns:acme="http://acme2009"> <simple:SimpleComponent/> <acme:AcmeComponent/> </s:Application>
You are not required to include all namespaces that you define as target namespaces. You can define multiple namespaces, but use only one target namespace. You might do this if some components use other components that are not directly exposed as MXML tags. You cannot then directly access the components in the unused namespace, however.
The following command line example defines two namespaces, http://acme2009 and http://mynamespace, but only includes one as a namespace target:
compc -source-path . -output c:/jrun4/servers/flex/flex/WEB-INF/flex/user_classes/MyButtons.swc -namespace http://acme2009 AcmeManifest.xml -namespace http://mynamespace SimpleManifest.xml -include-namespaces http://mynamespace
You can add any classes that you want to use in your applications to a SWC file. These classes do not have to be components, but are often files that components use. They are classes that might be used at run time and, therefore, are not checked by the compiler. For example, your components might use a library of classes that perform mathematical functions, or use a custom logging utility. This documentation refers to these classes as utility classes. Utility classes are not exposed as MXML tags.
To add utility classes to a SWC file, you use the include-sources option. This option lets you specify a path to a class file rather than the class name, or specify an entire directory of classes.
The following command-line example adds the FV_calc.as and FV_format.as utility classes to the SWC file:
compc -source-path . -output c:/jrun4/servers/flex/WEB-INF/flex/user_classes/MySwc.swc -include-sources FV_classes/FV_format.as FV_classes/FV_calc.as -include-classes asbutton.MyButton
In a configuration file, these options appear as the following example shows:
<compiler> <source-path> <path-element>.</path-element> </source-path> <output>c:/jrun4/servers/flex/flex/WEB-INF/flex/user_classes/ MySwc.swc</output> </compiler> <include-classes> <class>asbutton.MyButton</class> </include-classes> <include-sources> <path-element>FV_classes/FV_format.as</path-element> <path-element>FV_classes/FV_calc.as</path-element> <include-sources>
When specifying files with the include-sources option, you must give the full filename (for example, FV_calc.as instead of FV_calc) because the file is not a component. If you use this option to include MXML components that are in a non-default package, you must include the source folder in the source path.
You can also provide a directory name to the include-sources option. In this case, the compiler includes all files with an MXML or AS extension, and ignores all other files.
Classes that you add with the include-sources option can be accessed from the generic namespace in your applications. To use them, you need to add the following code in your application tag:
xmlns:local="*"
You can then use them as tags; for example:
<local:FV_calc id="calc" rate=".0125" nper="12" pmt="100" pv="0" type="1"/>
You often include noncompiled (or nonsource) files with your applications. A nonsource file is a class or resource (such as a style sheet or graphic) that is not compiled but is included in the SWC file for other classes to use. For example, a font file that you embed or a set of images that you use as graphical skins in a component's style sheet should not be compiled but should be included in the SWC file. These are classes that you typically do not use the [Embed] syntax to link in to your application.
Use the include-file option to define nonsource files in a SWC file.
The syntax for the include-file option is as follows:
-include-file name path
The name argument is the name used to reference the embedded file in your applications. The path argument is the current path to the file in the file system.
When you use the include-file option, you specify both a name and a filepath, as the following example shows:
compc -include-file logo.gif c:/images/logo/logo1.gif ...
In a configuration file, these options appear as the following example shows:
<compiler> <output>c:/jrun4/servers/flex/flex/WEB-INF/flex/user_classes/Combo.swc</output> </compiler> <include-file> <name>logo.gif</name> <path>c:/images/logo/logo1.gif</path> </include-file> <include-classes> <class>asbutton.MyButton</class> <include-classes>
Each name that you assign to a resource must be unique because the name becomes a global variable.
You cannot specify a list of files with the include-file option. So, you must add a separate include-file option for each file that you include, as the following command-line example shows:
compc -include-file file1.jpg ../images/file1.jpg -include-file file2.jpg ../images/file2.jpg -- -output MyFile.swc
If you want to add many resources to the SWC file, consider using a configuration file rather than listing all the resources on the command line. For an example of a configuration file that includes multiple resources in a SWC file, see Styles and themes.
In general, specify a file extension for files that you include with the include-file option. In some cases, omitting the file extension can lead to a loss of functionality. For example, if you include a CSS file in a theme SWC file, you must set the name to be *.css. When Flex examines the SWC file, it applies all CSS files in that SWC file to the application. CSS files without the CSS extension are ignored.
You can use the include-file and include-classes options to add skin files and style sheets to a SWC file. The SWC file can then be used as a theme. For more information about using themes in applications, see Styles and themes.
You can use the compiler options to specify what level of warnings and errors to view. Also, you can set levels of logging with the compiler options.
There are several options that let you customize the level of warnings and errors that are displayed by the Flex compilers, including the following:
show-actionscript-warnings
show-binding-warnings
show-invalid-css-property-warnings
show-shadowed-device-font-warnings
show-unused-type-selector-warnings
strict
warnings
To disable all warnings, set the warnings option to false.
The show-actionscript-warnings option displays compiler warnings for the following situations:
Situations that are probably not what the developer intended, but are still legal; for example:
if (a = 10) // Did you really want '==' instead of '='? if (b == NaN) // Any comparison with NaN is always false. var b; // Missing type declaration.
Usage of deprecated or removed ActionScript 2.0 APIs.
Situations where APIs behave differently in ActionScript 2.0 than in ActionScript 3.0.
You can customize the types of warnings displayed by using options that begin with warn (for example, warn-constructor-return-values and warn-bad-type-cast). A complete list of warnings are available in the advanced command-line help or in the flex-config.xml file.
The strict option enforces typing and reports run-time verifier errors at compile time. This option assumes that definitions are not dynamically redefined at run time, so these checks can be made at compile time. It displays errors for conditions such as undefined references, const and private violations, argument mismatches, and type checking.
The show-binding-warnings option displays warnings when Flash Player cannot detect changes to bound properties.
In some cases, Flex functionality has been deprecated. Deprecated features and properties have the following characteristics:
Generate compiler warnings.
Continue to work in Flex 4.x.
Will be removed from the product in a future major release.
The command-line compilers report deprecation warnings by default. You can suppress deprecation warnings by setting the show-deprecation-warnings option to false.
In some cases, deprecated functionality does not work as expected unless you instruct the compiler to use an earlier version of the compiler with the compatibility-version compiler argument. For example, to use functionality that was deprecated since Flex 3, you could use the following command-line compiler argument:
-compatibility-version=3.0.0
Possible values for this compiler argument are defined as constants in the FlexVersion class. For more information on using this compiler argument, see Backward compatibility.
You can use the [Deprecated] metadata tag to deprecate your own classes and class elements. For more information, see Deprecated metadata tag.
A SWC file is an archive file, sometimes also referred to as a class library, for components and other assets. SWC files contain a SWF file and a catalog.xml file, in addition to properties files and other uncompiled assets such as CSS files. The SWF file implements the compiled component or group of components and includes embedded resources as symbols. An application extracts the SWF file from a SWC file. It uses the SWF file's contents when the application refers to resources in that SWC file. The catalog.xml file lists of the contents of the component package and its individual components.
In most cases, the symbols defined in the SWF file that are referenced by the application are embedded in the application at compile-time. This is known as static linking. The application compiler only includes those classes that are used by your application, and dependent classes, in the final SWF file.
You can also dynamically link the contents of SWC files. Dynamic linking is when the entire SWF file is loaded at run time. To achieve dynamic linking of the SWF file, you must use the SWC file as a Runtime Shared Library, or RSL. For more information, see Runtime Shared Libraries.
SWC files make it easy to exchange components and other assets among Flex developers. You need only exchange a single file, rather than the MXML or ActionScript files and images and other resource files. The SWF file in a SWC file is compiled, which means that the code is loaded efficiently and it is hidden from casual view. Also, compiling a component as a SWC file can make namespace allocation an easier process.
You can package and expand SWC files with tools that support the PKZip archive format, such as WinZip or jar. However, do not manually change the contents of a SWC file, and do not try to run the SWF file that is in a SWC file in Flash Player.
You typically create SWC files by using compc, the command-line component compiler.
You can also save SWC files as open directories rather than archived files. This gives you easier access to the contents of the SWC file. You create an open directory SWC by setting the directory option to true. This is typically only used when you create a custom RSL because RSLs require that you deploy the SWF file with your application.
The properties files inside SWC files are uncompiled text files in UTF-8 format. They are used as resource bundles for localization of applications. Within the SWC file, they are stored in the /locale/locale_string directory, where locale_string is something like en_US or fr_FR. For more information, see Localization.
After you generate a SWC file, you can use it in your applications.
You can also copy SWC files to a directory specified by the library-path compiler option. You must store SWC files at the top level of the user_classes directory or the directory specified by the library-path. You cannot store SWC files in subdirectories.
To use a SWC file when compiling components or applications from the command line, you specify the location of the SWC file with the library-path compiler option.
If a component in a SWC file does not have a namespace, you can add a generic namespace identifier in your <s:Application> tag to use the component, as the following example shows:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:a="*">
If the component has a package name as part of its namespace, you must do one of the following:
Add the package name to the namespace declaration in the <s:Application> tag; for example:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:but="mycomponents.*">
Create a manifest file and recompile the SWC file. You pass the manifest file to the compc compiler by using the namespace option. In the <s:Application> tag, you specify only the unique namespace URI that you used with compc. For more information on specifying a namespace for the component, see Compiling components using namespaces.
Manifest files map a component namespace to class names. They define the package names that the components used before being compiled into a SWC file. They are not required when compiling SWC files, but they can help keep your source files organized.
Manifest files use the following syntax:
<?xml version="1.0"?> <componentPackage> <component id="component_name" class="component_class"/> [...] </componentPackage>
For example:
<?xml version="1.0"?> <componentPackage> <component id="MyButton" class="package1.MyButton"/> <component id="MyOtherButton" class="package2.MyOtherButton"/> </componentPackage>
In a manifest file, the id property of each <component> tag must be unique. It is the name you use for the tag in your applications. For example, you define the id as MyButton in the manifest file:
<component id="MyButton" class="asbutton.MyButton"/>
In your application, you use MyButton as the tag name:
<local:MyButton label="Click Me"/>
The id property in the manifest file entry is optional. If you omit it, you can use the class name as the tag. This is useful if you have two classes with the same name in different packages. In this case, you use the manifest to define the tags, as the following example shows:
<?xml version="1.0"?> <componentPackage> <component id="BoringButton" class="boring.MyButton"/> <component id="GreatButton" class="great.MyButton"/> </componentPackage>
Some SWC files consist of multiple components from different packages, so compc includes a manifest file with your SWC file in those cases to prevent compiler errors.
When compiling the SWC file, you specify the manifest file by using the namespace and the include-namespaces options. You define the namespace and its contents with the namespace option:
-namespace http://mynamespace mymanifest.xml
Then you identify that namespace's contents for inclusion in the SWC file:
-include-namespaces http://mynamespace
The fcsh (Flex Compiler Shell) utility provides a shell environment that you use to compile applications, modules, and component libraries. It works very similarly to the mxmlc and compc command line compilers, but it compiles faster than the mxmlc and compc command-line compilers. One reason is that by keeping everything in memory, fcsh eliminates the overhead of launching the JVM and loading the compiler classes. Another reason is that compilation results (for example, type information) can be kept in memory for subsequent compilations.
This utility is intended to improve the experience of users of the command-line compilers.
For simple applications, fcsh might not be necessary. But for more complex applications that you compile frequently, you should experience a significant performance improvement over using the mxmlc and compc command-line compilers.
When you first compile an application with fcsh, you will not typically notice any difference in speed between the fcsh and the command-line compilers. This is because fcsh must load the application model and custom libraries into memory, just as the command-line compilers would. After that, however, each subsequent compilation uses the libraries in memory to compile. This reduces the amount of disk access that the compilers need to perform and should result in shorter compile times.
The fcsh tool is in the bin directory. For Unix and Mac OS, it is a shell script called fcsh. For Windows, it is fcsh.exe. You invoke it only from the command line. The Java settings are managed by the jvm.config file in the bin directory.
You invoke fcsh from the command line. You can launch the utility either as an executable (Windows) or shell command (Unix/Linux/Mac).
Open a command prompt.
Navigate to the {SDK_root}/bin directory.
Enter fcsh at the command line. Your commands will now be executed within the fcsh environment. You will know this if your command prompt becomes (fcsh).
Typically, you compile a simple application when you first launch fcsh; for example:
(fcsh) mxmlc c:/myfiles/MyApp.mxml
The fcsh utility returns a target id:
fcsh: Assigned 1 as the compile target id.
You can then refer to the target ids when using subsequent commands inside the fcsh utility. For example, to compile the previous application with incremental compilation:
(fcsh) compile 1
You can enter help in the fcsh shell to see a list of available options; for example:
(fcsh) help
You can enter quit in the fcsh shell to exit fcsh and return to the command prompt; for example:
(fcsh) quit
The following example shows that fcsh dramatically reduces compilation time when compiling the same application multiple times. The first compilation takes 8885 milliseconds. The second takes only 5140 milliseconds:
(fcsh) mxmlc -benchmark=true flexstore.mxml Total time: 8885ms Peak memory usage: 84 MB (Heap: 58, Non-Heap: 26) (fcsh) mxmlc -benchmark=true flexstore.mxml Total time: 5140ms Peak memory usage: 84 MB (Heap: 57, Non-Heap: 27)
In addition, subsequent full compilations of the same application are much faster, as the following example shows:
> touch flexstore.mxml (fcsh) compile 1 Files changed: 1 Files affected: 0 Total time: 933ms Peak memory usage: 88 MB (Heap: 62, Non-Heap: 26) flexstore.swf (522456 bytes) Total time: 1102ms Peak memory usage: 77 MB (Heap: 51, Non-Heap: 26) (fcsh)
The following table describes the available fcsh commands:
|
Option |
Description |
|---|---|
clear [id] |
Removes the target id(s) from memory but saves the target's *.cache file. If you enter this command without specifying an id argument, fcsh clears all target ids. For information about cache files, see About incremental compilation. |
compile id |
Uses incremental compilation (without linking) to compile the specified id. This command uses the same arguments used in previous compilations. If you try to compile a target that has not changed, fcsh skips that target. |
compc arg1 [...] |
Compiles SWC files from the specified sources. This command returns a target id that you can then pass to other fcsh options. The target ids are incremented by 1 for each new compilation. If you quit fcsh and then relaunch it, all targets are cleared and the ids start at 1 again. This command takes all the same arguments as the compc command-line compiler. For information about using compc, see Using compc, the component compiler. |
|
help |
Lists commands. Commands not listed but also supported include cp, mv, rm, and touch. |
info [id] |
Displays compiler target information such as the source files and cache file name. If you do not specify a target id, fcsh prints information for all targets in reverse id order. |
mxmlc arg1 [...] |
Compiles and optimizes the target application or module using the mxmlc command-line compiler. This command returns a target id that you can then pass to other fcsh options. The target ids are incremented by 1 for each new compilation. If you quit fcsh and then relaunch it, all targets are cleared and the ids start at 1 again. This command takes all the same arguments as the mxmlc command-line compiler. For information about using mxmlc, see Using mxmlc, the application compiler. |
quit |
Exits the fcsh utility. All data stored in memory is destroyed. When you relaunch fcsh, you cannot access targets that you created in a previous session. |
cp
mv
rm
touch
Navigation
Adobe, Adobe Flash, Adobe Flash Player, and Adobe LiveCycle Data Services ES are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries and are used by permission from Adobe. No other license to the Adobe trademarks are granted.