Loading Modules with Module Loader
The simplest way you can modularize your application is by using
Flex modules. The class Module
is a VBox
that, like Application
, is a Container
that also gets compiled, along with
the dependent classes, to a separate .swf file. Example 7-5 illustrates a trivial module.
Example 7-5. Example of the module
<?xml version="1.0"?> <!-SimpleModule.xml --> <mx:Module xmlns:mx=http://www.adobe.com/2006/mxml layout="vertical"> <mx:Text text="This is the simplest module" > </mx:Module>
Any functional part of your application UI that can be developed and tested independently is a good candidate to become a module. The advantages are obvious: you can delegate the development and testing efforts to a different team or allocate a different time slot to it. Modularization will also improve memory utilization, because you can unload the module when the application does not need it anymore.
For Flash Builder to compile your module, it needs to be included into the .actionScriptProperties file of your project. You typically add the module via the project’s properties, as shown in Figure 7-2, or by using the New Module wizard.
Figure 7-2. Registration of the module to be compiled by Flash Builder
The easiest way to load a module to your application during runtime
is via ModuleLoader
, a descendant of
the VBox
that has an extra API to load and unload module SWF files, as shown ...
Get Agile Enterprise Application Development with Flex now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.