Force compile-time linking of all classes in a SWC

Posted by aaaidan on Stack Overflow See other posts from Stack Overflow or by aaaidan
Published on 2010-06-08T03:06:27Z Indexed on 2010/06/08 3:12 UTC
Read the original article Hit count: 365

Filed under:
|
|
|

Using Flash CS4, I am making a game that has a dozen or so sounds and a couple of music tracks. To cut down on publish/compile time, I have moved the sounds and music into an (external) SWC, which is located in a "Library Path" for the project. This works, but with a caveat...

Until before I externalised the assets, I had been dynamically instantiating the Sound objects of the embedded sound by getting their classes with getDefinitionByName.

// something like...
var soundSubClass:Class = Class(getDefinitionByName(soundClassName));
var mySound:Sound = new soundSubClass();

But now that they're located in an external SWC, I need to have "concrete" references to the classes in order to load them like this, otherwise they are not included in the published SWF, and there is a runtime error when getDefinitionByName tries to get a class that doesn't exist.

So, my question: in Flash Professional CS4, is there any way to force a library's assets to be included, regardless of whether they are statically linked?

FlashDevelop has a compiler option "SWC Include Libraries", which is exactly what I want, and is distinct from the "SWC Libraries" option. The description of the "SWC Include Libraries" option is "Links all classes inside a SWC file to the resulting application SWF file, regardless of whether or not they are used."

(Also, it's important to me that all the assets are contained within the one compiled SWF. Linking at runtime isn't what I'm after.)

© Stack Overflow or respective owner

Related posts about flex

Related posts about flash