Share on Google+Share on Google+

ModuleManager for load or unload module in Flex 3

In this example, we will used module manager to load and unload modules in the application

Load 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.


loginmodule.swf code

<?xml version="1.0"?>

<mx:Module xmlns:mx="" width="100%" height="100%" >


import mx.controls.Alert;

private function submit():void{

var name:String = loginnametext.text;

var password:String = loginpasswordtext.text;

if(name!="" && password!=""){"User Name is :" + name);

loginnametext.text = "";

loginpasswordtext.text = "";


else{"Enter correct name and password!");





<mx:Panel id="loginpanel" height="200" width="328">

<mx:HBox width="302">

<mx:Label id="loginname" text="Enter name "/>

<mx:TextInput id="loginnametext"/>


<mx:HBox width="301">

<mx:Label id="loginpassword" text="Enter password"/>

<mx:TextInput id="loginpasswordtext" displayAsPassword="true"/>



<mx:Button label="Submit" click="submit()"/>




main.swf code

<?xml version="1.0"?>

<mx:Application xmlns:mx=""





import mx.modules.ModuleManager;

import mx.modules.IModuleInfo;

public var moduleinfo:IModuleInfo;

private function initApp():void {

moduleinfo = ModuleManager.getModule("loginmodule.swf");

moduleinfo.addEventListener(ModuleEvent.READY, moduleEventHandler);



private function moduleEventHandler(e:ModuleEvent):void {

loginbox.addChild(moduleinfo.factory.create() as DisplayObject);




<mx:VBox id="loginbox"/>


In this example you can see how to use module manager for the module based application.


Download this code



Posted on: July 12, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null