Section 1
//Actor (Actor)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class Actor extends EventDispatcher {
public var borderSize:int;
public var actorClip:MovieClip;
public var expired:Boolean;
protected var accurateLocation:Point;
public function Actor(_arg1:DisplayObjectContainer){
expired = false;
_arg1.addChild(actorClip);
borderSize = 30;
}
public function location():Point{
return (accurateLocation);
}
public function destroy():void{
actorClip.parent.removeChild(actorClip);
actorClip = null;
}
public function spawnChildren(_arg1:Array):void{
}
public function spawnCoin(_arg1:Array, _arg2:int):void{
}
public function eachFrame(_arg1:Number, _arg2:Number):void{
accurateLocation.x = (accurateLocation.x - _arg1);
accurateLocation.y = (accurateLocation.y - _arg2);
if (accurateLocation.x < -(borderSize)){
accurateLocation.x = (accurateLocation.x + (500 + (2 * borderSize)));
};
if (accurateLocation.y < -(borderSize)){
accurateLocation.y = (accurateLocation.y + (500 + (2 * borderSize)));
};
if (accurateLocation.x > (500 + borderSize)){
accurateLocation.x = (accurateLocation.x - (500 + (2 * borderSize)));
};
if (accurateLocation.y > (500 + borderSize)){
accurateLocation.y = (accurateLocation.y - (500 + (2 * borderSize)));
};
actorClip.x = accurateLocation.x;
actorClip.y = accurateLocation.y;
}
public function placeAtLoc(_arg1:Number, _arg2:Number):void{
accurateLocation = new Point(_arg1, _arg2);
actorClip.x = accurateLocation.x;
actorClip.y = accurateLocation.y;
}
public function placeAtScreenEdge():void{
if (Math.random() < 0.5){
accurateLocation = new Point(-(borderSize), (Math.random() * 500));
} else {
accurateLocation = new Point((Math.random() * 500), -(borderSize));
};
}
}
}//package
Section 2
//AlienShip (AlienShip)
package {
import flash.display.*;
import flash.geom.*;
public class AlienShip extends Enemy {
private var lifeCount:int;
private var soundCount:int;
private static var BULLET_VELOCITY:Number = 4;
public function AlienShip(_arg1:DisplayObjectContainer):void{
var _local3:Number;
lifeCount = Math.floor((Math.random() * 50));
soundCount = lifeCount;
actorClip = new Stealer();
super(_arg1);
var _local2:Number = (50 + (Math.random() * 400));
if (Math.random() < 0.5){
driftX = -3;
_local3 = 510;
} else {
driftX = 3;
_local3 = -10;
};
driftY = 0;
placeAtLoc(_local3, _local2);
hits = 1;
xRadius = 20;
yRadius = 10;
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
if (((lifeCount - soundCount) % 80) == 0){
SoundManager.addSound(AlienSound);
};
if ((lifeCount % 50) == 0){
if (driftY != 0){
driftY = 0;
} else {
if (Math.random() < 0.5){
driftY = (driftX / 2);
} else {
driftY = (-(driftX) / 2);
};
};
};
lifeCount++;
accurateLocation.x = (accurateLocation.x + driftX);
accurateLocation.y = (accurateLocation.y + driftY);
if (((((((accurateLocation.x - _arg1) < -30)) || (((accurateLocation.x - _arg1) > 530)))) && (((lifeCount - soundCount) > 50)))){
expired = true;
escaped = true;
};
super.eachFrame(_arg1, _arg2);
}
override public function spawnChildren(_arg1:Array):void{
if (!escaped){
SoundManager.addSound(HeroBang);
};
}
override public function checkforCollisionWithHeroShip():int{
var _local1:int;
var _local2:int = ((xRadius + 10) * (xRadius + 10));
var _local3:Number = (accurateLocation.x - 250);
var _local4:Number = ((accurateLocation.y - 250) * 1.41);
if (((_local3 * _local3) + (_local4 * _local4)) < _local2){
gotHit(50);
_local1 = 1;
};
return (_local1);
}
override public function freeToFire():Boolean{
return ((((lifeCount + 25) % 50) == 0));
}
override public function launchBullet(_arg1:Array):void{
var _local2:Number = (250 - accurateLocation.x);
var _local3:Number = (250 - accurateLocation.y);
var _local4:Number = (45 + (90 * Math.floor((Math.random() * 4))));
var _local5:Point = new Point(Math.cos(_local4), Math.sin(_local4));
_local5.normalize(BULLET_VELOCITY);
var _local6:Point = new Point((accurateLocation.x + ((_local5.x * xRadius) / BULLET_VELOCITY)), (accurateLocation.y + ((_local5.y * yRadius) / BULLET_VELOCITY)));
var _local7:Bullet = new Bullet(actorClip.parent, _local6, _local5, this);
_arg1.push(_local7);
SoundManager.addSound(LaserShoot);
}
}
}//package
Section 3
//AlienSound (AlienSound)
package {
import flash.media.*;
public dynamic class AlienSound extends Sound {
}
}//package
Section 4
//AsBang1 (AsBang1)
package {
import flash.media.*;
public dynamic class AsBang1 extends Sound {
}
}//package
Section 5
//AsBang2 (AsBang2)
package {
import flash.media.*;
public dynamic class AsBang2 extends Sound {
}
}//package
Section 6
//AsBang3 (AsBang3)
package {
import flash.media.*;
public dynamic class AsBang3 extends Sound {
}
}//package
Section 7
//Asteroid (Asteroid)
package {
import flash.display.*;
public class Asteroid extends Enemy {
private var rotSpeed:Number;
private var size:int;
private var dLevel:int;
public function Asteroid(_arg1:int, _arg2:DisplayObjectContainer, _arg3:int){
var _local5:Number;
hits = 1;
dLevel = _arg3;
size = _arg1;
actorClip = new AsteroidL();
var _local4:int = (1 + Math.floor((Math.random() * 3)));
actorClip.gotoAndStop(((_local4 + (size * 3)) - 3));
actorClip.rotation = (Math.random() * 360);
super(_arg2);
if (size == 6){
borderSize = 100;
xRadius = 100;
yRadius = 100;
};
if (size == 5){
borderSize = 60;
xRadius = 60;
yRadius = 60;
};
if (size == 4){
borderSize = 45;
xRadius = 45;
yRadius = 45;
};
if (size == 3){
xRadius = 30;
yRadius = 30;
};
if (size == 2){
xRadius = 18;
yRadius = 18;
};
if (size == 1){
xRadius = 12;
yRadius = 12;
};
rotSpeed = ((Math.random() * 2) + 1);
if (Math.random() < 0.5){
rotSpeed = -(rotSpeed);
};
_local5 = ((Math.random() * 2) * Math.PI);
var _local6:Number = (((Math.random() * 1) + 1) + (_arg3 * 0.05));
driftX = (Math.cos(_local5) * _local6);
driftY = (Math.sin(_local5) * _local6);
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
accurateLocation.x = (accurateLocation.x + driftX);
accurateLocation.y = (accurateLocation.y + driftY);
actorClip.rotation = (actorClip.rotation + rotSpeed);
super.eachFrame(_arg1, _arg2);
}
override public function spawnChildren(_arg1:Array):void{
var _local2:int;
var _local3:Asteroid;
if (size > 1){
_local2 = 0;
while (_local2 < 3) {
_local3 = new Asteroid((size - 1), actorClip.parent, dLevel);
_local3.placeAtLoc(actorClip.x, actorClip.y);
_arg1.push(_local3);
_local2++;
};
};
if (size == 1){
SoundManager.addSound(AsBang1);
};
if (size == 2){
SoundManager.addSound(AsBang2);
};
if (size >= 3){
SoundManager.addSound(AsBang3);
};
}
override public function spawnCoin(_arg1:Array, _arg2:int):void{
var _local3:Coin;
if (size == 1){
_local3 = new Coin(actorClip.parent, 10);
_local3.placeAtLoc(actorClip.x, actorClip.y);
_arg1.push(_local3);
};
}
override public function smash():void{
if (size > 1){
expired = true;
if (size == 2){
SoundManager.addSound(AsBang2);
} else {
SoundManager.addSound(AsBang3);
};
};
}
}
}//package
Section 8
//AsteroidHit (AsteroidHit)
package {
import flash.media.*;
public dynamic class AsteroidHit extends Sound {
}
}//package
Section 9
//AsteroidL (AsteroidL)
package {
import flash.display.*;
public dynamic class AsteroidL extends MovieClip {
}
}//package
Section 10
//BackgroundSprite (BackgroundSprite)
package {
import flash.display.*;
public dynamic class BackgroundSprite extends Sprite {
}
}//package
Section 11
//BeepSound (BeepSound)
package {
import flash.media.*;
public dynamic class BeepSound extends Sound {
}
}//package
Section 12
//Bullet (Bullet)
package {
import flash.display.*;
import flash.geom.*;
public class Bullet extends Actor {
private var bx:Number;
private var by:Number;
public var owner:Object;
public function Bullet(_arg1:DisplayObjectContainer, _arg2:Point, _arg3:Point, _arg4:Object){
owner = _arg4;
actorClip = new BulletClip();
placeAtLoc(_arg2.x, _arg2.y);
bx = _arg3.x;
by = _arg3.y;
super(_arg1);
if ((_arg4 is Enemy)){
actorClip.gotoAndStop(2);
} else {
actorClip.gotoAndStop(1);
};
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
accurateLocation.x = (accurateLocation.x + bx);
accurateLocation.y = (accurateLocation.y + by);
if (((((((((accurateLocation.x - _arg1) < -30)) || (((accurateLocation.y - _arg2) < -30)))) || (((accurateLocation.x - _arg1) > 530)))) || (((accurateLocation.y - _arg2) > 530)))){
expired = true;
};
super.eachFrame(_arg1, _arg2);
}
public function lastLocation():Point{
return (new Point((accurateLocation.x - bx), (accurateLocation.y - by)));
}
public function nextLocation():Point{
return (new Point((accurateLocation.x + bx), (accurateLocation.y + by)));
}
public function checkforCollisionWithHeroShip():int{
var _local1:int;
var _local2:int = (250 - accurateLocation.x);
var _local3:int = (250 - accurateLocation.y);
var _local4:int = ((_local2 * _local2) + (_local3 * _local3));
if (_local4 < 400){
expired = true;
_local1 = 1;
};
return (_local1);
}
override public function destroy():void{
owner = null;
super.destroy();
}
}
}//package
Section 13
//BulletClip (BulletClip)
package {
import flash.display.*;
public dynamic class BulletClip extends MovieClip {
}
}//package
Section 14
//CashClip (CashClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class CashClip extends MovieClip {
public var cText:TextField;
}
}//package
Section 15
//Coin (Coin)
package {
import flash.display.*;
import flash.geom.*;
public class Coin extends Actor {
private const COIN_LIFE:int = 1000;
private var duration:int;// = 0
public var value:int;
private var xv:Number;
private var yv:Number;
private static const COIN_DRAG:Number = 0.8;
private static const MAGNET_POWER:Number = 1;
public function Coin(_arg1:DisplayObjectContainer, _arg2:int):void{
duration = 0;
value = _arg2;
actorClip = new RotatingCoin();
xv = 0;
yv = 0;
if (_arg2 > 50){
actorClip.scaleX = 1.4;
actorClip.scaleY = 1.4;
};
super(_arg1);
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
duration++;
accurateLocation.x = (accurateLocation.x + xv);
accurateLocation.y = (accurateLocation.y + yv);
xv = (xv * COIN_DRAG);
yv = (yv * COIN_DRAG);
if (duration == Math.floor((COIN_LIFE * 0.8))){
actorClip.alpha = 0.5;
};
if (duration > COIN_LIFE){
expired = true;
};
super.eachFrame(_arg1, _arg2);
}
public function checkforCollisionWithHeroShip(_arg1:int):int{
var _local6:Point;
var _local2:int;
var _local3:int = (250 - accurateLocation.x);
var _local4:int = (250 - accurateLocation.y);
var _local5:int = ((_local3 * _local3) + (_local4 * _local4));
if (_local5 < 400){
expired = true;
_local2 = value;
SoundManager.addSound(GrabCoin);
} else {
if (_local5 < (_arg1 * _arg1)){
_local6 = new Point(_local3, _local4);
_local6.normalize(MAGNET_POWER);
xv = (xv + _local6.x);
yv = (yv + _local6.y);
};
};
return (_local2);
}
}
}//package
Section 16
//CollisionManager (CollisionManager)
package {
import flash.geom.*;
public class CollisionManager {
public static function checkIntersection(_arg1:Bullet, _arg2:Enemy):void{
var _local3:Point;
var _local4:Point;
var _local5:Point;
var _local6:Point;
if (((!(_arg1.expired)) && (!(_arg2.expired)))){
_local3 = _arg1.lastLocation().subtract(_arg2.location());
_local4 = _arg1.location().subtract(_arg2.location());
_local5 = new Point((_local3.x / _arg2.xRadius), (_local3.y / _arg2.yRadius));
_local6 = new Point((_local4.x / _arg2.xRadius), (_local4.y / _arg2.yRadius));
if (circleLineIntersect(_local5, _local6)){
if (_arg1.owner != _arg2){
_arg2.gotHit(1);
_arg1.expired = true;
};
};
};
}
public static function circleLineIntersect(_arg1:Point, _arg2:Point):Boolean{
var _local3:Point = new Point();
if (_arg1.equals(_arg2)){
_local3 = _arg1;
} else {
_local3 = closestPointOnLine(_arg1, _arg2);
};
return (circlePointIntersect(_local3));
}
public static function circlePointIntersect(_arg1:Point):Boolean{
if (((_arg1.x * _arg1.x) + (_arg1.y * _arg1.y)) < 1){
return (true);
};
return (false);
}
public static function closestPointOnLine(_arg1:Point, _arg2:Point):Point{
var _local3:Point;
var _local4:Point;
var _local5:Point;
var _local6:Number;
var _local7:Number;
if (_arg1.equals(_arg2)){
return (_arg1);
};
_local3 = new Point(0, 0);
_local4 = _arg2.subtract(_arg1);
_local5 = _local3.subtract(_arg1);
_local6 = (dot(_local5, _local4) / dot(_local4, _local4));
if (_local6 < 0){
_local6 = 0;
};
if (_local6 > 1){
_local6 = 1;
};
_local7 = (1 - _local6);
return (new Point(((_local7 * _arg1.x) + (_local6 * _arg2.x)), ((_local7 * _arg1.y) + (_local6 * _arg2.y))));
}
public static function dot(_arg1:Point, _arg2:Point):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
}
}//package
Section 17
//DialogBoxClip (DialogBoxClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class DialogBoxClip extends MovieClip {
public var rb:GenericButtonClip;
public var generalText:TextField;
public var titleText:TextField;
public var lb:GenericButtonClip;
}
}//package
Section 18
//Enemy (Enemy)
package {
import flash.display.*;
import flash.geom.*;
public class Enemy extends Actor {
public var xRadius:int;
public var yRadius:int;
protected var driftX:Number;
protected var driftY:Number;
protected var hits:int;
public var escaped:Boolean;
public var boomColour:int;
public function Enemy(_arg1:DisplayObjectContainer){
boomColour = 1;
escaped = false;
super(_arg1);
}
public function drift():Point{
return (new Point(driftX, driftY));
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
super.eachFrame(_arg1, _arg2);
}
public function gotHit(_arg1:int){
hits = (hits - _arg1);
if (hits <= 0){
expired = true;
} else {
SoundManager.addSound(AsteroidHit);
};
}
public function checkforCollisionWithHeroShip():int{
var _local1:int;
var _local2:int = ((xRadius + 10) * (yRadius + 10));
var _local3:int = (accurateLocation.x - 250);
var _local4:int = (accurateLocation.y - 250);
if (((_local3 * _local3) + (_local4 * _local4)) < _local2){
gotHit(50);
_local1 = 1;
};
return (_local1);
}
public function freeToFire():Boolean{
return (false);
}
public function launchBullet(_arg1:Array):void{
}
public function smash():void{
}
override public function spawnCoin(_arg1:Array, _arg2:int):void{
var _local3:int;
var _local4:Pickup;
var _local5:Coin;
if ((((_arg2 > 0)) && (!(escaped)))){
_local3 = (1 + Math.floor((Math.random() * _arg2)));
_local4 = new Pickup(actorClip.parent, _local3);
_local4.placeAtLoc(actorClip.x, actorClip.y);
_arg1.push(_local4);
} else {
if (!escaped){
_local5 = new Coin(actorClip.parent, 10);
_local5.placeAtLoc(actorClip.x, actorClip.y);
_arg1.push(_local5);
};
};
}
public function homing():void{
}
}
}//package
Section 19
//FGLAds (FGLAds)
package {
import flash.display.*;
import flash.events.*;
import flash.system.*;
import flash.net.*;
public dynamic class FGLAds extends Sprite {
private var _status:String;// = "Loading"
private var _loaded:Boolean;// = false
private var _stageWidth:Number;// = 550
private var _stageHeight:Number;// = 400
private var _inUse:Boolean;// = false
private var _referer:String;// = ""
private var _loader:Loader;
private var _context:LoaderContext;
private var _tmpSkin:Object;
private var _request:URLRequest;
private var _evt_NetworkingError:Function;// = null
private var _evt_ApiReady:Function;// = null
private var _evt_AdLoaded:Function;// = null
private var _evt_AdShown:Function;// = null
private var _evt_AdClicked:Function;// = null
private var _evt_AdClosed:Function;// = null
private var _evt_AdUnavailable:Function;// = null
private var _evt_AdLoadingError:Function;// = null
private var _fglAds:Object;
private var _stage:Stage;
private var _storedGameID:String;// = ""
public static const version:String = "01";
public static const EVT_NETWORKING_ERROR:String = "networking_error";
public static const EVT_API_READY:String = "api_ready";
public static const EVT_AD_LOADED:String = "ad_loaded";
public static const EVT_AD_SHOWN:String = "ad_shown";
public static const EVT_AD_CLOSED:String = "ad_closed";
public static const EVT_AD_CLICKED:String = "ad_clicked";
public static const EVT_AD_UNAVAILABLE:String = "ad_unavailable";
public static const EVT_AD_LOADING_ERROR:String = "ad_loading_error";
public static const FORMAT_AUTO:String = "format_auto";
public static const FORMAT_640x440:String = "640x440";
public static const FORMAT_300x250:String = "300x250";
public static const FORMAT_90x90:String = "90x90";
protected static var _instance:FGLAds;
public function FGLAds(_arg1, _arg2:String):void{
var parent = _arg1;
var gameID = _arg2;
_loader = new Loader();
_context = new LoaderContext(true);
_tmpSkin = new Object();
_request = new URLRequest((("http://ads.fgl.com/swf/FGLAds." + version) + ".swf"));
super();
if (_instance == null){
_instance = this;
} else {
trace("FGLAds: Instance Error: The FGLAds class is a singleton and should only be constructed once. Use FGLAds.api to access it after it has been constructed.");
return;
};
_storedGameID = gameID;
Security.allowDomain("*");
Security.allowInsecureDomain("*");
_context.applicationDomain = ApplicationDomain.currentDomain;
_status = "Downloading";
try {
_loader.load(_request, _context);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLoadingError);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete);
} catch(e:Error) {
_status = "Failed";
trace("FGLAds: SecurityError: cannot load client library");
_loader = null;
};
addEventListener(Event.ADDED_TO_STAGE, setupStage);
if ((((((parent is Sprite)) || ((parent is MovieClip)))) || ((parent is Stage)))){
parent.addChild(this);
} else {
trace("FGLAds: Incompatible parent! Parent must be a Sprite, MovieClip, or Stage");
};
}
public function showAdPopup(_arg1:String="format_auto", _arg2:Number=3000, _arg3:Number=0):void{
if (_loaded == false){
return;
};
_fglAds.showAdPopup(_arg1, _arg2, _arg3);
}
public function get status():String{
return (_status);
}
public function disable():void{
if (_status == "Ready"){
_status = "Disabled";
_loaded = false;
};
}
public function enable():void{
if (_status == "Disabled"){
_status = "Ready";
_loaded = true;
};
}
public function setStyle(_arg1:String, _arg2):void{
if (_loaded == false){
_tmpSkin[_arg1] = _arg2;
return;
};
var _local3:Object = new Object();
_local3[_arg1] = _arg2;
_fglAds.setSkin(_local3);
}
public function set onNetworkingError(_arg1:Function):void{
_evt_NetworkingError = _arg1;
}
public function get onNetworkingError():Function{
return (_evt_NetworkingError);
}
private function e_onNetworkingError(_arg1:Event):void{
if (_evt_NetworkingError != null){
_evt_NetworkingError();
};
dispatchEvent(_arg1);
}
public function set onApiReady(_arg1:Function):void{
_evt_ApiReady = _arg1;
}
public function get onApiReady():Function{
return (_evt_ApiReady);
}
private function e_onApiReady(_arg1:Event):void{
if (_evt_ApiReady != null){
_evt_ApiReady();
};
dispatchEvent(_arg1);
}
public function set onAdLoaded(_arg1:Function):void{
_evt_AdLoaded = _arg1;
}
public function get onAdLoaded():Function{
return (_evt_AdLoaded);
}
private function e_onAdLoaded(_arg1:Event):void{
if (_evt_AdLoaded != null){
_evt_AdLoaded();
};
dispatchEvent(_arg1);
}
public function set onAdShown(_arg1:Function):void{
_evt_AdShown = _arg1;
}
public function get onAdShown():Function{
return (_evt_AdShown);
}
private function e_onAdShown(_arg1:Event):void{
if (_evt_AdShown != null){
_evt_AdShown();
};
dispatchEvent(_arg1);
}
public function set onAdClicked(_arg1:Function):void{
_evt_AdClicked = _arg1;
}
public function get onAdClicked():Function{
return (_evt_AdClicked);
}
private function e_onAdClicked(_arg1:Event):void{
if (_evt_AdClicked != null){
_evt_AdClicked();
};
dispatchEvent(_arg1);
}
public function set onAdClosed(_arg1:Function):void{
_evt_AdClosed = _arg1;
}
public function get onAdClosed():Function{
return (_evt_AdClosed);
}
private function e_onAdClosed(_arg1:Event):void{
if (_evt_AdClosed != null){
_evt_AdClosed();
};
dispatchEvent(_arg1);
}
public function set onAdUnavailable(_arg1:Function):void{
_evt_AdUnavailable = _arg1;
}
public function get onAdUnavailable():Function{
return (_evt_AdUnavailable);
}
private function e_onAdUnavailable(_arg1:Event):void{
if (_evt_AdUnavailable != null){
_evt_AdUnavailable();
};
dispatchEvent(_arg1);
}
public function set onAdLoadingError(_arg1:Function):void{
_evt_AdLoadingError = _arg1;
}
public function get onAdLoadingError():Function{
return (_evt_AdLoadingError);
}
private function e_onAdLoadingError(_arg1:Event):void{
if (_evt_AdLoadingError != null){
_evt_AdLoadingError();
};
dispatchEvent(_arg1);
}
private function resizeStage(_arg1:Event):void{
if (_loaded == false){
return;
};
_stageWidth = _stage.stageWidth;
_stageHeight = _stage.stageHeight;
_fglAds.componentWidth = _stageWidth;
_fglAds.componentHeight = _stageHeight;
}
private function setupStage(_arg1:Event):void{
if (stage == null){
return;
};
_stage = stage;
_stage.addEventListener(Event.RESIZE, resizeStage);
_stageWidth = stage.stageWidth;
_stageHeight = stage.stageHeight;
if (root != null){
_referer = root.loaderInfo.loaderURL;
};
if (_loaded){
_fglAds.componentWidth = _stageWidth;
_fglAds.componentHeight = _stageHeight;
_stage.addChild((_fglAds as Sprite));
};
}
private function onLoadingComplete(_arg1:Event):void{
_status = "Ready";
_loaded = true;
_fglAds = (_loader.content as Object);
_fglAds.componentWidth = _stageWidth;
_fglAds.componentHeight = _stageHeight;
_fglAds.setSkin(_tmpSkin);
_fglAds.addEventListener(EVT_NETWORKING_ERROR, e_onNetworkingError);
_fglAds.addEventListener(EVT_API_READY, e_onApiReady);
_fglAds.addEventListener(EVT_AD_LOADED, e_onAdLoaded);
_fglAds.addEventListener(EVT_AD_SHOWN, e_onAdShown);
_fglAds.addEventListener(EVT_AD_CLICKED, e_onAdClicked);
_fglAds.addEventListener(EVT_AD_CLOSED, e_onAdClosed);
_fglAds.addEventListener(EVT_AD_UNAVAILABLE, e_onAdUnavailable);
_fglAds.addEventListener(EVT_AD_LOADING_ERROR, e_onAdLoadingError);
if (_stage != null){
_stage.addChild((_fglAds as Sprite));
};
if (root != null){
_referer = root.loaderInfo.loaderURL;
};
_fglAds.init(_stage, _referer, _storedGameID);
}
private function onLoadingError(_arg1:IOErrorEvent):void{
_loaded = false;
_status = "Failed";
trace("FGLAds: Failed to load client SWF");
}
public static function get api():FGLAds{
if (_instance == null){
trace("FGLAds: Instance Error: Attempted to get instance before construction.");
return (null);
};
return (_instance);
}
public static function get apiLoaded():Boolean{
return (!((_instance == null)));
}
}
}//package
Section 20
//FightScreen (FightScreen)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class FightScreen extends EventDispatcher {
private const FADE_OUT_TIME:int = 110;
private const LARGE_ASTEROID:String = "Asteroid3";
private var backgroundSprite:Sprite;
private var heroShipClip:Sprite;
private var hud:Sprite;
private var playerInput:PlayerInput;
private var shieldClip:Sprite;
private var shieldBarClip:MovieClip;
private var spareLives:Array;
public var cash:int;
public var roidsDestroyed:int;
private var cashClip:MovieClip;
private var muteButton:MovieClip;
private var musicButton:MovieClip;
private var heroRot:Number;
private var rotationDecay:Number;
private var rotationThrust:Number;
private var heroXV:Number;
private var heroYV:Number;
private var heroSpaceFriction:Number;
private var heroMainThrust:Number;
private var heroReverseThrust:Number;
private var heroDeadTime:int;
private var heroHealth:int;
private var shieldPower:Number;
private var shieldUp:Boolean;
private var heroFailed:Boolean;
private var thrustDuration:int;
private var fragmentList:Array;
private var flakList:Array;
private var bulletList:Array;
private var enemyList:Array;
private var camera:DisplayObjectContainer;
private var framesSinceLastHeroShot:int;
private var bulletLaunchVelocity:Number;
private var endOfLevelCountdown:int;
private var upgradesOwned:Array;
public var levelNumber:int;
public var autoRestart:Boolean;
public var autoUpgrade:Boolean;
private var levelComplete:Boolean;
private var pauseBox:MovieClip;
private var gamePaused:Boolean;
private var frameCount:int;
private var alienShipsSeen:int;
private var prepareClip:MovieClip;
private var readyCounter:int;
private var gameCompleteDialog:MovieClip;
private var startingCash:int;
private var tutorClip:MovieClip;
private var maxAliensAllowed:int;
private var bonusFireRate:int;
private var aliensDestroyed:int;
private static var maxSpecialsAllowed:Array = ["x", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
public function FightScreen(_arg1:DisplayObjectContainer, _arg2:int, _arg3:int, _arg4:Array, _arg5:PlayerInput){
_arg5.enterGameMode();
autoRestart = false;
autoUpgrade = false;
startingCash = _arg3;
SoundManager.changeTrack(1);
levelComplete = false;
gamePaused = false;
frameCount = 0;
alienShipsSeen = 0;
roidsDestroyed = 0;
upgradesOwned = _arg4;
levelNumber = _arg2;
cash = _arg3;
endOfLevelCountdown = FADE_OUT_TIME;
camera = new Sprite();
_arg1.addChild(camera);
setUpHud(_arg1);
enemyList = [];
flakList = [];
bulletList = [];
fragmentList = [];
playerInput = _arg5;
setUpStarfield();
setUpHeroShip();
setUpLevel(levelNumber);
eachFrame();
_arg1.addEventListener(Event.ENTER_FRAME, prepareForBattle);
Stage(_arg1).focus = _arg1;
maxAliensAllowed = maxSpecialsAllowed[levelNumber];
readyCounter = 65;
aliensDestroyed = 0;
muteButton.buttonMode = true;
musicButton.buttonMode = true;
muteButton.useHandCursor = true;
musicButton.useHandCursor = true;
showMuteLevels();
}
private function prepareForBattle(_arg1:Event):void{
rotatePlayerShip();
var _local2:DisplayObjectContainer = prepareClip.parent;
readyCounter--;
prepareClip.numberText.text = Number((readyCounter / 20)).toFixed(1);
if (readyCounter <= 0){
_local2.addEventListener(Event.ENTER_FRAME, eachFrame);
_local2.removeEventListener(Event.ENTER_FRAME, prepareForBattle);
_local2.removeChild(prepareClip);
};
}
private function setUpLevel(_arg1:int):void{
var _local5:int;
var _local2:Array = ["x", 3, 1, 2, 0, 0, 32, 0, 0, 16, 0, 32, 0, 10, 0, 0, 0];
var _local3:Array = ["x", 0, 2, 3, 4, 2, 0, 7, 9, 2, 8, 0, 3, 4, 10, 0, 0];
var _local4:Array = ["x", 0, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 4, 4, 5, 10, 3];
_local5 = 0;
while (_local5 < _local2[_arg1]) {
addNewAsteroid(2);
_local5++;
};
_local5 = 0;
while (_local5 < _local3[_arg1]) {
addNewAsteroid(3);
_local5++;
};
_local5 = 0;
while (_local5 < _local4[_arg1]) {
addNewAsteroid(4);
_local5++;
};
if (_arg1 == 16){
addNewAsteroid(6);
};
}
private function muteButtonPressed(_arg1:Event=null):void{
SoundManager.muteButtonPressed();
showMuteLevels();
}
private function musicMuteButtonPressed(_arg1:Event=null):void{
SoundManager.musicMuteButtonPressed();
showMuteLevels();
}
private function showMuteLevels():void{
if (SoundManager.soundVolume == 0){
muteButton.alpha = 0.5;
} else {
muteButton.alpha = 1;
};
if (SoundManager.musicMuted){
musicButton.alpha = 0.5;
} else {
musicButton.alpha = 10;
};
}
private function setUpHud(_arg1:DisplayObjectContainer):void{
var _local3:Sprite;
hud = new HUDFrame();
_arg1.addChild(hud);
cashClip = new CashClip();
_arg1.addChild(cashClip);
cashClip.x = 100;
cashClip.y = 505;
cashClip.cText.text = ("$" + cash.toString());
shieldBarClip = new InvulnerableBarClip();
_arg1.addChild(shieldBarClip);
shieldBarClip.x = 200;
shieldBarClip.y = 495;
shieldBarClip.gotoAndStop(100);
musicButton = new MusicButton();
musicButton.addEventListener(MouseEvent.CLICK, musicMuteButtonPressed);
_arg1.addChild(musicButton);
musicButton.x = 440;
musicButton.y = 22;
muteButton = new MuteSoundsButton();
muteButton.addEventListener(MouseEvent.CLICK, muteButtonPressed);
_arg1.addChild(muteButton);
muteButton.x = 475;
muteButton.y = 20;
spareLives = [];
var _local2:int;
while (_local2 < UpgraderScreen.startingLives(upgradesOwned[UpgraderScreen.STARTING_LIVES])) {
_local3 = new HeroShipClip();
_local3.rotation = -90;
_local3.y = 480;
_local3.x = (480 - (_local2 * 30));
if (_local2 >= 3){
_local3.y = (_local3.y - 50);
_local3.x = (_local3.x + 90);
};
_arg1.addChild(_local3);
spareLives.push(_local3);
_local2++;
};
prepareClip = new GetReadyCounterClip();
_arg1.addChild(prepareClip);
prepareClip.x = 250;
prepareClip.y = 125;
tutorClip = new InstructionsClip();
tutorClip.mouseEnabled = false;
_arg1.addChild(tutorClip);
tutorClip.x = 250;
tutorClip.y = 250;
if (levelNumber > 1){
tutorClip.visible = false;
};
}
private function eachFrame(_arg1:Event=null):void{
if (!levelComplete){
frameCount++;
moveHeroShip();
moveBackground();
moveActors();
checkCollisions();
removeDeadActors();
if ((((frameCount > 150)) && ((frameCount < 350)))){
tutorClip.alpha = ((350 - frameCount) * 0.005);
};
if (frameCount == 350){
tutorClip.visible = false;
};
if (playerInput._keyDown[80]){
pauseGame();
};
if (playerInput._keyDown[27]){
playerInput._keyDown[27] = false;
heroFailed = true;
endOfLevelCountdown = -1;
};
if ((((enemyList.length == 0)) || (heroFailed))){
endOfLevelCountdown--;
if (endOfLevelCountdown < 0){
quitGame();
};
} else {
endOfLevelCountdown = FADE_OUT_TIME;
};
};
}
private function pauseGame():void{
playerInput._keyDown[80] = false;
camera.parent.removeEventListener(Event.ENTER_FRAME, eachFrame);
camera.parent.addEventListener(Event.ENTER_FRAME, pauseFrame);
pauseBox = new DialogBoxClip();
camera.parent.addChild(pauseBox);
pauseBox.x = 250;
pauseBox.y = 250;
pauseBox.alpha = 0.7;
pauseBox.titleText.text = "Game Paused";
pauseBox.generalText.text = "";
pauseBox.lb.bText.text = "Quit";
pauseBox.rb.bText.text = "Resume";
pauseBox.rb.addEventListener(MouseEvent.CLICK, resumeGame);
pauseBox.lb.addEventListener(MouseEvent.CLICK, quitFromPauseScreen);
}
private function pauseFrame(_arg1:Event):void{
if (playerInput._keyDown[80]){
resumeGame();
playerInput._keyDown[80] = false;
};
}
private function quitFromPauseScreen(_arg1:MouseEvent):void{
heroFailed = true;
endOfLevelCountdown = -1;
resumeGame();
}
private function resumeGame(_arg1:Event=null):void{
pauseBox.lb.removeEventListener(MouseEvent.CLICK, resumeGame);
pauseBox.rb.removeEventListener(MouseEvent.CLICK, quitFromPauseScreen);
pauseBox.parent.removeChild(pauseBox);
camera.parent.removeEventListener(Event.ENTER_FRAME, pauseFrame);
camera.parent.addEventListener(Event.ENTER_FRAME, eachFrame);
camera.parent.stage.focus = camera.parent.stage;
}
private function removeDeadActors():void{
removeActorArray(enemyList);
removeActorArray(flakList);
removeActorArray(bulletList);
removeActorArray(fragmentList);
}
private function removeActorArray(_arg1:Array):void{
var _local3:Enemy;
var _local2:int = (_arg1.length - 1);
while (_local2 >= 0) {
if (_arg1[_local2].expired){
if ((_arg1[_local2] is Enemy)){
_local3 = _arg1[_local2];
if (!Enemy(_arg1[_local2]).escaped){
fragmentBurst(_local3.location(), _local3.drift(), 10, _local3.boomColour);
if (!(_arg1[_local2] is Asteroid)){
aliensDestroyed++;
} else {
roidsDestroyed++;
};
if ((_arg1[_local2] is ProxMine)){
_arg1[_local2].spawnBullets(bulletList);
};
};
};
_arg1[_local2].spawnChildren(enemyList);
_arg1[_local2].spawnCoin(flakList, bonusNumber());
_arg1[_local2].destroy();
_arg1.splice(_local2, 1);
};
_local2--;
};
}
private function checkCollisions():void{
var _local1:Enemy;
var _local2:Bullet;
var _local3:Actor;
var _local5:int;
var _local6:int;
var _local4:int;
for each (_local1 in enemyList) {
if (heroDeadTime == 0){
Enemy(_local1).homing();
};
if ((((heroDeadTime == 0)) && (!(shieldUp)))){
_local4 = (_local4 + _local1.checkforCollisionWithHeroShip());
};
for each (_local2 in bulletList) {
CollisionManager.checkIntersection(_local2, _local1);
};
};
if (heroDeadTime == 0){
for each (_local3 in flakList) {
if ((_local3 is Coin)){
_local5 = UpgraderScreen.coinDrawDistance(upgradesOwned[UpgraderScreen.COIN_MAGNET]);
if (endOfLevelCountdown < FADE_OUT_TIME){
_local5 = 10000;
};
cash = (cash + Coin(_local3).checkforCollisionWithHeroShip(_local5));
cashClip.cText.text = ("$" + cash.toString());
};
if ((_local3 is Pickup)){
_local6 = Pickup(_local3).checkforCollisionWithHeroShip(UpgraderScreen.coinDrawDistance(upgradesOwned[UpgraderScreen.COIN_MAGNET]));
applyBonus(_local6);
};
};
if (!shieldUp){
for each (_local2 in bulletList) {
if (_local2.owner != heroShipClip){
_local4 = (_local4 + _local2.checkforCollisionWithHeroShip());
};
};
};
};
if ((((heroDeadTime == 0)) && (!(shieldUp)))){
heroHealth = (heroHealth - _local4);
if (heroHealth < 1){
killPlayerShip();
};
};
}
private function applyBonus(_arg1:int):void{
var _local2:int;
var _local3:Number;
var _local4:Number;
var _local5:int;
var _local6:Point;
var _local7:Point;
var _local8:Point;
var _local9:Bullet;
var _local10:Enemy;
if (_arg1 == Pickup.STARBURST){
_local2 = 16;
_local3 = 22.5;
_local4 = heroShipClip.rotation;
_local5 = 0;
while (_local5 < _local2) {
_local6 = new Point(Math.cos(((Math.PI * _local4) / 180)), Math.sin(((Math.PI * _local4) / 180)));
_local7 = new Point((250 + (_local6.x * 15)), (250 + (_local6.y * 15)));
_local8 = new Point((_local6.x * bulletLaunchVelocity), (_local6.y * bulletLaunchVelocity));
new Point((_local6.x * bulletLaunchVelocity), (_local6.y * bulletLaunchVelocity)).x = (_local8.x + heroXV);
_local8.y = (_local8.y + heroYV);
_local9 = new Bullet(camera, _local7, _local8, heroShipClip);
bulletList.push(_local9);
_local4 = (_local4 + _local3);
_local5++;
};
SoundManager.addSound(LaserShoot);
};
if (_arg1 == Pickup.SHIELD){
shieldPower = 200;
shieldUp = true;
shieldClip.visible = true;
shieldBarClip.visible = true;
};
if (_arg1 == Pickup.BONUS_ROF){
bonusFireRate = 200;
};
if (_arg1 == Pickup.SMASH){
for each (_local10 in enemyList) {
_local10.smash();
};
};
}
private function killPlayerShip():void{
var _local2:Sprite;
heroShipClip.visible = false;
heroDeadTime = 1;
var _local1:int = spareLives.length;
if (_local1 > 0){
_local2 = Sprite(spareLives[(_local1 - 1)]);
_local2.parent.removeChild(_local2);
spareLives.splice((_local1 - 1), 1);
} else {
heroFailed = true;
};
fragmentBurst(new Point(250, 250), new Point((heroXV * 0.5), (heroYV * 0.5)), 25, 1);
SoundManager.addSound(HeroBang);
}
private function fragmentBurst(_arg1:Point, _arg2:Point, _arg3:int, _arg4:int):void{
var _local6:Fragment;
var _local5:int;
while (_local5 < _arg3) {
_local6 = new Fragment(_arg1, _arg2, camera, _arg4);
fragmentList.push(_local6);
_local5++;
};
}
private function moveActors():void{
var _local1:Enemy;
checkObjectQueue();
moveActorArray(enemyList);
moveActorArray(flakList);
moveActorArray(bulletList);
moveActorArray(fragmentList);
for each (_local1 in enemyList) {
if (_local1.freeToFire()){
_local1.launchBullet(bulletList);
};
};
}
private function moveActorArray(_arg1:Array):void{
var _local2:Actor;
for each (_local2 in _arg1) {
_local2.eachFrame(heroXV, heroYV);
};
}
private function checkObjectQueue():void{
if ((((((frameCount > ((400 - (levelNumber * 4)) + (alienShipsSeen * 400)))) && ((alienShipsSeen < maxAliensAllowed)))) && ((endOfLevelCountdown == FADE_OUT_TIME)))){
addNewAlien();
alienShipsSeen++;
};
}
private function moveHeroShip():void{
var _local1:Number;
framesSinceLastHeroShot++;
if (bonusFireRate > 0){
bonusFireRate--;
};
if (heroDeadTime > 0){
heroDeadTime++;
if ((((heroDeadTime > 100)) && (!(heroFailed)))){
resurrectHeroShip();
};
};
if (shieldUp){
shieldPower = (shieldPower - UpgraderScreen.shieldDrain(upgradesOwned[UpgraderScreen.SHIELD_DRAIN]));
shieldBarClip.gotoAndStop((Math.floor(shieldPower) + 1));
if (shieldPower <= 0){
shieldPower = 0;
shieldClip.visible = false;
shieldUp = false;
shieldBarClip.visible = false;
};
};
if (heroDeadTime == 0){
rotatePlayerShip();
if (playerInput.downKey()){
heroXV = (heroXV - (heroReverseThrust * Math.cos(((Math.PI * heroShipClip.rotation) / 180))));
heroYV = (heroYV - (heroReverseThrust * Math.sin(((Math.PI * heroShipClip.rotation) / 180))));
};
if (playerInput.upKey()){
heroXV = (heroXV + (heroMainThrust * Math.cos(((Math.PI * heroShipClip.rotation) / 180))));
heroYV = (heroYV + (heroMainThrust * Math.sin(((Math.PI * heroShipClip.rotation) / 180))));
};
if (((playerInput.upKey()) || (playerInput.downKey()))){
if (thrustDuration == 0){
SoundManager.addSound(HeroJet);
};
thrustDuration = (thrustDuration + 1);
if (thrustDuration > 19){
thrustDuration = 0;
};
} else {
thrustDuration = 0;
};
if (playerInput.fireKey()){
_local1 = UpgraderScreen.rateOfFire(upgradesOwned[UpgraderScreen.ROF]);
if (bonusFireRate > 0){
_local1 = 480;
};
if (framesSinceLastHeroShot >= (2400 / _local1)){
framesSinceLastHeroShot = 0;
heroShipLaunchBullets();
};
};
};
heroXV = (heroXV * heroSpaceFriction);
heroYV = (heroYV * heroSpaceFriction);
}
private function rotatePlayerShip():void{
heroRot = (heroRot * rotationDecay);
if (playerInput.leftKey(heroShipClip.rotation)){
heroRot = (heroRot - rotationThrust);
};
if (playerInput.rightKey(heroShipClip.rotation)){
heroRot = (heroRot + rotationThrust);
};
heroShipClip.rotation = (heroShipClip.rotation + heroRot);
}
private function heroShipLaunchBullets():void{
var _local6:Point;
var _local7:Point;
var _local8:Point;
var _local9:Point;
var _local10:Bullet;
var _local1:int = UpgraderScreen.numShots(upgradesOwned[UpgraderScreen.MULTISHOT]);
var _local2:Number = 6;
var _local3:Number = (((_local2 * 0.5) + heroShipClip.rotation) - ((_local1 * _local2) * 0.5));
var _local4:Array = [[], [0], [-8, 8], [-8, 0, 8]];
var _local5:int;
while (_local5 < _local1) {
_local6 = new Point(Math.cos(((Math.PI * _local3) / 180)), Math.sin(((Math.PI * _local3) / 180)));
_local7 = new Point(Math.cos(((Math.PI * (_local3 + 90)) / 180)), Math.sin(((Math.PI * (_local3 + 90)) / 180)));
_local8 = new Point((250 + (_local6.x * 15)), (250 + (_local6.y * 15)));
new Point((250 + (_local6.x * 15)), (250 + (_local6.y * 15))).x = (_local8.x + (_local7.x * _local4[_local1][_local5]));
_local8.y = (_local8.y + (_local7.y * _local4[_local1][_local5]));
_local9 = new Point((_local6.x * bulletLaunchVelocity), (_local6.y * bulletLaunchVelocity));
new Point((_local6.x * bulletLaunchVelocity), (_local6.y * bulletLaunchVelocity)).x = (_local9.x + heroXV);
_local9.y = (_local9.y + heroYV);
_local10 = new Bullet(camera, _local8, _local9, heroShipClip);
bulletList.push(_local10);
_local3 = (_local3 + _local2);
_local5++;
};
SoundManager.addSound(LaserShoot);
}
private function resurrectHeroShip():void{
shieldClip.visible = true;
heroShipClip.visible = true;
heroDeadTime = 0;
shieldPower = 200;
shieldUp = true;
shieldBarClip.visible = true;
heroRot = 0;
heroXV = 0;
heroYV = 0;
heroShipClip.rotation = -90;
heroHealth = 1;
framesSinceLastHeroShot = 0;
thrustDuration = 0;
}
private function setUpHeroShip():void{
heroShipClip = new HeroShipClip();
camera.addChild(heroShipClip);
heroShipClip.x = 250;
heroShipClip.y = 250;
shieldClip = new ShieldClip();
heroShipClip.addChild(shieldClip);
rotationDecay = 0.7;
rotationThrust = 2.5;
heroSpaceFriction = 0.95;
heroMainThrust = 0.5;
heroReverseThrust = 0.2;
bulletLaunchVelocity = 12;
resurrectHeroShip();
heroFailed = false;
bonusFireRate = 0;
}
private function addNewAsteroid(_arg1:int):void{
var _local2:Actor = new Asteroid(_arg1, camera, levelNumber);
_local2.placeAtScreenEdge();
enemyList.push(_local2);
}
private function bonusNumber():int{
var _local1:int = Math.floor(((levelNumber + 3) / 4));
if (_local1 > 3){
_local1 = 3;
};
return (_local1);
}
private function addNewAlien():void{
var _local1:Actor;
var _local2 = 3;
if (levelNumber < 10){
_local2 = 2;
};
if (levelNumber < 3){
_local2 = 1;
};
var _local3:int = Math.floor((Math.random() * _local2));
if (levelNumber == 3){
_local3 = 1;
};
if (levelNumber == 10){
_local3 = 2;
};
if (_local3 == 0){
if (levelNumber < 7){
_local1 = new AlienShip(camera);
} else {
if (levelNumber < 14){
_local1 = new RedAlienShip(camera, false);
} else {
_local1 = new RedAlienShip(camera, true);
};
};
} else {
if (_local3 == 1){
if (levelNumber < 12){
_local1 = new ProxMine(camera, false);
} else {
_local1 = new ProxMine(camera, true);
};
} else {
_local1 = new HomingRocket(camera);
};
};
enemyList.push(_local1);
}
private function moveBackground():void{
backgroundSprite.x = (backgroundSprite.x - heroXV);
backgroundSprite.y = (backgroundSprite.y - heroYV);
if (backgroundSprite.x > 0){
backgroundSprite.x = (backgroundSprite.x - 500);
};
if (backgroundSprite.y > 0){
backgroundSprite.y = (backgroundSprite.y - 500);
};
if (backgroundSprite.x < -500){
backgroundSprite.x = (backgroundSprite.x + 500);
};
if (backgroundSprite.y < -500){
backgroundSprite.y = (backgroundSprite.y + 500);
};
}
private function setUpStarfield():void{
backgroundSprite = new BackgroundSprite();
camera.addChild(backgroundSprite);
}
private function quitGame():void{
var _local2:int;
levelComplete = true;
playerInput.exitGameMode();
playerInput.releaseFireKey();
SoundManager.changeTrack(2);
camera.parent.removeEventListener(Event.ENTER_FRAME, eachFrame);
var _local1:int = (aliensDestroyed * 100);
cash = (cash + _local1);
if (heroFailed){
gameCompleteDialog = new LoseBoxClip();
camera.parent.addChild(gameCompleteDialog);
gameCompleteDialog.x = 250;
gameCompleteDialog.y = 250;
gameCompleteDialog.awardText.text = ((("Coins Collected: $" + int(((cash - startingCash) - _local1)).toString()) + "\nAlien Hunter Bonus: $") + _local1.toString());
gameCompleteDialog.rb.bText.text = "Retry";
gameCompleteDialog.lb.bText.text = "Menu";
camera.parent.addEventListener(Event.ENTER_FRAME, eachFrameDefeat);
gameCompleteDialog.lb.addEventListener(MouseEvent.CLICK, doneDefeat);
gameCompleteDialog.rb.addEventListener(MouseEvent.CLICK, restartAndDoneDefeat);
gameCompleteDialog.mb.addEventListener(MouseEvent.CLICK, upgradeAndDoneDefeat);
} else {
dispatchEvent(new GameEvent(GameEvent.LEVEL_WON));
gameCompleteDialog = new WinBoxClip();
camera.parent.addChild(gameCompleteDialog);
gameCompleteDialog.x = 250;
gameCompleteDialog.y = 250;
_local2 = (50 + (levelNumber * 50));
gameCompleteDialog.awardText.text = ((((("Coins Collected: $" + int(((cash - startingCash) - _local1)).toString()) + "\nAlien Hunter Bonus: $") + _local1.toString()) + "\nCompletion Bonus: $") + _local2.toString());
cash = (cash + _local2);
gameCompleteDialog.totalText.text = ("Total: $" + int((cash - startingCash)).toString());
gameCompleteDialog.rb.bText.text = "Done";
camera.parent.addEventListener(Event.ENTER_FRAME, eachFrameVictory);
gameCompleteDialog.rb.addEventListener(MouseEvent.CLICK, doneVictory);
gameCompleteDialog.mb.addEventListener(MouseEvent.CLICK, upgradeAndDoneVictory);
};
cashClip.cText.text = ("$" + cash.toString());
}
private function upgradeAndDoneVictory(_arg1:MouseEvent):void{
autoUpgrade = true;
doneVictory();
}
private function upgradeAndDoneDefeat(_arg1:MouseEvent):void{
autoUpgrade = true;
doneDefeat();
}
private function restartAndDoneDefeat(_arg1:MouseEvent=null):void{
autoRestart = true;
doneDefeat();
}
private function doneDefeat(_arg1:MouseEvent=null):void{
playerInput.releaseFireKey();
camera.parent.removeEventListener(Event.ENTER_FRAME, eachFrameDefeat);
gameCompleteDialog.rb.removeEventListener(MouseEvent.CLICK, doneDefeat);
gameCompleteDialog.rb.removeEventListener(MouseEvent.CLICK, restartAndDoneDefeat);
gameCompleteDialog.mb.removeEventListener(MouseEvent.CLICK, upgradeAndDoneDefeat);
camera.parent.removeChild(gameCompleteDialog);
clearUpAndGoHome();
}
private function eachFrameDefeat(_arg1:Event=null):void{
if (playerInput.fireKey()){
playerInput.releaseFireKey();
restartAndDoneDefeat();
} else {
if (playerInput._keyDown[27]){
playerInput._keyDown[27] = false;
doneDefeat();
};
};
}
private function doneVictory(_arg1:MouseEvent=null):void{
playerInput.releaseFireKey();
camera.parent.removeEventListener(Event.ENTER_FRAME, eachFrameVictory);
gameCompleteDialog.rb.removeEventListener(MouseEvent.CLICK, doneVictory);
gameCompleteDialog.mb.removeEventListener(MouseEvent.CLICK, upgradeAndDoneVictory);
camera.parent.removeChild(gameCompleteDialog);
clearUpAndGoHome();
}
private function eachFrameVictory(_arg1:Event):void{
if (playerInput.fireKey()){
doneVictory();
};
}
private function clearUpAndGoHome():void{
var _local2:Sprite;
removeAllActors(enemyList);
removeAllActors(flakList);
removeAllActors(bulletList);
removeAllActors(fragmentList);
playerInput.releaseFireKey();
playerInput = null;
heroShipClip.removeChild(shieldClip);
camera.removeChild(heroShipClip);
heroShipClip = null;
camera.removeChild(backgroundSprite);
backgroundSprite = null;
var _local1:DisplayObjectContainer = camera.parent;
muteButton.removeEventListener(MouseEvent.CLICK, muteButtonPressed);
_local1.removeChild(muteButton);
musicButton.removeEventListener(MouseEvent.CLICK, musicMuteButtonPressed);
_local1.removeChild(musicButton);
_local1.removeChild(cashClip);
_local1.removeChild(shieldBarClip);
_local1.removeChild(tutorClip);
for each (_local2 in spareLives) {
_local1.removeChild(_local2);
};
_local1.removeChild(hud);
_local1.removeChild(camera);
dispatchEvent(new GameEvent(GameEvent.LEVEL_CLOSED));
}
private function removeAllActors(_arg1:Array):void{
var _local2:int = (_arg1.length - 1);
while (_local2 >= 0) {
_arg1[_local2].destroy();
_arg1.splice(_local2, 1);
_local2--;
};
_arg1 = [];
}
}
}//package
Section 21
//FloatingTextClip (FloatingTextClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class FloatingTextClip extends MovieClip {
public var tBox:TextField;
public var ls:MovieClip;
}
}//package
Section 22
//Fragment (Fragment)
package {
import flash.display.*;
import flash.geom.*;
public class Fragment extends Actor {
private var duration:int;
private var xv:Number;
private var yv:Number;
public function Fragment(_arg1:Point, _arg2:Point, _arg3:DisplayObjectContainer, _arg4:int):void{
duration = (20 + Math.floor((Math.random() * 30)));
actorClip = new FragmentClip();
actorClip.gotoAndStop(_arg4);
super(_arg3);
var _local5:Number = ((Math.random() * 2) * Math.PI);
var _local6:Number = ((Math.random() * 2) + 2);
xv = (_arg2.x + (Math.cos(_local5) * _local6));
yv = (_arg2.y + (Math.sin(_local5) * _local6));
placeAtLoc((_arg1.x + (xv * 2)), (_arg1.y + (yv * 2)));
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
duration--;
if (duration < 0){
expired = true;
};
accurateLocation.x = (accurateLocation.x + xv);
accurateLocation.y = (accurateLocation.y + yv);
super.eachFrame(_arg1, _arg2);
}
}
}//package
Section 23
//FragmentClip (FragmentClip)
package {
import flash.display.*;
public dynamic class FragmentClip extends MovieClip {
}
}//package
Section 24
//GameEvent (GameEvent)
package {
import flash.events.*;
public class GameEvent extends Event {
public var arg;
public static const LEVEL_WON:String = "Level Won";
public static const LEVEL_CLOSED:String = "Level Closed";
public static const QUIT_UPGRADER:String = "Quit Upgrader";
public function GameEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, ... _args){
super(_arg1, _arg2, _arg3);
arg = _args;
}
override public function clone():Event{
return (new GameEvent(type, bubbles, cancelable));
}
override public function toString():String{
return (formatToString("GameEvent", "type", "bubbles", "cancelable", "eventPhase"));
}
}
}//package
Section 25
//GameMenuScreenClip (GameMenuScreenClip)
package {
import flash.display.*;
public dynamic class GameMenuScreenClip extends MovieClip {
public var muteButton:MuteSoundsButton;
public var instructionsClip:InstructionsClip;
public var moreGamesButton:MoreGamesButtonClip;
public var continueGameButton:GenericButtonClip;
public var webClickButton:SimpleButton;
public var instructionsButton:GenericButtonClip;
public var blackdrop:MovieClip;
public var newGameButton:GenericButtonClip;
public var musicButton:MusicButton;
}
}//package
Section 26
//GameMusic (GameMusic)
package {
import flash.media.*;
public dynamic class GameMusic extends Sound {
}
}//package
Section 27
//GenericButton (GenericButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class GenericButton extends MovieClip {
public var bText:TextField;
public function GenericButton():void{
this.buttonMode = true;
this.useHandCursor = true;
this.addEventListener(MouseEvent.MOUSE_OVER, mouseIsOver);
this.addEventListener(MouseEvent.CLICK, buttonPressed);
bText.mouseEnabled = false;
}
private function buttonPressed(_arg1:MouseEvent):void{
SoundManager.addSound(BeepSound);
}
private function mouseIsOver(_arg1:MouseEvent):void{
SoundManager.addSound(ShortBeepSound);
}
public function destroy():void{
this.removeEventListener(MouseEvent.MOUSE_OVER, mouseIsOver);
this.removeEventListener(MouseEvent.CLICK, buttonPressed);
this.parent.removeChild(this);
}
}
}//package
Section 28
//GenericButtonClip (GenericButtonClip)
package {
public dynamic class GenericButtonClip extends GenericButton {
}
}//package
Section 29
//GetReadyCounterClip (GetReadyCounterClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class GetReadyCounterClip extends MovieClip {
public var titleText:TextField;
public var numberText:TextField;
}
}//package
Section 30
//GrabCoin (GrabCoin)
package {
import flash.media.*;
public dynamic class GrabCoin extends Sound {
}
}//package
Section 31
//HeroBang (HeroBang)
package {
import flash.media.*;
public dynamic class HeroBang extends Sound {
}
}//package
Section 32
//HeroJet (HeroJet)
package {
import flash.media.*;
public dynamic class HeroJet extends Sound {
}
}//package
Section 33
//HeroShipClip (HeroShipClip)
package {
import flash.display.*;
public dynamic class HeroShipClip extends MovieClip {
}
}//package
Section 34
//HomingBeep (HomingBeep)
package {
import flash.media.*;
public dynamic class HomingBeep extends Sound {
}
}//package
Section 35
//HomingRocket (HomingRocket)
package {
import flash.display.*;
public class HomingRocket extends Enemy {
private static const turnSpeed:Number = 2.5;
private static const accel:Number = 0.5;
private static const drag:Number = 0.9;
public function HomingRocket(_arg1:DisplayObjectContainer){
hits = 1;
boomColour = 2;
actorClip = new HomingRocketClip();
actorClip.rotation = (Math.random() * 360);
super(_arg1);
xRadius = 15;
yRadius = 15;
var _local2:Number = ((Math.random() * 1) + 1.5);
driftX = 0;
driftY = 0;
placeAtScreenEdge();
SoundManager.addSound(HomingBeep);
}
override public function homing():void{
var _local1:Number = (250 - accurateLocation.x);
var _local2:Number = (250 - accurateLocation.y);
var _local3:Number = ((180 * Math.atan2(_local2, _local1)) / Math.PI);
var _local4:Number = (_local3 - actorClip.rotation);
if (_local4 > 180){
_local4 = (_local4 - 360);
};
if (_local4 < -180){
_local4 = (_local4 + 360);
};
if (_local4 < -5){
actorClip.rotation = (actorClip.rotation - turnSpeed);
};
if (_local4 > 5){
actorClip.rotation = (actorClip.rotation + turnSpeed);
};
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
driftX = (driftX * drag);
driftY = (driftY * drag);
var _local3:Number = ((Math.PI * actorClip.rotation) / 180);
driftX = (driftX + (accel * Math.cos(_local3)));
driftY = (driftY + (accel * Math.sin(_local3)));
accurateLocation.x = (accurateLocation.x + driftX);
accurateLocation.y = (accurateLocation.y + driftY);
super.eachFrame(_arg1, _arg2);
}
override public function spawnChildren(_arg1:Array):void{
SoundManager.addSound(HeroBang);
}
}
}//package
Section 36
//HomingRocketClip (HomingRocketClip)
package {
import flash.display.*;
public dynamic class HomingRocketClip extends MovieClip {
}
}//package
Section 37
//HUDFrame (HUDFrame)
package {
import flash.display.*;
public dynamic class HUDFrame extends MovieClip {
}
}//package
Section 38
//InstructionsClip (InstructionsClip)
package {
import flash.display.*;
public dynamic class InstructionsClip extends MovieClip {
}
}//package
Section 39
//InvulnerableBarClip (InvulnerableBarClip)
package {
import flash.display.*;
public dynamic class InvulnerableBarClip extends MovieClip {
}
}//package
Section 40
//LaserShoot (LaserShoot)
package {
import flash.media.*;
public dynamic class LaserShoot extends Sound {
}
}//package
Section 41
//LevelSelectAsteroid (LevelSelectAsteroid)
package {
import flash.display.*;
import flash.geom.*;
public class LevelSelectAsteroid extends Actor {
private const NAME_LIST:Array;
private var rotSpeed:Number;
private var centrePoint:Point;
private var orbitAngle:Number;
private var orbitDistance:Number;
private var levelTextClip:MovieClip;
private var asteroidClip:MovieClip;
public function LevelSelectAsteroid(_arg1:int, _arg2:Point, _arg3:Number, _arg4:DisplayObjectContainer){
var _local5:Number;
var _local6:Number;
NAME_LIST = ["Juno", "Astraea", "Sylvia", "Antiope", "Undina", "Juewa", "Kleopatra", "Ida", "Eros", "Veritas", "Hektor", "Hidalgo", "Icarus", "Itokawa", "Vesta", "Pallas", "Ceres"];
actorClip = new MovieClip();
super(_arg4);
if ((((_arg1 > 0)) && ((_arg1 <= 16)))){
asteroidClip = new RedAsteroidL();
_local5 = (0.5 + (0.05 * Math.random()));
_local6 = (490 + (20 * Math.random()));
levelTextClip = new FloatingTextClip();
actorClip.addChild(levelTextClip);
levelTextClip.buttonMode = true;
levelTextClip.useHandCursor = true;
levelTextClip.tBox.mouseEnabled = false;
levelTextClip.tBox.text = NAME_LIST[_arg1];
} else {
asteroidClip = new AsteroidL();
_local5 = (0.15 + (0.25 * Math.random()));
_local6 = (440 + (120 * Math.random()));
};
if (((((_arg3 % 20) == 2)) || (((_arg3 % 20) == 18)))){
_local6 = (440 + (20 * Math.random()));
if (Math.random() < 0.5){
_local6 = (_local6 + 100);
};
};
actorClip.addChild(asteroidClip);
asteroidClip.gotoAndStop((1 + Math.floor((Math.random() * 9))));
asteroidClip.rotation = (Math.random() * 360);
asteroidClip.scaleX = _local5;
asteroidClip.scaleY = _local5;
rotSpeed = ((Math.random() * 1) + 0.5);
if (Math.random() < 0.5){
rotSpeed = -(rotSpeed);
};
centrePoint = _arg2;
orbitAngle = _arg3;
orbitDistance = _local6;
setLoc(0);
actorClip.level = _arg1;
if ((((_arg1 > 0)) && ((_arg1 <= 16)))){
actorClip.buttonMode = true;
actorClip.useHandCursor = true;
};
}
private function setLoc(_arg1:Number):void{
actorClip.x = (centrePoint.x + ((1 * orbitDistance) * Math.cos(((Math.PI * ((orbitAngle + _arg1) - 90)) / 180))));
actorClip.y = (centrePoint.y + ((1 * orbitDistance) * Math.sin(((Math.PI * ((orbitAngle + _arg1) - 90)) / 180))));
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
setLoc(_arg1);
asteroidClip.rotation = (asteroidClip.rotation + rotSpeed);
}
}
}//package
Section 42
//LevelSelectScreenClip (LevelSelectScreenClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class LevelSelectScreenClip extends MovieClip {
public var rButton:SimpleButton;
public var roidsText:TextField;
public var lButton:SimpleButton;
public var muteButton:MuteSoundsButton;
public var cClip:CashClip;
public var upgradeStation:MovieClip;
public var menuButton:SimpleButton;
public var blackdrop:MovieClip;
public var musicButton:MusicButton;
}
}//package
Section 43
//LoseBoxClip (LoseBoxClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class LoseBoxClip extends MovieClip {
public var rb:SmallerGenericButtonClip;
public var titleText:TextField;
public var awardText:TextField;
public var mb:SmallerGenericButtonClip;
public var lb:SmallerGenericButtonClip;
}
}//package
Section 44
//MenuMusic (MenuMusic)
package {
import flash.media.*;
public dynamic class MenuMusic extends Sound {
}
}//package
Section 45
//MoreGamesButtonClip (MoreGamesButtonClip)
package {
public dynamic class MoreGamesButtonClip extends GenericButton {
}
}//package
Section 46
//MusicButton (MusicButton)
package {
import flash.display.*;
public dynamic class MusicButton extends MovieClip {
}
}//package
Section 47
//MuteSoundsButton (MuteSoundsButton)
package {
import flash.display.*;
public dynamic class MuteSoundsButton extends MovieClip {
}
}//package
Section 48
//Pickup (Pickup)
package {
import flash.display.*;
public class Pickup extends Actor {
private const PICKUP_LIFE:int = 1000;
private var duration:int;// = 0
public var variant:int;
private var xv:Number;
private var yv:Number;
private static const COIN_DRAG:Number = 0.8;
private static const MAGNET_POWER:Number = 1;
public static const STARBURST:int = 1;
public static const SHIELD:int = 2;
public static const BONUS_ROF:int = 3;
public static const REAR_SHOT:int = 5;
public static const SMASH:int = 4;
public function Pickup(_arg1:DisplayObjectContainer, _arg2:int):void{
duration = 0;
variant = _arg2;
actorClip = new PickupClip();
actorClip.gotoAndStop(variant);
xv = 0;
yv = 0;
super(_arg1);
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
duration++;
accurateLocation.x = (accurateLocation.x + xv);
accurateLocation.y = (accurateLocation.y + yv);
xv = (xv * COIN_DRAG);
yv = (yv * COIN_DRAG);
if (duration == Math.floor((PICKUP_LIFE * 0.8))){
actorClip.alpha = 0.5;
};
if (duration > PICKUP_LIFE){
expired = true;
};
super.eachFrame(_arg1, _arg2);
}
public function checkforCollisionWithHeroShip(_arg1:int):int{
var _local2:int;
var _local3:int = (250 - accurateLocation.x);
var _local4:int = (250 - accurateLocation.y);
var _local5:int = ((_local3 * _local3) + (_local4 * _local4));
if (_local5 < 900){
expired = true;
SoundManager.addSound(ShieldUpSound);
_local2 = variant;
};
return (_local2);
}
}
}//package
Section 49
//PickupClip (PickupClip)
package {
import flash.display.*;
public dynamic class PickupClip extends MovieClip {
}
}//package
Section 50
//PlayerInput (PlayerInput)
package {
import flash.display.*;
import flash.events.*;
public class PlayerInput {
private const MOVE_KEYS:Array;
private var _stage:Stage;
public var _keyDown:Array;
private var _buttonDown:Boolean;
private var _gameMode:Boolean;
private var _usingMouse:Boolean;
public function PlayerInput(_arg1:Stage):void{
MOVE_KEYS = [37, 38, 39, 40, 65, 68, 83, 87];
super();
_usingMouse = false;
_gameMode = false;
_keyDown = [];
var _local2:int;
while (_local2 < 200) {
_keyDown.push(false);
_local2++;
};
_stage = _arg1;
_stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed, false, 0, true);
_stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased, false, 0, true);
_stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseButtonDown, false, 0, true);
_stage.addEventListener(MouseEvent.MOUSE_UP, MouseButtonUp, false, 0, true);
_stage.focus = _stage;
_buttonDown = false;
}
private function MouseButtonUp(_arg1:MouseEvent):void{
_buttonDown = false;
}
private function MouseButtonDown(_arg1:MouseEvent):void{
_buttonDown = true;
if (_gameMode){
_usingMouse = true;
};
}
private function keyPressed(_arg1:KeyboardEvent):void{
_keyDown[_arg1.keyCode] = true;
if (_arg1.keyCode == 77){
};
if ((((((((_arg1.keyCode == 65)) || ((_arg1.keyCode == 68)))) || ((_arg1.keyCode == 37)))) || ((_arg1.keyCode == 39)))){
if (((_gameMode) && (!(_buttonDown)))){
_usingMouse = false;
};
};
}
private function keyReleased(_arg1:KeyboardEvent):void{
_keyDown[_arg1.keyCode] = false;
}
public function fireKey():Boolean{
return (((((((((((((((_keyDown[13]) || (_keyDown[88]))) || (_keyDown[16]))) || (_keyDown[90]))) || (_keyDown[67]))) || (_keyDown[70]))) || (_keyDown[32]))) || (((_buttonDown) && (_gameMode)))));
}
public function releaseFireKey():void{
_keyDown[13] = false;
_keyDown[88] = false;
_keyDown[16] = false;
_keyDown[90] = false;
_keyDown[67] = false;
_keyDown[70] = false;
_buttonDown = false;
}
public function upKey():Boolean{
return (((_keyDown[87]) || (_keyDown[38])));
}
public function downKey():Boolean{
return (((_keyDown[83]) || (_keyDown[40])));
}
private function getMouseAngle():Number{
var _local1:Number = (_stage.mouseX - 250);
var _local2:Number = (_stage.mouseY - 250);
var _local3:Number = Math.atan2(_local2, _local1);
_local3 = ((_local3 * 180) / Math.PI);
return (_local3);
}
private function compareShipAngle(_arg1:Number):Number{
var _local2:Number = (_arg1 - getMouseAngle());
if (_local2 > 180){
_local2 = (_local2 - 360);
};
if (_local2 < -180){
_local2 = (_local2 + 360);
};
if (Math.abs(_local2) < 5){
_local2 = 0;
};
return (_local2);
}
public function leftKey(_arg1:Number):Boolean{
var _local2:Boolean;
if (((_usingMouse) && (_gameMode))){
if (compareShipAngle(_arg1) > 0){
_local2 = true;
};
} else {
_local2 = ((_keyDown[65]) || (_keyDown[37]));
};
return (_local2);
}
public function rightKey(_arg1:Number):Boolean{
var _local2:Boolean;
if (((_usingMouse) && (_gameMode))){
if (compareShipAngle(_arg1) < 0){
_local2 = true;
};
} else {
_local2 = ((_keyDown[68]) || (_keyDown[39]));
};
return (_local2);
}
public function enterGameMode():void{
_gameMode = true;
}
public function exitGameMode():void{
_gameMode = false;
}
public function destroy(){
_stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
_stage.removeEventListener(KeyboardEvent.KEY_UP, keyReleased);
_stage.removeEventListener(MouseEvent.MOUSE_DOWN, MouseButtonDown);
_stage.removeEventListener(MouseEvent.MOUSE_UP, MouseButtonUp);
_stage = null;
}
}
}//package
Section 51
//ProxMine (ProxMine)
package {
import flash.display.*;
import flash.geom.*;
public class ProxMine extends Enemy {
private var rotSpeed:Number;
private var chaseRange:int;
private var shotSpread:int;
private var notHomingCounter:int;
public function ProxMine(_arg1:DisplayObjectContainer, _arg2:Boolean){
var _local4:Number;
notHomingCounter = 0;
hits = 1;
boomColour = 2;
actorClip = new ProxMineClip();
actorClip.rotation = (Math.random() * 360);
super(_arg1);
xRadius = 20;
yRadius = 20;
rotSpeed = ((Math.random() * 2) + 2);
if (Math.random() < 0.5){
rotSpeed = -(rotSpeed);
};
var _local3:Number = ((Math.random() * 2) * Math.PI);
_local4 = (Math.random() + 2);
driftX = (Math.cos(_local3) * _local4);
driftY = (Math.sin(_local3) * _local4);
placeAtScreenEdge();
if (_arg2){
actorClip.gotoAndStop(2);
chaseRange = 21000;
shotSpread = 45;
} else {
actorClip.gotoAndStop(1);
chaseRange = 12000;
shotSpread = 90;
};
}
override public function homing():void{
var _local4:Point;
var _local1:int = (250 - accurateLocation.x);
var _local2:int = (250 - accurateLocation.y);
var _local3:int = ((_local1 * _local1) + (_local2 * _local2));
if (_local3 < chaseRange){
_local4 = new Point(_local1, _local2);
_local4.normalize(0.2);
driftX = (driftX + _local4.x);
driftY = (driftY + _local4.y);
if (notHomingCounter > 40){
SoundManager.addSound(HomingBeep);
};
notHomingCounter = 0;
};
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
notHomingCounter++;
var _local3:Number = ((driftX * driftX) + (driftY * driftY));
if (_local3 > 2.5){
driftX = (driftX * 0.95);
driftY = (driftY * 0.95);
};
accurateLocation.x = (accurateLocation.x + driftX);
accurateLocation.y = (accurateLocation.y + driftY);
actorClip.rotation = (actorClip.rotation + rotSpeed);
super.eachFrame(_arg1, _arg2);
}
public function spawnBullets(_arg1:Array):void{
var _local3:Number;
var _local4:Point;
var _local5:Point;
var _local6:Point;
var _local7:Bullet;
var _local2:int;
while (_local2 < 360) {
_local3 = ((Math.PI * (_local2 + actorClip.rotation)) / 180);
_local4 = new Point(Math.cos(_local3), Math.sin(_local3));
_local5 = new Point((_local4.x * 5), (_local4.y * 5));
_local6 = new Point(accurateLocation.x, accurateLocation.y);
_local7 = new Bullet(actorClip.parent, _local6, _local5, this);
_arg1.push(_local7);
_local2 = (_local2 + shotSpread);
};
}
override public function spawnChildren(_arg1:Array):void{
SoundManager.addSound(HeroBang);
}
}
}//package
Section 52
//ProxMineClip (ProxMineClip)
package {
import flash.display.*;
public dynamic class ProxMineClip extends MovieClip {
}
}//package
Section 53
//RedAlienShip (RedAlienShip)
package {
import flash.display.*;
import flash.geom.*;
public class RedAlienShip extends Enemy {
private var lifeCount:int;
private var soundCount:int;
private var fireRate:int;
private static var BULLET_VELOCITY:Number = 4;
public function RedAlienShip(_arg1:DisplayObjectContainer, _arg2:Boolean):void{
var _local4:Number;
fireRate = 50;
if (_arg2){
fireRate = 25;
};
lifeCount = Math.floor((Math.random() * 50));
soundCount = lifeCount;
actorClip = new RedStealer();
super(_arg1);
boomColour = 2;
var _local3:Number = (50 + (Math.random() * 400));
if (Math.random() < 0.5){
driftX = -3;
_local4 = 510;
} else {
driftX = 3;
_local4 = -10;
};
driftY = 0;
placeAtLoc(_local4, _local3);
hits = 1;
xRadius = 20;
yRadius = 10;
}
override public function eachFrame(_arg1:Number, _arg2:Number):void{
if (((lifeCount - soundCount) % 80) == 0){
SoundManager.addSound(AlienSound);
};
if ((lifeCount % 50) == 0){
if (driftY != 0){
driftY = 0;
} else {
if (Math.random() < 0.5){
driftY = (driftX / 2);
} else {
driftY = (-(driftX) / 2);
};
};
};
lifeCount++;
accurateLocation.x = (accurateLocation.x + driftX);
accurateLocation.y = (accurateLocation.y + driftY);
if (((((((accurateLocation.x - _arg1) < -30)) || (((accurateLocation.x - _arg1) > 530)))) && (((lifeCount - soundCount) > 50)))){
expired = true;
escaped = true;
};
super.eachFrame(_arg1, _arg2);
}
override public function spawnChildren(_arg1:Array):void{
if (!escaped){
SoundManager.addSound(HeroBang);
};
}
override public function checkforCollisionWithHeroShip():int{
var _local1:int;
var _local2:int = ((xRadius + 10) * (xRadius + 10));
var _local3:Number = (accurateLocation.x - 250);
var _local4:Number = ((accurateLocation.y - 250) * 1.41);
if (((_local3 * _local3) + (_local4 * _local4)) < _local2){
gotHit(50);
_local1 = 1;
};
return (_local1);
}
override public function freeToFire():Boolean{
return ((((lifeCount + 25) % fireRate) == 0));
}
override public function launchBullet(_arg1:Array):void{
var _local2:Number = (250 - accurateLocation.x);
var _local3:Number = (250 - accurateLocation.y);
var _local4:Number = Math.atan2(_local3, _local2);
var _local5:Point = new Point(Math.cos(_local4), Math.sin(_local4));
_local5.normalize(BULLET_VELOCITY);
var _local6:Point = new Point((accurateLocation.x + ((_local5.x * xRadius) / BULLET_VELOCITY)), (accurateLocation.y + ((_local5.y * yRadius) / BULLET_VELOCITY)));
var _local7:Bullet = new Bullet(actorClip.parent, _local6, _local5, this);
_arg1.push(_local7);
SoundManager.addSound(LaserShoot);
}
}
}//package
Section 54
//RedAsteroidL (RedAsteroidL)
package {
import flash.display.*;
public dynamic class RedAsteroidL extends MovieClip {
}
}//package
Section 55
//RedStealer (RedStealer)
package {
import flash.display.*;
public dynamic class RedStealer extends MovieClip {
}
}//package
Section 56
//RotatingCoin (RotatingCoin)
package {
import flash.display.*;
public dynamic class RotatingCoin extends MovieClip {
}
}//package
Section 57
//ShieldClip (ShieldClip)
package {
import flash.display.*;
public dynamic class ShieldClip extends Sprite {
}
}//package
Section 58
//ShieldUpSound (ShieldUpSound)
package {
import flash.media.*;
public dynamic class ShieldUpSound extends Sound {
}
}//package
Section 59
//ShortBeepSound (ShortBeepSound)
package {
import flash.media.*;
public dynamic class ShortBeepSound extends Sound {
}
}//package
Section 60
//SmallerGenericButtonClip (SmallerGenericButtonClip)
package {
public dynamic class SmallerGenericButtonClip extends GenericButton {
}
}//package
Section 61
//SoundManager (SoundManager)
package {
import flash.events.*;
import flash.media.*;
public class SoundManager {
public static var soundVolume:Number = 1;
private static var soundList:Array = [];
public static var musicMuted:Boolean = false;
private static var trackPlaying:int = 0;
private static var musicChannel:SoundChannel = new SoundChannel();
public function SoundManager():void{
}
public static function changeTrack(_arg1:int):void{
if ((((trackPlaying > 0)) && (!(musicMuted)))){
stopMusic();
};
trackPlaying = _arg1;
if (!musicMuted){
startTrack();
};
}
private static function startTrack():void{
var _local1:Sound;
if (trackPlaying == 1){
_local1 = new GameMusic();
} else {
if (trackPlaying == 2){
_local1 = new MenuMusic();
};
};
if ((((trackPlaying == 1)) || ((trackPlaying == 2)))){
musicChannel = _local1.play(0.8);
musicChannel.addEventListener(Event.SOUND_COMPLETE, loopMusic);
};
}
private static function stopMusic():void{
if (trackPlaying > 0){
try {
musicChannel.removeEventListener(Event.SOUND_COMPLETE, loopMusic);
} catch(err:Error) {
trace(err.errorID);
};
musicChannel.stop();
};
}
private static function loopMusic(_arg1:Event):void{
stopMusic();
startTrack();
}
public static function musicMuteButtonPressed(_arg1:Event=null):void{
if (musicMuted){
musicMuted = false;
startTrack();
} else {
musicMuted = true;
stopMusic();
};
}
public static function muteButtonPressed(_arg1:Event=null):void{
if (soundVolume == 0){
soundVolume = 1;
} else {
soundVolume = 0;
};
}
public static function eachFrame(_arg1:Event=null):void{
var _local3:Class;
var _local2:SoundTransform = new SoundTransform(soundVolume, 0);
for each (_local3 in soundList) {
new (_local3).play(0, 1, _local2);
};
soundList = [];
}
public static function addSound(_arg1:Class):void{
if (soundList.indexOf(_arg1) == -1){
soundList.push(_arg1);
};
}
}
}//package
Section 62
//SplashNoSound (SplashNoSound)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class SplashNoSound extends MovieClip {
public var player:MovieClip;
public var button_url:SimpleButton;
public function SplashNoSound(){
addFrameScript(1, frame2, 199, frame200);
}
public function url_pull(_arg1:MouseEvent){
var _local2:String = this.root.loaderInfo.url.replace("&", "%26");
var _local3:* = (("http://www.crazygames.com/?utm_source=" + _local2) + "&utm_medium=splash&utm_campaign=upgradaroids");
var _local4:URLRequest = new URLRequest(_local3);
navigateToURL(_local4, "_blank");
}
function frame2(){
button_url.addEventListener(MouseEvent.CLICK, url_pull);
button_url.useHandCursor = true;
}
function frame200(){
stop();
}
}
}//package
Section 63
//SplashWithSound (SplashWithSound)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class SplashWithSound extends MovieClip {
public var player:MovieClip;
public var button_url:SimpleButton;
public function SplashWithSound(){
addFrameScript(1, frame2, 199, frame200);
}
public function url_pull(_arg1:MouseEvent){
var _local2:String = this.root.loaderInfo.url.replace("&", "%26");
var _local3:* = (("http://www.crazygames.com/?utm_source=" + _local2) + "&utm_medium=splash&utm_campaign=upgradaroids");
var _local4:URLRequest = new URLRequest(_local3);
navigateToURL(_local4, "_blank");
}
function frame2(){
button_url.addEventListener(MouseEvent.CLICK, url_pull);
button_url.useHandCursor = true;
}
function frame200(){
stop();
}
}
}//package
Section 64
//StartLevelClip (StartLevelClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class StartLevelClip extends MovieClip {
public var roid:RedAsteroidL;
public var rb:GenericButtonClip;
public var generalText:TextField;
public var titleText:TextField;
public var statText:TextField;
public var lb:GenericButtonClip;
}
}//package
Section 65
//Stealer (Stealer)
package {
import flash.display.*;
public dynamic class Stealer extends MovieClip {
}
}//package
Section 66
//Upgradaroids (Upgradaroids)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.media.*;
import flash.net.*;
import flash.text.*;
public class Upgradaroids extends MovieClip {
public var startGameButton:MovieClip;
public var playNoSoundButton:SimpleButton;
public var moreText:TextField;
public var playSoundButton:SimpleButton;
public var progressText:TextField;
public var frameCounter:Number;
private var asteroidArray:Array;
private var frontMenuClip:MovieClip;
private var levelSelectScreenClip:MovieClip;
private var levelSelectRotation:Number;
private var asteroidDrift:Number;
private var highestLevelAccessible:int;
private var fightScreen:FightScreen;
private var saveGame:SharedObject;
private var coins:int;
private var totalRoidsDestroyed:int;
private var dialogBox:MovieClip;
private var playerInput:PlayerInput;
private var upgradeList:Array;
private var upgrader:UpgraderScreen;
private var levelSelectClip:MovieClip;
private var clipNumberOpen:int;
private var frameCount:int;// = 0
private var startSound:Boolean;// = true
private var ads:FGLAds;
public function Upgradaroids():void{
addFrameScript(0, frame1, 2, frame3, 3, frame4, 4, frame5);
stage.showDefaultContextMenu = false;
stage.focus = stage;
stage.stageFocusRect = false;
}
public function loadProgress(_arg1:Event){
frameCounter = (frameCounter + 2.5);
var _local2:int = this.root.loaderInfo.bytesLoaded;
var _local3:int = this.root.loaderInfo.bytesTotal;
progressText.text = (Math.floor(Math.min(((100 * _local2) / _local3), frameCounter)).toString() + "/100");
if ((((_local2 >= _local3)) && ((frameCounter > 100)))){
removeEventListener(Event.ENTER_FRAME, loadProgress);
progressText.visible = false;
gotoAndStop(3);
};
}
public function startGame(_arg1:MouseEvent){
var _local2:SoundTransform = new SoundTransform(0);
gotoAndStop(4);
}
public function startQuietGame(_arg1:MouseEvent){
var _local2:SoundTransform = new SoundTransform(0);
gotoAndStop(5);
}
private function showFGLAds():void{
ads = new FGLAds(stage, "FGD-20028250");
ads.addEventListener(FGLAds.EVT_API_READY, showStartupAd);
}
function showStartupAd(_arg1:Event):void{
ads.showAdPopup();
}
function makeStartGameButtonAButton():void{
startGameButton.visible = false;
startGameButton.useHandCursor = true;
startGameButton.buttonMode = true;
}
public function beginNoSound():void{
addEventListener(Event.ENTER_FRAME, splashFrameCounter);
makeStartGameButtonAButton();
startSound = false;
}
public function beginWithSound():void{
addEventListener(Event.ENTER_FRAME, splashFrameCounter);
makeStartGameButtonAButton();
}
private function splashFrameCounter(_arg1:Event):void{
frameCount++;
if (frameCount >= 180){
removeEventListener(Event.ENTER_FRAME, splashFrameCounter);
startGameButton.visible = true;
startGameButton.addEventListener(MouseEvent.CLICK, skipSplashScreen);
};
}
private function skipSplashScreen(_arg1:Event=null){
startGameButton.removeEventListener(MouseEvent.CLICK, skipSplashScreen);
startGameButton.visible = false;
setEverythingUp();
if (!startSound){
SoundManager.musicMuteButtonPressed();
SoundManager.muteButtonPressed();
};
launchGame();
}
private function setEverythingUp():void{
playerInput = new PlayerInput(stage);
saveGame = SharedObject.getLocal("CuriousGaming/Upgradaroids001sav", "/");
addEventListener(Event.ENTER_FRAME, SoundManager.eachFrame);
upgrader = new UpgraderScreen(stage);
upgrader.addEventListener(GameEvent.QUIT_UPGRADER, closeUpgrader);
levelSelectScreenClip = new LevelSelectScreenClip();
addChild(levelSelectScreenClip);
levelSelectScreenClip.menuButton.addEventListener(MouseEvent.CLICK, menuButtonPressed);
levelSelectScreenClip.menuButton.addEventListener(MouseEvent.MOUSE_OVER, playShortBeep);
levelSelectScreenClip.lButton.addEventListener(MouseEvent.MOUSE_OVER, sendLeft);
levelSelectScreenClip.rButton.addEventListener(MouseEvent.MOUSE_OVER, sendRight);
levelSelectScreenClip.lButton.addEventListener(MouseEvent.MOUSE_OUT, stopAsteroidDrift);
levelSelectScreenClip.rButton.addEventListener(MouseEvent.MOUSE_OUT, stopAsteroidDrift);
levelSelectScreenClip.lButton.addEventListener(MouseEvent.MOUSE_OVER, playShortBeep);
levelSelectScreenClip.rButton.addEventListener(MouseEvent.MOUSE_OVER, playShortBeep);
levelSelectScreenClip.upgradeStation.addEventListener(MouseEvent.MOUSE_OVER, playShortBeep);
levelSelectScreenClip.upgradeStation.addEventListener(MouseEvent.CLICK, upgradeStationClicked);
MovieClip(levelSelectScreenClip.upgradeStation.us.windows).mouseEnabled = false;
MovieClip(levelSelectScreenClip.upgradeStation).useHandCursor = true;
MovieClip(levelSelectScreenClip.upgradeStation).buttonMode = true;
levelSelectScreenClip.muteButton.addEventListener(MouseEvent.CLICK, muteButtonPressed);
levelSelectScreenClip.musicButton.addEventListener(MouseEvent.CLICK, musicMuteButtonPressed);
MovieClip(levelSelectScreenClip.muteButton).buttonMode = true;
MovieClip(levelSelectScreenClip.musicButton).buttonMode = true;
MovieClip(levelSelectScreenClip.muteButton).useHandCursor = true;
MovieClip(levelSelectScreenClip.musicButton).useHandCursor = true;
levelSelectScreenClip.visible = false;
asteroidDrift = 0;
frontMenuClip = new GameMenuScreenClip();
addChild(frontMenuClip);
asteroidArray = [];
frontMenuClip.newGameButton.addEventListener(MouseEvent.CLICK, newGameButtonPressed);
frontMenuClip.newGameButton.bText.text = "New Game";
frontMenuClip.continueGameButton.bText.text = "Continue Game";
frontMenuClip.muteButton.addEventListener(MouseEvent.CLICK, muteButtonPressed);
frontMenuClip.musicButton.addEventListener(MouseEvent.CLICK, musicMuteButtonPressed);
MovieClip(frontMenuClip.muteButton).buttonMode = true;
MovieClip(frontMenuClip.musicButton).buttonMode = true;
MovieClip(frontMenuClip.muteButton).useHandCursor = true;
MovieClip(frontMenuClip.musicButton).useHandCursor = true;
frontMenuClip.instructionsButton.bText.text = "Instructions";
frontMenuClip.instructionsButton.addEventListener(MouseEvent.MOUSE_OVER, showInstructions);
frontMenuClip.instructionsButton.addEventListener(MouseEvent.MOUSE_OUT, hideInstructions);
frontMenuClip.instructionsClip.visible = false;
frontMenuClip.webClickButton.addEventListener(MouseEvent.CLICK, webLink);
frontMenuClip.moreGamesButton.addEventListener(MouseEvent.CLICK, moreGamesLink);
}
private function webLink(_arg1:Event=null){
var _local2:URLRequest = new URLRequest("http://www.curiousgaming.co.uk");
navigateToURL(_local2, "_blank");
}
private function moreGamesLink(_arg1:Event=null){
var _local2:String = stage.root.loaderInfo.url.replace("&", "%26");
var _local3:* = (("http://www.crazygames.com/?utm_source=" + _local2) + "&utm_medium=more_games_menu&utm_campaign=upgradaroids");
var _local4:URLRequest = new URLRequest(_local3);
navigateToURL(_local4, "_blank");
}
private function launchGame():void{
SoundManager.changeTrack(2);
frontMenuClip.continueGameButton.addEventListener(MouseEvent.CLICK, continueGame);
showFrontMenu();
}
private function muteButtonPressed(_arg1:Event=null):void{
SoundManager.muteButtonPressed();
showMuteLevels();
}
private function musicMuteButtonPressed(_arg1:Event=null):void{
SoundManager.musicMuteButtonPressed();
showMuteLevels();
}
private function showMuteLevels():void{
if (SoundManager.musicMuted){
frontMenuClip.musicButton.alpha = 0.5;
levelSelectScreenClip.musicButton.alpha = 0.5;
} else {
frontMenuClip.musicButton.alpha = 1;
levelSelectScreenClip.musicButton.alpha = 1;
};
if (SoundManager.soundVolume == 0){
frontMenuClip.muteButton.alpha = 0.5;
levelSelectScreenClip.muteButton.alpha = 0.5;
} else {
frontMenuClip.muteButton.alpha = 1;
levelSelectScreenClip.muteButton.alpha = 1;
};
}
private function hideInstructions(_arg1:MouseEvent):void{
frontMenuClip.instructionsClip.visible = false;
}
private function showInstructions(_arg1:MouseEvent):void{
frontMenuClip.instructionsClip.visible = true;
}
private function playBeep(_arg1:Event=null):void{
SoundManager.addSound(BeepSound);
}
private function playShortBeep(_arg1:Event=null):void{
SoundManager.addSound(ShortBeepSound);
}
private function showFrontMenu():void{
showMuteLevels();
if (saveGame.data.exists == null){
frontMenuClip.continueGameButton.visible = false;
} else {
frontMenuClip.continueGameButton.visible = true;
};
addEventListener(Event.ENTER_FRAME, mainMenuEachFrame);
frontMenuClip.visible = true;
addFrontMenuAsteroids();
}
private function hidefrontMenu():void{
frontMenuClip.visible = false;
removeEventListener(Event.ENTER_FRAME, mainMenuEachFrame);
removeAsteroids();
}
private function addFrontMenuAsteroids():void{
var _local2:Asteroid;
var _local1:int;
while (_local1 < 15) {
_local2 = new Asteroid(((_local1 % 3) + 1), frontMenuClip.blackdrop, 1);
_local2.placeAtLoc((Math.random() * 500), (Math.random() * 500));
asteroidArray.push(_local2);
_local1++;
};
}
private function saveTheGame():void{
saveGame.data.exists = true;
saveGame.data.levelReached = highestLevelAccessible;
saveGame.data.money = coins;
saveGame.data.upgradeList = upgradeList;
saveGame.data.roidsDestroyed = totalRoidsDestroyed;
saveGame.flush();
}
private function newGameButtonPressed(_arg1:MouseEvent):void{
if (saveGame.data.exists == null){
newGame();
} else {
dialogBox = new DialogBoxClip();
addChild(dialogBox);
dialogBox.x = 250;
dialogBox.y = 250;
dialogBox.rb.bText.text = "No";
dialogBox.titleText.text = "Are you sure?";
dialogBox.generalText.text = "Starting a new game will erase your previous game data";
dialogBox.lb.addEventListener(MouseEvent.CLICK, dismissDialogBoxAndNewGame);
dialogBox.rb.addEventListener(MouseEvent.CLICK, dismissDialogBox);
};
}
private function dismissDialogBox(_arg1:MouseEvent=null):void{
dialogBox.rb.removeEventListener(MouseEvent.CLICK, dismissDialogBox);
dialogBox.lb.removeEventListener(MouseEvent.CLICK, dismissDialogBoxAndNewGame);
dialogBox.lb.destroy();
dialogBox.rb.destroy();
removeChild(dialogBox);
dialogBox = null;
}
private function dismissDialogBoxAndNewGame(_arg1:MouseEvent):void{
dismissDialogBox();
newGame();
}
private function newGame(_arg1:MouseEvent=null):void{
highestLevelAccessible = 1;
coins = 0;
totalRoidsDestroyed = 0;
upgradeList = [0, 0, 0, 0, 0, 0];
saveTheGame();
hidefrontMenu();
showLevelSelectScreen();
stage.focus = stage;
}
private function continueGame(_arg1:MouseEvent=null):void{
if (saveGame.data.exists == null){
newGame();
} else {
highestLevelAccessible = saveGame.data.levelReached;
coins = saveGame.data.money;
totalRoidsDestroyed = saveGame.data.roidsDestroyed;
upgradeList = saveGame.data.upgradeList;
hidefrontMenu();
showLevelSelectScreen();
};
stage.focus = stage;
playBeep();
}
private function removeAsteroids():void{
var _local1:Actor;
for each (_local1 in asteroidArray) {
_local1.destroy();
};
asteroidArray = [];
}
private function removeAsteroidEvents():void{
var _local1:LevelSelectAsteroid;
for each (_local1 in asteroidArray) {
if (_local1.actorClip.level > 0){
_local1.actorClip.removeEventListener(MouseEvent.CLICK, levelButtonClicked);
_local1.actorClip.removeEventListener(MouseEvent.MOUSE_OVER, playShortBeep);
};
};
}
private function mainMenuEachFrame(_arg1:Event):void{
var _local2:Asteroid;
for each (_local2 in asteroidArray) {
_local2.eachFrame(0, 0);
};
}
private function showLevelSelectScreen():void{
var _local3:int;
var _local4:LevelSelectAsteroid;
showMuteLevels();
clipNumberOpen = 0;
playerInput.releaseFireKey();
levelSelectScreenClip.visible = true;
levelSelectScreenClip.cClip.cText.text = ("$" + coins.toString());
levelSelectScreenClip.roidsText.text = ("Total Asteroids Destroyed: " + totalRoidsDestroyed.toString());
var _local1:Point = new Point(50, 600);
var _local2 = 358;
while (_local2 >= 0) {
_local3 = 0;
if ((_local2 % 20) == 0){
_local3 = (1 + Math.floor((_local2 / 20)));
if (_local3 > 16){
_local3 = 0;
};
};
_local4 = new LevelSelectAsteroid(_local3, _local1, _local2, levelSelectScreenClip.blackdrop);
asteroidArray.push(_local4);
if (_local3 > 0){
_local4.actorClip.addEventListener(MouseEvent.CLICK, levelButtonClicked);
_local4.actorClip.addEventListener(MouseEvent.MOUSE_OVER, playShortBeep);
if (_local3 > highestLevelAccessible){
_local4.actorClip.visible = false;
};
};
_local2 = (_local2 - 2);
};
levelSelectRotation = ((highestLevelAccessible * -20) + 20);
if (highestLevelAccessible < 3){
levelSelectScreenClip.lButton.visible = false;
levelSelectScreenClip.rButton.visible = false;
} else {
levelSelectScreenClip.lButton.visible = true;
levelSelectScreenClip.rButton.visible = true;
};
addEventListener(Event.ENTER_FRAME, levelSelectEachFrame);
levelSelectEachFrame();
}
private function levelSelectEachFrame(_arg1:Event=null):void{
var _local2:LevelSelectAsteroid;
var _local3:Number;
for each (_local2 in asteroidArray) {
_local2.eachFrame(levelSelectRotation, 0);
};
_local3 = asteroidDrift;
if (playerInput.leftKey(0)){
_local3 = 1;
};
if (playerInput.rightKey(0)){
_local3 = -1;
};
levelSelectRotation = (levelSelectRotation + _local3);
if (levelSelectRotation < ((highestLevelAccessible * -20) + 50)){
levelSelectRotation = ((highestLevelAccessible * -20) + 50);
};
if (levelSelectRotation > 0){
levelSelectRotation = 0;
};
if (clipNumberOpen == 0){
if (playerInput.fireKey()){
openSelectBox(highestLevelAccessible);
} else {
if (playerInput._keyDown[27]){
menuButtonPressed();
};
};
} else {
levelSelectClip.roid.rotation = (levelSelectClip.roid.rotation + 1.5);
if (playerInput._keyDown[27]){
dontPlayLevel();
playerInput._keyDown[27] = false;
} else {
if (playerInput.fireKey()){
playLevel(clipNumberOpen);
};
};
};
}
private function sendLeft(_arg1:MouseEvent):void{
asteroidDrift = 1;
}
private function sendRight(_arg1:MouseEvent):void{
asteroidDrift = -1;
}
private function stopAsteroidDrift(_arg1:MouseEvent):void{
asteroidDrift = 0;
}
private function hideLevelSelect():void{
removeEventListener(Event.ENTER_FRAME, levelSelectEachFrame);
removeAsteroidEvents();
removeAsteroids();
levelSelectScreenClip.visible = false;
stage.focus = stage;
}
private function menuButtonPressed(_arg1:MouseEvent=null):void{
playBeep();
hideLevelSelect();
showFrontMenu();
}
private function levelButtonClicked(_arg1:MouseEvent):void{
var _local2:MovieClip = MovieClip(_arg1.currentTarget);
clipNumberOpen = int(_local2.level);
openSelectBox(clipNumberOpen);
stage.focus = stage;
}
private function openSelectBox(_arg1:int):void{
clipNumberOpen = _arg1;
playerInput.releaseFireKey();
levelSelectClip = new StartLevelClip();
stage.addChild(levelSelectClip);
levelSelectClip.x = 250;
levelSelectClip.y = 250;
levelSelectClip.lb.bText.text = "Cancel";
levelSelectClip.lb.addEventListener(MouseEvent.CLICK, dontPlayLevel);
levelSelectClip.rb.bText.text = "Play";
levelSelectClip.rb.addEventListener(MouseEvent.CLICK, playLevelClicked);
levelSelectClip.roid.gotoAndStop(1);
var _local2:Array = ["Tibetalk", "Astraea", "Sylvia", "Antiope", "Undina", "Juewa", "Kleopatra", "Ida", "Eros", "Veritas", "Hektor", "Hidalgo", "Icarus", "Itokawa", "Vesta", "Pallas", "Ceres"];
levelSelectClip.titleText.text = _local2[clipNumberOpen];
switch (clipNumberOpen){
case 1:
levelSelectClip.statText.text = "Diameter: 117km\nDiscovered: 1845, December 8\nClass: S-type";
levelSelectClip.generalText.text = "This asteroid rose to fame after starring in an Atari game in the 1980's.";
break;
case 2:
levelSelectClip.statText.text = "Diameter: 261m\nDiscovered: 1866, May 16\nClass: X-type";
levelSelectClip.generalText.text = "Fact: Asteroids mysteriously attract flying saucers and other aliens.";
break;
case 3:
levelSelectClip.statText.text = "Diameter: 80km\nDiscovered: 1866, October 1\nClass: C-type";
levelSelectClip.generalText.text = "Asteroids are often mined for their Nvidium, a valuable rare mineral.";
break;
case 4:
levelSelectClip.statText.text = "Diameter: 226km\nDiscovered: 1867, July 7\nClass: M-type";
levelSelectClip.generalText.text = "Asteroid football has been banned in nine galaxies.";
break;
case 5:
levelSelectClip.statText.text = "Diameter: 162km\nDiscovered: 1874, October 10\nClass: C-type";
levelSelectClip.generalText.text = "Ingredients for asteroid soup: Take one small asteroid and melt in a pan.";
break;
case 6:
levelSelectClip.statText.text = "Diameter: 217km\nDiscovered: 1880, April 10\nClass: M-type";
levelSelectClip.generalText.text = "This is not the asteroid you are looking for.";
break;
case 7:
levelSelectClip.statText.text = "Diameter: 56km\nDiscovered: 1884, September 29\nClass: S-type";
levelSelectClip.generalText.text = "This asteroid is made from frozen dog milk. Its origin is a complete mystery.";
break;
case 8:
levelSelectClip.statText.text = "Diameter: 33km\nDiscovered: 1898, August 13\nClass: S-type";
levelSelectClip.generalText.text = "Choking hazard: Do not let young children play with the asteroids.";
break;
case 9:
levelSelectClip.statText.text = "Diameter: 115m\nDiscovered: 1902, September 3\nClass: Unknown";
levelSelectClip.generalText.text = "Do not smash two asteroids together to see what happens.";
break;
case 10:
levelSelectClip.statText.text = "Diameter: 370m\nDiscovered: 1907, February 10\nClass: D-type";
levelSelectClip.generalText.text = "You aren't going to leave these innocent asteroids alone, are you?";
break;
case 11:
levelSelectClip.statText.text = "Diameter: 38km\nDiscovered: 1920, October 31\nClass: D-type";
levelSelectClip.generalText.text = "Q: What is an asteroids favourite candy? A: Rock.";
break;
case 12:
levelSelectClip.statText.text = "Diameter: 1400m\nDiscovered: 1949, June 27\nClass: U-type";
levelSelectClip.generalText.text = "If Bruce Willis can blow them up, why can't you?";
break;
case 13:
levelSelectClip.statText.text = "Diameter: 630m\nDiscovered: 1998, September 26\nClass: S-type";
levelSelectClip.generalText.text = "Thanks to you, asteroids are now an endangered species.";
break;
case 14:
levelSelectClip.statText.text = "Diameter: 529km\nDiscovered: 1807, March 29\nClass: V-type";
levelSelectClip.generalText.text = "This asteroid has sworn to destroy you.";
break;
case 15:
levelSelectClip.statText.text = "Diameter: 544km\nDiscovered: 1802, March 28\nClass: B-type";
levelSelectClip.generalText.text = "Fact: After killing every dinosaur, this asteroid jumped back into orbit.";
break;
case 16:
levelSelectClip.statText.text = "Diameter: 952km\nDiscovered: 1801, January 1\nClass: G-type";
levelSelectClip.generalText.text = "The big daddy of all the asteroids. It has come for revenge.";
break;
};
stage.focus = stage;
}
private function dontPlayLevel(_arg1:Event=null):void{
closeSelectBox();
}
private function playLevelClicked(_arg1:MouseEvent):void{
playLevel(clipNumberOpen);
}
private function closeSelectBox():void{
clipNumberOpen = 0;
levelSelectClip.lb.removeEventListener(MouseEvent.CLICK, dontPlayLevel);
stage.removeChild(levelSelectClip);
levelSelectClip = null;
playBeep();
}
private function playLevel(_arg1:int):void{
closeSelectBox();
hideLevelSelect();
playerInput.releaseFireKey();
fightScreen = new FightScreen(stage, _arg1, coins, upgradeList, playerInput);
fightScreen.addEventListener(GameEvent.LEVEL_CLOSED, roundFinished);
fightScreen.addEventListener(GameEvent.LEVEL_WON, levelWon);
playBeep();
}
private function replayLevel(_arg1:int):void{
hideLevelSelect();
fightScreen = new FightScreen(stage, _arg1, coins, upgradeList, playerInput);
fightScreen.addEventListener(GameEvent.LEVEL_CLOSED, roundFinished);
fightScreen.addEventListener(GameEvent.LEVEL_WON, levelWon);
playBeep();
}
private function upgradeStationClicked(_arg1:MouseEvent):void{
playBeep();
hideLevelSelect();
showUpgrader();
}
private function showUpgrader():void{
upgrader.show(upgradeList, coins);
showMuteLevels();
}
private function closeUpgrader(_arg1:GameEvent):void{
upgradeList = upgrader.upgradeList;
coins = upgrader.cash;
saveTheGame();
upgrader.hide();
showLevelSelectScreen();
}
private function levelWon(_arg1:GameEvent):void{
if (fightScreen.levelNumber == highestLevelAccessible){
highestLevelAccessible++;
};
if (highestLevelAccessible > 16){
highestLevelAccessible = 16;
dialogBox = new WinGameClip();
addChild(dialogBox);
dialogBox.rb.bText.text = "Continue";
dialogBox.rb.addEventListener(MouseEvent.CLICK, dismissVictoryBox);
};
}
private function dismissVictoryBox(_arg1:MouseEvent=null):void{
dialogBox.rb.removeEventListener(MouseEvent.CLICK, dismissDialogBox);
dialogBox.rb.destroy();
removeChild(dialogBox);
dialogBox = null;
}
private function roundFinished(_arg1:GameEvent):void{
playerInput.releaseFireKey();
var _local2:Boolean = fightScreen.autoRestart;
var _local3:int = fightScreen.levelNumber;
var _local4:Boolean = fightScreen.autoUpgrade;
coins = fightScreen.cash;
totalRoidsDestroyed = (totalRoidsDestroyed + fightScreen.roidsDestroyed);
levelSelectScreenClip.cClip.cText.text = ("$" + coins.toString());
fightScreen.removeEventListener(GameEvent.LEVEL_CLOSED, roundFinished);
fightScreen.removeEventListener(GameEvent.LEVEL_WON, levelWon);
fightScreen = null;
showLevelSelectScreen();
saveTheGame();
if (_local2){
replayLevel(_local3);
};
if (_local4){
hideLevelSelect();
showUpgrader();
};
}
function frame1(){
stop();
addEventListener(Event.ENTER_FRAME, loadProgress);
frameCounter = 0;
}
function frame3(){
stop();
playSoundButton.addEventListener(MouseEvent.CLICK, startGame);
playNoSoundButton.addEventListener(MouseEvent.CLICK, startQuietGame);
}
function frame4(){
beginWithSound();
}
function frame5(){
beginNoSound();
}
}
}//package
Section 67
//UpgraderClip (UpgraderClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class UpgraderClip extends MovieClip {
public var box1:MovieClip;
public var box2:MovieClip;
public var box3:MovieClip;
public var box4:MovieClip;
public var box5:MovieClip;
public var box6:MovieClip;
public var exitButton:GenericButtonClip;
public var cashText:TextField;
}
}//package
Section 68
//UpgraderScreen (UpgraderScreen)
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
public class UpgraderScreen extends EventDispatcher {
private var screenClip:MovieClip;
public var upgradeList:Array;
public var cash:int;
public static const MULTISHOT:int = 0;
public static const STARTING_LIVES:int = 1;
public static const ROF:int = 2;
public static const COIN_MAGNET:int = 3;
public static const SHIELD_DRAIN:int = 4;
public static const BONUS_DROPS:int = 5;
private static const MAX_MULTISHOT:int = 2;
private static const MAX_LIVES:int = 4;
private static const MAX_ROF:int = 6;
private static const MAX_SHIELD_DRAIN:int = 4;
private static const MAX_BONUS_DROPS:int = 4;
private static const MAX_COIN_MAGNET:int = 5;
public function UpgraderScreen(_arg1:DisplayObjectContainer){
screenClip = new UpgraderClip();
_arg1.addChild(screenClip);
screenClip.exitButton.bText.text = "Done";
screenClip.exitButton.addEventListener(MouseEvent.CLICK, quitButtonPressed);
screenClip.box1.titleText.text = "Multishot";
screenClip.box1.boxPic.gotoAndStop(1);
screenClip.box1.addEventListener(MouseEvent.CLICK, upgradeMultishot);
setupBox(screenClip.box1);
screenClip.box2.titleText.text = "Extra Lives";
screenClip.box2.boxPic.gotoAndStop(2);
screenClip.box2.addEventListener(MouseEvent.CLICK, upgradeShipLives);
setupBox(screenClip.box2);
screenClip.box3.titleText.text = "Rate of Fire";
screenClip.box3.boxPic.gotoAndStop(3);
screenClip.box3.addEventListener(MouseEvent.CLICK, upgradeROF);
setupBox(screenClip.box3);
screenClip.box4.titleText.text = "Coin Magnet Range";
screenClip.box4.boxPic.gotoAndStop(4);
screenClip.box4.addEventListener(MouseEvent.CLICK, upgradeCoinMagnet);
setupBox(screenClip.box4);
screenClip.box5.titleText.text = "Shield Duration";
screenClip.box5.boxPic.gotoAndStop(5);
screenClip.box5.addEventListener(MouseEvent.CLICK, upgradeShieldDrain);
setupBox(screenClip.box5);
screenClip.box6.titleText.text = "Play More Games";
screenClip.box6.boxPic.gotoAndStop(6);
screenClip.box6.addEventListener(MouseEvent.CLICK, upgradeBonusDrops);
setupBox(screenClip.box6);
screenClip.box6.currentText.text = "Visit";
screenClip.box6.nextText.text = "CrazyGames.com";
TextField(screenClip.box6.nextText).scaleX = 0.8;
TextField(screenClip.box6.nextText).scaleY = 0.8;
TextField(screenClip.box6.nextText).x = (TextField(screenClip.box6.nextText).x + 15);
screenClip.box6.costText.text = "Cost: $FREE!";
hide();
}
private function setupBox(_arg1:MovieClip):void{
_arg1.addEventListener(MouseEvent.MOUSE_OVER, playShortBeep);
_arg1.titleText.mouseEnabled = false;
_arg1.boxPic.mouseEnabled = false;
MovieClip(_arg1.boxPic).mouseChildren = false;
_arg1.nextText.mouseEnabled = false;
_arg1.currentText.mouseEnabled = false;
_arg1.costText.mouseEnabled = false;
_arg1.buttonMode = true;
_arg1.useHandCursor = true;
}
private function playShortBeep(_arg1:Event=null):void{
SoundManager.addSound(ShortBeepSound);
}
private function updateCurrent():void{
var _local2:String;
var _local1:String = ("Cash: $" + numberDelimiter(cash));
screenClip.cashText.text = _local1;
screenClip.box1.currentText.text = ("Current: " + numShots(upgradeList[MULTISHOT]));
if (upgradeList[MULTISHOT] == MAX_MULTISHOT){
screenClip.box1.nextText.text = "Fully Upgraded";
screenClip.box1.costText.text = "";
} else {
screenClip.box1.nextText.text = ("Next: " + numShots((upgradeList[MULTISHOT] + 1)));
_local2 = numberDelimiter(multishotCost());
screenClip.box1.costText.text = ("Cost: $" + _local2);
};
screenClip.box2.currentText.text = ("Current: " + startingLives(upgradeList[STARTING_LIVES]));
if (upgradeList[STARTING_LIVES] == MAX_LIVES){
screenClip.box2.nextText.text = "Fully Upgraded";
screenClip.box2.costText.text = "";
} else {
screenClip.box2.nextText.text = ("Next: " + startingLives((upgradeList[STARTING_LIVES] + 1)));
_local2 = numberDelimiter(StartingLivesCost());
screenClip.box2.costText.text = ("Cost: $" + _local2);
};
screenClip.box3.currentText.text = (("Current: " + rateOfFire(upgradeList[ROF])) + " RPM");
if (upgradeList[ROF] == MAX_ROF){
screenClip.box3.nextText.text = "Fully Upgraded";
screenClip.box3.costText.text = "";
} else {
screenClip.box3.nextText.text = (("Next: " + rateOfFire((upgradeList[ROF] + 1))) + " RPM");
_local2 = numberDelimiter(ROFCost());
screenClip.box3.costText.text = ("Cost: $" + _local2);
};
screenClip.box4.currentText.text = ("Current: " + coinDrawDistance(upgradeList[COIN_MAGNET]));
if (upgradeList[COIN_MAGNET] == MAX_COIN_MAGNET){
screenClip.box4.nextText.text = "Fully Upgraded";
screenClip.box4.costText.text = "";
} else {
screenClip.box4.nextText.text = ("Next: " + coinDrawDistance((upgradeList[COIN_MAGNET] + 1)));
_local2 = numberDelimiter(coinMagnetCost());
screenClip.box4.costText.text = ("Cost: $" + _local2);
};
var _local3:Number = (4 / shieldDrain(upgradeList[SHIELD_DRAIN]));
screenClip.box5.currentText.text = (("Current: " + _local3.toFixed(1)) + " secs");
if (upgradeList[SHIELD_DRAIN] == MAX_SHIELD_DRAIN){
screenClip.box5.nextText.text = "Fully Upgraded";
screenClip.box5.costText.text = "";
} else {
_local3 = (4 / shieldDrain((upgradeList[SHIELD_DRAIN] + 1)));
screenClip.box5.nextText.text = (("Next: " + _local3.toFixed(1)) + " secs");
_local2 = numberDelimiter(shieldDrainCost());
screenClip.box5.costText.text = ("Cost: $" + _local2);
};
}
private function quitButtonPressed(_arg1:MouseEvent):void{
dispatchEvent(new GameEvent(GameEvent.QUIT_UPGRADER));
}
public function show(_arg1:Array, _arg2:int):void{
upgradeList = _arg1;
cash = _arg2;
updateCurrent();
screenClip.visible = true;
}
public function hide():void{
screenClip.visible = false;
}
private function upgradeMultishot(_arg1:MouseEvent):void{
if ((((cash >= multishotCost())) && ((upgradeList[MULTISHOT] < MAX_MULTISHOT)))){
cash = (cash - multishotCost());
var _local2 = upgradeList;
var _local3 = MULTISHOT;
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
updateCurrent();
SoundManager.addSound(BeepSound);
};
}
private function multishotCost():int{
var _local1:Array = [2000, 4500];
return (_local1[upgradeList[MULTISHOT]]);
}
private function upgradeShipLives(_arg1:MouseEvent):void{
if ((((cash >= StartingLivesCost())) && ((upgradeList[STARTING_LIVES] < MAX_LIVES)))){
cash = (cash - StartingLivesCost());
var _local2 = upgradeList;
var _local3 = STARTING_LIVES;
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
updateCurrent();
SoundManager.addSound(BeepSound);
};
}
private function StartingLivesCost():int{
var _local1:Array = [500, 900, 1500, 2100];
return (_local1[upgradeList[STARTING_LIVES]]);
}
private function upgradeROF(_arg1:MouseEvent):void{
if ((((cash >= ROFCost())) && ((upgradeList[ROF] < MAX_ROF)))){
cash = (cash - ROFCost());
var _local2 = upgradeList;
var _local3 = ROF;
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
updateCurrent();
SoundManager.addSound(BeepSound);
};
}
private function ROFCost():int{
var _local1:Array = [300, 800, 1600, 2500, 3500, 5000];
return (_local1[upgradeList[ROF]]);
}
private function upgradeCoinMagnet(_arg1:MouseEvent):void{
if ((((cash >= coinMagnetCost())) && ((upgradeList[COIN_MAGNET] < MAX_COIN_MAGNET)))){
cash = (cash - coinMagnetCost());
var _local2 = upgradeList;
var _local3 = COIN_MAGNET;
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
updateCurrent();
SoundManager.addSound(BeepSound);
};
}
private function coinMagnetCost():int{
var _local1:Array = [200, 500, 1000, 1400, 1800];
return (_local1[upgradeList[COIN_MAGNET]]);
}
private function upgradeShieldDrain(_arg1:MouseEvent):void{
if ((((cash >= shieldDrainCost())) && ((upgradeList[SHIELD_DRAIN] < MAX_SHIELD_DRAIN)))){
cash = (cash - shieldDrainCost());
var _local2 = upgradeList;
var _local3 = SHIELD_DRAIN;
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
updateCurrent();
SoundManager.addSound(BeepSound);
};
}
private function shieldDrainCost():int{
var _local1:Array = [250, 600, 1100, 2000];
return (_local1[upgradeList[SHIELD_DRAIN]]);
}
private function upgradeBonusDrops(_arg1:MouseEvent):void{
var _local2:String = screenClip.stage.root.loaderInfo.url.replace("&", "%26");
var _local3:* = (("http://www.crazygames.com/?utm_source=" + _local2) + "&utm_medium=more_games_shop&utm_campaign=upgradaroids");
var _local4:URLRequest = new URLRequest(_local3);
navigateToURL(_local4, "_blank");
SoundManager.addSound(BeepSound);
}
private function bonusDropsCost():int{
var _local1:Array = [400, 700, 1400, 2500];
return (_local1[upgradeList[BONUS_DROPS]]);
}
public static function numShots(_arg1:int):int{
return ((_arg1 + 1));
}
public static function startingLives(_arg1:int):int{
return ((_arg1 + 2));
}
public static function rateOfFire(_arg1:int):int{
_arg1 = Math.max(Math.min(MAX_ROF, _arg1), 0);
var _local2:Array = [150, 180, 200, 220, 250, 275, 300];
return (_local2[_arg1]);
}
public static function coinDrawDistance(_arg1:int):int{
var _local2:Array = [40, 60, 80, 100, 120, 150];
return (_local2[_arg1]);
}
public static function shieldDrain(_arg1:int):Number{
_arg1 = Math.max(Math.min(MAX_SHIELD_DRAIN, _arg1), 0);
var _local2:Array = [2, 1.33, 1, 0.67, 0.5];
return (_local2[_arg1]);
}
public static function bonosDrops(_arg1:int):Number{
return (_arg1);
}
public static function numberDelimiter(_arg1:Number, _arg2:String=",", _arg3:Number=3, _arg4:int=0):String{
var _local5 = "";
if (_arg4 != 0){
_local5 = String(Number((_arg1 % 1)).toFixed(_arg4)).substring(1);
};
var _local6:String = ("" + Math.round(_arg1));
var _local7 = "";
var _local8:int;
var _local9:int = (_local6.length - 1);
while (_local9 >= 0) {
_local8++;
_local7 = (_local6.substr(_local9, 1) + _local7);
if ((((_local8 == _arg3)) && (!((_local9 == 0))))){
_local7 = (_arg2 + _local7);
_local8 = 0;
};
_local9--;
};
_local7 = (_local7 + _local5);
return (_local7);
}
}
}//package
Section 69
//WinBoxClip (WinBoxClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class WinBoxClip extends MovieClip {
public var rb:SmallerGenericButtonClip;
public var titleText:TextField;
public var totalText:TextField;
public var awardText:TextField;
public var mb:SmallerGenericButtonClip;
}
}//package
Section 70
//WinGameClip (WinGameClip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class WinGameClip extends MovieClip {
public var rb:SmallerGenericButtonClip;
public var titleText:TextField;
public var awardText:TextField;
}
}//package