效果图:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" pageTitle="警告窗口示例"
applicationComplete="initFn()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.CloseEvent;
// 图标:
[Bindable]
[Embed(source="src/img/jiafm.gif")]
protected var _iconWarning:Class;
protected function initFn():void{
// 警告窗口变量:
var alert:Alert;
// 修饰警告窗口:
Alert.buttonWidth = 80;
Alert.okLabel = "确认";
Alert.yesLabel = "是的";
Alert.noLabel = "不是";
Alert.cancelLabel = "取消";
// 示例化警告窗口:
alert = Alert.show("修饰警告窗口显示!", "警告窗口示例", Alert.OK|Alert.YES|Alert.NO|Alert.CANCEL,
this, onAlertClose, _iconWarning, Alert.YES);
// 像操作标准弹出式窗口一样操作警告窗口;
alert.height = 230; // 高度;
alert.width = 450; // 宽度;
// 恢复属性值:
Alert.okLabel = "OK";
Alert.yesLabel = "Yes";
Alert.noLabel = "No";
Alert.cancelLabel = "Cancel";
}
protected function onAlertClose(event:CloseEvent):void{
trace("=>警告窗口关闭回调函数!");
switch (event.detail) {
case Alert.YES:
trace(Alert.YES);
break;
case Alert.NO:
trace(Alert.NO);
break;
case Alert.OK:
trace(Alert.OK);
break;
case Alert.CANCEL:
trace(Alert.CANCEL);
break;
}
}
]]>
</fx:Script>
</s:Application>