package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.geom.ColorTransform;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
public class hello extends Sprite{
var sp:Sprite;
var colorInfo:ColorTransform;
public function hello() {
sp = new Sprite();
sp.graphics.beginFill(0xf00ff00);
sp.graphics.drawRect(0,0,20,20);
sp.graphics.endFill();
sp.buttonMode = false;
addChild(sp);
colorInfo = sp.transform.colorTransform;
stage.addEventListener(KeyboardEvent.KEY_DOWN,press);
}
public function press(evt:KeyboardEvent):void
{
switch(evt.keyCode)
{
case Keyboard.UP:
sp.y-=2;break;
case Keyboard.DOWN:
sp.y+=2;break;
case Keyboard.LEFT:
sp.x-=2;break;
case Keyboard.RIGHT:
sp.x+=2;break;
default:break;
}
}
}
}