<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Style>
Alert{
fontSize:12pt;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.CloseEvent;
//用于显示位于 Alert 控件中文本左侧的图标
[Embed(source="p.png")]
private var iconContent:Class;
//用于显示标题左侧的图标
[Embed(source="p.png")]
private var icontitle:Class;
private var alert:Alert;
private function popAlert():void{
//Alert对话框的按钮有Alert.YES|Alert.NO|Alert.OK|Alert.CANCEL
Alert.yesLabel="是";
Alert.noLabel="否";
Alert.cancelLabel="取消";
Alert.okLabel="确定";
//显示对话框
alert=Alert.show("显示的内容","对话框标题",Alert.YES|Alert.NO,this,clickSelectHandler,iconContent,1);
//显示标题图标
alert.titleIcon=icontitle;
}
private function clickSelectHandler(e:CloseEvent):void{
if(e.detail==Alert.YES){
//点击了是按钮
}else if (e.detail==Alert.NO){
//点击了否按钮
}
}
]]>
</mx:Script>
<mx:Button x="278"
y="103"
label="弹出窗口"
id="btn"
click="popAlert()"/>
</mx:Application>
Alert显示对话框的完整使用实例
最新推荐文章于 2021-06-08 19:59:57 发布