0

我是 flex 新手,我正在尝试在新窗口模式中打开模块。我已经设法在容器( vbox )中加载和添加模块,但我真正需要的是在单独的窗口中打开它们。我能找到的所有帖子都是关于如何加载模块的示例,但没有关于如何显示它们的示例。我在这里找到了一个帖子 Modules and Panels issue ,它通过屏幕截图看起来正是我正在寻找的。

谢谢你的帮助。

4

1 回答 1

0

我找到了一种方法。感谢所有的指点

这就是我是如何做到的,供大家查看和使用。如果您有改进的建议,请随时发表评论。

我正在使用一个组件:collapsabletitlewindow

主应用程序.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication 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:components="de.aggro.components.*">
<fx:Script>
<![CDATA[

import de.aggro.components.*;

private function createWindow():void{
var w:window = new window;
w.title = "Window " + container.numChildren;
container.addChild(w);
}
]]>
</fx:Script>
<components:CollapsableTitleWindowContainer id="container" width="100%" height="100%" >
</components:CollapsableTitleWindowContainer>
<s:Button buttonDown="createWindow()" label="Create Window" />
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:WindowedApplication>

窗口.mxml

<?xml version="1.0" encoding="utf-8"?>
<components:CollapsableTitleWindow 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:components="de.aggro.components.*"     layout="absolute" width="400" height="300"
   creationComplete="initApp()" >
<fx:Script>
<![CDATA[
import mx.events.ModuleEvent;
import mx.modules.ModuleManager;
import mx.modules.IModuleInfo;        
import mx.core.IVisualElement;

public var info:IModuleInfo;

private function initApp():void {
info = ModuleManager.getModule("mod.swf");
info.addEventListener(ModuleEvent.READY, modEventHandler);           

/* Load the module into memory. Calling load() makes the
IFlexModuleFactory available. You can then get an
instance of the class using the factory's create()
method. */
info.load(null, null, null, moduleFactory);
}

/* Add an instance of the module's class to the display list. */        
private function modEventHandler(e:ModuleEvent):void {

this.addElement(info.factory.create() as IVisualElement);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

</components:CollapsableTitleWindow>

模组.mxml

<?xml version="1.0" encoding="utf-8"?>
<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">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:LinkButton x="131" y="124" label="Module link"/>
</s:Module>
于 2012-06-02T01:08:00.010 回答