Check your sandboxType. I'll bet it is local-trusted and not local-with-networking.
From: [email protected] [mailto:[email protected]] On Behalf Of hughesmatt78 Sent: Saturday, December 13, 2008 11:33 AM To: [email protected] Subject: [flexcoders] Loading network SWFs from SWF hosted on filesystem (SWF is not a loadable module I'm trying so far in vain to load a module from a network domain from a SWF that was loaded via the filesystem. Every time I try and load the module, I get the following error: "SWF is not a loadable module." I have seen this same problem discussed elsewhere on FlexCoders and other blogs but I am getting very conflicting views. Some people say this kind of module loading is not supported (http://www.nabble.com/Problems-using-Flex-modules-td15188446.html) but the Adobe Flash Player 9 Security white paper clearly indicate it is possible: "A SWF file may also call Security.allowDomain() with the wildcard parameter "*" to allow any domain. This is necessary to allow a local-with-networking SWF file to cross-script a network SWF file." Anyway, off to the example project I created. Here are two very basic mxmls. TestApplication.mxml -- (loaded via file system, this attempts to load a simple module hosted at localhost) <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" initialize="init()"> <mx:Script> <![CDATA[ import mx.events.ModuleEvent; private function init() : void { Security.allowDomain("localhost"); Security.loadPolicyFile("http://localhost/crossdomain.xml"); var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, function(event : Event) { trace("Finished loading crossdomain."); trace(loader.data); }); loader.load(new URLRequest("http://localhost/crossdomain.xml")); } private function erroredOut(event : ModuleEvent) : void { trace(event.errorText); } private function loadIt() : void { loaderOfModules.url = "http://localhost/SimpleModule.swf"; } ]]> </mx:Script> <mx:Button click="loadIt()" label="Load module from localhost" /> <!-- Sandbox type reads local-trusted --> <mx:Text text="{Security.sandboxType}" /> <mx:ModuleLoader id="loaderOfModules" width="100%" height="500" error="erroredOut(event)" applicationDomain="{ApplicationDomain.currentDomain}"/> </mx:Application> SimpleModule.mxml (the module hosted at localhost) <?xml version="1.0" encoding="utf-8"?> <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" initialize="Security.allowDomain('*')" > <mx:Text text="Hi there" /> </mx:Module> And the crossdomain.xml file hosted at localhost. (Although according to some Adobe docs, this file is not even needed to do crossscripting, only for loading data.) <?xml version="1.0"?> <cross-domain-policy> <allow-access-from domain="*" /> </cross-domain-policy> Note that I can get this example to work fine if I host the Application SWF from one network domain and load the module from another network domain without changing a thing. I only get the error when the loading SWF is hosted on the filesystem. Also note that the Application.swf is in a folder designated as locally trusted and I confirm this by looking at the Security.sandboxType variable at runtime. I am using Flex 3 and running this with Flash Player 9 debugger version. So my questions are: * Is this scenario even supported? If not, what's with the documentation I quoted from Adobe above? If yes, what am I missing? * And do crossdomain.xml files even used when doing crossscripting? Or are they just often conflated with module loading because you often load modules and data from the same server?

