package { import flash.display.MovieClip; import flash.events.*; import flash.ui.Keyboard; public class Game extends MovieClip { public var playerone:MovieClip = new MovieClip; public function Game() { stage.focus = this; playerone.graphics.beginFill(0xffffff); playerone.graphics.drawRect(0,0,20,100); playerone.x = 10; playerone.y = 140; stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyboardDown); addChild(playerone); } public function onKeyboardDown(event:KeyboardEvent):void { if (event.keyCode == Keyboard.UP) { if (playerone.y > 0) { playerone.y -= 5; } } else if (event.keyCode == Keyboard.DOWN) { if (playerone.y < 300) { playerone.y +=5; } } } } }