1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| package {
import flash.display.*;
import flash.events.*;
public class moveCar extends MovieClip {
private var fg,fd,fh:Boolean;
public function moveCar() {
var voiture:CAR = new CAR();
voiture.x = 200;
voiture.y = 200;
addChild(voiture);
addEventListener(Event.ENTER_FRAME, movingCar);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keydown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyup);
}
public function keydown (event:KeyboardEvent) {
if(event.keyCode == 37)
fg = true;
else if (event.keyCode == 39)
fd = true;
else if (event.keyCode == 38)
fh = true;
}
public function keyup (event:KeyboardEvent) {
if(event.keyCode == 37)
fg = false;
else if (event.keyCode == 39)
fd = false;
else if (event.keyCode == 38)
fh = false;
}
public function movingCar(event:Event) {
if(fg)
voiture.rotation -= 5;
else if(fd)
voiture.rotation += 5;
else if(fh)
moveavant();
}
public function moveavant() {
}
}
} |
Partager