I'm still a newbie when it comes to PureMVC and fabrication, but I feel that I'm up to the challenge of being productive with these useful frameworks.
What I would like to know is how to properly use Flex's ModuleManager
class with classes that inherit from the fabrication FlexModule
The Fabrication Wiki details the basics of how to load Flex modules with the Flex ModuleManager class:
Using Module Manager for Flex Modules
Flex modules can also be loaded using the ModuleManager. The ModuleManager only loads the module swf. It does not instantiate the loaded swf. That needs to be done manually after the loading has completed by invoking create on the module's factory.
Loads the module, my_module.swf using ModuleManager.
var module:IModuleInfo = ModuleManager.getModule("my_module.swf");
private function moduleReadyListener(event:ModuleEvent):void
var moduleInstance:Object = event.module.factory.create();
My fabrication application essentially follows the above example. I must be doing something wrong because the xStartupCommand command class for my module is not being called, even though my modules main class specifies the xStartupCommand class in its getStartupCommand()
To ensure the same functionality as if the fabrication FlexLoader
class had been used, are some extra configuration steps needed for using Flex's ModuleManager
class to load the FlexModule
I was able to get something working using code to the effect of the following:
var moduleInstance:FlexModule = event.module.factory.create() as FlexModule;
moduleInstance.router = (this.fabFacade.getApplication() as FlexApplication).router;
Is this essentially the right way to go about it, or is there a better way?