blob: 75a38cc408308151398633caf6da2e0d811406f3 [file] [log] [blame]
<?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:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
//use a datagrid to hold all submodules, load/unload is based on selection index
//or use tabnavigator
import mx.managers.PopUpManager;
import mx.events.ModuleEvent;
import mx.events.FlexEvent;
import mx.controls.Alert;
import mx.events.ModuleEvent;
import mx.modules.Module;
private var errMsg:String="";
PopUpManager;
private function errorModuleHandler(e:ModuleEvent):void
{
e.currentTarget.removeEventListener(ModuleEvent.ERROR,errorModuleHandler);
errMsg=e.errorText;
Alert.show(e.errorText);
}
public function loadModule1():void
{
loadModule(subModuleLoader1, "assets/SimpleASModuleTest.swf");
}
private function loadModule(ml:ModuleLoader, moduleURL:String):void
{
if (ml.url==null)
ml.url = moduleURL;
else ml.loadModule();
}
private function init():void
{
subModuleLoader1.addEventListener(ModuleEvent.READY,handleModuleLoaded);
subModuleLoader1.addEventListener(ModuleEvent.ERROR,errorModuleHandler);
subModuleLoader1.addEventListener(ModuleEvent.UNLOAD,removeModuleLoaded);
}
public function handleModuleLoaded(e:ModuleEvent):void
{
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"));
}
]]>
</fx:Script>
<s:Label text="Module2" />
<s:Button id="mdBtn1" label="load SimpleASModuleTest" click="loadModule(subModuleLoader1,'assets/SimpleASModuleTest.swf')" /><!-- TitleWindowModule.swf -->
<s:Button id="mdBtn2" label="unload SimpleASModuleTest" click="{subModuleLoader1.unloadModule(); subModuleLoader1.url=null;}" />
<s:ModuleLoader id="subModuleLoader1" />
</s:Module>