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 apoll