« ArrayCollection, Arrays and Server Data | Main | Thinking About Item Renderers »

SWF is not a loadable Module

Did you get this error using modules? This error means that you tried to load the module from a different server than the one the loader is running on, and/or you don't have crossdomain.xml permission to load the module from that server.

Flash/Flex has a lot of security built in so that mean people can't use Flash/Flex to do mean things to other servers. All SWFs therefore belong to the domain of the server where that SWF lives.

For example, if we're running a SWF that lives at http://a.b.com/main.SWF, that SWF belongs to the domain "a.b.com". If you try to load a SWF from somewhere else, such as http://c.b.com/module.SWF or http://e.f.org/module.SWF, then you are loading across domains.

The Flash Player will then look in the root directory of c.b.com or e.f.org for a file called crossdomain.xml, and see if a.b.com is listed in that file (or the file lists '*" which means "everybody"). If not, you cannot load the SWF as a module because, due to other security restrictions in the Flash Player, SWF loaded from another domain without crossdomain.xml permission go in a separate SecurityDomain, which means that it will have its own ApplicationDomain which means it cannot share classes with the main SWF and thus the ModuleManager can't see the objects in the SWF as Modules.

Because this is a security-related issue, there are no real workarounds. You either have to make sure that your modules are in the same domain as the SWFs that load them, or you have to set up crossdomain.xml files so they can be used from SWFs in other domains. If you are trying to use a third-party module, you probably don't have access to the third-party's server and thus can't add yourself as an accepted domain in their crossdomain.xml file. That's annoying, but those are the rules. Server owners must either give explicit permission or decide to openly share SWFs resources on a server by listing your domain in crossdomain.xml or using '*".

Comments

I'm running into this error when I load up a swf. I understand the security/cross domain issues, but I'm loading the swf locally, from my bin.

The weird thing is that I can load up a styled swf that I get from compiling a css file just fine. But with a swf that I have skinned using flash or illustrator, I get this error.

I got the templates from http://www.adobe.com/devnet/flex/articles/flex_skins.html

Any ideas why I would get this error only for skinned swfs, and not for styled swfs, even when they are sitting in the same directory?

The swf that is giving me problems is here: http://skin.bryceb.staging.mediarain.com/flex_skins.swf Keep in mind, I'm not loading it from there, I'm only putting it there so you can see it.

Any Ideas?

thanks
Bryce

------------------

flex_skins.swf is an application swf and not a module swf and thus you can't load it via modules otherwise you'll get that error. You can load it via SWFLoader or at a lower level using flash.display.Loader.

Modules have special startup code to talk to the ModuleManager.

-Alex

is there a way to load a remote SWF from the ModuleLoader when the loading SWF is local-with-network or local-trusted? every time I try this, the loaded module throws "LayoutContainer could not be found"

--------------------

Haven't tried it. You probably have to specify the SecurityDomain as SecurityDomain.currentDomain in the LoaderContext. I would not expect it to work with local-trusted.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)