



CODE:
[Copy to clipboard]
onClipEvent (keyDown) {
//定义速度
var v = 2;
if (Key.isDown(Key.LEFT)) {
if (this._currentframe != "Left") {
this.gotoAndStop("Left");
}
this._x -= v;
}
if (Key.isDown(Key.RIGHT)) {
if (this._currentframe != "Right") {
this.gotoAndStop("Right");
}
this._x += v;
}
if (Key.isDown(Key.DOWN)) {
if (this._currentframe != "Down") {
this.gotoAndStop("Down");
}
this._y += v;
}
if (Key.isDown(Key.UP)) {
if (this._currentframe != "Up") {
this.gotoAndStop("Up");
}
this._y -= v;
}
}
onClipEvent (keyUp) {
if (Key.getCode() == 38) {
this.gotoAndStop("UP2");
}
if (Key.getCode() == 39) {
this.gotoAndStop("RIGHT2");
}
if (Key.getCode() == 40) {
this.gotoAndStop("DOWN2");
}
if (Key.getCode() == 37) {
this.gotoAndStop("LEFT2");
}
}
