[旧文存档]Flex: Alert 使用总结 Using Alert in Flex

Categories: Flex; Tagged with: ; @ August 29th, 2010 18:17

1. 通过Alert强制用户选择.

2. 使用一个方法 Handle多个Alert.

 
 
// 弹出Alert
			Alert.show(RM.getString(BUNDLE_ONLINE_TEST, "olt.attempt.warn.remove"), RM.getString(BUNDLE_ONLINE_TEST, "olt.confirm.title"),
				Alert.YES|Alert.CANCEL, null, onAlertClose).data = "remove";
//----------------------统一响应---------------------------------
 
	// onWarning Close
	private function onAlertClose(e:CloseEvent):void {
		if((e.target as Alert).data == "remove") {
			if(e.detail == Alert.YES) {
			...
			}else {
				// do nothing
			}
		}else if((e.target as Alert).data == ALERT_ATTEMPT) {
			if(e.detail == Alert.YES) {
				...
			}
		}else if((e.target as Alert).data == ALERT_GO_ON_ATTEMPT) {
			if(e.detail == Alert.YES) {
				...
			}
		}else {
			throw new Error("无法识别的Alert关闭类型: " + e.toString());
		}
	}

Flex中使用Alert提示用户选择 Use Alert in Flex

Categories: Flex; Tagged with: ; @ October 12th, 2008 12:02

在日常应用中,经常需要弹出一个Alert,提示用户进行选择. 如删除文件时提示用户是否确定删除,然后根据用户选择进行下一步操作:

应用举例:

AS代码:

		import mx.controls.Text;
		import mx.events.CloseEvent;
		import mx.controls.Alert;
		private function popAlert():void{
			Alert.yesLabel = "是";
			Alert.noLabel = "否";
			
			Alert.show("请选择是或者否","选择对话框",Alert.YES|Alert.NO,
			this,clickselectHandler,null,1);
		}
		
		private function clickselectHandler(event:CloseEvent):void{
			if (event.detail==Alert.YES){
			displaySelect_txt.text="选择了是";}
			else{
			
			displaySelect_txt.text="选择了否";}
		}

在MXML中使用上面的代码:

	
	

效果:

image image



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.