Macromedia flex 2 Manual
68
Compiling Components
Distributing components as RSLs
One way to reduce the size of your application’s SWF file is by externalizing shared assets into
stand-alone files that can be separately downloaded and cached on the client. These shared
assets are loaded by any number of applications at run time, but must be transferred to the
client only once. These shared files are known as Runtime Shared Libraries (RSLs).
stand-alone files that can be separately downloaded and cached on the client. These shared
assets are loaded by any number of applications at run time, but must be transferred to the
client only once. These shared files are known as Runtime Shared Libraries (RSLs).
If you have multiple applications but those applications share a core set of components or
classes, your users download those assets only once as an RSL. The applications that share the
assets in the RSL use the same cached RSL as the source for the libraries as long as they are in
the same domain. By using an RSL, you can reduce the resulting file size for your
applications. The benefits increase as the number of applications that use the RSL increases. If
you only have one application, putting components into RSLs does not reduce the aggregate
download size, and may increase it.
classes, your users download those assets only once as an RSL. The applications that share the
assets in the RSL use the same cached RSL as the source for the libraries as long as they are in
the same domain. By using an RSL, you can reduce the resulting file size for your
applications. The benefits increase as the number of applications that use the RSL increases. If
you only have one application, putting components into RSLs does not reduce the aggregate
download size, and may increase it.
When you compile your application, you specify the directory location of an RSL file by using
one of the following methods:
one of the following methods:
Flex Builder
Open the Project Properties dialog box, and then select Flex Build Path to set
the library directories that contain the SWC files.
Command-line compiler
Set the
external-library-path
option to the mxmlc compiler
to specify the location of the RSL file at compile time. Set the
runtime-shared-libraries
option to the mxmlc compiler to specify the relative location of the RSL file when the
application is deployed.
application is deployed.
For more information, including information on how to create an RSL file, see Chapter 10, “Using Runtime Shared Libraries,” in Building and Deploying Flex 2 Applications.
Example: Compiling a custom formatter component
This section contains an example that uses a custom formatter component that is defined as
an ActionScript file. The name of the formatter is MySimpleFormatter, and it is defined in the
file MySimpleFormatter.as. For more information on creating customer formatter
components, see
an ActionScript file. The name of the formatter is MySimpleFormatter, and it is defined in the
file MySimpleFormatter.as. For more information on creating customer formatter
components, see
The process for compiling an MXML file is the same as for an ActionScript file. For an
example of deploying an MXML file, see
example of deploying an MXML file, see
.