In this example, we will used module manager to load and unload modules in the application
In this example, we will used module manager to load and unload modules in the applicationLoad module with the help of ModuleManager class:-
In this example, we will used module manager to load and unload modules in the application. It is loaded module with the help of IModuleInfo interface by using the ModuleManager getModule() method that's provide the reference of the module. After that user can used load() method to load module.
Example:-
loginmodule.swf code
|
<?xml version="1.0"?> <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" >Alert.show( "User Name is :" + name);loginnametext.text = "";loginpasswordtext.text = "";} else{Alert.show( "Enter correct name and password!");} } ]]> </mx:Module> |
main.swf code
|
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"creationComplete="initApp()" > <mx:Script><![CDATA[ moduleinfo = ModuleManager.getModule( "loginmodule.swf");moduleinfo.addEventListener(ModuleEvent.READY, moduleEventHandler); moduleinfo.load(); } private function moduleEventHandler(e:ModuleEvent):void {loginbox.addChild(moduleinfo.factory.create() as DisplayObject);} ]]> </mx:Application> |
In this example you can see how to use module manager for the module based application.
Output:-
