2011-03-04 82 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