Using SWC Library assets dynamically in Flex
I was working on a Flex project last week that dynamically used assets from a Flash library SWC and came across something I thought was worth sharing.
The application compiled correctly when using the assets within the code i.e. var object:Asset = new Asset(). However, when choosing to use the asset dynamically (with the use of getClassByAlias()) the application threw a runtime error. So, unless the asset was used within the application it was not compiled into the published application.
I found that by changing the link type of the SWC from ‘Merged into code’ to ‘Runtime shared library (RSL)’ I was able to use the asset dynamically within the application without the asset being used within the code.
Therefore, if you want to use Flash library assets from a SWC dynamically ensure that the link type of the SWC is set to ‘Runtime shared library’.
Does anyone have any comments or different solutions?


Awesome! Thanks for this, it was bewildering me a bit, and your solution was perfect.
February 16th, 2010