I've been developing Flex apps for a while now and never had a problem
with Flex 3, then when Flex 4 came out I started running into all kinds
of problems with developing an application with modules. Whereas it's
well documented pertaining problems with loading Modules in Flex 4
regarding shared resources, it makes me wonder how to build a fast
loading large Flex app.
I use the Mate Framework and use Events to load data, trigger moves, and
load other pieces. I do not use the main application to call functions
or interface with the other modules. They pretty much run indepentent of
each other, only sharing RemoteObjects. I was under the assumption that
modules were a good way to break up pieces of an application to keep
each pieces smaller so they load quickly, but I am finding out that it
seems it is not the preferred way, so I thought I would ask the experts
for some education on how to achieve a application that is lightweight
but full featured.
Here is a break down of my application:
I have a portal online that is shared by 4 different types of users. The
main application loads basically a login box and a has a block of code
to load a module based on the user's account type. I use stock (Module
Manager) loader ActionScript (see below) that loads one of 2 different
modules based on if the user is in one group (kids) or a site admin
(parents, a hospital, or myself for super admin rights) once they log
in. Problem is that when the module loads it throws errors regarding
'One of the parameters is invalid.' and always having to do with the
Style Manager.
I broke the application down into about a dozen modules since the kid's
UI is complete different than the other three groups and, in the other 3
groups, they have access to different types of functionality based on
their user types. The kids application application has access to about
10 different types of views (arts & crafts, web cam chat, journal, chat
rooms, account manager, photo uploading/managing, etc). The admins
(parents, hospitals, myself) have access to journals, account managers,
analytics, etc). To keep the size of the application down I created
modules for each type of sub application and just load them when the
user wants to use them. I liken it to traditional web when each sub
application would be another page of the web site and the index page is
just a link to those pages.
In this scenerio, are modules not the best way to work? What are the
alternatives to creating 10 sub applications in a main application
without bloating the size? I know that creating each sub app as a
component is not the answer for 2 main reasons: Components are shared
pieces of an application and not full sub apps, and components are
complied into the application and the size.
So, to make a long question short (too late), what is the best method to
create an application with lots of 'pages' but not bloat the size of the
swf? If it is to break each sub application into a module, what is the
magic bullet that helps load them. I am currently using:
private function loadModule(path:String):void {
modLoader = ModuleManager.getModule(path);
modLoader.addEventListener(ModuleEvent.ERROR,
modErrorHandler);
modLoader.addEventListener(ModuleEvent.READY,
modReadyHandler);
modLoader.load();
}
private function modErrorHandler(e:ModuleEvent):void {
Alert.show("Module did not load correctly", "Module
Loading Error");
}
private function modReadyHandler(e:ModuleEvent):void {
this.removeAllElements();
this.addElement(modLoader.factory.create() as
IVisualElement);
}
I guess my next question, what are the benefits to using ModuleManager
to load them or using Moduleloader? Does one work better than the other?
I really want to continue with Flex and want to be a better developer,
but all these new errors with Flex 4 is very disappointing and SLOWING
down my development. Thanks!