Section 1
//MochiScores (mochi.MochiScores)
package mochi {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var options = _arg1;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local2:Object;
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
_local2 = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (_arg1 != null){
if (_arg1.error != null){
if (_arg1.error == true){
if (onErrorHandler != null){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi
Section 2
//MochiServices (mochi.MochiServices)
package mochi {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
private static var _sendChannel:LocalConnection;
private static var _rcvChannelName:String;
private static var _gatewayURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _startTime:Number;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__mochiservices";
private static var _rcvChannel:LocalConnection;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (_clip != null){
if (_clip._queue != null){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function get childClip():Object{
return (_clip);
}
public static function get id():String{
return (_id);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function getVersion():String{
return ("1.32");
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_listenChannel.close();
_rcvChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
Security.allowDomain("*");
Security.allowInsecureDomain("*");
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
return (_local2);
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
private static function initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion()});
_rcvChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var cb:String;
var cblst:Object;
var method:*;
var methodName:String;
var obj:Object;
var pkg = _arg1;
cb = pkg.callbackID;
cblst = this.client._callbacks[cb];
if (!cblst){
return;
};
method = cblst.callbackMethod;
methodName = "";
obj = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
_rcvChannel.connect(_rcvChannelName);
trace("connected!");
_connecting = false;
_connected = true;
_listenChannel.close();
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
public static function get clip():Object{
return (_container);
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
_rcvChannelName = _arg1;
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var clipname:String;
var f:Function;
var req:URLRequest;
var id = _arg1;
var clip = _arg2;
clipname = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
MochiServices.allowDomains(_gatewayURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
_timer = new Timer(1000, 0);
_startTime = getTimer();
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
f = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
req = new URLRequest(_gatewayURL);
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_rcvChannel = new LocalConnection();
_rcvChannel.allowDomain("*", "localhost");
_rcvChannel.allowInsecureDomain("*", "localhost");
_rcvChannel.client = _clip;
_clip._nextcallbackID = 0;
_clip._callbacks = {};
listen();
return (_clip);
}
public static function bringToTop(_arg1:Event):void{
var e = _arg1;
if (MochiServices.clip != null){
if (MochiServices.childClip != null){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
if ((clip is DisplayObject)){
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var mc:MovieClip;
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
mc = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function connectWait(_arg1:TimerEvent):void{
if ((getTimer() - _startTime) > 10000){
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_timer.stop();
};
}
}
}//package mochi
Section 3
//cinematicMC_58 (SaveTheEarth_fla.cinematicMC_58)
package SaveTheEarth_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class cinematicMC_58 extends MovieClip {
public function cinematicMC_58(){
addFrameScript(0, frame1, 60, frame61, 120, frame121, 181, frame182, 243, frame244, 305, frame306, 366, frame367, 428, frame429, 490, frame491, 552, frame553);
}
function frame306(){
stop();
gotoAndStop(1);
}
function frame553(){
stop();
gotoAndStop(1);
}
function frame1(){
stop();
}
function frame182(){
stop();
gotoAndStop(1);
}
function frame367(){
stop();
gotoAndStop(1);
}
function frame244(){
stop();
gotoAndStop(1);
}
function frame121(){
stop();
gotoAndStop(1);
}
function frame491(){
stop();
gotoAndStop(1);
}
function frame61(){
stop();
gotoAndStop(1);
}
function frame429(){
stop();
gotoAndStop(1);
}
}
}//package SaveTheEarth_fla
Section 4
//collectGem_40 (SaveTheEarth_fla.collectGem_40)
package SaveTheEarth_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class collectGem_40 extends MovieClip {
public function collectGem_40(){
addFrameScript(24, frame25);
}
function frame25(){
stop();
}
}
}//package SaveTheEarth_fla
Section 5
//earthEnergyIndicator_55 (SaveTheEarth_fla.earthEnergyIndicator_55)
package SaveTheEarth_fla {
import flash.display.*;
public dynamic class earthEnergyIndicator_55 extends MovieClip {
public var maskMC:MovieClip;
}
}//package SaveTheEarth_fla
Section 6
//earthMC_50 (SaveTheEarth_fla.earthMC_50)
package SaveTheEarth_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class earthMC_50 extends MovieClip {
public var earthMC:MovieClip;
public var exploded:Boolean;
public function earthMC_50(){
addFrameScript(0, frame1, 9, frame10, 10, frame11, 11, frame12, 12, frame13, 13, frame14, 24, frame25, 32, frame33);
}
function frame10(){
earthMC.x = -2;
earthMC.y = -2;
}
function frame14(){
earthMC.x = 0;
earthMC.y = 0;
gotoAndStop("1");
}
function frame12(){
earthMC.x = 2;
earthMC.y = -2;
}
function frame1(){
exploded = false;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
stop();
}
function frame25(){
stop();
}
function frame13(){
earthMC.x = -2;
earthMC.y = 2;
}
public function EnterFrame(_arg1:Event){
if (exploded){
parent.gameIsOver = true;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
};
}
function frame11(){
earthMC.x = 2;
earthMC.y = 2;
}
function frame33(){
stop();
parent.gameIsOver = true;
}
}
}//package SaveTheEarth_fla
Section 7
//exp1_mc_35 (SaveTheEarth_fla.exp1_mc_35)
package SaveTheEarth_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class exp1_mc_35 extends MovieClip {
public function exp1_mc_35(){
addFrameScript(35, frame36);
}
function frame36(){
stop();
parent.exploded = true;
}
}
}//package SaveTheEarth_fla
Section 8
//exp2_79 (SaveTheEarth_fla.exp2_79)
package SaveTheEarth_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class exp2_79 extends MovieClip {
public function exp2_79(){
addFrameScript(20, frame21);
}
function frame21(){
stop();
}
}
}//package SaveTheEarth_fla
Section 9
//fader_2 (SaveTheEarth_fla.fader_2)
package SaveTheEarth_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class fader_2 extends MovieClip {
public function fader_2(){
addFrameScript(0, frame1, 12, frame13, 23, frame24);
}
function frame1(){
stop();
this.x = 1000;
}
function frame13(){
MovieClip(parent).gotoAndStop(MovieClip(parent).link);
}
function frame24(){
MovieClip(parent).gotoAndStop(MovieClip(parent).link);
}
}
}//package SaveTheEarth_fla
Section 10
//playerLifeIndicator_57 (SaveTheEarth_fla.playerLifeIndicator_57)
package SaveTheEarth_fla {
import flash.display.*;
public dynamic class playerLifeIndicator_57 extends MovieClip {
public var maskMC:MovieClip;
}
}//package SaveTheEarth_fla
Section 11
//upgradeIndicator_69 (SaveTheEarth_fla.upgradeIndicator_69)
package SaveTheEarth_fla {
import flash.display.*;
public dynamic class upgradeIndicator_69 extends MovieClip {
public var maskMC:MovieClip;
}
}//package SaveTheEarth_fla
Section 12
//alienBugMC (alienBugMC)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class alienBugMC extends MovieClip {
var explodeTimer:Timer;
var life:int;
var ID:int;
public var gemType:int;
var speed:Number;
public var dead:Boolean;// = false
var unghi:Number;// = 0
public var lifeBar:MovieClip;
var maxLife:int;
public var exploded:Boolean;// = false
var angle:Number;
public var bugGraphic:MovieClip;
var explode:deadScream;
public function alienBugMC(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:int, _arg6:int){
dead = false;
exploded = false;
unghi = 0;
super();
addFrameScript(0, frame1, 4, frame5);
this.x = _arg1;
this.y = _arg2;
angle = _arg3;
unghi = (1 + rand(0, 3));
ID = _arg6;
speed = _arg4;
gemType = _arg5;
life = (maxLife = 180);
this.rotation = ((angle * 180) / 3.14);
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(1000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function rand(_arg1:int, _arg2:int):int{
return (Math.round((_arg1 + (Math.random() * (_arg2 - _arg1)))));
}
function heroHitFunction(){
dead = true;
this.rotation = 0;
gotoAndStop("explode");
explodeSnd();
explodeTimer.start();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeEnemyID(this.ID);
}
function frame1(){
stop();
}
function frame5(){
stop();
}
function hitFunction(_arg1:Number){
life = (life - _arg1);
lifeBar.scaleX = (life / maxLife);
if (life <= 0){
dead = true;
gotoAndStop("explode");
parent.parent.playerScore = (parent.parent.playerScore + 125);
explodeSnd();
explodeTimer.start();
parent.parent.addGem(this.x, this.y, gemType);
};
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
this.x = (this.x + (speed * Math.cos(angle)));
this.y = (this.y + (speed * Math.sin(angle)));
if ((((Math.sqrt((((this.x - 350) * (this.x - 350)) + ((this.y - 267) * (this.y - 267)))) <= 65)) && (!(parent.parent.earthIsDead)))){
dead = true;
gotoAndStop("explode");
explodeTimer.start();
explodeSnd();
if (!parent.parent.earthIsDead){
parent.parent.earthMC.gotoAndPlay("move");
};
parent.parent.energy = (parent.parent.energy - 20);
parent.parent.updateGUI();
};
if ((((((((this.x < -50)) || ((this.x > 750)))) || ((this.y < -50)))) || ((this.y > 575)))){
parent.parent.removeEnemyID(this.ID);
};
}
function explodeSnd(){
var _local1:SoundChannel;
explode = new deadScream();
_local1 = explode.play();
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 13
//asteroidMC (asteroidMC)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class asteroidMC extends MovieClip {
var explodeTimer:Timer;
var ID:int;
var speed:Number;
public var dead:Boolean;// = false
var unghi:Number;// = 0
public var exploded:Boolean;// = false
var angle:Number;
var explode:astExplode;
public function asteroidMC(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:int){
dead = false;
exploded = false;
unghi = 0;
super();
addFrameScript(0, frame1, 4, frame5);
this.x = _arg1;
this.y = _arg2;
angle = _arg3;
unghi = (1 + rand(0, 3));
ID = _arg5;
speed = _arg4;
this.rotation = ((rand(0, 360) * 3.14) / 180);
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(1000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function rand(_arg1:int, _arg2:int):int{
return (Math.round((_arg1 + (Math.random() * (_arg2 - _arg1)))));
}
function heroHitFunction(){
dead = true;
this.rotation = 0;
gotoAndStop("explode");
explodeSnd();
explodeTimer.start();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeEnemyID(this.ID);
}
function frame5(){
stop();
}
function frame1(){
stop();
}
function hitFunction(_arg1:Number){
dead = true;
this.rotation = 0;
gotoAndStop("explode");
parent.parent.playerScore = (parent.parent.playerScore + 100);
explodeSnd();
explodeTimer.start();
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
this.rotation = (this.rotation + unghi);
this.x = (this.x + (speed * Math.cos(angle)));
this.y = (this.y + (speed * Math.sin(angle)));
if ((((Math.sqrt((((this.x - 350) * (this.x - 350)) + ((this.y - 267) * (this.y - 267)))) <= 65)) && (!(parent.parent.earthIsDead)))){
dead = true;
this.rotation = 0;
gotoAndStop("explode");
explodeTimer.start();
explodeSnd();
if (!parent.parent.earthIsDead){
parent.parent.earthMC.gotoAndPlay("move");
};
parent.parent.energy = (parent.parent.energy - 20);
parent.parent.updateGUI();
};
if ((((((((this.x < -50)) || ((this.x > 750)))) || ((this.y < -50)))) || ((this.y > 575)))){
parent.parent.removeEnemyID(this.ID);
};
}
function explodeSnd(){
var _local1:SoundChannel;
explode = new astExplode();
_local1 = explode.play();
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 14
//astExplode (astExplode)
package {
import flash.media.*;
public dynamic class astExplode extends Sound {
}
}//package
Section 15
//bigShootMC (bigShootMC)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class bigShootMC extends MovieClip {
var explodeTimer:Timer;
public var ident:int;// = 3
var ID:Number;
var speed:Number;
public var dead:Boolean;// = false
var contor:Number;
var dir:Number;
public var exploded:Boolean;// = false
var collectSnd:weaponUpgrade;
public var bigShoot:MovieClip;
public function bigShootMC(_arg1:Number, _arg2:Number, _arg3:int){
ident = 3;
dead = false;
exploded = false;
super();
addFrameScript(0, frame1, 30, frame31);
this.x = _arg1;
this.y = _arg2;
ID = _arg3;
speed = 0.7;
dir = rand(0, 360);
dir = ((dir * 3.14) / 180);
contor = 0;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(1000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function rand(_arg1:int, _arg2:int):int{
return (Math.round((_arg1 + (Math.random() * (_arg2 - _arg1)))));
}
function heroHitFunction(){
dead = true;
bigShoot.rotation = 0;
gotoAndPlay("explode");
explodeTimer.start();
collectSndFunc();
}
function collectSndFunc(){
var _local1:SoundChannel;
collectSnd = new weaponUpgrade();
_local1 = collectSnd.play();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeGemID(this.ID);
}
function frame1(){
stop();
}
function frame31(){
stop();
parent.exploded = true;
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
if (this.x < -100){
this.x = 755;
};
if (this.x > 800){
this.x = -50;
};
if (this.y < -100){
this.y = 575;
};
if (this.y > 625){
this.y = -50;
};
this.x = (this.x + (speed * Math.cos(dir)));
this.y = (this.y + (speed * Math.sin(dir)));
if (contor < 300){
contor++;
} else {
if (bigShoot.alpha > 0){
bigShoot.alpha = (bigShoot.alpha - 0.01);
} else {
dead = true;
parent.parent.removeGemID(this.ID);
return;
};
};
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 16
//credits (credits)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class credits extends MovieClip {
public var creditsMainBt:SimpleButton;
public function credits(){
addFrameScript(0, frame1);
}
public function goToMain(_arg1:MouseEvent){
root.link = "mainMenu";
root.faderMC.x = -50;
root.faderMC.play();
}
function frame1(){
creditsMainBt.addEventListener(MouseEvent.CLICK, goToMain);
}
}
}//package
Section 17
//deadScream (deadScream)
package {
import flash.media.*;
public dynamic class deadScream extends Sound {
}
}//package
Section 18
//debrisMC (debrisMC)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class debrisMC extends MovieClip {
var explodeTimer:Timer;
var ID:Number;
var speed:Number;
public var dead:Boolean;// = false
public var debris:MovieClip;
var contor:Number;
var dir:Number;
public var exploded:Boolean;// = false
var collectSnd:debrisPoints;
public var ident:int;// = 0
public function debrisMC(_arg1:Number, _arg2:Number, _arg3:int){
ident = 0;
dead = false;
exploded = false;
super();
addFrameScript(0, frame1, 30, frame31);
this.x = _arg1;
this.y = _arg2;
ID = _arg3;
speed = 0.7;
dir = rand(0, 360);
dir = ((dir * 3.14) / 180);
contor = 0;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(1000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function rand(_arg1:int, _arg2:int):int{
return (Math.round((_arg1 + (Math.random() * (_arg2 - _arg1)))));
}
function heroHitFunction(){
dead = true;
debris.rotation = 0;
gotoAndPlay("explode");
collectSndFunc();
explodeTimer.start();
}
function collectSndFunc(){
var _local1:SoundChannel;
collectSnd = new debrisPoints();
_local1 = collectSnd.play();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeGemID(this.ID);
}
function frame1(){
stop();
}
function frame31(){
stop();
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
if (this.x < -100){
this.x = 755;
};
if (this.x > 800){
this.x = -50;
};
if (this.y < -100){
this.y = 575;
};
if (this.y > 625){
this.y = -50;
};
this.x = (this.x + (speed * Math.cos(dir)));
this.y = (this.y + (speed * Math.sin(dir)));
debris.rotation = (debris.rotation + 5);
if (contor < 300){
contor++;
} else {
if (debris.alpha > 0){
debris.alpha = (debris.alpha - 0.01);
} else {
dead = true;
parent.parent.removeGemID(this.ID);
return;
};
};
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 19
//debrisPoints (debrisPoints)
package {
import flash.media.*;
public dynamic class debrisPoints extends Sound {
}
}//package
Section 20
//doubleShootMC (doubleShootMC)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class doubleShootMC extends MovieClip {
var explodeTimer:Timer;
var ID:Number;
var speed:Number;
public var dead:Boolean;// = false
var contor:Number;
var dir:Number;
public var exploded:Boolean;// = false
public var doubleShoot:MovieClip;
var collectSnd:dShoot;
public var ident:int;// = 4
public function doubleShootMC(_arg1:Number, _arg2:Number, _arg3:int){
ident = 4;
dead = false;
exploded = false;
super();
addFrameScript(0, frame1, 30, frame31);
this.x = _arg1;
this.y = _arg2;
ID = _arg3;
speed = 0.7;
dir = rand(0, 360);
dir = ((dir * 3.14) / 180);
contor = 0;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(1000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function rand(_arg1:int, _arg2:int):int{
return (Math.round((_arg1 + (Math.random() * (_arg2 - _arg1)))));
}
function heroHitFunction(){
dead = true;
doubleShoot.rotation = 0;
gotoAndPlay("explode");
explodeTimer.start();
collectSndFunc();
}
function collectSndFunc(){
var _local1:SoundChannel;
collectSnd = new dShoot();
_local1 = collectSnd.play();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeGemID(this.ID);
}
function frame1(){
stop();
}
function frame31(){
stop();
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
if (this.x < -100){
this.x = 755;
};
if (this.x > 800){
this.x = -50;
};
if (this.y < -100){
this.y = 575;
};
if (this.y > 625){
this.y = -50;
};
this.x = (this.x + (speed * Math.cos(dir)));
this.y = (this.y + (speed * Math.sin(dir)));
if (contor < 300){
contor++;
} else {
if (doubleShoot.alpha > 0){
doubleShoot.alpha = (doubleShoot.alpha - 0.01);
} else {
dead = true;
parent.parent.removeGemID(this.ID);
return;
};
};
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 21
//dShoot (dShoot)
package {
import flash.media.*;
public dynamic class dShoot extends Sound {
}
}//package
Section 22
//earthEnergyMC (earthEnergyMC)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class earthEnergyMC extends MovieClip {
var ID:Number;
var explodeTimer:Timer;
var speed:Number;
public var dead:Boolean;// = false
public var earthEnergy:MovieClip;
var contor:Number;
var dir:Number;
public var exploded:Boolean;// = false
var collectSnd:life_energy;
public var ident:int;// = 2
public function earthEnergyMC(_arg1:Number, _arg2:Number, _arg3:int){
ident = 2;
dead = false;
exploded = false;
super();
addFrameScript(0, frame1, 30, frame31);
this.x = _arg1;
this.y = _arg2;
ID = _arg3;
speed = 0.7;
dir = rand(0, 360);
dir = ((dir * 3.14) / 180);
contor = 0;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(1000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function rand(_arg1:int, _arg2:int):int{
return (Math.round((_arg1 + (Math.random() * (_arg2 - _arg1)))));
}
function collectSndFunc(){
var _local1:SoundChannel;
collectSnd = new life_energy();
_local1 = collectSnd.play();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeGemID(this.ID);
}
function heroHitFunction(){
dead = true;
earthEnergy.rotation = 0;
gotoAndPlay("explode");
explodeTimer.start();
collectSndFunc();
}
function frame1(){
stop();
}
function frame31(){
stop();
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
if (this.x < -100){
this.x = 755;
};
if (this.x > 800){
this.x = -50;
};
if (this.y < -100){
this.y = 575;
};
if (this.y > 625){
this.y = -50;
};
this.x = (this.x + (speed * Math.cos(dir)));
this.y = (this.y + (speed * Math.sin(dir)));
if (contor < 300){
contor++;
} else {
if (earthEnergy.alpha > 0){
earthEnergy.alpha = (earthEnergy.alpha - 0.01);
} else {
dead = true;
parent.parent.removeGemID(this.ID);
return;
};
};
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 23
//fasterShoot (fasterShoot)
package {
import flash.media.*;
public dynamic class fasterShoot extends Sound {
}
}//package
Section 24
//fireBallMC (fireBallMC)
package {
import flash.display.*;
import flash.events.*;
public class fireBallMC extends MovieClip {
var ID:int;
var strength:Number;
var speed:Number;
var dead:Boolean;// = false
var type:int;
var angle:Number;
public function fireBallMC(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:int, _arg5:int){
dead = false;
super();
this.x = _arg1;
this.y = _arg2;
angle = _arg3;
type = _arg4;
ID = _arg5;
speed = 20;
switch (type){
case 1:
strength = 50;
break;
case 2:
strength = 100;
break;
case 3:
strength = 100;
break;
};
gotoAndStop(type);
this.rotation = ((-(angle) * 180) / 3.14);
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
this.x = (this.x + (speed * Math.cos(angle)));
this.y = (this.y - (speed * Math.sin(angle)));
hitEnemyTest();
if ((((((((this.x < -150)) || ((this.x > 850)))) || ((this.y < -150)))) || ((this.y > 675)))){
parent.parent.removeBuletID(this.ID);
};
}
function cleanUp(){
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
public function hitEnemyTest(){
var _local1:*;
_local1 = 0;
while (_local1 < parent.parent.nEnemy) {
if (((this.hitTestObject(parent.parent.enemy[_local1])) && (!(parent.parent.enemy[_local1].dead)))){
dead = true;
parent.parent.enemy[_local1].hitFunction(strength);
parent.parent.updateGUI();
parent.parent.removeBuletID(this.ID);
break;
};
_local1++;
};
}
}
}//package
Section 25
//GameDirector (GameDirector)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.ui.*;
public class GameDirector extends MovieClip {
var waveDelay:int;// = 0
public var playerScore:int;// = 0
var curentWave:int;
var heroShoot:playerShoot;
public var cross:MovieClip;
public var cinematicMC:MovieClip;
public var gameLayer:MovieClip;
public var upgradeStat:int;// = 0
public var energy:int;// = 100
var upgradeTimer:Timer;
var nGems:int;// = 0
var shootDelay:int;// = 0
public var ee:MovieClip;
public var uu:MovieClip;
var IDs:int;// = 0
var upgr:Array;
var nWaves:int;
public var playerIsDead:Boolean;// = false
var wave:Array;
public var life:int;// = 100
var gems:Array;
public var gemLayer:MovieClip;
var nBullets:int;// = 0
public var earthMC:MovieClip;
var waveIndex:int;
public var scoreField:TextField;
var enemy:Array;
public var earthIsDead:Boolean;// = false
public var gameIsOver:Boolean;// = false
var bullets:Array;
var nEnemy:int;// = 0
var hero:heroMC;
public var pl:MovieClip;
public function GameDirector(){
waveDelay = 0;
nEnemy = 0;
nBullets = 0;
nGems = 0;
IDs = 0;
earthIsDead = false;
playerIsDead = false;
gameIsOver = false;
playerScore = 0;
life = 100;
energy = 100;
upgradeStat = 0;
shootDelay = 0;
super();
wave = new Array();
upgr = new Array();
wave[0] = "1111111111111111111111111111111111111111111121111111111111111111211111111111111111111121111111112111";
upgr[0] = "0000000000000000000000000000000000000000000000000000000000000000100000000000000000000020000000002000";
wave[1] = "1111211111111211111111111211111111111111111121111111111111111111211111111111121111111111121111111121";
upgr[1] = "0000000000000000000000000200000000000000000040000000000000000000100000000000000000000000020000000000";
wave[2] = "1211111111211111111121111111121111111112111111121111111121111111112111112111111121111112111112111112";
upgr[2] = "0000000000500000000010000000040000000002000000040000000020000000003000000000000000000000000001000002";
wave[3] = "1111211111211112111121111211112111111112111111121112111121111111112111112111211121111112112112111211";
upgr[3] = "0000000000200000000030000000000000000005000000040000000020000000003000000000200000000003000001000000";
wave[4] = "1111121111211111211112222211111121111112111112111112222211111121111121111111222111223221111123112111";
upgr[4] = "0000010000000000000000020000000000000000000001000000020000000040000000000000050000102010000000000000";
wave[5] = "1111121111211131211112222211111121113112111112113112222211111121111121111311211111223221111123112111";
upgr[5] = "0000010000400000000000020000000000000000000001000000020000000040000000000000000000102010000000000000";
wave[6] = "1111123111214111211112232221111121141113113112111112232241111121111131114111311111323231111123142111";
upgr[6] = "0000010000400000000000020000000000000000000001000000040000000020000000000000000000102010000000000000";
wave[7] = "1114123111211411211412232211311121141113114112111112232211411121114131114111311411323231141123112141";
upgr[7] = "0002010000000000000000020000000000040000000002000000010000000020000000000000000000102010030000000000";
wave[8] = "1114123111211411211412232211141121141113141142114112232211411121114131411411311411323231141123112141";
upgr[8] = "0000010000400000000000020000000000000000000001000000040000000020000000000000000000102010000000000000";
wave[9] = "1414123141231411211412232241141121142123124112114112232211411121414131414141311411323231141123112141";
upgr[9] = "0002010010000000000000020000000000040000000002000000010000000020000000000000000000102010030000000000";
curentWave = 0;
waveIndex = 0;
nWaves = 8;
enemy = new Array();
nEnemy = 0;
gems = new Array();
nGems = 0;
bullets = new Array();
nBullets = 0;
cross.startDrag(true);
Mouse.hide();
}
function rand(_arg1:int, _arg2:int):int{
return (Math.round((_arg1 + (Math.random() * (_arg2 - _arg1)))));
}
function isTimeForNewWave():Boolean{
if ((((waveIndex >= wave[curentWave].length)) && ((nEnemy <= 0)))){
return (true);
};
return (false);
}
function setUpgradeInterval(){
upgradeStat = 100;
upgradeTimer.stop();
upgradeTimer.reset();
upgradeTimer.start();
}
public function removeGemID(_arg1:int){
var _local2:Number;
var _local3:Boolean;
_local2 = 0;
_local3 = false;
trace("removing gem..........");
_local2 = 0;
while (_local2 < nGems) {
if (gems[_local2].ID == _arg1){
gems[_local2].cleanUp();
gemLayer.removeChild(gems[_local2]);
gems[_local2] = null;
_local3 = true;
break;
};
_local2++;
};
if ((((_local2 < nGems)) && (_local3))){
while (_local2 < (nGems - 1)) {
gems[_local2] = gems[(_local2 + 1)];
_local2++;
};
nGems--;
};
}
public function cleanUp(){
var _local1:*;
this.removeEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
_local1 = 0;
while (_local1 < nEnemy) {
enemy[_local1].cleanUp();
gameLayer.removeChild(enemy[_local1]);
enemy[_local1] = null;
_local1++;
};
_local1 = 0;
while (_local1 < nBullets) {
bullets[_local1].cleanUp();
gameLayer.removeChild(bullets[_local1]);
bullets[_local1] = null;
_local1++;
};
_local1 = 0;
while (_local1 < nGems) {
gems[_local1].cleanUp();
gemLayer.removeChild(gems[_local1]);
gems[_local1] = null;
_local1++;
};
nEnemy = 0;
nBullets = 0;
nGems = 0;
gameLayer.removeChild(hero);
hero.cleanUp();
hero = null;
heroShoot = null;
upgradeTimer.stop();
upgradeTimer = null;
}
function playerShootSnd(){
var _local1:SoundChannel;
heroShoot = new playerShoot();
_local1 = heroShoot.play();
}
function MouseDown(_arg1:MouseEvent){
if (hero.dead){
return;
};
if (shootDelay < hero.shootSpeed){
return;
};
shootDelay = 0;
if (hero.singleShoot){
bullets[nBullets] = gameLayer.addChild(new fireBallMC(hero.x, hero.y, ((-(hero.heroGraphic.rotation) * 3.14) / 180), hero.weapon, IDs));
nBullets++;
IDs++;
} else {
bullets[nBullets] = gameLayer.addChild(new fireBallMC(hero.x, hero.y, ((-((hero.heroGraphic.rotation - 5)) * 3.14) / 180), hero.weapon, IDs));
nBullets++;
IDs++;
bullets[nBullets] = gameLayer.addChild(new fireBallMC(hero.x, hero.y, ((-((hero.heroGraphic.rotation + 5)) * 3.14) / 180), hero.weapon, IDs));
nBullets++;
IDs++;
};
playerShootSnd();
}
public function removeBuletID(_arg1:int){
var _local2:Number;
var _local3:Boolean;
_local2 = 0;
_local3 = false;
_local2 = 0;
while (_local2 < nBullets) {
if (bullets[_local2].ID == _arg1){
bullets[_local2].cleanUp();
gameLayer.removeChild(bullets[_local2]);
bullets[_local2] = null;
_local3 = true;
break;
};
_local2++;
};
if ((((_local2 < nBullets)) && (_local3))){
while (_local2 < (nBullets - 1)) {
bullets[_local2] = bullets[(_local2 + 1)];
_local2++;
};
nBullets--;
};
}
function addGem(_arg1:Number, _arg2:Number, _arg3:int){
switch (_arg3){
case 0:
gems[nGems] = gemLayer.addChild(new debrisMC(_arg1, _arg2, IDs));
break;
case 1:
gems[nGems] = gemLayer.addChild(new shipLifeMC(_arg1, _arg2, IDs));
break;
case 2:
gems[nGems] = gemLayer.addChild(new earthEnergyMC(_arg1, _arg2, IDs));
break;
case 3:
gems[nGems] = gemLayer.addChild(new bigShootMC(_arg1, _arg2, IDs));
break;
case 4:
gems[nGems] = gemLayer.addChild(new doubleShootMC(_arg1, _arg2, IDs));
break;
case 5:
gems[nGems] = gemLayer.addChild(new rapidShootMC(_arg1, _arg2, IDs));
break;
};
IDs++;
nGems++;
}
function runAtInterval(_arg1:TimerEvent):void{
upgradeStat--;
updateGUI();
if (upgradeStat <= 0){
hero.singleShoot = true;
};
}
public function init(){
hero = new heroMC();
gameLayer.addChild(hero);
hero.x = 280;
hero.y = 180;
hero.init();
upgradeTimer = new Timer(150, 100);
upgradeTimer.addEventListener(TimerEvent.TIMER, runAtInterval);
this.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
}
function addEnemy(){
var _local1:*;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local1 = 0;
while (_local1 < 3) {
if (waveIndex < wave[curentWave].length){
_local2 = ((rand(0, 360) * 3.1457) / 180);
_local3 = (350 + (400 * Math.cos(_local2)));
_local4 = (260 + (300 * Math.sin(_local2)));
switch (wave[curentWave].charAt(waveIndex)){
case "1":
_local5 = ((1 + (curentWave / 2)) + Math.random());
if (_local5 > 2.5){
_local5 = (2 + Math.random());
};
enemy[nEnemy] = gameLayer.addChild(new asteroidMC(_local3, _local4, Math.atan2((267 - _local4), (350 - _local3)), _local5, IDs));
break;
case "2":
_local5 = (2 + (curentWave / 1.3));
if (_local5 > 5.5){
_local5 = 5.5;
};
enemy[nEnemy] = gameLayer.addChild(new rocketMC(_local3, _local4, _local5, Number(upgr[curentWave].charAt(waveIndex)), IDs));
break;
case "3":
_local5 = (2.5 + (curentWave / 1.5));
if (_local5 > 4.5){
_local5 = 4.5;
};
enemy[nEnemy] = gameLayer.addChild(new shootingShip(_local3, _local4, _local5, Number(upgr[curentWave].charAt(waveIndex)), IDs));
break;
case "4":
_local5 = ((1 + (curentWave / 2)) + Math.random());
if (_local5 > 2.5){
_local5 = (2 + Math.random());
};
enemy[nEnemy] = gameLayer.addChild(new alienBugMC(_local3, _local4, Math.atan2((267 - _local4), (350 - _local3)), _local5, Number(upgr[curentWave].charAt(waveIndex)), IDs));
break;
};
IDs++;
nEnemy++;
waveIndex++;
};
_local1++;
};
}
public function removeEnemyID(_arg1:int){
var _local2:Number;
var _local3:Boolean;
_local2 = 0;
_local3 = false;
_local2 = 0;
while (_local2 < nEnemy) {
if (enemy[_local2].ID == _arg1){
enemy[_local2].cleanUp();
gameLayer.removeChild(enemy[_local2]);
enemy[_local2] = null;
_local3 = true;
break;
};
_local2++;
};
if ((((_local2 < nEnemy)) && (_local3))){
while (_local2 < (nEnemy - 1)) {
enemy[_local2] = enemy[(_local2 + 1)];
_local2++;
};
nEnemy--;
};
}
function EnterFrame(_arg1:Event){
if (gameIsOver){
root.postScore = playerScore;
root.link = "gameOver";
root.faderMC.x = -50;
root.faderMC.play();
return;
};
shootDelay++;
if (isTimeForNewWave()){
if ((curentWave + 1) < nWaves){
curentWave++;
waveIndex = 0;
switch (curentWave){
case 1:
cinematicMC.gotoAndPlay("one");
break;
case 2:
cinematicMC.gotoAndPlay("two");
break;
case 3:
cinematicMC.gotoAndPlay("three");
break;
case 4:
cinematicMC.gotoAndPlay("four");
break;
case 5:
cinematicMC.gotoAndPlay("five");
break;
case 6:
cinematicMC.gotoAndPlay("six");
break;
case 7:
cinematicMC.gotoAndPlay("seven");
break;
case 8:
cinematicMC.gotoAndPlay("eight");
break;
case 9:
cinematicMC.gotoAndPlay("nine");
break;
case 10:
cinematicMC.gotoAndPlay("ten");
break;
};
} else {
root.postScore = playerScore;
root.link = "victory";
root.faderMC.x = -50;
root.faderMC.play();
return;
};
} else {
waveDelay++;
if (waveDelay >= (65 - (curentWave * 2))){
waveDelay = 0;
addEnemy();
};
};
}
public function updateGUI(){
scoreField.text = playerScore;
pl.maskMC.x = (1.6 * (100 - life));
ee.maskMC.x = (-1.6 * (100 - energy));
uu.maskMC.x = (-560 + ((560 * upgradeStat) / 100));
if ((((energy <= 0)) && (!(earthIsDead)))){
earthMC.gotoAndStop("explode");
earthIsDead = true;
};
}
}
}//package
Section 26
//gameOver (gameOver)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class gameOver extends MovieClip {
public var goMainBt:SimpleButton;
public var nameField:TextField;
public var submitBt:SimpleButton;
public var tipsText:TextField;
public var submitScoreField:TextField;
public var goPlayAgainBt:SimpleButton;
public function gameOver(){
addFrameScript(0, frame1);
}
public function goToMain(_arg1:MouseEvent){
root.link = "mainMenu";
root.faderMC.x = -50;
root.faderMC.play();
}
public function submitFnc(_arg1:MouseEvent){
if (nameField.text == ""){
return;
};
root.postName = nameField.text;
root.link = "submitScore";
root.faderMC.x = -50;
root.faderMC.play();
}
function frame1(){
Mouse.show();
submitScoreField.text = root.postScore;
submitBt.addEventListener(MouseEvent.CLICK, submitFnc);
goPlayAgainBt.addEventListener(MouseEvent.CLICK, playAgain);
goMainBt.addEventListener(MouseEvent.CLICK, goToMain);
}
public function playAgain(_arg1:MouseEvent){
root.link = "startGame";
root.faderMC.x = -50;
root.faderMC.play();
}
}
}//package
Section 27
//heroMC (heroMC)
package {
import flash.display.*;
import flash.events.*;
import flash.ui.*;
public class heroMC extends MovieClip {
var upPressed:Boolean;// = false
var leftPressed:Boolean;// = false
public var weapon:int;// = 1
var ySpeed:Number;
var downPressed:Boolean;// = false
public var dead:Boolean;// = false
public var shootSpeed:int;// = 5
public var heroGraphic:MovieClip;
var rightPressed:Boolean;// = false
var xSpeed:Number;
public var singleShoot:Boolean;// = true
public var exploded:Boolean;// = false
public function heroMC(){
dead = false;
exploded = false;
weapon = 1;
singleShoot = true;
shootSpeed = 5;
upPressed = false;
downPressed = false;
leftPressed = false;
rightPressed = false;
super();
addFrameScript(0, frame1, 4, frame5);
xSpeed = 0;
ySpeed = 0;
weapon = 1;
}
public function init(){
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyIsDown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyIsUp);
}
function keyIsDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.LEFT)) || ((_arg1.keyCode == 65)))){
leftPressed = true;
};
if ((((_arg1.keyCode == Keyboard.RIGHT)) || ((_arg1.keyCode == 68)))){
rightPressed = true;
};
if ((((_arg1.keyCode == Keyboard.UP)) || ((_arg1.keyCode == 87)))){
upPressed = true;
};
if ((((_arg1.keyCode == Keyboard.DOWN)) || ((_arg1.keyCode == 83)))){
downPressed = true;
};
}
public function enemyHitTest(){
var _local1:*;
if (parent.parent.nEnemy == 0){
return;
};
_local1 = 0;
while (_local1 < parent.parent.nEnemy) {
if (((this.hitTestObject(parent.parent.enemy[_local1])) && (!(parent.parent.enemy[_local1].dead)))){
parent.parent.enemy[_local1].heroHitFunction();
parent.parent.life = (parent.parent.life - 20);
parent.parent.updateGUI();
break;
};
_local1++;
};
if (parent.parent.life <= 0){
hitFunction();
};
}
function keyIsUp(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.LEFT)) || ((_arg1.keyCode == 65)))){
leftPressed = false;
};
if ((((_arg1.keyCode == Keyboard.RIGHT)) || ((_arg1.keyCode == 68)))){
rightPressed = false;
};
if ((((_arg1.keyCode == Keyboard.UP)) || ((_arg1.keyCode == 87)))){
upPressed = false;
};
if ((((_arg1.keyCode == Keyboard.DOWN)) || ((_arg1.keyCode == 83)))){
downPressed = false;
};
}
function frame5(){
stop();
}
function frame1(){
stop();
}
public function gemHitTest(){
var _local1:*;
if (parent.parent.nGems == 0){
return;
};
_local1 = 0;
while (_local1 < parent.parent.nGems) {
if (((this.hitTestObject(parent.parent.gems[_local1])) && (!(parent.parent.gems[_local1].dead)))){
switch (parent.parent.gems[_local1].ident){
case 0:
parent.parent.playerScore = (parent.parent.playerScore + 500);
parent.parent.updateGUI();
break;
case 1:
parent.parent.life = (parent.parent.life + 25);
if (parent.parent.life > 100){
parent.parent.life = 100;
};
parent.parent.updateGUI();
break;
case 2:
parent.parent.energy = (parent.parent.energy + 25);
if (parent.parent.energy > 100){
parent.parent.energy = 100;
};
parent.parent.updateGUI();
break;
case 3:
weapon = 2;
break;
case 4:
singleShoot = false;
parent.parent.setUpgradeInterval();
break;
case 5:
shootSpeed = 0;
break;
};
parent.parent.gems[_local1].heroHitFunction();
break;
};
_local1++;
};
}
function hitFunction(){
dead = true;
this.rotation = 0;
gotoAndStop("explode");
}
function EnterFrame(_arg1:Event){
if (exploded){
parent.parent.gameIsOver = true;
};
if (dead){
return;
};
if (leftPressed){
if (Math.abs(xSpeed) < 10){
xSpeed = (xSpeed - 0.4);
};
};
if (rightPressed){
if (Math.abs(xSpeed) < 10){
xSpeed = (xSpeed + 0.4);
};
};
if (upPressed){
if (Math.abs(ySpeed) < 10){
ySpeed = (ySpeed - 0.4);
};
};
if (downPressed){
if (Math.abs(ySpeed) < 10){
ySpeed = (ySpeed + 0.4);
};
};
heroGraphic.rotation = int(((Math.atan2((this.mouseY - heroGraphic.y), (this.mouseX - heroGraphic.x)) * 180) / Math.PI));
if (((((this.x + xSpeed) < 700)) && (((this.x + xSpeed) > 0)))){
this.x = (this.x + xSpeed);
} else {
xSpeed = 0;
};
if (((((this.y + ySpeed) < 525)) && (((this.y + ySpeed) > 0)))){
this.y = (this.y + ySpeed);
} else {
ySpeed = 0;
};
if (!((((((leftPressed) || (rightPressed))) || (upPressed))) || (downPressed))){
if (xSpeed > 0.05){
xSpeed = (xSpeed - 0.4);
};
if (xSpeed < -0.05){
xSpeed = (xSpeed + 0.4);
};
if (ySpeed > 0.05){
ySpeed = (ySpeed - 0.4);
};
if (ySpeed < -0.05){
ySpeed = (ySpeed + 0.4);
};
};
enemyHitTest();
gemHitTest();
}
public function cleanUp(){
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 28
//highScores (highScores)
package {
import flash.display.*;
import flash.events.*;
import mochi.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class highScores extends MovieClip {
public var tipsText:TextField;
public function highScores(){
addFrameScript(0, frame1);
}
function frame1(){
MochiScores.showLeaderboard({boardID:"f69eec1643afa9c1", onClose:function (){
root.link = "mainMenu";
root.faderMC.x = -50;
root.faderMC.play();
}});
}
}
}//package
Section 29
//instructions (instructions)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class instructions extends MovieClip {
public var instructionsMainBt:SimpleButton;
public function instructions(){
addFrameScript(0, frame1);
}
public function goToMain(_arg1:MouseEvent){
root.link = "mainMenu";
root.faderMC.x = -50;
root.faderMC.play();
}
function frame1(){
instructionsMainBt.addEventListener(MouseEvent.CLICK, goToMain);
}
}
}//package
Section 30
//life_energy (life_energy)
package {
import flash.media.*;
public dynamic class life_energy extends Sound {
}
}//package
Section 31
//MochiAd (MochiAd)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return ("2.5");
}
public static function showClickAwayAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_timeout:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var sendHostProgress:Boolean;
var options = _arg1;
DEFAULTS = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
sendHostProgress = false;
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
_local3 = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.root == null){
_local3 = true;
};
if (_local3){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(_arg1:String):String{
var _local2:String;
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (_arg1.origFrameRate != undefined){
_arg1.stage.frameRate = _arg1.origFrameRate;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad._containerLCName != undefined){
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "notify", {id:"unload"});
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (_local2 > chk.ad_msec){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local3:Object;
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
_local3 = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _cleanup(_arg1:Object):void{
var idx:Number;
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
idx = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(_arg1:Object):MovieClip{
var DEFAULTS:Object;
var clip:Object;
var depth:Number;
var mc:MovieClip;
var wh:Array;
var lv:URLVariables;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
DEFAULTS = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
wh = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
};
lv = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(_arg1:Object, _arg2:String, _arg3:Array):Object{
var _local4:Array;
var _local5:Number;
_local4 = _arg2.split(".");
_local5 = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
if (typeof(_arg1[_local4[_local5]]) == "function"){
return (_arg1[_local4[_local5]].apply(_arg1, _arg3));
};
return (undefined);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip;
_local4 = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local3:Object;
var _local4:Number;
var _local5:Number;
var _local6:Array;
_local3 = _arg2.getBounds(_arg2.root);
_local4 = 0;
_local5 = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function adShowing(_arg1:Object):void{
_arg1.origFrameRate = _arg1.stage.frameRate;
_arg1.stage.frameRate = 30;
}
public static function getValue(_arg1:Object, _arg2:String):Object{
var _local3:Array;
var _local4:Number;
_local3 = _arg2.split(".");
_local4 = 0;
while (_local4 < (_local3.length - 1)) {
if ((((_arg1[_local3[_local4]] == undefined)) || ((_arg1[_local3[_local4]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local3[_local4]];
_local4++;
};
return (_arg1[_local3[_local4]]);
}
public static function rpc(_arg1:Object, _arg2:Number, _arg3:Object):void{
var _local4:Object;
var _local5:Object;
switch (_arg3.id){
case "setValue":
MochiAd.setValue(_arg1, _arg3.objectName, _arg3.value);
break;
case "getValue":
_local4 = MochiAd.getValue(_arg1, _arg3.objectName);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(_arg1, _arg3.method, _arg3.args);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + _arg3.id));
};
}
public static function setValue(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Array;
var _local5:Number;
_local4 = _arg2.split(".");
_local5 = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return;
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
_arg1[_local4[_local5]] = _arg3;
}
public static function showPreGameAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var bar:MovieClip;
var bar_color:Number;
var bar_background:Number;
var bar_outline:Number;
var backing_mc:MovieClip;
var backing:Object;
var inside_mc:MovieClip;
var inside:Object;
var outline_mc:MovieClip;
var outline:Object;
var complete:Boolean;
var unloaded:Boolean;
var f:Function;
var sendHostProgress:Boolean;
var r:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (_arg1:Number):void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
setTimeout(options.ad_finished, 100);
return;
};
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
var fn:Function;
MochiAd._cleanup(mc);
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
bar = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = 10;
bar.y = (h - 20);
};
bar_color = options.color;
delete options.color;
bar_background = options.background;
delete options.background;
bar_outline = options.outline;
delete options.outline;
backing_mc = createEmptyMovieClip(bar, "_outline", 1);
backing = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
inside_mc = createEmptyMovieClip(bar, "_inside", 2);
inside = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
outline_mc = createEmptyMovieClip(bar, "_outline", 3);
outline = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
f = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
mc.rpcTestFn = function (_arg1:String):Object{
trace(("[MOCHIAD rpcTestFn] " + _arg1));
return (_arg1);
};
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (_arg1:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Object;
var _local3:Number;
var _local4:Boolean;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Object;
var _local10:Number;
var _local11:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
_local1 = this.parent.parent.root;
_local2 = this.parent._mochiad_ctr;
_local3 = (getTimer() - this.started);
_local4 = false;
_local5 = _local1.loaderInfo.bytesTotal;
_local6 = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
_local7 = ((100 * _local6) / _local5);
_local8 = ((100 * _local3) / chk.ad_msec);
_local9 = this._mochiad_bar._inside;
_local10 = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
options.ad_progress(_local10);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local7});
if (_local7 == 100){
sendHostProgress = false;
};
};
if (!chk.showing){
_local11 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local11 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((_local3 > chk.ad_timeout)) && ((_local7 == 100)))){
options.ad_failed();
_local4 = true;
};
};
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(_arg1);
}
public static function showTimedAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(_arg1);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var f:Function;
var mc = _arg1;
f = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package
Section 32
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
var _local3:MochiBot;
var _local4:String;
var _local5:URLVariables;
var _local6:String;
var _local7:URLRequest;
var _local8:Loader;
if (Security.sandboxType == "localWithFile"){
return (null);
};
_local3 = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
_local4 = "http://core.mochibot.com/my/core.swf";
_local5 = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
_local6 = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
_local7 = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
_local8 = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 33
//playButton (playButton)
package {
import flash.display.*;
public dynamic class playButton extends SimpleButton {
}
}//package
Section 34
//playerShoot (playerShoot)
package {
import flash.media.*;
public dynamic class playerShoot extends Sound {
}
}//package
Section 35
//rapidShootMC (rapidShootMC)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class rapidShootMC extends MovieClip {
var ID:Number;
var explodeTimer:Timer;
var speed:Number;
public var dead:Boolean;// = false
public var rapidShoot:MovieClip;
var contor:Number;
var dir:Number;
public var exploded:Boolean;// = false
var collectSnd:fasterShoot;
public var ident:int;// = 5
public function rapidShootMC(_arg1:Number, _arg2:Number, _arg3:int){
ident = 5;
dead = false;
exploded = false;
super();
addFrameScript(0, frame1, 30, frame31);
this.x = _arg1;
this.y = _arg2;
ID = _arg3;
speed = 0.7;
dir = rand(0, 360);
dir = ((dir * 3.14) / 180);
contor = 0;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(2000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function rand(_arg1:int, _arg2:int):int{
return (Math.round((_arg1 + (Math.random() * (_arg2 - _arg1)))));
}
function collectSndFunc(){
var _local1:SoundChannel;
collectSnd = new fasterShoot();
_local1 = collectSnd.play();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeGemID(this.ID);
}
function heroHitFunction(){
dead = true;
rapidShootMC.rotation = 0;
gotoAndPlay("explode");
explodeTimer.start();
collectSndFunc();
}
function frame1(){
stop();
}
function frame31(){
stop();
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
if (this.x < -100){
this.x = 755;
};
if (this.x > 800){
this.x = -50;
};
if (this.y < -100){
this.y = 575;
};
if (this.y > 625){
this.y = -50;
};
this.x = (this.x + (speed * Math.cos(dir)));
this.y = (this.y + (speed * Math.sin(dir)));
if (contor < 300){
contor++;
} else {
if (rapidShootMC.alpha > 0){
rapidShootMC.alpha = (rapidShootMC.alpha - 0.01);
} else {
dead = true;
parent.parent.removeGemID(this.ID);
return;
};
};
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 36
//rocketExplode (rocketExplode)
package {
import flash.media.*;
public dynamic class rocketExplode extends Sound {
}
}//package
Section 37
//rocketMC (rocketMC)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class rocketMC extends MovieClip {
var explodeTimer:Timer;
var life:int;
var ID:Number;
public var gemType:int;
var speed:Number;
var dx_dir:Number;
public var dead:Boolean;// = false
var new_dir:Number;
public var lifeBar:MovieClip;
public var rocketGraphic:MovieClip;
var maxLife:int;
var once:Boolean;// = false
var radius:Number;// = 13
var dir:Number;
public var exploded:Boolean;// = false
var angle:Number;
var explode:rocketExplode;
public function rocketMC(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:int, _arg5:int){
dead = false;
exploded = false;
radius = 13;
once = false;
super();
addFrameScript(0, frame1, 3, frame4);
this.x = _arg1;
this.y = _arg2;
gemType = _arg4;
ID = _arg5;
speed = _arg3;
life = 100;
maxLife = 100;
dx_dir = 0.015;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(1000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function heroHitFunction(){
dead = true;
rocketGraphic.rotation = 0;
gotoAndStop("explode");
explodeTimer.start();
explodeSnd();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeEnemyID(this.ID);
trace("removing rocket................");
}
function frame4(){
stop();
}
function frame1(){
stop();
}
function hitFunction(_arg1:Number){
life = (life - _arg1);
lifeBar.scaleX = (life / maxLife);
if (life <= 0){
dead = true;
rocketGraphic.rotation = 0;
gotoAndStop("explode");
explodeTimer.start();
explodeSnd();
parent.parent.playerScore = (parent.parent.playerScore + 250);
parent.parent.addGem(this.x, this.y, gemType);
};
}
function EnterFrame(_arg1:Event){
if (!once){
dir = Math.atan2((parent.parent.hero.y - this.y), (parent.parent.hero.x - this.x));
angle = ((dir * 180) / 3.14);
rocketGraphic.rotation = angle;
once = true;
};
if (dead){
return;
};
if (this.x < -100){
this.x = 755;
};
if (this.x > 800){
this.x = -50;
};
if (this.y < -100){
this.y = 575;
};
if (this.y > 625){
this.y = -50;
};
this.x = (this.x + (speed * Math.cos(dir)));
this.y = (this.y + (speed * Math.sin(dir)));
if (parent.parent.hero.dead){
return;
};
new_dir = Math.atan2((parent.parent.hero.y - this.y), (parent.parent.hero.x - this.x));
if (new_dir > dir){
dir = (dir + dx_dir);
} else {
if (new_dir < dir){
dir = (dir - dx_dir);
};
};
angle = ((dir * 180) / 3.14);
rocketGraphic.rotation = angle;
}
function explodeSnd(){
var _local1:SoundChannel;
explode = new rocketExplode();
_local1 = explode.play();
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 38
//saveTheEarth (saveTheEarth)
package {
import flash.display.*;
import flash.events.*;
import mochi.*;
import flash.text.*;
import flash.net.*;
public dynamic class saveTheEarth extends MovieClip {
public var mochiMC:MovieClip;
public var link:String;// = ""
public var prevState:String;// = ""
public var submitScoreInstance:submitScore;
public var urlText:TextField;
public var postName:String;// = ""
public var instructionsInstance:instructions;
public var creditsInstance:credits;
public var highScoresInstance:highScores;
public var screens:MovieClip;
public var tipsText:TextField;
public var websiteBt:SimpleButton;
public var playBt:playButton;
public var gameOverInstance:gameOver;
public var faderMC:MovieClip;
public var hsBt:SimpleButton;
public var creditsBt:SimpleButton;
public var gameInstance:GameDirector;
public var victoryInstance:victory;
public var postScore:Number;// = 0
public var curentState:String;// = ""
public var instructionsBt:SimpleButton;
public function saveTheEarth(){
curentState = "";
prevState = "";
link = "";
postScore = 0;
postName = "";
super();
addFrameScript(0, frame1, 5, frame6, 9, frame10, 18, frame19, 28, frame29, 37, frame38, 48, frame49, 59, frame60, 67, frame68, 76, frame77, 85, frame86);
}
function frame77(){
stop();
setState("gameOver");
}
public function instructionsClick(_arg1:MouseEvent){
link = "instructions";
faderMC.x = -50;
faderMC.play();
}
public function removePrevState(){
if (prevState == ""){
return;
};
switch (prevState){
case "game":
gameInstance.cleanUp();
screens.removeChild(gameInstance);
gameInstance = null;
break;
case "gameOver":
screens.removeChild(gameOverInstance);
gameOverInstance = null;
break;
case "victory":
screens.removeChild(victoryInstance);
victoryInstance = null;
break;
case "submit":
screens.removeChild(submitScoreInstance);
submitScoreInstance = null;
break;
case "highScores":
screens.removeChild(highScoresInstance);
highScoresInstance = null;
break;
case "instructions":
screens.removeChild(instructionsInstance);
instructionsInstance = null;
break;
case "credits":
screens.removeChild(creditsInstance);
creditsInstance = null;
break;
case "mainMenu":
break;
};
}
function frame86(){
stop();
setState("victory");
}
public function creditsClick(_arg1:MouseEvent){
link = "credits";
faderMC.x = -50;
faderMC.play();
}
public function setScore(_arg1:int){
scoreField.text = _arg1;
}
public function highScoreClick(_arg1:MouseEvent){
link = "highScores";
faderMC.x = -50;
faderMC.play();
}
function frame1(){
MochiBot.track(this, "b0f88ea7");
mochiMC = new MovieClip();
this.addChild(mochiMC);
MochiServices.connect("d91734c705ea5cf8", mochiMC);
urls_allowed = ["gamestudio.ro", "flashgamelicense.com", "nonoba.com", "newgrounds.com"];
sitelock(urls_allowed);
stop();
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
this.loaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
}
function frame19(){
stop();
setState("game");
}
function frame6(){
MochiAd.showPreGameAd({id:"d91734c705ea5cf8", res:"700x525", clip:this});
}
public function setState(_arg1:String){
prevState = curentState;
curentState = _arg1;
removePrevState();
switch (curentState){
case "game":
gameInstance = new GameDirector();
screens.addChild(gameInstance);
gameInstance.init();
break;
case "gameOver":
gameOverInstance = new gameOver();
screens.addChild(gameOverInstance);
break;
case "victory":
victoryInstance = new victory();
screens.addChild(victoryInstance);
break;
case "submit":
submitScoreInstance = new submitScore();
screens.addChild(submitScoreInstance);
break;
case "highScores":
highScoresInstance = new highScores();
screens.addChild(highScoresInstance);
break;
case "instructions":
instructionsInstance = new instructions();
screens.addChild(instructionsInstance);
break;
case "credits":
creditsInstance = new credits();
screens.addChild(creditsInstance);
break;
case "mainMenu":
break;
};
}
function frame29(){
stop();
setState("highScores");
}
public function setEnergy(_arg1:int){
ee.maskMC.x = (-1.6 * (100 - _arg1));
}
function frame38(){
stop();
setState("submit");
}
public function websiteClick(_arg1:MouseEvent){
var req:URLRequest;
var me = _arg1;
req = new URLRequest("http://www.gamestudio.ro/");
try {
navigateToURL(req, "_blank");
} catch(e:Error) {
trace("Navigate to URL failed", e.message);
};
}
function frame10(){
stop();
setState("mainMenu");
playBt.addEventListener(MouseEvent.CLICK, playClick);
hsBt.addEventListener(MouseEvent.CLICK, highScoreClick);
instructionsBt.addEventListener(MouseEvent.CLICK, instructionsClick);
creditsBt.addEventListener(MouseEvent.CLICK, creditsClick);
websiteBt.addEventListener(MouseEvent.CLICK, websiteClick);
}
public function setLife(_arg1:int){
pl.maskMC.x = (1.6 * (100 - _arg1));
}
public function playClick(_arg1:MouseEvent){
link = "startGame";
faderMC.x = -50;
faderMC.play();
}
public function onLoadComplete(_arg1:Event):void{
link = "ads";
faderMC.x = -50;
faderMC.play();
}
public function onLoadProgress(_arg1:ProgressEvent):void{
var _local2:uint;
var _local3:uint;
var _local4:int;
_local2 = _arg1.bytesLoaded;
_local3 = _arg1.bytesTotal;
_local4 = Math.floor(((_local2 / _local3) * 100));
}
function frame49(){
stop();
setState("instructions");
}
function frame60(){
stop();
setState("credits");
}
function frame68(){
gotoAndPlay("startGame");
}
public function sitelock(_arg1){
lock = true;
domain_parts = root.loaderInfo.url;
for (x in _arg1) {
if (domain_parts.indexOf(_arg1[x]) >= 0){
lock = false;
};
};
if (lock){
};
}
}
}//package
Section 39
//shipLifeMC (shipLifeMC)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class shipLifeMC extends MovieClip {
var explodeTimer:Timer;
var ID:Number;
public var shipLife:MovieClip;
var speed:Number;
public var dead:Boolean;// = false
var contor:Number;
var dir:Number;
public var exploded:Boolean;// = false
var collectSnd:life_energy;
public var ident:int;// = 1
public function shipLifeMC(_arg1:Number, _arg2:Number, _arg3:int){
ident = 1;
dead = false;
exploded = false;
super();
addFrameScript(0, frame1, 30, frame31);
this.x = _arg1;
this.y = _arg2;
ID = _arg3;
speed = 0.7;
dir = rand(0, 360);
dir = ((dir * 3.14) / 180);
contor = 0;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(1000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function rand(_arg1:int, _arg2:int):int{
return (Math.round((_arg1 + (Math.random() * (_arg2 - _arg1)))));
}
function heroHitFunction(){
dead = true;
shipLife.rotation = 0;
gotoAndPlay("explode");
explodeTimer.start();
collectSndFunc();
}
function collectSndFunc(){
var _local1:SoundChannel;
collectSnd = new life_energy();
_local1 = collectSnd.play();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeGemID(this.ID);
}
function frame1(){
stop();
}
function frame31(){
stop();
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
if (this.x < -100){
this.x = 755;
};
if (this.x > 800){
this.x = -50;
};
if (this.y < -100){
this.y = 575;
};
if (this.y > 625){
this.y = -50;
};
this.x = (this.x + (speed * Math.cos(dir)));
this.y = (this.y + (speed * Math.sin(dir)));
if (contor < 300){
contor++;
} else {
if (shipLife.alpha > 0){
shipLife.alpha = (shipLife.alpha - 0.01);
} else {
dead = true;
parent.parent.removeGemID(this.ID);
return;
};
};
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 40
//shootingShip (shootingShip)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class shootingShip extends MovieClip {
var explodeTimer:Timer;
var life:int;
public var shipGraphic:MovieClip;
var ID:Number;
public var gemType:int;
var shipShoot:shootingShipSnd;
var speed:Number;
var dx_dir:Number;
public var dead:Boolean;// = false
var new_dir:Number;
public var lifeBar:MovieClip;
var maxLife:int;
var once:Boolean;// = false
var contor:int;// = 30
var dir:Number;
public var exploded:Boolean;// = false
var angle:Number;
var explode:shootingShipExplode;
public function shootingShip(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:int, _arg5:int){
dead = false;
exploded = false;
contor = 30;
once = false;
super();
addFrameScript(0, frame1, 4, frame5);
this.x = _arg1;
this.y = _arg2;
gemType = _arg4;
ID = _arg5;
speed = _arg3;
life = 150;
maxLife = 150;
dx_dir = 0.02;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
explodeTimer = new Timer(1000, 1);
explodeTimer.addEventListener(TimerEvent.TIMER, runExploded);
}
function shipShootSnd(){
var _local1:SoundChannel;
shipShoot = new shootingShipSnd();
_local1 = shipShoot.play();
}
function heroHitFunction(){
dead = true;
shipGraphic.rotation = 0;
gotoAndStop("explode");
explodeTimer.start();
explodeSnd();
}
function runExploded(_arg1:TimerEvent):void{
parent.parent.removeEnemyID(this.ID);
trace("removing shootingShip................");
}
function frame1(){
stop();
}
function frame5(){
stop();
}
function hitFunction(_arg1:Number){
life = (life - _arg1);
lifeBar.scaleX = (life / maxLife);
if (life <= 0){
dead = true;
shipGraphic.rotation = 0;
gotoAndStop("explode");
parent.parent.playerScore = (parent.parent.playerScore + 450);
parent.parent.addGem(this.x, this.y, gemType);
explodeTimer.start();
explodeSnd();
};
}
function EnterFrame(_arg1:Event){
if (dead){
return;
};
if (!once){
dir = Math.atan2((parent.parent.hero.y - this.y), (parent.parent.hero.x - this.x));
angle = ((dir * 180) / 3.14);
shipGraphic.rotation = angle;
once = true;
};
if (this.x < -100){
this.x = 750;
};
if (this.x > 800){
this.x = -50;
};
if (this.y < -100){
this.y = 575;
};
if (this.y > 625){
this.y = -50;
};
this.x = (this.x + (speed * Math.cos(dir)));
this.y = (this.y + (speed * Math.sin(dir)));
if (parent.parent.hero.dead){
return;
};
new_dir = Math.atan2((parent.parent.hero.y - this.y), (parent.parent.hero.x - this.x));
if (new_dir > dir){
dir = (dir + dx_dir);
} else {
if (new_dir < dir){
dir = (dir - dx_dir);
};
};
angle = ((dir * 180) / 3.14);
shipGraphic.rotation = angle;
contor++;
if ((((Math.abs((dir - new_dir)) < 0.06)) && ((contor > 50)))){
contor = 0;
parent.parent.enemy[parent.parent.nEnemy] = parent.parent.gameLayer.addChild(new shootingShipBulet(this.x, this.y, shipGraphic.rotation, parent.parent.IDs));
parent.parent.IDs++;
parent.parent.nEnemy++;
shipShootSnd();
};
}
function explodeSnd(){
var _local1:SoundChannel;
explode = new shootingShipExplode();
_local1 = explode.play();
}
function cleanUp(){
explodeTimer.stop();
explodeTimer.removeEventListener(TimerEvent.TIMER, runExploded);
explodeTimer = null;
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
shipShoot = null;
}
}
}//package
Section 41
//shootingShipBulet (shootingShipBulet)
package {
import flash.display.*;
import flash.events.*;
public class shootingShipBulet extends MovieClip {
var ID:Number;
var speed:Number;
var dead:Boolean;// = false
var dy:Number;
var dx:Number;
var radAngle:Number;
var angle:Number;
public function shootingShipBulet(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:int){
dead = false;
super();
this.x = _arg1;
this.y = _arg2;
angle = _arg3;
radAngle = ((angle * 3.14) / 180);
speed = 20;
dx = (Math.cos(radAngle) * speed);
dy = (Math.sin(radAngle) * speed);
this.rotation = angle;
ID = _arg4;
this.addEventListener(Event.ENTER_FRAME, EnterFrame);
}
function heroHitFunction(){
dead = true;
parent.parent.removeEnemyID(this.ID);
}
function hitFunction(_arg1:Number){
dead = true;
parent.parent.playerScore = (parent.parent.playerScore + 25);
parent.parent.removeEnemyID(this.ID);
}
function EnterFrame(_arg1:Event){
this.x = (this.x + dx);
this.y = (this.y + dy);
if ((((((((this.x < -50)) || ((this.x > 750)))) || ((this.y < -50)))) || ((this.y > 575)))){
parent.parent.removeEnemyID(this.ID);
};
}
function cleanUp(){
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
}
}
}//package
Section 42
//shootingShipExplode (shootingShipExplode)
package {
import flash.media.*;
public dynamic class shootingShipExplode extends Sound {
}
}//package
Section 43
//shootingShipSnd (shootingShipSnd)
package {
import flash.media.*;
public dynamic class shootingShipSnd extends Sound {
}
}//package
Section 44
//submitScore (submitScore)
package {
import flash.display.*;
import flash.events.*;
import mochi.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class submitScore extends MovieClip {
public var tipsText:TextField;
public function submitScore(){
addFrameScript(0, frame1);
}
function frame1(){
MochiScores.showLeaderboard({boardID:"f69eec1643afa9c1", name:root.postName, score:root.postScore, onClose:function (){
root.link = "mainMenu";
root.faderMC.x = -50;
root.faderMC.play();
}});
root.HPScoreService.postScore(200, "");
}
}
}//package
Section 45
//weaponUpgrade (weaponUpgrade)
package {
import flash.media.*;
public dynamic class weaponUpgrade extends Sound {
}
}//package
Section 46
//victory (victory)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
public dynamic class victory extends MovieClip {
public var nameField:TextField;
public var submitBt:SimpleButton;
public var victoryMainBt:SimpleButton;
public var tipsText:TextField;
public var submitScoreField:TextField;
public var goPlayAgainBt:SimpleButton;
public function victory(){
addFrameScript(0, frame1);
}
public function goToMain(_arg1:MouseEvent){
root.link = "mainMenu";
root.faderMC.x = -50;
root.faderMC.play();
}
public function submitFnc(_arg1:MouseEvent){
if (nameField.text == ""){
return;
};
root.postName = nameField.text;
root.link = "submitScore";
root.faderMC.x = -50;
root.faderMC.play();
}
function frame1(){
Mouse.show();
submitScoreField.text = root.postScore;
submitBt.addEventListener(MouseEvent.CLICK, submitFnc);
goPlayAgainBt.addEventListener(MouseEvent.CLICK, playAgain);
victoryMainBt.addEventListener(MouseEvent.CLICK, goToMain);
}
public function playAgain(_arg1:MouseEvent){
root.link = "startGame";
root.faderMC.x = -50;
root.faderMC.play();
}
}
}//package