| <?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[ |
| |
| import mx.events.FlexEvent; |
| |
| import flash.events.Event; |
| |
| import mx.core.IUIComponent; |
| |
| import mx.controls.Alert; |
| |
| import mx.managers.SystemManager; |
| |
| |
| |
| public var subAppRef:SystemManager; |
| |
| public function handleSWFLoaded(e:Event):void |
| { |
| e.currentTarget.removeEventListener("complete", handleSWFLoaded); |
| subAppRef=(contentLoader.content as SystemManager); |
| subAppRef.addEventListener(FlexEvent.APPLICATION_COMPLETE, handleSWFLoadedAndReady); |
| trace("subAppRef="+subAppRef); |
| |
| |
| } |
| public function handleSWFLoadedAndReady(e:Event):void |
| { |
| subAppRef.removeEventListener(FlexEvent.APPLICATION_COMPLETE, handleSWFLoadedAndReady); |
| dispatchEvent(new FlexEvent("SWFLoaded")); |
| } |
| |
| public function handleSWFLoadedError(e:Event):void |
| |
| { |
| |
| |
| |
| dispatchEvent(new FlexEvent("ErrorSWFLoad")); |
| |
| trace(e); |
| |
| Alert.show(e.toString()); |
| |
| |
| |
| |
| |
| } |
| |
| public function handleSWFUnloaded(e:Event):void |
| |
| { |
| |
| e.currentTarget.removeEventListener("unload", handleSWFUnloaded); |
| |
| dispatchEvent(new FlexEvent("SWFUnloaded")); |
| |
| } |
| |
| public function init():void |
| |
| { |
| |
| contentLoader.addEventListener("complete",handleSWFLoaded); |
| |
| contentLoader.addEventListener("unload",handleSWFUnloaded); |
| |
| contentLoader.addEventListener("ioError",handleSWFLoadedError); |
| |
| contentLoader.addEventListener("securityError",handleSWFLoadedError); |
| |
| contentLoader.load("assets/SubApp2.swf"); |
| |
| } |
| |
| ]]> |
| |
| </fx:Script> |
| |
| |
| |
| <s:Label text="Module4" /> |
| |
| <mx:Panel id="myPanel" title="SubApp2 Loaded by module"> |
| |
| <mx:SWFLoader id="contentLoader" /> |
| |
| |
| |
| <s:Button id="btn1" label="load content" click="contentLoader.load('assets/SubApp2.swf');"/> |
| |
| </mx:Panel> |
| |
| |
| |
| </s:Module> |
| |