我已經用Winforms和WPF做了很多C#編程。我正在爲Flex/Air應用程序開發跨平臺支持。但這是我的第一個靈活項目,所以我正在學習。Flex:彈出窗口 - 獲取[ok]或[取消]
我有一個窗口,我想彈出,用戶將填寫表單,然後點擊確定或取消。我將它設置爲與C#中的方式相同,但它不起作用,並且我無法真正地找到一種方法使其按照我想要的方式工作。
編輯: 所以我想現在的事件,這些事件似乎只是沒有被處理......再次
編輯: 哦,那是因爲在彈出的經理似乎創造的新實例Form對象,而不是使用我已經創建的那個。
所以在的ShowWindow方法,我把這個代碼,而不是彈出經理:
parent.addChild(this);
然後我刪除它,當我關閉它。唯一的問題是,它不會像彈出式管理器那樣禁用父級的其餘部分。對此有何建議?
家長:
private function btnAdd_Clicked():void
{
var form:Form = new Form();
form.addEventListener(CloseEvent.CLOSE, onFormClosed, false, 0, true);
recipeForm.showWindow(this);
}
private function onFormClosed(e:CloseEvent):void
{
//none of these Alerts are ever shown. I also tried breakpoints in debug to try an follow the code, with no luck
Alert.show("Closed");
if(e.detail == Alert.OK)
{
Alert.show("OK");
}
else if(e.detail == Alert.CANCEL)
{
Alert.show("Cancel");
}
}
子:
private function btnCancel_Clicked():void
{
okClicked = false;
closeWindow();
}
public function closeWindow():void
{
var e:CloseEvent = new CloseEvent(CloseEvent.CLOSE);
e.detail = okClicked ? Alert.OK : Alert.CANCEL;
dispatchEvent(e);
PopUpManager.removePopUp(this);
}
public function showWindow(parent:WindowedApplication):void
{
var window:IFlexDisplayObject = PopUpManager.createPopUp(parent, RecipeForm, true);
PopUpManager.centerPopUp(window);
}
這似乎是它應該工作,但事件似乎並不需要處理...... 孩子: 公共職能closeWindow():無效 { \t變種E:=的closeEvent新的closeEvent(的closeEvent。關); \t e.detail = okClicked? Alert.OK:Alert.CANCEL; (e); \t dispatchEvent(e); \t \t PopUpManager.removePopUp(this); } 父: 私有函數btnAddRecipe_Clicked():無效 {\t \t \t \t \t VAR recipeForm:RecipeForm =新RecipeForm(); \t recipeForm.addEventListener(CloseEvent.CLOSE,onRecipeFormClosed,false,0,true); \t \t recipeForm.showWindow(this); } 私有函數onRecipeFormClosed(E:的closeEvent):無效 {// 永遠不會送過來...:/ } – Joel 2009-05-23 05:43:04