[Flex]設置Alert的響應等待時間
1
<?xml version="1.0" encoding="utf-8"?>
2
<!-- http://blog.flexexamples.com/2008/10/17/disabling-an-alert-control-in-flex/ -->
3
<mx:Application name="Alert_enabled_test"
4
xmlns:mx="http://www.adobe.com/2006/mxml"
5
layout="vertical"
6
verticalAlign="middle"
7
backgroundColor="white">
8
9
<mx:Script>
10
<
16
private const ENABLE_DELAY:uint = 3000; // 3 秒
17
private var a:Alert;
18
19
private function showAlert():void {
20
a = Alert.show("You have been logged out.", "Goodbye");
21
toggleButtons(a, false);
22
setTimeout(enableAlert, ENABLE_DELAY, a);
23
}
24
25
private function enableAlert(target:Alert):void {
26
toggleButtons(target, true);
27
}
28
29
private function toggleButtons(target:Alert, isEnabled:Boolean):void {
30
var buttonArr:Array = target.mx_internal::alertForm.mx_internal::buttons;
31
var btn:Button;
32
for each (btn in buttonArr) {
33
btn.enabled = isEnabled;
34
}
35
}
36
]]>
37
</mx:Script>
38
39
<mx:Button id="button"
40
label="Logout"
41
click="showAlert();" />
42
43
</mx:Application>

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

35

36

37

38

39

40

41

42

43

效果如下:
posted on 2008-10-28 00:21 孤影 閱讀(1465) 評論(1) 編輯 收藏 所屬分類: Flex