Hi, I too am having difficulties with loading modules in apollo. Please correct me if i'm wrong but it seems that the current behaviour is that only local swfs placed and referenced from the app-storage directory can be loaded as modules?
Here's a bit of code to test. First, make a regular Flex project and make a class called ApolloModule.as that extends ModuleBase. I use the generated ApolloModule-debug.swf for testing. The class is empty. Next, make an apollo app. put the code at the end of this message inside an mx:Script tag in your main mxml file and add creationComplete="init()" Uncomment the different values for "path" to see which ones load the module and which ones don't. There may be incorrect carriage returns in the variable assignment, so ... It seems that the ModuleLoader will load swfs inside app-resources and not complain with "SWF is not a loadable module". I think this is specified somewhere in the Understanding Apollo Security (http://labs.adobe.com/wiki/index.php/Apollo:Documentation:Understanding_Apollo_security), but I'm not totally certain. The reason for my uncertainty is that passing a relative url using ".." then you won't get an error. If anybody can clarify this I'd really appreciate it. thanks /r http://www.searchcoders.com/flex/search/apollo+modules ---- START CODE HERE -------------------- import flash.filesystem.File; import mx.events.ModuleEvent; import mx.modules.ModuleManager; import mx.modules.IModuleInfo; import mx.modules.ModuleBase; public function init():void { var path:String = ""; // --- THESE DON'T WORK // * Doesn't work, SWF is not a loadable module //path = "c:/work/searchcoders/ApolloModuleLoader/ApolloModule-debug.swf"; // * Doesn't work (URL NOT FOUND app-resource:/app-resource ...) //path = "app-resource:../ApolloModule-debug.swf"; // * Doesn't Work, SWF is not a loadable module //path = File.appStorageDirectory.resolve("ApolloModule-debug.swf").url; // * Doesn't work, SWF is not a loadable module // this path below is to an internal server with a // crossdomain.xml allowing access to "*" //path = "http://local.simple/ApolloModule-debug.swf"; // --- THESE WORK //path = "app-resource:/ApolloModule-debug.swf"; //path = "ApolloModule-debug.swf"; //path = "/ApolloModule-debug.swf"; //path = File.appResourceDirectory.resolve("ApolloModule-debug.swf").url; // --- THIS ONE WORKS! BUT NOT IN app-resource! why? // path = "../ApolloModule-debug.swf"; trace("Raw Path: " + path); try { // Try to convert to file and then show url and native var file:File = new File(path); trace("Loading from: " + file.nativePath); trace("URL IS: " + file.url); } catch (e:Error) { trace(e); } var info:IModuleInfo = ModuleManager.getModule(path); info.addEventListener(ModuleEvent.ERROR, moduleEvent); info.addEventListener(ModuleEvent.READY, moduleEvent); info.addEventListener(ModuleEvent.READY, moduleEvent); info.addEventListener(ModuleEvent.PROGRESS, moduleEvent); info.load(); } public function moduleEvent(event:ModuleEvent):void { trace("event: " + event); if (event.type == ModuleEvent.ERROR) { trace("\tBOOM!" + event.errorText); } if (event.type == ModuleEvent.READY) { var info:IModuleInfo = event.target as IModuleInfo; trace("info: " + info); try { var file:File = new File(info.url); trace("Canonical Path : " + file.canonicalize()) } catch (e:Error) { trace("Error: " + e); } trace("Module: " + info); var module:ModuleBase = info.factory.create() as ModuleBase; trace("Defined? " + module); } } ---- END CODE HERE -------------------- if anybody wants the original source file just let me know and i'll email it to you as an attachment. Matt Chotin wrote: > We may need to turn this into a bug so we can make sure it's > straightforward to move between the web and Apollo. can you please file > an issue at http://www.adobe.com/go/wish explaining how you were loading > your module originally and how you needed to change it for Apollo? > > Matt > > ________________________________ > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of Mark Doberenz > Sent: Friday, March 23, 2007 10:03 AM > To: flexcoders@yahoogroups.com > Subject: Re: [flexcoders] Re: Apollo isn't loading my modules > > > > In ended up figuring this one out. > It seems that Flex wants the full path to the modules, but apollo wants > the relative path. Once I changed this, it worked just fine. > > Hope that helps. > > > On 23 Mar 2007 09:20:05 -0700, mthielman11 <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > wrote: > > I am having a similar problem, app works fine in flex and works > fine from apollo if I build > it and run, but when I try exporting and running it will not > load the module. I got it to > work once or twice initially and that was it. Any ideas? > > > > --- In flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> , "Mark Doberenz" <[EMAIL PROTECTED]> > wrote: > > > > Is there something special I need to do to make Apollo load my > modules? > > Flex builder is showing them just fine, but when I run the > app, they don't > > show up in the view. > > The debugger is showing that the SWF is being loaded, but then > after > > clicking around on the app for a bit, the debugger says > [Unload SWF] and it > > unloads the module SWF. > > > > Any ideas on this one? > > > > Mark > > > > > > > > > > > >