Guest User

Untitled

a guest
Oct 17th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.events.KeyboardEvent;
  2. stage.addEventListener(KeyboardEvent.KEY_DOWN, motion);
  3. stage.addEventListener(KeyboardEvent.KEY_DOWN, motion2);
  4.     function motion(event:KeyboardEvent):void
  5.     {
  6.         if (event.keyCode == Keyboard.LEFT)
  7.         {
  8.             car.x-=10;
  9.         }
  10.        
  11.         if (car.x<=50)
  12.         {
  13.             stage.addEventListener(KeyboardEvent.KEY_DOWN, motion2);
  14.         }
  15.     }
  16.    
  17.     function motion2(event:KeyboardEvent):void
  18.     {
  19.         if (car.x<=50)
  20.         {
  21.             car.scaleX*=-1;
  22.             car.x+=15;
  23.             car.y+=50;
  24.             stage.removeEventListener(KeyboardEvent.KEY_DOWN, motion);
  25.             stage.addEventListener(KeyboardEvent.KEY_DOWN, motion3);
  26.         }
  27.     }  
  28.     function motion3(event:KeyboardEvent):void
  29.     {
  30.         if (event.keyCode == Keyboard.RIGHT)
  31.         {
  32.             car.x+=10;
  33.         }
  34.        
  35.         if (car.x>=500)
  36.         {
  37.             car.scaleX*=-1;
  38.             car.x-=15;
  39.             car.y-=50;
  40.            
  41.             stage.removeEventListener(KeyboardEvent.KEY_DOWN, motion2);
  42.             stage.addEventListener(KeyboardEvent.KEY_DOWN, motion);
  43.             stage.removeEventListener(KeyboardEvent.KEY_DOWN, motion3);
  44.         }
  45.     }
Add Comment
Please, Sign In to add comment