flash 移动问题,(定重谢)

来源:百度知道 编辑:UC知道 时间:2024/07/04 12:52:14
我在FLASH里做个一个MC ,之后我不知道在那里添加代码,和添加什么代码?

目的,按键盘上的"上""下""左""右",这个MC就移动.

定重谢

在舞台上写一个MC,设置它的实例名为 car_mc

然后在第一帧写上下列代码

car_mc.onEnterFrame = function() {
if (Key.isDown(Key.DOWN)) {
this._y += 10;
} else if (Key.isDown(Key.UP)) {
this._y -= 10;
} else if (Key.isDown(Key.LEFT)) {
this._x -= 10;
} else if (Key.isDown(Key.RIGHT)) {
this._x += 10;
}
};

就可以了