Loads and unloads the module when you click the button
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> import mx.modules.*; public function createModule(m:ModuleLoader):void { m.url = "a.swf"; m.loadModule(); } public function removeModule(m:ModuleLoader):void { m.unloadModule(); } </mx:Script> <mx:Panel title="Module Example" height="90%" width="90%"> <mx:TabNavigator id="tn" width="100%" height="100%" creationPolicy="auto"> <mx:VBox id="vb1" label="Column Chart Module"> <mx:Button label="Load" click="createModule(chartModuleLoader)" /> <mx:Button label="Unload" click="removeModule(chartModuleLoader)" /> <mx:ModuleLoader id="chartModuleLoader" /> </mx:VBox> <mx:VBox id="vb2" label="Form Module"> <mx:Button label="Load" click="createModule(formModuleLoader)" /> <mx:Button label="Unload" click="removeModule(formModuleLoader)" /> <mx:ModuleLoader id="formModuleLoader" /> </mx:VBox> </mx:TabNavigator> </mx:Panel> </mx:Application>