Flex 4.11和AS3:使用MDIWindow从外部SWF访问MainApp.swf和MDICanvas

时间:2014-02-12 19:18:59

标签: actionscript-3 flex

我正在使用FlexLib 2.5(MDICanvas和MDIWindow)

现在,我有MainApp.swf加载MyPage.swf。这很好。

<?xml version="1.0" encoding="utf-8"?>
<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:flexlib="http://code.google.com/p/flexlib/"
               creationComplete="creationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;
            import mx.managers.PopUpManager;
            import mx.managers.SystemManager;

            import spark.components.Alert;

            [Bindable]
            private var extSM:SystemManager;

            private var _externalSwfLoaded:Boolean;

            [Bindable]
            public function get externalSwfLoaded():Boolean
            {
                return _externalSwfLoaded;
            }

            public function set externalSwfLoaded(value:Boolean):void
            {
                _externalSwfLoaded = value;
            }

            protected function creationCompleteHandler(event:FlexEvent):void
            {
                var context:LoaderContext = new LoaderContext();
                context.applicationDomain = ApplicationDomain.currentDomain;
                loader.loaderContext = context;
                loader.load("MyPage.swf");
            }

            protected function loaderCompleteHandler(event:Event):void
            {
                extSM = loader.content as SystemManager;
                //    Set the swf loaded flag if you have the SystemManager
                if (extSM)
                    externalSwfLoaded = true;

            }

            protected function loaderIoErrorHandler(event:IOErrorEvent):void
            {
                trace(event.toString());
                Alert.show(event.type + ":" + event.text, "IO error occured");

            }

            protected function openPropreties(event:MouseEvent):void
            {
                Object(extSM.application).openPropretiesWin();
                canvas.windowManager.add(Object(extSM.application).openPropretiesWindow);
            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Platzieren Sie nichtvisuelle Elemente (z. B. Dienste, Wertobjekte) hier -->
    </fx:Declarations>
    <s:SWFLoader id="loader" left="0" top="0" bottom="40" width="100%"
                 complete="loaderCompleteHandler(event)" ioError="loaderIoErrorHandler(event)"
                 trustContent="true"/>
    <s:Button left="150" bottom="10" label="Open Propreties" click="openPropreties(event)"/>
    <flexlib:MDICanvas id="canvas" left="0" right="0" top="0" bottom="39">
    </flexlib:MDICanvas>
</s:Application>

这是MyPage.swf:

<?xml version="1.0" encoding="utf-8"?>
<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"
               backgroundAlpha="0" creationComplete="initApp(event)">
    <fx:Script>
        <![CDATA[
            import flexlib.mdi.containers.MDIWindow;

            import mx.events.FlexEvent;

            [Bindable]
            public var openPropretiesWindow:MDIWindow;

            public function openPropretiesWin():void
            {
                openPropretiesWindow = new MDIWindow;
                openPropretiesWindow.width = 300;
                openPropretiesWindow.height = 400;
                openPropretiesWindow.title = "Propreties";
            }

            protected function initApp(event:FlexEvent):void
            {
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Platzieren Sie nichtvisuelle Elemente (z. B. Dienste, Wertobjekte) hier -->
    </fx:Declarations>
</s:Application>

如果我运行该应用程序,它可以正常工作。 :)

有什么建议吗?加载多个外部swf文件的改进?在从swfLoader打开的多个flash应用程序中,就像操作系统加载桌面应用程序一样?

我如何知道loader.load("path-to-swf);的数组是否应该从任何swf文件中选择(带有完整MDIWindow的Flash应用程序)。

当我创建calcApp.swf(这是一个Calc应用程序)并且我创建任何应用程序为“filename.swf”...

MainApp.swf是桌面 CalcApp.swf是外部swf(它是MDIWindow Calc App) FileManagerApp.swf是外部swf(MDIWindow文件管理器应用程序,如Explorer或Finder等)。

但我不知道如何将多个swf文件加载到一个加载器中。我会使用数组或实例吗?

我想展示图片: Image 1:

Image 2: Image 3:

他们是swfs:

Image 4:

PS:抱歉语言是德语,来自我的最新图片。

感谢您的支持并让我了解好主意:)

最诚挚的问候,来自德国,Jens

0 个答案:

没有答案