Loading Modules/Runtime CSS into an AIR App
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 your application at a later time can be downloaded using AIR’s update API via Updater.update().
7 Comments
Leave a comment
About Dan
Categories
- ActionScript (1)
- AIR (5)
- Cayri (7)
- Design Patterns (4)
- Flex (8)
- Mapping (1)
- Mesh (1)
- Mixbook (1)
Recent Posts
- Mesh – A Persistence Framework For Flex
- Making ActionScript Look Beautiful: Increasing Readability and Loosing Verboseness
- Help Dan find a Flex Engineer and get a free paid trip for 2 to Hawaii
- What’s Happening With Cayri?
- Saving Flex’s Application State to a Database
- Loading Modules/Runtime CSS into an AIR App
- CollectionEventKind.RESET, WTF Does That Mean?
- When to Use Weak References
- Embedding Cayri on Your Website
- The State Pattern in Flex 2
- @zeeyang just get an iPhone already :)
- @neiltyson I'd love to see you speak this week, but damn.. $270!! Your talk costs 3x more than a rock concert.
- @almeida_miguel sorry, but Mixbook doesn't offer licensing of its software at the moment.
- @usbank -1 for telemarketing your own customers.
- I might go to The Black Keys @ San Jose City College. http://t.co/d81dAPfu





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
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.
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.
Sorry, mx.modules.ModuleManager class.
[...] [3] – Another solution using AIR Update framework: http://www.intriguemedia.net/2008/02/22/loading-modulesruntime-css-into-an-air-app/ [...]
Our development team faced the same problem as your and we have the solution like tim and Lanny suggested, here is the post http://blog.esofthead.com/?p=117
I came across a fix on the Flex bugs site:
http://bugs.adobe.com/jira/browse/SDK-15393
I implemented the code that Tom Schober posted, and it worked great!
Glenn.