Tony Polinelli
Tarwin Stroh-Spijer

contact [at]

6/25 Easey Street
Collingwood, 3066
Vic, Australia

+61 3 8060 5321

Workaround for AS2′s exclude.xml in AS3

When creating external libraries, you often want the contents to have have a base class from your application. When you do this however, the whole application will often be compiled into your library due to its imports. This means two issues arise:

1/ You have a whole lot of duplicate code comipiled into your libraries, which will not be used (as when the lib is loaded any classes of the same name will not override the existing ones)

2/ It takes a bloody long time to compile your library (when it should be fast)

The best way we have found to get around this is to create a empty classes, which work similar to intrinsics (but are totally empty -no functions, vars or imports), to replicate the base class.

If in your application you have a class for example: 'sprites.enemies.Monster'
In your lib you will want to create an asset with identifier: 'Lib_Monster' and base class 'sprites.enemies.Monster'. Normally this would compile in the full Monster class and all its dependencies.

If you set up your lib.swf in a seperate folder to the application then create another class, lets call it a placeholder class, 'sprites.enemies.Monster' and just have it empty eg:

  1. package sprites.enemies
  2. {
  3.     import flash.display.MovieClip;
  4.     public class Monster extends MovieClip{
  5.         public function Monster{}
  6.     }
  7. }

When it compiles the Lib_Monster will have the correct baseclass, but it will not include any code.

The trick is that, when the lib is loaded into your application the class 'sprites.enemies.Monster' will conflict. The application should have its own compiled version (the one with functionality) and when the lib loads in, it will ditch its version (the empty one) and adopt the existing (correct) version.

It only takes a few seconds to create the placeholder class for the library reference.

If you want to have the lib.fla in the same folder as the application, then you can even set up a different classpath for the lib. To do this go tot the publish settings and add a new classpath (eg. ./intrinsics). This path will be checked first for your placeholder class.

If for some crazzzy reason your classes arn't used (and so compiled) in the application (if you reference them with weak references), you will need to force them to be compiled in like this.

Tags: , ,


  1. Santiago Puente

    I've been looking for an answer to this problem! I almost start using String identifiers but it was still very limiting and slow!
    Our app (game) takes 50 seconds to compile almost 400 clases, even if the sounds and bitmaps come frome separete swf files.
    Love you man!!!

  2. This is another solution.

    1) First create your main.fla document and write code and base classes.

    2) Then go to Publish Settings and select Export SWC option in the Flash tab.

    3) Compile your movie. This will also generate an swc file.

    This is an only one time process.

    The for each Module:

    1) Now create your module.fla document in a separate folder to avoid including base classes.

    2) Go to the Publish Settings -> Flash tab -> Script Settings... -> Library Path.

    3) Here you must add another library by pressing the plus (+) sign and then the "browse to SWC file" button (the one with an f in the icon).

    4) Browse to the SWC file generated by the main.fla.

    5) Once the SWC file is added, click the plus sign (+) beside it to open more options.

    6) Double click the first option "Link Type..."

    7) In the popup that opens select External as "Link Type". External means the code will not be included in the SWF file and will not be loaded as an RSL either. You have to add this classes manually either by loading an SWF file or by loading the Module into another SWF file with this classes.

    8) Close everything with the OK button and that's it. This is a one time process for each Module.

    Then, whenever you change the base classes in your main flash you'll have to compile the movie again, and then recompile the modules as well.


Leave a Reply

Our Friends:

Powered by haXe / poko cms | Copyright 2008-09 TouchMyPixel