blob: 7f4311e830ece6fb75a7e786434cc70c30bac75e [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.
-->
<!-- basic swf for subModule tests, module is loaded by ModuleLoader -->
<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"
creationComplete="init()"
>
<fx:Style source="../../../../Assets/Fonts/VeraFontStyles.css" />
<fx:Style>
@namespace mx "library://ns.adobe.com/flex/mx/";
@namespace s "library://ns.adobe.com/flex/spark/";
mx|Module,
mx|DataGrid{
fontFamily: MyVeraHalo;
fontLookup: embeddedCFF;
fontAntiAliasType: normal;
}
s|Label,
s|TitleWindow{
fontFamily: MyVeraSpark;
fontLookup: embeddedCFF;
fontAntiAliasType: normal;
}
</fx:Style>
<s:layout> <s:VerticalLayout/> </s:layout>
<fx:Script>
<![CDATA[
import mx.events.ModuleEvent;
import mx.events.FlexEvent;
import mx.controls.Alert;
import mx.events.ModuleEvent;
import mx.modules.Module;
import mx.collections.ArrayList;
import mx.managers.PopUpManager;
PopUpManager;
private var moduleErrorMsg:String="";
private function errorModuleHandler(e:ModuleEvent):void
{
e.currentTarget.removeEventListener(ModuleEvent.ERROR,errorModuleHandler);
moduleErrorMsg=e.errorText;
Alert.show(e.errorText);
}
private var arr:Array = [ { moduleName: "assets/Module1.swf"},
{ moduleName: "assets/Module2.swf"},
{ moduleName: "assets/Module3.swf"},
{ moduleName: "assets/Module4.swf"},
{ moduleName: "assets/SimpleASModuleTest.swf"}
];
private function init():void
{
dg.dataProvider = new ArrayList(arr);
setModuleLoaderListeners();
}
public function setModuleLoaderListeners():void
{
moduleLoader1.addEventListener(ModuleEvent.READY,handleModuleLoaded);
moduleLoader1.addEventListener(ModuleEvent.ERROR,errorModuleHandler);
moduleLoader1.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"));
}
private function loadModule(ml:ModuleLoader, moduleURL:String):void
{
if (ml.url==null)
ml.url = moduleURL;
else ml.loadModule();
}
private function unloadModule(ml:ModuleLoader):void
{
ml.unloadModule();
ml.url=null;
}
public function resetModuleLoader():void
{
setModuleLoaderListeners();
}
]]>
</fx:Script>
<mx:DataGrid id="dg" />
<s:Button id="btn1" label="load Module1" click="loadModule(moduleLoader1,dg.selectedItem.moduleName)" />
<s:Button id="btn2" label="unload Module1" click="unloadModule(moduleLoader1);" />
<mx:ModuleLoader id="moduleLoader1" />
</s:Application>