import CYPL.Game.Key;
var box:Sprite;
with (box=Sprite(addChild(new Sprite))) {
graphics.beginFill(0xff0000);
graphics.drawRect(100,100,100,100);
}
Key.init(stage,keyTestHandler);
function keyTestHandler(e:Event) {
if (Key.isDown(Keyboard.LEFT)) {
box.x-=5;
}
if (Key.isDown(Keyboard.RIGHT)) {
box.x+=5;
}
if (Key.isDown(Keyboard.DOWN)) {
box.y+=5;
}
if (Key.isDown(Keyboard.UP)) {
box.y-=5;
}
}
附件下载:key.rar