小球上下左右移动

 stage.addEventListener(KeyboardEvent.KEY_DOWN,yuan); 
function yuan(e:KeyboardEvent):void { 
    switch (e.keyCode) { 
        case 37 : 
            //mc.x-=10;  x-=10等于下面的式子mc.x=duo_mc.x-10; 
            mc.x=mc.x-10; 
            break; 
        case 38 : 
            //mc.y-=10; y-=10等于下面的式子mc.y=duo_mc.y-10; 
            mc.y=mc.y-10; 
            break; 
        case 39 : 
            //mc.x+=10;  x+=10等于下面的式子mc.x=duo_mc.x+10; 
            mc.x=mc.x+10; 
            break; 
        case 40 : 
            //mc.y+=10;  y+=10等于下面的式子mc.y=duo_mc.y+10; 
            mc.y=mc.y+10; 
            break; 
    } 
}

 

posted @ 2010-11-05 14:35  sinsoul  阅读(282)  评论(0编辑  收藏  举报