Specifications
196
CHAPTER 10
You can create your own RSLs from custom libraries. You do this by using either the Adobe® Flex® Builder’s™ Build
Project option for your Flex Library Project or the compc command-line compiler.
About linking
Understanding linking can help you understand how RSLs work and how you can most benefit from their use.
The Flex compilers support static linking and dynamic linking. Static linking is the most common type of linking
when compiling a Flex application. However, dynamic linking lets you take advantage of RSLs to achieve a
reduction of the final SWF file size and, therefore, a reduction in the application download time.
When you use static linking, the compiler includes all referenced classes and their dependencies in the application
SWF file. The end result is a larger file that takes longer to download than a dynamically-linked application, but
loads and runs quickly because all the code is in the SWF file.
To statically link a library’s definitions into your application, you use the
library-path and include-
libraries
compiler options to specify locations of SWC files.
When you use the
library-path option, the compiler includes only those classes required at compile time in the
SWF file, so the entire contents of a library are not necessarily compiled into the SWF file. The
include-
libraries
option includes the entire contents of the library, regardless of which classes are required. You can also
use the
source-path and includes options to embed individual classes in your SWF file.
In Flex Builder, you use the Project > Properties > Flex Builder Path > Library Path dialog to add libraries to your
project. To statically link a library at compile time, you select Merged Into Code for the library’s Link Type. This
includes only those classes that are used in the application, so it is the equivalent of the
library-path compiler
option.
If you statically link any part of a library into your application, you cannot use that library as an RSL.
Dynamic linking is when some classes used by an application are left in an external file that is loaded at run time.
The result is a smaller SWF file size for the main application, but the application relies on external files that are
loaded at run time. Dynamic linking is used by modules, runtime stylesheets, and RSLs.
When you want to use a dynamically-linked library, you instruct the compiler to exclude that library’s contents
from the application SWF file when you compile the application. You must provide link-checking at compile time
even though the classes are not going to be included in the final SWF file. At run time, the application loads the
entire library into the application SWF file, which can result in slower startup times and greater memory usage.
You can use the
runtime-shared-library-path and runtime-shared-libraries options to specify the
location of dynamically-linked libraries.










