<?xml version="1.0"?> <!-- modules/SimpleProgressEventHandler.mxml --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:control="ipslib.control.*" implements="flash.events.IEventDispatcher"> <fx:Declarations> </fx:Declarations> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.FlexEvent; import mx.events.ModuleEvent; import mx.modules.*; [Bindable] public var progBar:String = ""; [Bindable] public var progMessage:String = ""; public function createModule():void { firstLoader.loadModule(moduleTxt.text); } public function createModule2():void { secondLoader.loadModule(moduleTxt2.text); } public function removeModule():void { firstLoader.unloadModule(); } public function removeModule2():void { secondLoader.unloadModule(); } protected function moduleLoader_error(event:ModuleEvent):void { Alert.show("error " + event.errorText); } ]]> </fx:Script> <s:VGroup width="100%" height="100%"> <mx:HBox> <mx:Button label="Load 1st module" click="createModule()"/> <mx:Button label="Unload 1st module" click="removeModule()"/> <mx:TextInput id="moduleTxt" text="Module1.swf"/> </mx:HBox> <mx:ModuleLoader id="firstLoader" width="100%" height="100%" error="moduleLoader_error(event)" ready="moduleLoader_error(event)"/> <mx:HBox> <mx:Button label="Load 2nd module" click="createModule2()"/> <mx:Button label="Unload 2nd module" click="removeModule2()"/> <mx:TextInput id="moduleTxt2" text="Module2.swf"/> </mx:HBox> <mx:ModuleLoader id="secondLoader" width="100%" height="100%" error="moduleLoader_error(event)"/> </s:VGroup> </s:Application> |