2011-03-04 29 views
0

我需要顯示一個模式確認對話框,選擇yes no按鈕,並獲得用戶在ActionScript 3中點擊的結果。Actionscript 3消息框?

ok保存diaglog不會在退出被調用時退出應用程序。

Alert.show("Do you realy want to delete", "My Title", 3,null, 
     function alertClickHandler(event:CloseEvent):void 
     { 
       if (event.detail==Alert.YES) 
       { 
       canvas.save();  // does not popup when next line is present       
       exit(); 

       } 
     }); 

阿卜杜勒哈利克

+0

爲什麼要使用退出()?取下它 – 2011-03-04 09:07:32

+0

我需要在圖像保存後分機不應該如何保存和退出功能假設工作。 – 2011-03-04 09:14:52

+0

對不起,但真的很難理解你。那麼,現在有什麼問題?你想讓你的應用退出嗎? – 2011-03-04 09:20:34

回答

2

ActionScript中的呼叫有時異步的。

特別呼籲文件保存和所有。

什麼你應該做的是:

Alert.show("Do you realy want to delete", "My Title", 3,null, 
     function alertClickHandler(event:CloseEvent):void 
     { 
       if (event.detail==Alert.YES) 
       { 
       canvas.save(true);  // does not popup when next line is present       
       exit(); 

       } 
     }); 

修改保存功能如下:

public function save(exitAfterSave:boolean):void 
{ 
    //do whatever you need to do to save the file 
    if(exitAfterSave) 
    exit(); 
} 
3

這是一個警告框的例子:

Alert.show("Do you realy want to delete", "My Title", 3,null, 
     function alertClickHandler(event:CloseEvent):void 
     { 
         if (event.detail==Alert.YES) 
         { 
           //do stuff if clicked yes  
         } 
     }); 
+0

Adnan我已經編輯了包括你的答案的問題,但是當exit()被稱爲應用程序剛剛存在時,顯示對話框不顯示。 – 2011-03-04 08:25:43