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):
com.me.myapp.shell.controller.*
com.me.myapp.shell.model.*
com.me.myapp.shell.view.*
TortoiseModule classes (in Tortoise project):
com.me.myapp.tortoise.controller.*
com.me.myapp.tortoise.model.*
com.me.myapp.tortoise.view.*
HareModule classes (in Hare project):
com.me.myapp.hare.controller.*
com.me.myapp.hare.model.*
com.me.myapp.hare.view.*
Common classes (separate library, made available to all projects):
com.me.myapp.common.controller.*
com.me.myapp.common.model.*
com.me.myapp.common.view.*
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
[1] 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.
-=Cliff>
PureMVC Loadup Utility
http://trac.puremvc.org/Utility_AS3_Loadup