
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
334
|
Chapter 14: Distributing Class Libraries
For this command to work, Flash MX 2004 must not be running. After the com-
mand is issued, the compiled petsupplies.swf movie appears in the directory c:\data\
projects\pet.
Loading Classes at Runtime
When working with multiple .swf files that make use of the same class, compiling the
class into every .swf is a waste of space. When file size is a concern, you can prevent
such redundancies by externalizing the class library into a separate .swf file and load-
ing it at runtime. Once the library has loaded the first time, it is cached on the end
user’s machine and can be reused by other .swf files without being downloaded again.
A class library loaded at runtime is known as a dynamic class library.
To create a dynamic class library, we compile the desired classes into a .swf file. We
then use loadMovie( ) to load that .swf into any movie that needs the classes. How-
ever, in order for this technique to work, we must be sure that the classes in the class
library are excluded from the movies that load them. To prevent runtime-loaded
classes from being compiled into the movies that load them, we use an exclusion
XML file. The exclusion XML file lets a .fla file access classes locally for the sake of
compile-time type checking but prevents those ...