After i loaded the module to the shell, the loaded module now uses the exported class from the shell. I tried renaming the exported class and it worked well. However, it's quite cumbersome to rename the modules exported class that conflicts the shell. Is there anyway to fix this?
Yes, just package them differently.
I don't know what your conflicting class name is, but the only reason it can be conflicting is if it lives in the same package node in both the shell and module projects. So just make sure your packaging is unique for every core of your app, be it a module or the shell.
For instance:Shell classes
(in Shell project):
(in Tortoise project):
(in Hare project):
(separate library, made available to all projects):
Also, what's the best way to handle loading of modules. Should i place it in a LoadModuleCommand or a LoadModuleMediator?
There are lots of ways to do this.
Commands are for business logic and should be shielded from the boundaries of the app (i.e., services and UI) as much as possible. However, it is short-lived, and for a transitory task like loading a module and perhaps mediating it, a Command is an acceptable place.
You could write a simple Proxy to load the module and send it off in a note to be mediated once it's been loaded. The Proxy usually shouldn't be involved in any way with visual componentry, but in the case that it is treated essentially like data, and no operations are performed on it beyond fetching, it is an acceptable responsibility for the Proxy role.
You could use the Loadup
utility, but that might be overkill if you don't really have any other assets to load you'd have to look into it and see what you think. It treats a swf as just another asset type, and gives you the benefit of retry policies and error handling being taken care of.
A Mediator can work well too, but be careful of overloading it with lots of logic for plumbing and the like. You would at most want to send it a note saying to load a module, then it would send out success or failure notes that are handled by a Command that does the plumbing.
PureMVC Loadup Utilityhttp://trac.puremvc.org/Utility_AS3_Loadup