With Alchemy most builds are static swc builds. These are great for linking directly against a library, but if you try to use more than one at a time, you usually (always?) run into problems with the shared memory space. One solution I've read about is to build swf's instead and load those dynamically into their own ApplicationDomain. This would give all libraries their own memory and would allow you to load multiple Alchemy libraries. (As mentioned in these threads on the adobe forums: http://forums.adobe.com/message/3665801 and http://forums.adobe.com/message/3927791)
My question is: how do I load these swf's and get to the code inside of them? There doesn't seem to be any documentation on this issue and although I do know how to load an swf, I don't know how to get to the code because I don't have any interface to the swf.
The problem is that we want to dynamically load the Alchemy lib, but if we build the library as a SWF it won't work (as that makes a standalone app). But we can't dynamically load a SWC-- or can we?
Here's what to do (assuming a library named mylib
):
mylib
as a SWC.mylib.swc
and extract the library.swf
file; rename it to mylib.swf
mylib.swf
as a binary assetByteArray
ByteArray
to Loader#loadBytescmodule.mylib.CLibInit
init
, etc.You can embed an arbitrary number of Alchemy libraries this way, each running in its own ApplicationDomain.