ITeye博客

Alert显示对话框的完整使用实例

china34420 · 2010-08-29 12:47 · Flex · Web前端 · Markdown

<?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>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。