利用键盘按键操控地图

下载fla文件下载swf文件 
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
35
36
37
38
39
40
41
42
43
stage.addEventListener(KeyboardEvent.KEY_DOWN,controlMap);
function controlMap(me:KeyboardEvent){
    switch(me.keyCode){
        case Keyboard.UP:
        map_mc.y -= 2;
        act_txt.text="上移";
        break;
        case Keyboard.DOWN:
        map_mc.y += 2;
        act_txt.text="下移";
        break;
        case Keyboard.LEFT:
        map_mc.x -= 2;
        act_txt.text="左移";
        break;
        case Keyboard.RIGHT:
        map_mc.x += 2;
        act_txt.text="右移";
        break;
        case Keyboard.PAGE_UP:
        map_mc.scaleX += .1;
        map_mc.scaleY += .1;
        act_txt.text="放大地圖";
        break;
        case Keyboard.PAGE_DOWN:
        map_mc.scaleX -= .1;
        map_mc.scaleY -= .1;
        act_txt.text="缩小地图";
        break;
        case Keyboard.HOME:
        map_mc.rotation += 10;
        act_txt.text="向右旋转地图";
        break;
        case Keyboard.END:
        map_mc.rotation -= 10;
        act_txt.text="向左旋转地图";
        break;
    }
    x_txt.text=String(map_mc.x);
    y_txt.text=String(map_mc.y);
    zoom_txt.text=String(Math.floor(map_mc.scaleX * 100)) + "%";
    rot_txt.text=String(map_mc.rotation) + "°";
}




posted @ 2013-01-03 14:44  thero  阅读(312)  评论(0编辑  收藏  举报