FLEX 如何跳出警告对话框 Alert

Posted on by hubertfc

參數大約下:
Alert.show(text,title,flags,parent,eventHandler,iconClass,defaultButtonFlag)

參數詳細說明:

text:Alert要秀出來的文字
title:彈出視窗的title
flags:彈出視窗中要顯現的按鈕,目前有 Alert.OK, Alert.CANCEL, Alert.YES, Alert.NO四種按鈕,Default是Alert.OK
parent:呼叫Alert的物件,通常為this
closeHandle:eventHandler的名稱,不需要加”"
iconClass:Alert要秀出的圖檔
defaultButtonFlag:可以為Alert.OK, Alert.CANCEL, Alert.YES, Alert.NO四種按鈕,Default是Alert.OK,主要目的是弱視窗彈出後直接按enter會按到哪個按鈕

簡例:

Alert.show(“Do you want to save your changes?”, “Save Changes”, Alert.OK|Alert.CANCEL|Alert.YES, this, alertClickHandler);

<xml version="1.0"?>
<!-- controls\alert\AlertEvent.mxml -->
<xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
        CDATA[
            import mx.controls.Alert;
            import mx.events.CloseEvent;

            private function alertListener(eventObj:CloseEvent):void {
                // Check to see if the OK button was pressed.
                if (eventObj.detail==Alert.OK) {
                    myText.text = myInput.text;
                }
            }
        ]]>
    </fx:Script>
   
    <s:VGroup>
       < TextInput id="myInput" width="150"  text="" />
        <s:Button id="myButton"  label="Copy Text"
click='Alert.show("Copy Text?", "Alert",  Alert.OK | Alert.CANCEL, this, alertListener, null, Alert.OK);'/>
        <TextInput id="myText"/>
    </s:VGroup>
</s:Application>

參考網址:http://livedocs.adobe.com/flex/3/langref/mx/controls/Alert.html#show()

原文地址:https://www.cnblogs.com/zcy_soft/p/1964999.html