Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.


Flash CS4 External Libraries with Symbol Classes

Posted July 21, 2009 by senocular

If you haven't noticed, Flash CS4 Professional now supports the use of an External Library Path to reference class definitions in SWC files to be used, but not compiled, in your resulting SWF. What this means is that you can make "child" SWFs that are intended to be loaded into another "parent" SWF and have all, or most, of the class definitions limited to the parent SWF. This reduces the redundancy of those classes in each of the children saving you on bandwidth. Right now, however, Flash has a small problem when using such classes with library symbols.
If, for example, you try to associate the class of a symbol in the library with a class that exists in an external library SWC, the class will not be recognized causing Flash to automatically generate a custom class of the name specified for that definition. This also occurs with non-external SWC library definitions. With those definitions, the workaround is to set the class as the base class, including a custom, auto-generated class for the main class of that symbol. Sadly this does not work with external libraries - not exactly, at least.

In truth, it does work. External library definitions can be used and recognized as base classes - when compiled. The problem is that the Properties Dialog GUI doesn't allow you to confirm the dialog when you try to use an external definition for the base class, complaining that the class doesn't exist. So for this to work, what you need to do is have the class(es) accessible for when those base classes are being set. In other words:

  1. In the publish settings, specify your external library SWC as a non-external library
  2. Set up symbol associations, setting symbol base classes to the necessary classes available in the SWC
  3. Go back to the publish settings and change the SWC from a non-external library to an external library

By using the SWC as a non-external library temporarily, we get around the GUI's complaints that the base class definition can't be found. When finally compiled, though, the definitions will be back as an external library so that the compiler will be aware of those definitions but will not compile them into the final SWF.