Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Code
- {
- import flash.display.MovieClip;
- import flash.display.Stage;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import flash.events.KeyboardEvent;
- import flash.ui.Keyboard;
- import flash.ui.Mouse;
- import flash.ui.KeyLocation;
- import flash.media.Sound;
- import flash.net.URLRequest;
- import flash.media.SoundLoaderContext;
- import flash.media.SoundChannel;
- public class Engine extends MovieClip
- {
- public var backGround:B1 = new B1();
- public var Crosshair:Cursor = new Cursor();
- public var SS:spaceStation = new spaceStation();
- public var intromusic:Sound = new Sound();
- public var shift:Number = .1; // movement of the background
- public static var enemyList:Array = new Array;
- public function Engine()
- {
- // constructor code
- addChild(backGround);
- backGround.x = -617;
- backGround.addEventListener(Event.ENTER_FRAME, moving);
- addChild(SS);
- SS.scaleX = 0.35;
- SS.scaleY = 0.35;
- SS.x = 400;
- SS.y = 50;
- addEventListener(Event.ENTER_FRAME, loop);
- Mouse.hide();
- addChild(Crosshair);
- addEventListener(MouseEvent.CLICK, shot1);
- addEventListener(MouseEvent.CLICK, fire1);
- addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
- intromusic.load(new URLRequest("Trancesaur.mp3"));
- intromusic.play(0, int.MAX_VALUE);
- function moving(e:Event):void
- {
- if (backGround.x > 0)
- {
- backGround.x = -617;
- }
- backGround.x = backGround.x + shift;
- }
- function intromusic (e:Event):void
- {
- intromusic.load(new URLRequest("Trancesaur.mp3"));
- intromusic.play(0, int.MAX_VALUE);
- }
- function loop(e:Event):void
- {
- if (Math.floor(Math.random() * 90) == 5)
- {
- var enemy:Enemy = new Enemy(stage, SS);
- enemy.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy, false, 0, true);
- enemyList.push(enemy);
- stage.addChild(enemy);
- }
- }
- function removeEnemy(e:Event)
- {
- enemyList.splice(enemyList.indexOf(e.currentTarget), 1);
- }
- function dragCursor(e:MouseEvent):void
- {
- Crosshair.x = mouseX;
- Crosshair.y = mouseY;
- }
- function fire1(e:MouseEvent):void
- {
- Crosshair.play();
- trace("bang");
- }
- function shot1(e:MouseEvent):void
- {
- var music2:Sound;
- music2 = new Sound();
- music2.load(new URLRequest("sniper1.mp3"));
- music2.play();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment