2 Replies Latest reply: May 9, 2011 9:13 AM by paleozogt RSS

    Several alchemy libraries in one swf?

    andrey.mironov


      Hello!

       

      I've sucessfuly compiled several c/c++ libraries into SWC libraries which I plan to use in my flex project. But I'm wondering is it beter to keep them as separate libraries or make one big glue.gg file with all interop code for all of this libraries?

        • 1. Re: Several alchemy libraries in one swf?
          audioMirror Community Member

          I went for the single .gg file.  I had blow-ups whenever I tried using two .gg-generated swc libraries in one swf.

          • 2. Re: Several alchemy libraries in one swf?
            paleozogt Community Member

            Because Alchemy uses statics to keep track of its ram, etc, you sort of can't have more than one instance.  The libraries would be sharing the same ram, which can cause problems.

             

            However, you can dodge the issue by loading your alchemy libraries into separate Application Domains.  I'm doing this in my project:

             

            1. Compile your libs as SWCs
            2. Extract the SWFs from inside the SWCs
            3. Embed the library SWFs in your application
            4. Use Loader.loadBytes to load your library into its own Application Domain

             

            The other benefit of doing it this way is that if your alchemy lib crashes it won't affect any other alchemy libraries because they're using entirely separate ByteArrays for ram, etc.