我是一个完整的 Flex/Flash 菜鸟,正在运行 Adobe Flash Builder 4 Beta 2。我有一个主要组件需要能够调用多个弹出窗口,除了一个功能和几个标签之外,每个都几乎相同。显然,我更希望能够在调用弹出窗口时定义此函数并更改这些标签,而不是拥有大量具有几乎相同代码的 .mxml 文件,我只是不知道该怎么做。我想出了如何更改标签,但不确定如何重新定义功能。
为简单起见,假设我的代码如下所示:
主.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" :s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.managers.PopUpManager;
protected function init():void
{
var alertWindow:IFlexDisplayObject = PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, popup, true);
PopUpManager.centerPopUp(alertWindow);
var popInstance:transmitRoundPop = alertWindow as transmitRoundPop;
popInstance.btnTest.label = "NEW";
}
]]>
</fx:Script>
</mx:Module>
弹出.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" width="400" height="300" xmlns:flash="services.flash.*">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.managers.PopUpManager;
public function test():void
{
Alert.show("ORIGINAL");
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
<s:Panel x="10" y="10" width="380" height="280" title="Test" id="pnlTest">
<s:Button x="131" y="104" label="OLD" id="btnTest" click="test()"/>
</s:Panel>
</s:Group>
现在说我想test()
在 main.mxml 中调用它时更改 popup.mxml ......我该怎么做?请提供详细信息...记住我是菜鸟:-)