| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <s:Module xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300" |
| creationComplete="init()"> |
| <s:layout><s:VerticalLayout/></s:layout> |
| <fx:Script> |
| <![CDATA[ |
| import mx.controls.Alert; |
| import mx.events.FlexEvent; |
| import mx.events.ModuleEvent; |
| |
| private var errMsg:String=""; |
| |
| private function errorModuleHandler(e:ModuleEvent):void |
| { |
| e.currentTarget.removeEventListener(ModuleEvent.ERROR,errorModuleHandler); |
| errMsg=e.errorText; |
| } |
| |
| public function loadModule1():void |
| { |
| trace("**************************************************"); |
| trace(" : LOAD MODULE : loadModule1() "); |
| trace("**************************************************"); |
| loadModule(subModuleLoader1, "assets/SimpleModuleWithLabel.swf"); |
| } |
| |
| private function loadModule(ml:spark.modules.ModuleLoader, moduleURL:String):void |
| { |
| this.lbl00.text="loading module..."; |
| trace(' ************************************************** loading module...'); |
| if (ml.url==null) |
| ml.url = moduleURL; |
| else ml.loadModule(); |
| } |
| |
| private function init():void |
| { |
| trace(' initializing subModuleLoader1 ...'); |
| lbl00.text ' initializing subModuleLoader1 ...'; |
| trace("*************************INIT*************************"); |
| trace(" : " + info.url + " : "); |
| |
| trace("*************************INIT*************************"); |
| subModuleLoader1.addEventListener(ModuleEvent.READY,handleModuleLoaded); |
| subModuleLoader1.addEventListener(ModuleEvent.ERROR,errorModuleHandler); |
| subModuleLoader1.addEventListener(ModuleEvent.UNLOAD,removeModuleLoaded); |
| } |
| |
| public function handleModuleLoaded(e:ModuleEvent):void |
| { |
| trace('*****TESTTESTTEST***** moduleLoaded *****TESTTESTTEST*****'); |
| lbl00.text="ready? "; |
| e.currentTarget.removeEventListener(ModuleEvent.READY, handleModuleLoaded); |
| dispatchEvent(new FlexEvent("moduleLoaded")); |
| } |
| |
| public function removeModuleLoaded(e:ModuleEvent):void |
| { |
| e.currentTarget.removeEventListener(ModuleEvent.UNLOAD, removeModuleLoaded); |
| dispatchEvent(new FlexEvent("moduleRemoved")); |
| } |
| |
| public function runmdBtn1():void |
| { |
| trace('*****TESTTESTTEST***** runmdBtn1 *****TESTTESTTEST*****'); |
| loadModule1() |
| } |
| ]]> |
| </fx:Script> |
| |
| <s:Label text="Module1" id="lbl00" /> |
| <s:Button id="mdBtn1" label="load SubModule1 Bill Sahlas" click="loadModule1()" /> |
| |
| <s:Button id="mdBtn2" label="unload SubModule1" click="{subModuleLoader1.unloadModule(); subModuleLoader1.url=null;}" /> |
| <s:ModuleLoader id="subModuleLoader1" /> |
| </s:Module> |
| |