Guest User

Untitled

a guest
Jan 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. package Code
  2. {
  3. import flash.display.MovieClip;
  4. import flash.display.Stage;
  5. import flash.events.Event;
  6. import flash.events.MouseEvent;
  7. import flash.events.KeyboardEvent;
  8. import flash.ui.Keyboard;
  9. import flash.ui.Mouse;
  10. import flash.ui.KeyLocation;
  11. import flash.media.Sound;
  12. import flash.net.URLRequest;
  13. import flash.media.SoundLoaderContext;
  14. import flash.media.SoundChannel;
  15.  
  16. public class Engine extends MovieClip
  17. {
  18. public var backGround:B1 = new B1();
  19. public var Crosshair:Cursor = new Cursor();
  20. public var SS:spaceStation = new spaceStation();
  21. public var intromusic:Sound = new Sound();
  22. public var shift:Number = .1; // movement of the background
  23. public static var enemyList:Array = new Array;
  24.  
  25. public function Engine()
  26. {
  27. // constructor code
  28. addChild(backGround);
  29. backGround.x = -617;
  30. backGround.addEventListener(Event.ENTER_FRAME, moving);
  31.  
  32. addChild(SS);
  33. SS.scaleX = 0.35;
  34. SS.scaleY = 0.35;
  35. SS.x = 400;
  36. SS.y = 50;
  37.  
  38. addEventListener(Event.ENTER_FRAME, loop);
  39. Mouse.hide();
  40. addChild(Crosshair);
  41. addEventListener(MouseEvent.CLICK, shot1);
  42. addEventListener(MouseEvent.CLICK, fire1);
  43. addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
  44.  
  45.  
  46. intromusic.load(new URLRequest("Trancesaur.mp3"));
  47. intromusic.play(0, int.MAX_VALUE);
  48.  
  49. function moving(e:Event):void
  50. {
  51. if (backGround.x > 0)
  52. {
  53. backGround.x = -617;
  54. }
  55. backGround.x = backGround.x + shift;
  56. }
  57.  
  58. function intromusic (e:Event):void
  59. {
  60. intromusic.load(new URLRequest("Trancesaur.mp3"));
  61. intromusic.play(0, int.MAX_VALUE);
  62. }
  63.  
  64. function loop(e:Event):void
  65. {
  66. if (Math.floor(Math.random() * 90) == 5)
  67. {
  68. var enemy:Enemy = new Enemy(stage, SS);
  69. enemy.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy, false, 0, true);
  70. enemyList.push(enemy);
  71. stage.addChild(enemy);
  72. }
  73. }
  74.  
  75. function removeEnemy(e:Event)
  76. {
  77. enemyList.splice(enemyList.indexOf(e.currentTarget), 1);
  78. }
  79.  
  80. function dragCursor(e:MouseEvent):void
  81. {
  82. Crosshair.x = mouseX;
  83. Crosshair.y = mouseY;
  84. }
  85.  
  86. function fire1(e:MouseEvent):void
  87. {
  88. Crosshair.play();
  89. trace("bang");
  90. }
  91.  
  92. function shot1(e:MouseEvent):void
  93. {
  94. var music2:Sound;
  95.  
  96. music2 = new Sound();
  97. music2.load(new URLRequest("sniper1.mp3"));
  98. music2.play();
  99. }
  100.  
  101. }
  102. }
  103.  
  104. }
Add Comment
Please, Sign In to add comment