我使用从不同MXML文件加载的弹出窗口:
private function showAddPopUp():void{
addPopUP = PopUpManager.createPopUp(this, add_popup, true);
PopUpManager.centerPopUp(addPopUP);
}
该文件如下(add_popus.mxml):
<mx:VBox width="100%" height="100%" paddingLeft="5" paddingTop="5" paddingRight="5" paddingBottom="5">
<mx:Label text="Enter name of the source:" />
<mx:TextInput width="100%" id="textName" />
<mx:Label text="Enter URL for the source:" />
<mx:TextInput width="100%" id="textURL" />
<mx:HBox width="100%">
<mx:Button label="OK" id="buttonOK" textAlign="center"/>
<mx:Button label="Cancel" id="buttonCancel" click="PopUpManager.removePopUp(this)" textAlign="center"/>
</mx:HBox>
</mx:VBox>
问题是我不知道在弹出窗口中点击buttonOK后如何将文本输入中的文本值传递给主要组件。我尝试过自定义事件,但它没有用。文档不是很有帮助。我会很感激任何想法。
答案 0 :(得分:1)
点击按钮
发送事件<!-- AddPopUp.mxml -->
<mx:Button label="OK" id="buttonOK" textAlign="center"
click="dispatchEvent(new Event(POPUP_DONE))"/>
<mx:Script>
<![CDATA[
public static const POPUP_DONE:String = "popupDone";
]]>
</mx:Script>
在另一堂课听。 event.target
将为您提供弹出窗口的句柄。
private function showAddPopUp():void
{
var addPopUp:AddPopup = PopUpManager.createPopUp(this, add_popup, true);
addPopUp.addEventListener(AddPopUp.POPUP_DONE, onPopupDone);
PopUpManager.centerPopUp(addPopUP);
}
private function onPopupDone(e:Event):void
{
var popup:AddPopUp = AddPopUp(e.target);
trace(popup.textName.text);
}