MVC meet H-MVC – Hierarchical MVC Saving Flex’s Application State to a Database
Feb 22

For those planning to load a Flex module into your AIR application from a remote server: take a look at this post before beating your head against the wall with this ambiguous error message Error: Unable to load style(SWF is not a loadable module).

Basically, loaded SWF’s are not allowed to be in the same security domain as your AIR app. Since modules and external styles loaded using StyleManager.loadStyleDeclaration() try to load themselves into the current security domain, an error will be thrown. The only workaround it appears is to bundle those modules with your application when it’s downloaded. Any new modules you want to add to you app at a later time can be downloaded using AIR’s update API via Updater.update().

4 Responses to “Loading Modules/Runtime CSS into an AIR App”

  1. tim Says:

    Hi,

    Have you also considered downloading the swf as a binary from the air app and then access it locally via SWFLoader? I am currently doing some research on this for one of our customers. It seems to work (at the first sight).

    Have a nice day!

    Tim

  2. dschultz Says:

    Haven’t tried that yet. But I think I’m going to take the Updater approach. I figure since it’s an AIR up, the user shouldn’t have to download anything unless there’s an update.

  3. Lanny Says:

    Thanks for the post. I ran into this exact issue today, and Tim’s comment was the tip I needed to make it work. Note that modules have an internal Loader process, so in order to make this work, you need to copy the ModuleLoader class to your application and change the Loader to a URLStream/LoadBytes instead. Its a bit convoluted, but it does work.

  4. Lanny Says:

    Sorry, mx.modules.ModuleManager class.

Leave a Reply