1 import flash.display.Sprite;
2 import flash.display.DisplayObject;
3 import flash.events.*;
4 stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
5 stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
6
7 var ddd:Array=new Array();
8 ddd=[0,0,0,0];
9
10 function keyDownHandler(event:KeyboardEvent):void {
11 switch (event.keyCode) {
12 case 37 :
13 ddd[0]=1;
14 break;
15 case 38 :
16 ddd[1]=1;
17 break;
18 case 39 :
19 ddd[2]=1;
20 break;
21 case 40 :
22 ddd[3]=1;
23 break;
24 }
25 ax.text=ddd.toString();
26 myKeyDownTest(ddd.join(""));
27 }
28
29 function keyUpHandler(event:KeyboardEvent):void {
30 switch (event.keyCode) {
31 case 37 :
32 ddd[0]=0;
33 break;
34 case 38 :
35 ddd[1]=0;
36 break;
37 case 39 :
38 ddd[2]=0;
39 break;
40 case 40 :
41 ddd[3]=0;
42 break;
43 }
44 ax.text=ddd.toString();
45 myKeyDownTest(ddd.join(""));
46 }
47
48 function myKeyDownTest(k:String) {
49 switch (k) {
50 case "0110" :
51 ax.text = " 上+右";
52 break;
53 case "1100" :
54 ax.text = " 上+左";
55 break;
56 case "0011" :
57 ax.text = " 下+右";
58 break;
59 case "1001" :
60 ax.text = " 下+左";
61 break;
62 case "1010" :
63 ax.text = " 左+右";
64 break;
65 case "0101" :
66 ax.text = " 上+下";
67 break;
68 case "1000" :
69 ax.text = " 左";
70 break;
71 case "0100" :
72 ax.text = " 上";
73 break;
74 case "0010" :
75 ax.text = " 右";
76 break;
77 case "0001" :
78 ax.text = " 下";
79 break;
80 }
81 }
2 import flash.display.DisplayObject;
3 import flash.events.*;
4 stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
5 stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
6
7 var ddd:Array=new Array();
8 ddd=[0,0,0,0];
9
10 function keyDownHandler(event:KeyboardEvent):void {
11 switch (event.keyCode) {
12 case 37 :
13 ddd[0]=1;
14 break;
15 case 38 :
16 ddd[1]=1;
17 break;
18 case 39 :
19 ddd[2]=1;
20 break;
21 case 40 :
22 ddd[3]=1;
23 break;
24 }
25 ax.text=ddd.toString();
26 myKeyDownTest(ddd.join(""));
27 }
28
29 function keyUpHandler(event:KeyboardEvent):void {
30 switch (event.keyCode) {
31 case 37 :
32 ddd[0]=0;
33 break;
34 case 38 :
35 ddd[1]=0;
36 break;
37 case 39 :
38 ddd[2]=0;
39 break;
40 case 40 :
41 ddd[3]=0;
42 break;
43 }
44 ax.text=ddd.toString();
45 myKeyDownTest(ddd.join(""));
46 }
47
48 function myKeyDownTest(k:String) {
49 switch (k) {
50 case "0110" :
51 ax.text = " 上+右";
52 break;
53 case "1100" :
54 ax.text = " 上+左";
55 break;
56 case "0011" :
57 ax.text = " 下+右";
58 break;
59 case "1001" :
60 ax.text = " 下+左";
61 break;
62 case "1010" :
63 ax.text = " 左+右";
64 break;
65 case "0101" :
66 ax.text = " 上+下";
67 break;
68 case "1000" :
69 ax.text = " 左";
70 break;
71 case "0100" :
72 ax.text = " 上";
73 break;
74 case "0010" :
75 ax.text = " 右";
76 break;
77 case "0001" :
78 ax.text = " 下";
79 break;
80 }
81 }