首页 > AIR/RIA > Flex Alert 组件结果处理实例

Flex Alert 组件结果处理实例

在使用Alert组件的时候,如何处理Alert提示框之后的CloseEvent呢?在这里提供了一种有别于官方已有样例的方案,例子如下:
其中有两点值得注意:一,通过evt.target可以获取当前点击组件的ID;二,CloseEvent的属性detail可以识别用户点击的按钮为yes or no^_^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!--l version="1.0" encoding="utf-8-->
 
		Application
		{
			background-color:#FFFFFF;
			theme-color:#FFFFFF;
			font-family:"MS YaHei";
			font-size:12;
		}
 
		<![CDATA[
			import mx.events.CloseEvent;
			import mx.controls.Alert;
			public var temp_btn=new Button();
 
			private function clickHandler(evt:MouseEvent):void
			{
				temp_btn=Button(evt.target);
				if (temp_btn.label == "点一点")
				{
					Alert.yesLabel="是呀";
					Alert.noLabel="不了";
					Alert.show("确实要点我吗?", "提示", 3, this, alertHandler);
				}
			}
 
			private function alertHandler(evt:CloseEvent):void
			{
				if (evt.detail == Alert.YES)
				{
					temp_btn.label="别点我了!^_^"
				}
			}
		]]>

附上例子的运行结果:

欢迎转载,转载请注明来源和作者,谢谢!

评论暂缺

  • (Required)
  • (Required, will not be published)

Verify Code   If you cannot see the CheckCode image,please refresh the page again!