Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flash.events.KeyboardEvent;
- stage.addEventListener(KeyboardEvent.KEY_DOWN, motion);
- stage.addEventListener(KeyboardEvent.KEY_DOWN, motion2);
- function motion(event:KeyboardEvent):void
- {
- if (event.keyCode == Keyboard.LEFT)
- {
- car.x-=10;
- }
- if (car.x<=50)
- {
- stage.addEventListener(KeyboardEvent.KEY_DOWN, motion2);
- }
- }
- function motion2(event:KeyboardEvent):void
- {
- if (car.x<=50)
- {
- car.scaleX*=-1;
- car.x+=15;
- car.y+=50;
- stage.removeEventListener(KeyboardEvent.KEY_DOWN, motion);
- stage.addEventListener(KeyboardEvent.KEY_DOWN, motion3);
- }
- }
- function motion3(event:KeyboardEvent):void
- {
- if (event.keyCode == Keyboard.RIGHT)
- {
- car.x+=10;
- }
- if (car.x>=500)
- {
- car.scaleX*=-1;
- car.x-=15;
- car.y-=50;
- stage.removeEventListener(KeyboardEvent.KEY_DOWN, motion2);
- stage.addEventListener(KeyboardEvent.KEY_DOWN, motion);
- stage.removeEventListener(KeyboardEvent.KEY_DOWN, motion3);
- }
- }
Add Comment
Please, Sign In to add comment