Section 1
//MochiAd (mochi.as3.MochiAd)
package mochi.as3 {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showClickAwayAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {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;
var ad_timeout:Number = 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();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = 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);
};
var sendHostProgress:Boolean;
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
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 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType == "application"){
return (_local2);
};
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 clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {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;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = 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();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = 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{
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Number = (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 = 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 _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
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 _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
var _local3:Object = {};
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 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);
};
var idx:Number = 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 clip:Object;
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;
var DEFAULTS:Object = {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 (!(clip is DisplayObject)){
trace("Warning: Object passed as container clip not a descendant of the DisplayObject type");
return (null);
};
if (MovieClip(clip).stage == null){
trace("Warning: Container clip for ad is not attached to the stage");
return (null);
};
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."));
};
var depth:Number = options.depth;
delete options.depth;
var mc:MovieClip = createEmptyMovieClip(clip, "_mochiad", depth);
var wh:Array = 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;
} else {
trace("[MochiAd] NOTE: Security Sandbox Violation errors below are normal");
};
var lv:URLVariables = 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?cacheBust=") + new Date().getTime()));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (_arg1:IOErrorEvent):void{
trace("[MochiAds] Blocked URL");
});
if (!options.skip){
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 = _arg2.split(".");
var _local5:Number = 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 = 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 _local6:Array;
var _local3:Object = _arg2.getBounds(_arg2.root);
var _local4:Number = 0;
var _local5:Number = 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 = _arg2.split(".");
var _local4:Number = 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 = _arg2.split(".");
var _local5:Number = 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 clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var complete:Boolean;
var unloaded:Boolean;
var sendHostProgress:Boolean;
var fn:Function;
var r:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {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{
}, progress_override:function (_arg1:Object):Number{
return (NaN);
}, bar_offset:0};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
return;
};
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
if (options.skip){
ad_timeout = 0;
};
delete options.ad_timeout;
var fadeout_time:Number = 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);
var fn:Function = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = 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);
var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = (10 + options.bar_offset);
bar.y = (h - 20);
};
var bar_w:Number = ((w - bar.x) - 10);
var bar_color:Number = options.color;
delete options.color;
var bar_background:Number = options.background;
delete options.background;
var bar_outline:Number = options.outline;
delete options.outline;
var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1);
var backing:Object = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo(bar_w, 0);
backing.lineTo(bar_w, 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2);
var inside:Object = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo(bar_w, 0);
inside.lineTo(bar_w, 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3);
var outline:Object = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo(bar_w, 0);
outline.lineTo(bar_w, 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 = (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;
var progress:Number = Math.min(1, options.progress_override(clip));
var f:Function = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
if (!isNaN(progress)){
complete = (progress == 1);
} else {
if (clip.loaderInfo.bytesLoaded == clip.loaderInfo.bytesTotal){
complete = true;
} else {
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
};
};
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 = 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 _local12:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
var _local1:Object = this.parent.parent.root;
var _local2:Object = this.parent._mochiad_ctr;
var _local3:Number = (getTimer() - this.started);
var _local4:Boolean;
var _local5:Number = _local1.loaderInfo.bytesTotal;
var _local6:Number = _local1.loaderInfo.bytesLoaded;
var _local7:Number = Math.min(1, options.progress_override(_local1));
if (_local7 == 1){
complete = true;
};
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
var _local8:Number = ((100 * _local6) / _local5);
if (!isNaN(_local7)){
_local8 = (100 * _local7);
};
var _local9:Number = ((100 * _local3) / chk.ad_msec);
var _local10:Object = this._mochiad_bar._inside;
var _local11:Number = Math.min(100, Math.min(((_local8) || (0)), _local9));
_local11 = Math.max(this.last_pcnt, _local11);
this.last_pcnt = _local11;
_local10.scaleX = (_local11 * 0.01);
options.ad_progress(_local11);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local8});
if (_local8 >= 100){
sendHostProgress = false;
};
};
if (!chk.showing){
_local12 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local12 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((_local3 > chk.ad_timeout)) && ((_local8 == 100)))){
options.ad_failed();
_local4 = true;
};
};
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (unloaded){
MochiAd.unload(_local1);
} else {
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 mc = _arg1;
var f:Function = 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 mochi.as3
Section 2
//MochiCoins (mochi.as3.MochiCoins)
package mochi.as3 {
public class MochiCoins {
public static const STORE_HIDE:String = "StoreHide";
public static const NO_USER:String = "NoUser";
public static const IO_ERROR:String = "IOError";
public static const ITEM_NEW:String = "ItemNew";
public static const ITEM_OWNED:String = "ItemOwned";
public static const STORE_ITEMS:String = "StoreItems";
public static const ERROR:String = "Error";
public static const STORE_SHOW:String = "StoreShow";
public static var _inventory:MochiInventory;
public static function triggerEvent(_arg1:String, _arg2:Object):void{
MochiSocial.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
MochiSocial.removeEventListener(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
MochiSocial.addEventListener(_arg1, _arg2);
}
public static function getStoreItems():void{
MochiServices.send("coins_getStoreItems");
}
public static function get inventory():MochiInventory{
return (_inventory);
}
public static function showStore(_arg1:Object=null):void{
MochiServices.bringToTop();
MochiServices.send("coins_showStore", {options:_arg1}, null, null);
}
public static function showItem(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showItem call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showItem", {options:_arg1}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showVideo(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showVideo call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showVideo", {options:_arg1}, null, null);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_inventory = new MochiInventory();
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_inventory = null;
});
}
}//package mochi.as3
Section 3
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Sibling:MochiDigits;
private var Fragment:Number;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function reencode():void{
var _local1:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function toString():String{
var _local1:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String = _arg1.toString();
var _temp1 = _arg2;
_arg2 = (_arg2 + 1);
Fragment = (_local3.charCodeAt(_temp1) ^ Encoder);
if (_arg2 < _local3.length){
Sibling = new MochiDigits(_arg1, _arg2);
} else {
Sibling = null;
};
reencode();
}
public function get value():Number{
return (Number(this.toString()));
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
}
}//package mochi.as3
Section 4
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher)
package mochi.as3 {
public class MochiEventDispatcher {
private var eventTable:Object;
public function MochiEventDispatcher():void{
eventTable = {};
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
return;
};
for (_local3 in eventTable[_arg1]) {
var _local6 = eventTable[_arg1];
_local6[_local3](_arg2);
};
}
public function removeEventListener(_arg1:String, _arg2:Function):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
eventTable[_arg1] = [];
return;
};
for (_local3 in eventTable[_arg1]) {
if (eventTable[_arg1][_local3] != _arg2){
} else {
eventTable[_arg1].splice(Number(_local3), 1);
};
};
}
public function addEventListener(_arg1:String, _arg2:Function):void{
removeEventListener(_arg1, _arg2);
eventTable[_arg1].push(_arg2);
}
}
}//package mochi.as3
Section 5
//MochiEvents (mochi.as3.MochiEvents)
package mochi.as3 {
import flash.display.*;
public class MochiEvents {
public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL";
public static const FORMAT_LONG:String = "LongForm";
public static const ALIGN_BOTTOM:String = "ALIGN_B";
public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived";
public static const FORMAT_SHORT:String = "ShortForm";
public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR";
public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR";
public static const ALIGN_TOP:String = "ALIGN_T";
public static const ALIGN_LEFT:String = "ALIGN_L";
public static const ALIGN_RIGHT:String = "ALIGN_R";
public static const ALIGN_TOP_LEFT:String = "ALIGN_TL";
public static const ALIGN_CENTER:String = "ALIGN_C";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
private static var gameStart:Number;
private static var levelStart:Number;
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function startSession(_arg1:String):void{
MochiServices.send("events_beginSession", {achievementID:_arg1}, null, null);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function setNotifications(_arg1:MovieClip, _arg2:Object):void{
var _local4:Object;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
_local3.clip = _arg1;
MochiServices.send("events_setNotifications", _local3, null, null);
}
public static function endGame():void{
var _local1:Number = (new Date().time - gameStart);
trigger("end_game", {time:_local1});
}
public static function startGame():void{
gameStart = new Date().time;
trigger("start_game");
}
public static function trigger(_arg1:String, _arg2:Object=null):void{
if (_arg2 == null){
_arg2 = {};
} else {
if (_arg2["kind"] != undefined){
trace("WARNING: optional arguments package contains key 'id', it will be overwritten");
_arg2["kind"] = _arg1;
};
};
MochiServices.send("events_triggerEvent", {eventObject:_arg2}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function startLevel():void{
levelStart = new Date().time;
trigger("start_level");
}
public static function endLevel():void{
var _local1:Number = (new Date().time - levelStart);
trigger("end_level", {time:_local1});
}
}
}//package mochi.as3
Section 6
//MochiInventory (mochi.as3.MochiInventory)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
public dynamic class MochiInventory extends Proxy {
private var _timer:Timer;
private var _names:Array;
private var _syncID:Number;
private var _consumableProperties:Object;
private var _storeSync:Object;
private var _outstandingID:Number;
private var _syncPending:Boolean;
public static const READY:String = "InvReady";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IoError";
private static const KEY_SALT:String = " syncMaint";
public static const WRITTEN:String = "InvWritten";
public static const NOT_READY:String = "InvNotReady";
public static const VALUE_ERROR:String = "InvValueError";
private static const CONSUMER_KEY:String = "MochiConsumables";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public function MochiInventory():void{
MochiCoins.addEventListener(MochiCoins.ITEM_OWNED, itemOwned);
MochiCoins.addEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, loggedOut);
_storeSync = new Object();
_syncPending = false;
_outstandingID = 0;
_syncID = 0;
_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, sync);
_timer.start();
if (MochiSocial.loggedIn){
loggedIn();
} else {
loggedOut();
};
}
private function newItems(_arg1:Object):void{
if (!this[(_arg1.id + KEY_SALT)]){
this[(_arg1.id + KEY_SALT)] = 0;
};
if (!this[_arg1.id]){
this[_arg1.id] = 0;
};
this[(_arg1.id + KEY_SALT)] = (this[(_arg1.id + KEY_SALT)] + _arg1.count);
this[_arg1.id] = (this[_arg1.id] + _arg1.count);
if (_arg1.privateProperties.consumable){
if (!this[_arg1.privateProperties.tag]){
this[_arg1.privateProperties.tag] = 0;
};
this[_arg1.privateProperties.tag] = (this[_arg1.privateProperties.tag] + (_arg1.privateProperties.inc * _arg1.count));
};
}
public function release():void{
MochiCoins.removeEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.removeEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.removeEventListener(MochiSocial.LOGGED_OUT, loggedOut);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (-1);
};
if (_consumableProperties[_arg1]){
return (MochiDigits(_consumableProperties[_arg1]).value);
};
return (undefined);
}
private function loggedIn(_arg1:Object=null):void{
MochiUserData.get(CONSUMER_KEY, getConsumableBag);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(_arg1):Boolean{
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (false);
};
if (_consumableProperties[_arg1] == undefined){
return (false);
};
return (true);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(_arg1:int):int{
return (((_arg1)>=_names.length) ? 0 : (_arg1 + 1));
}
private function putConsumableBag(_arg1:MochiUserData):void{
_syncPending = false;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
_outstandingID = -1;
};
triggerEvent(WRITTEN, {});
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
var _local3:MochiDigits;
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return;
};
if (!(_arg2 is Number)){
triggerEvent(ERROR, {type:VALUE_ERROR, error:"Invalid type", arg:_arg2});
return;
};
if (_consumableProperties[_arg1]){
_local3 = MochiDigits(_consumableProperties[_arg1]);
if (_local3.value == _arg2){
return;
};
_local3.value = _arg2;
} else {
_names.push(_arg1);
_consumableProperties[_arg1] = new MochiDigits(_arg2);
};
_syncID++;
}
private function itemOwned(_arg1:Object):void{
_storeSync[_arg1.id] = {properties:_arg1.properties, count:_arg1.count};
}
private function sync(_arg1:Event=null):void{
var _local3:String;
if (((_syncPending) || ((_syncID == _outstandingID)))){
return;
};
_outstandingID = _syncID;
var _local2:Object = {};
for (_local3 in _consumableProperties) {
_local2[_local3] = MochiDigits(_consumableProperties[_local3]).value;
};
MochiUserData.put(CONSUMER_KEY, _local2, putConsumableBag);
_syncPending = true;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(_arg1:int):String{
return (_names[(_arg1 - 1)]);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(_arg1):Boolean{
if (!_consumableProperties[_arg1]){
return (false);
};
_names.splice(_names.indexOf(_arg1), 1);
delete _consumableProperties[_arg1];
return (true);
}
private function getConsumableBag(_arg1:MochiUserData):void{
var _local2:String;
var _local3:Number;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
return;
};
_consumableProperties = {};
_names = new Array();
if (_arg1.data){
for (_local2 in _arg1.data) {
_names.push(_local2);
_consumableProperties[_local2] = new MochiDigits(_arg1.data[_local2]);
};
};
for (_local2 in _storeSync) {
_local3 = _storeSync[_local2].count;
if (_consumableProperties[(_local2 + KEY_SALT)]){
_local3 = (_local3 - _consumableProperties[_local2]);
};
if (_local3 == 0){
} else {
newItems({id:_local2, count:_local3, properties:_storeSync[_local2].properties});
};
};
triggerEvent(READY, {});
}
private function loggedOut(_arg1:Object=null):void{
_consumableProperties = null;
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
}
}//package mochi.as3
Section 7
//MochiScores (mochi.as3.MochiScores)
package mochi.as3 {
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 n:Number;
var options = _arg1;
if (options != null){
delete options.clip;
MochiServices.setContainer();
MochiServices.bringToTop();
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;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
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.warnID(options.boardID, true);
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
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 _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
var _local2:Object = {};
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{
_arg1 = Number(_arg1);
if (isNaN(_arg1)){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((_arg1 == Number.NEGATIVE_INFINITY)) || ((_arg1 == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(_arg1) != _arg1){
trace((("WARNING: Submitted score '" + String(_arg1)) + "' will be truncated"));
};
_arg1 = Number(_arg1);
};
};
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (((((_arg1) && ((_arg1.error == true)))) && (onErrorHandler))){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiServices.warnID(_arg1, true);
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi.as3
Section 8
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.geom.*;
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 _preserved:Object;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
public static var servicesSync:MochiSync = new MochiSync();
private static var _clip:MovieClip;
private static var _id:String;
private static var _services:String = "services.swf";
private static var _servURL:String = "http://www.mochiads.com/static/lib/services/";
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _loader:Loader;
private static var _connecting:Boolean = false;
private static var _mochiLocalConnection:MovieClip;
private static var _listenChannelName:String = "__ms_";
public static var onError:Object;
public static var netup:Boolean = true;
private static var _mochiLC:String = "MochiLC.swf";
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function onReceive(_arg1:Object):void{
var methodName:String;
var pkg = _arg1;
var cb:String = pkg.callbackID;
var cblst:Object = _clip._callbacks[cb];
if (!cblst){
return;
};
var method:* = cblst.callbackMethod;
methodName = "";
var obj:Object = 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 _clip._callbacks[cb];
}
public static function get childClip():Object{
return (_clip);
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + _arg1));
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++;
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local4:int;
var _local14:Loader;
var _local3:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
var _local5:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var _local6:Array = [0, 64, 0, 0, 0];
var _local7:MovieClip = new MovieClip();
var _local8:LocalConnection = new LocalConnection();
var _local9:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().time));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
var _local10:ByteArray = new ByteArray();
var _local11:ByteArray = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
var _local12:uint = ((_local3.length + _local11.length) + 4);
var _local13:uint = (_local12 + 35);
_local10.endian = Endian.LITTLE_ENDIAN;
_local10.writeUTFBytes("FWS");
_local10.writeByte(8);
_local10.writeUnsignedInt(_local13);
for each (_local4 in _local5) {
_local10.writeByte(_local4);
};
_local10.writeUnsignedInt(_local12);
_local10.writeByte(136);
_local10.writeShort(_local11.length);
_local10.writeBytes(_local11);
for each (_local4 in _local3) {
_local10.writeByte(_local4);
};
for each (_local4 in _local6) {
_local10.writeByte(_local4);
};
_local14 = new Loader();
_local14.loadBytes(_local10);
_local7.addChild(_local14);
return (_local7);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function addLinkEvent(_arg1:String, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Function=null):void{
var avm1Click:DisplayObject;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = _arg1;
var burl = _arg2;
var btn = _arg3;
var onClick = _arg4;
var vars:Object = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
var s = "?";
var i:Number = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://x.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (_arg1:String):void{
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
var _local2:Rectangle = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = _local2.x;
avm1Click.y = _local2.y;
avm1Click.scaleX = (0.01 * _local2.width);
avm1Click.scaleY = (0.01 * _local2.height);
};
err = function (_arg1:Object):void{
netup = false;
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
setURL(burl);
};
complete = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
public static function warnID(_arg1:String, _arg2:Boolean):void{
_arg1 = _arg1.toLowerCase();
if (_arg1.length != 16){
trace((("WARNING: " + (_arg2) ? "board" : "game") + " ID is not the appropriate length"));
return;
} else {
if (_arg1 == "1e113c7239048b3f"){
if (_arg2){
trace("WARNING: Using testing board ID");
} else {
trace("WARNING: Using testing board ID as game ID");
};
return;
} else {
if (_arg1 == "84993a1de4031cd8"){
if (_arg2){
trace("WARNING: Using testing game ID as board ID");
} else {
trace("WARNING: Using testing game ID");
};
return;
};
};
};
var _local3:Number = 0;
while (_local3 < _arg1.length) {
switch (_arg1.charAt(_local3)){
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
break;
default:
trace(("WARNING: Board ID contains illegal characters: " + _arg1));
return;
};
_local3++;
};
}
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 {
_mochiLocalConnection.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
};
return (_local2);
}
public static function getVersion():String{
return ("3.7 as3");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (((_clip) && (_clip._queue))){
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);
};
};
};
};
}
public static function get id():String{
return (_id);
}
private static function onEvent(_arg1:Object):void{
var _local2:String = _arg1.target;
var _local3:String = _arg1.event;
switch (_local2){
case "events":
MochiEvents.triggerEvent(_arg1.event, _arg1.args);
break;
case "coins":
MochiCoins.triggerEvent(_arg1.event, _arg1.args);
break;
case "sync":
servicesSync.triggerEvent(_arg1.event, _arg1.args);
break;
};
}
private static function urlOptions(_arg1:Object):Object{
var _local3:String;
var _local4:Array;
var _local5:Number;
var _local6:Array;
var _local2:Object = {};
if (_arg1.stage){
_local3 = _arg1.stage.loaderInfo.parameters.mochiad_options;
} else {
_local3 = _arg1.loaderInfo.parameters.mochiad_options;
};
if (_local3){
_local4 = _local3.split("&");
_local5 = 0;
while (_local5 < _local4.length) {
_local6 = _local4[_local5].split("=");
_local2[unescape(_local6[0])] = unescape(_local6[1]);
_local5++;
};
};
return (_local2);
}
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 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) {
};
};
};
};
}
private static function loadError(_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
}
private static function initComChannels():void{
if (!_connected){
trace("[SERVICES_API] connected!");
_connecting = false;
_connected = true;
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"registerGame", preserved:_preserved, id:_id, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_clip.onReceive = onReceive;
_clip.onEvent = onEvent;
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
while (_clip._queue.length > 0) {
_mochiLocalConnection.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function loadLCBridge(_arg1:Object):void{
var loader:Loader;
var clip = _arg1;
loader = new Loader();
var mochiLCURL:String = (_servURL + _mochiLC);
var req:URLRequest = new URLRequest(mochiLCURL);
var complete:Function = function (_arg1:Object):void{
_mochiLocalConnection = MovieClip(loader.content);
listen();
};
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
loader.load(req);
clip.addChild(loader);
}
private static function listen():void{
_mochiLocalConnection.connect(_listenChannelName);
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
trace("Waiting for MochiAds services to connect...");
}
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");
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var _local3:String = ("_mochiservices_com_" + _arg1);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(_arg2).servURL){
_servURL = urlOptions(_arg2).servURL;
};
var _local4:String = (_servURL + _services);
if (urlOptions(_arg2).servicesURL){
_local4 = urlOptions(_arg2).servicesURL;
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999))));
MochiServices.allowDomains(_local4);
_clip = createEmptyMovieClip(_arg2, _local3, 10336, false);
loadLCBridge(_clip);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
var _local5:URLRequest = new URLRequest(_local4);
var _local6:URLVariables = new URLVariables();
_local6.listenLC = _listenChannelName;
_local6.mochiad_options = _arg2.loaderInfo.parameters.mochiad_options;
_local6.api_version = getVersion();
if (widget){
_local6.widget = true;
};
_local5.data = _local6;
_loader.load(_local5);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_clip._nextcallbackID = 0;
_clip._callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
warnID(id, false);
if ((clip is DisplayObject)){
if (clip.stage == null){
trace("MochiServices connect requires the containing clip be attached to the stage");
};
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 parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
var mc:MovieClip = 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 bringToTop(_arg1:Event=null):void{
var e = _arg1;
if (((!((MochiServices.clip == null))) && (!((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 connectWait(_arg1:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
}
}
}//package mochi.as3
Section 9
//MochiSocial (mochi.as3.MochiSocial)
package mochi.as3 {
public class MochiSocial {
public static const LOGGED_IN:String = "LoggedIn";
public static const PROFILE_HIDE:String = "ProfileHide";
public static const NO_USER:String = "NoUser";
public static const PROPERTIES_SIZE:String = "PropertiesSize";
public static const IO_ERROR:String = "IOError";
public static const PROPERTIES_SAVED:String = "PropertySaved";
public static const WIDGET_LOADED:String = "WidgetLoaded";
public static const USER_INFO:String = "UserInfo";
public static const ERROR:String = "Error";
public static const LOGIN_SHOW:String = "LoginShow";
public static const LOGGED_OUT:String = "LoggedOut";
public static const PROFILE_SHOW:String = "ProfileShow";
public static const LOGIN_SHOWN:String = "LoginShown";
public static const LOGIN_HIDE:String = "LoginHide";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static var _user_info:Object = null;
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function saveUserProperties(_arg1:Object):void{
MochiServices.send("coins_saveUserProperties", _arg1);
}
public static function get loggedIn():Boolean{
return (!((_user_info == null)));
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function getUserInfo():void{
MochiServices.send("coins_getUserInfo");
}
public static function showLoginWidget(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showLoginWidget", {options:_arg1});
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function requestLogin():void{
MochiServices.send("coins_requestLogin");
}
public static function getAPIURL():String{
if (!_user_info){
return (null);
};
return (_user_info.api_url);
}
public static function hideLoginWidget():void{
MochiServices.send("coins_hideLoginWidget");
}
public static function getAPIToken():String{
if (!_user_info){
return (null);
};
return (_user_info.api_token);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_user_info = _arg1;
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_user_info = null;
});
}
}//package mochi.as3
Section 10
//MochiSync (mochi.as3.MochiSync)
package mochi.as3 {
import flash.utils.*;
public dynamic class MochiSync extends Proxy {
private var _syncContainer:Object;
public static var SYNC_PROPERTY:String = "UpdateProperty";
public static var SYNC_REQUEST:String = "SyncRequest";
public function MochiSync():void{
_syncContainer = {};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
if (_syncContainer[_arg1] == _arg2){
return;
};
var _local3:String = _arg1.toString();
_syncContainer[_local3] = _arg2;
MochiServices.send("sync_propUpdate", {name:_local3, value:_arg2});
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
return (_syncContainer[_arg1]);
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
switch (_arg1){
case SYNC_REQUEST:
MochiServices.send("sync_syncronize", _syncContainer);
break;
case SYNC_PROPERTY:
_syncContainer[_arg2.name] = _arg2.value;
break;
};
}
}
}//package mochi.as3
Section 11
//MochiUserData (mochi.as3.MochiUserData)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class MochiUserData extends EventDispatcher {
public var callback:Function;// = null
public var operation:String;// = null
public var error:Event;// = null
public var data;// = null
public var _loader:URLLoader;
public var key:String;// = null
public function MochiUserData(_arg1:String="", _arg2:Function=null){
this.key = _arg1;
this.callback = _arg2;
}
public function serialize(_arg1):ByteArray{
var _local2:ByteArray = new ByteArray();
_local2.objectEncoding = ObjectEncoding.AMF3;
_local2.writeObject(_arg1);
_local2.compress();
return (_local2);
}
public function errorHandler(_arg1:IOErrorEvent):void{
data = null;
error = _arg1;
if (callback != null){
performCallback();
} else {
dispatchEvent(_arg1);
};
close();
}
public function putEvent(_arg1):void{
request("put", serialize(_arg1));
}
public function deserialize(_arg1:ByteArray){
_arg1.objectEncoding = ObjectEncoding.AMF3;
_arg1.uncompress();
return (_arg1.readObject());
}
public function securityErrorHandler(_arg1:SecurityErrorEvent):void{
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + _arg1.toString())));
}
public function getEvent():void{
request("get", serialize(null));
}
override public function toString():String{
return ((((((((("[MochiUserData operation=" + operation) + " key=\"") + key) + "\" data=") + data) + " error=\"") + error) + "\"]"));
}
public function performCallback():void{
try {
callback(this);
} catch(e:Error) {
trace(("[MochiUserData] exception during callback: " + e));
};
}
public function request(_arg1:String, _arg2:ByteArray):void{
var _operation = _arg1;
var _data = _arg2;
operation = _operation;
var api_url:String = MochiSocial.getAPIURL();
var api_token:String = MochiSocial.getAPIToken();
if ((((api_url == null)) || ((api_token == null)))){
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "not logged in"));
return;
};
_loader = new URLLoader();
var args:URLVariables = new URLVariables();
args.op = _operation;
args.key = key;
var req:URLRequest = new URLRequest((((MochiSocial.getAPIURL() + "/") + "MochiUserData?") + args.toString()));
req.method = URLRequestMethod.POST;
req.contentType = "application/x-mochi-userdata";
req.requestHeaders = [new URLRequestHeader("x-mochi-services-version", MochiServices.getVersion()), new URLRequestHeader("x-mochi-api-token", api_token)];
req.data = _data;
_loader.dataFormat = URLLoaderDataFormat.BINARY;
_loader.addEventListener(Event.COMPLETE, completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
try {
_loader.load(req);
} catch(e:SecurityError) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + e.toString())));
};
}
public function completeHandler(_arg1:Event):void{
var event = _arg1;
try {
if (_loader.data.length){
data = deserialize(_loader.data);
} else {
data = null;
};
} catch(e:Error) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("deserialize error: " + e.toString())));
return;
};
if (callback != null){
performCallback();
} else {
dispatchEvent(event);
};
close();
}
public function close():void{
if (_loader){
_loader.removeEventListener(Event.COMPLETE, completeHandler);
_loader.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_loader.close();
_loader = null;
};
error = null;
callback = null;
}
public static function get(_arg1:String, _arg2:Function):void{
var _local3:MochiUserData = new MochiUserData(_arg1, _arg2);
_local3.getEvent();
}
public static function put(_arg1:String, _arg2, _arg3:Function):void{
var _local4:MochiUserData = new MochiUserData(_arg1, _arg3);
_local4.putEvent(_arg2);
}
}
}//package mochi.as3
Section 12
//BeepSound (BeepSound)
package {
import flash.media.*;
public dynamic class BeepSound extends Sound {
}
}//package
Section 13
//Bomb (Bomb)
package {
import flash.display.*;
import flash.geom.*;
public class Bomb extends Sprite {
public var yspeed:Number;
public var myColor:ColorTransform;
private var xspeed:Number;
public function Bomb(){
myColor = this.transform.colorTransform;
myColor.color = (Math.random() * 0xFFFFFF);
this.transform.colorTransform = myColor;
this.xspeed = -3;
this.yspeed = 6;
this.scaleX = (this.scaleY = 0.6);
}
public function move():void{
this.x = (this.x + xspeed);
this.y = (this.y + yspeed);
yspeed = (yspeed + 0.4);
}
public function returnColor():Number{
return (myColor.color);
}
}
}//package
Section 14
//BombSplat (BombSplat)
package {
public class BombSplat extends Splat {
public function BombSplat(_arg1:Bomb, _arg2:int, _arg3:Number, _arg4:Number){
this.x = _arg3;
this.y = _arg4;
this.scaleX = (this.scaleY = _arg2);
this.gotoAndStop(Math.ceil((Math.random() * 3)));
this.transform.colorTransform = _arg1.myColor;
}
}
}//package
Section 15
//Bullet (Bullet)
package {
import flash.display.*;
public class Bullet extends Sprite {
public var color;// = 0
public var yspeed:Number;
public var speed:int;
public var xspeed:Number;
public function Bullet(){
graphics.beginFill(getColor());
graphics.drawCircle(0, 0, 4);
graphics.endFill();
this.scaleX = (this.scaleY = 0.6);
}
public function move():void{
this.x = (this.x + xspeed);
this.y = (this.y + yspeed);
}
public function getColor(){
}
}
}//package
Section 16
//BulletSplat (BulletSplat)
package {
import flash.geom.*;
public class BulletSplat extends Splat {
public function BulletSplat(_arg1:Bullet, _arg2:Number, _arg3:Number){
this.x = _arg2;
this.y = _arg3;
this.gotoAndStop(Math.ceil((Math.random() * 3)));
var _local4:ColorTransform = this.transform.colorTransform;
_local4.color = _arg1.color;
this.transform.colorTransform = _local4;
}
}
}//package
Section 17
//ColorChangeSound (ColorChangeSound)
package {
import flash.media.*;
public dynamic class ColorChangeSound extends Sound {
}
}//package
Section 18
//DocumentClass (DocumentClass)
package {
import flash.display.*;
import flash.events.*;
import mochi.as3.*;
public dynamic class DocumentClass extends MovieClip {
private var loaderBar:PreLoader;
private var boardID:String;
private var loaded:Boolean;
private var mochiScreen:MochiScreen;
private var adfinished:Boolean;
private var preLoader:PreLoader;
private var firstTime:Boolean;
private var playscreen:PlayScreen;
private var loseScreen:LoseScreen;
private var winScreen:WinScreen;
private var o:Object;
private var mainMenu:MainMenu;
public function DocumentClass(){
o = {n:[12, 10, 9, 10, 12, 9, 7, 14, 4, 2, 7, 6, 1, 2, 12, 5], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
boardID = o.f(0, "");
super();
addFrameScript(0, frame1);
mochiScreen = new MochiScreen();
addChild(mochiScreen);
stage.stageFocusRect = false;
preLoader = new PreLoader();
addChild(preLoader);
swapChildren(mochiScreen, preLoader);
var _mochiads_game_id = "2a7c22461efae6b8";
MochiServices.connect("2a7c22461efae6b8", mochiScreen);
MochiAd.showPreGameAd({clip:root, id:"2a7c22461efae6b8", res:"600x350", background:13172731, color:35071, outline:3953109, no_bg:true, ad_finished:function ():void{
adDone();
}});
loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressMade);
loaderInfo.addEventListener(Event.COMPLETE, onLoaded);
}
private function onLoaded(_arg1:Event):void{
loaded = true;
if (adfinished){
if (currentFrame != 3){
gotoAndStop(3);
};
if (preLoader != null){
removeChild(preLoader);
preLoader = null;
};
mainMenu = new MainMenu();
mainMenu.x = 300;
mainMenu.y = 175;
addChild(mainMenu);
swapChildren(mochiScreen, mainMenu);
if (_arg1 == null){
if (firstTime){
mainMenu.gotoAndStop(25);
} else {
firstTime = true;
};
};
mainMenu.playbutton.addEventListener(MouseEvent.CLICK, onPlay);
mainMenu.OptionsButton.addEventListener(MouseEvent.CLICK, onOptions);
mainMenu.scorebutton.addEventListener(MouseEvent.CLICK, showScores);
};
}
private function onBackMain(_arg1:MouseEvent):void{
if (winScreen){
winScreen.mainmenuButton.removeEventListener(MouseEvent.CLICK, onBackMain);
removeChild(winScreen);
winScreen = null;
};
if (loseScreen){
loseScreen.mainmenuButton.removeEventListener(MouseEvent.CLICK, onBackMain);
loseScreen.retryButton.removeEventListener(MouseEvent.CLICK, onRetry);
removeChild(loseScreen);
loseScreen = null;
};
onLoaded(null);
}
private function onPlay(_arg1:MouseEvent):void{
if (mainMenu != null){
mainMenu.onRemove();
mainMenu.playbutton.removeEventListener(MouseEvent.CLICK, onPlay);
mainMenu.OptionsButton.removeEventListener(MouseEvent.CLICK, onOptions);
mainMenu.scorebutton.removeEventListener(MouseEvent.CLICK, showScores);
removeChild(mainMenu);
mainMenu = null;
};
playscreen = new PlayScreen();
addChild(playscreen);
stage.focus = playscreen;
playscreen.addEventListener(NavigationEvent.LOSE, onLose);
playscreen.addEventListener(NavigationEvent.WIN, onWin);
playscreen.initGame();
}
private function adDone():void{
adfinished = true;
if (loaded){
onLoaded(null);
};
}
private function onLose(_arg1:NavigationEvent):void{
var _local2:int = playscreen.getScore();
playscreen.removeEventListener(NavigationEvent.LOSE, onLose);
playscreen.removeEventListener(NavigationEvent.WIN, onWin);
playscreen.IGSSoundchannel.stop();
removeChild(playscreen);
playscreen = null;
loseScreen = new LoseScreen();
loseScreen.x = 300;
loseScreen.y = 175;
loseScreen.mainmenuButton.addEventListener(MouseEvent.CLICK, onBackMain);
loseScreen.retryButton.addEventListener(MouseEvent.CLICK, onRetry);
loseScreen.setScore(_local2);
addChild(loseScreen);
swapChildren(mochiScreen, loseScreen);
MochiScores.showLeaderboard({boardID:boardID, score:_local2});
}
private function onRetry(_arg1:MouseEvent):void{
loseScreen.mainmenuButton.removeEventListener(MouseEvent.CLICK, onBackMain);
loseScreen.retryButton.removeEventListener(MouseEvent.CLICK, onRetry);
removeChild(loseScreen);
loseScreen = null;
onPlay(null);
}
function frame1(){
stop();
}
private function onProgressMade(_arg1:ProgressEvent):void{
preLoader.loaderBar.scaleX = (Math.round(((loaderInfo.bytesLoaded / loaderInfo.bytesTotal) * 100)) / 100);
}
private function onWin(_arg1:NavigationEvent):void{
var _local2:int = (playscreen.getScore() + 1000);
playscreen.removeEventListener(NavigationEvent.LOSE, onLose);
playscreen.removeEventListener(NavigationEvent.WIN, onWin);
playscreen.IGSSoundchannel.stop();
removeChild(playscreen);
playscreen = null;
winScreen = new WinScreen();
winScreen.x = 300;
winScreen.y = 175;
winScreen.mainmenuButton.addEventListener(MouseEvent.CLICK, onBackMain);
winScreen.setScore(_local2);
addChild(winScreen);
swapChildren(mochiScreen, winScreen);
MochiScores.showLeaderboard({boardID:boardID, score:_local2});
}
private function showScores(_arg1:MouseEvent):void{
MochiScores.showLeaderboard({boardID:boardID});
}
private function onOptions(_arg1:MouseEvent):void{
if (mainMenu.currentFrame == 50){
mainMenu.gotoAndPlay(26);
} else {
mainMenu.play();
};
}
}
}//package
Section 19
//DoublePanel (DoublePanel)
package {
import flash.display.*;
public class DoublePanel extends Sprite {
public function move():void{
this.x = (this.x - 2);
if (this.x <= -1967.3){
this.x = 0;
};
}
}
}//package
Section 20
//Enemy (Enemy)
package {
import flash.display.*;
import flash.media.*;
import flash.geom.*;
public dynamic class Enemy extends MovieClip {
public var splat:PlaneSplat;
public var died:Boolean;
public var speed:int;
public var stageRef:Sprite;
public var shootChance:int;
public var explosion:EnemyDie;
public var shoot:Boolean;
public var worth:int;
public var lifePoints:int;
public function Enemy(){
x = 680;
y = (20 + (Math.random() * 210));
this.scaleX = (this.scaleY = 0.5);
this.splat.stop();
died = false;
}
public function move():void{
x = (x - speed);
}
public function getHit(_arg1):void{
var _local2:SplatterSound;
var _local3:SoundTransform;
var _local4:SoundChannel;
var _local5:ColorTransform;
var _local6:ExplosionSound;
var _local7:SoundChannel;
var _local8:ColorTransform;
if ((_arg1 is Bullet)){
lifePoints--;
this.splat.nextFrame();
_local2 = new SplatterSound();
_local3 = new SoundTransform(0.35);
_local4 = _local2.play();
_local4.soundTransform = _local3;
_local5 = splat.transform.colorTransform;
_local5.color = _arg1.color;
splat.transform.colorTransform = _local5;
} else {
if ((_arg1 is Bomb)){
lifePoints = 0;
};
};
if (lifePoints == 0){
died = true;
explosion = new EnemyDie();
explosion.x = this.x;
explosion.y = this.y;
stageRef.addChild(explosion);
_local6 = new ExplosionSound();
_local7 = _local6.play();
if ((_arg1 is Bullet)){
_local8 = explosion.transform.colorTransform;
_local8.color = _arg1.color;
explosion.transform.colorTransform = _local8;
} else {
if ((_arg1 is Bomb)){
explosion.transform.colorTransform = _arg1.myColor;
};
};
};
}
public function playerHit():void{
explosion = new EnemyDie();
explosion.x = this.x;
explosion.y = this.y;
stageRef.addChild(explosion);
var _local1:ExplosionSound = new ExplosionSound();
var _local2:SoundChannel = _local1.play();
var _local3:ColorTransform = explosion.transform.colorTransform;
_local3.color = 0;
explosion.transform.colorTransform = _local3;
died = true;
}
public function tryShoot():Boolean{
if ((Math.random() * 100) < shootChance){
shoot = true;
} else {
shoot = false;
};
return (shoot);
}
public function getDie():Boolean{
return (died);
}
}
}//package
Section 21
//EnemyBalloon (EnemyBalloon)
package {
import flash.display.*;
public class EnemyBalloon extends Enemy {
public function EnemyBalloon(_arg1:Sprite){
speed = 4;
lifePoints = 4;
worth = 25;
shootChance = 25;
this.stageRef = _arg1;
}
}
}//package
Section 22
//enemyblipsplat (enemyblipsplat)
package {
public dynamic class enemyblipsplat extends PlaneSplat {
}
}//package
Section 23
//EnemyBullet (EnemyBullet)
package {
public class EnemyBullet extends Bullet {
override public function getColor(){
return (0);
}
}
}//package
Section 24
//EnemyCopter (EnemyCopter)
package {
import flash.display.*;
public class EnemyCopter extends Enemy {
public function EnemyCopter(_arg1:Sprite){
speed = 5;
lifePoints = 6;
worth = 50;
shootChance = 20;
this.stageRef = _arg1;
}
}
}//package
Section 25
//EnemyDie (EnemyDie)
package {
import flash.display.*;
import flash.events.*;
public class EnemyDie extends MovieClip {
public function EnemyDie(){
addFrameScript(13, frame14);
addEventListener(Event.ENTER_FRAME, checkEnd);
}
function frame14(){
stop();
}
private function checkEnd(_arg1:Event):void{
}
}
}//package
Section 26
//EnemyPlane (EnemyPlane)
package {
import flash.display.*;
public class EnemyPlane extends Enemy {
public function EnemyPlane(_arg1:Sprite){
speed = 7;
lifePoints = 2;
worth = 10;
shootChance = 20;
this.stageRef = _arg1;
}
}
}//package
Section 27
//ExplosionSound (ExplosionSound)
package {
import flash.media.*;
public dynamic class ExplosionSound extends Sound {
}
}//package
Section 28
//FloorBar (FloorBar)
package {
import flash.display.*;
public dynamic class FloorBar extends MovieClip {
}
}//package
Section 29
//GameSound (GameSound)
package {
import flash.media.*;
public dynamic class GameSound extends Sound {
}
}//package
Section 30
//GameTimer (GameTimer)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
public class GameTimer extends MovieClip {
private var realSeconds:int;
public var TimerLeft:TextField;
private var secondsString:String;
private var secondTimer:Timer;
private var TimeLeft:int;
private var minutesString:String;
public var complete:Boolean;
private var minutes:int;
public function GameTimer(_arg1:int){
TimeLeft = _arg1;
this.scaleY = 2;
secondTimer = new Timer(1000);
secondTimer.addEventListener(TimerEvent.TIMER, decreaseSeconds);
secondTimer.start();
minutes = Math.floor((TimeLeft / 60));
realSeconds = (TimeLeft % 60);
if (minutes < 10){
minutesString = (0 + minutes.toString());
} else {
minutesString = minutes.toString();
};
if (realSeconds < 10){
secondsString = (0 + realSeconds.toString());
} else {
secondsString = realSeconds.toString();
};
TimerLeft.text = ((minutesString + ":") + secondsString);
}
private function decreaseSeconds(_arg1:TimerEvent):void{
minutes = Math.floor((TimeLeft / 60));
realSeconds = (TimeLeft % 60);
if (minutes >= 0){
if (minutes < 10){
minutesString = ("0" + minutes.toString());
} else {
minutesString = minutes.toString();
};
};
if (realSeconds >= 0){
if (realSeconds < 10){
secondsString = ("0" + realSeconds.toString());
} else {
secondsString = realSeconds.toString();
};
};
if (TimeLeft <= 0){
TimeLeft = 0;
complete = true;
};
TimerLeft.text = ((minutesString + ":") + secondsString);
TimeLeft = (TimeLeft - 1);
}
public function getComplete():Boolean{
return (complete);
}
}
}//package
Section 31
//HealthMeter (HealthMeter)
package {
import flash.display.*;
public dynamic class HealthMeter extends MovieClip {
public function HealthMeter(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 32
//helisplat (helisplat)
package {
public dynamic class helisplat extends PlaneSplat {
}
}//package
Section 33
//HitBox (HitBox)
package {
import flash.display.*;
public dynamic class HitBox extends MovieClip {
}
}//package
Section 34
//House (House)
package {
import flash.display.*;
import flash.media.*;
import flash.geom.*;
public dynamic class House extends MovieClip {
public var hitNumber:int;
public var worth:int;
private var ccSound:ColorChangeSound;
public var changed:Boolean;
private var ccSoundChanel:SoundChannel;
public var pointsGiven:Boolean;
public var hitCount:int;// = 0
public function House(){
this.x = 680;
this.y = 320;
stop();
changed = false;
this.scaleX = (this.scaleY = 0.6);
pointsGiven = false;
}
public function move():void{
this.x = (this.x - 4);
}
public function getHit(_arg1):void{
var _local5:SoundTransform;
var _local6:ColorTransform;
if ((_arg1 is Bomb)){
hitCount = (hitCount + 5);
} else {
hitCount++;
};
var _local2:SplatterSound = new SplatterSound();
var _local3:SoundTransform = new SoundTransform(0.35);
var _local4:SoundChannel = _local2.play();
_local4.soundTransform = _local3;
if ((((this.hitCount >= this.hitNumber)) && (!(changed)))){
changed = true;
ccSound = new ColorChangeSound();
ccSoundChanel = ccSound.play();
_local5 = new SoundTransform(3);
ccSoundChanel.soundTransform = _local5;
if ((_arg1 is Bomb)){
this.transform.colorTransform = _arg1.myColor;
} else {
_local6 = this.transform.colorTransform;
_local6.color = _arg1.color;
this.transform.colorTransform = _local6;
};
play();
};
}
}
}//package
Section 35
//House1 (House1)
package {
public class House1 extends House {
public var maskclip:MaskClip;
public var masklayer:house1Mask;
public function House1(){
addFrameScript(9, frame10);
hitNumber = 5;
worth = 50;
}
function frame10(){
stop();
}
}
}//package
Section 36
//house1Mask (house1Mask)
package {
import flash.display.*;
public dynamic class house1Mask extends MovieClip {
}
}//package
Section 37
//House2 (House2)
package {
public class House2 extends House {
public var maskclip:MaskClip;
public var masklayer:house2Mask;
public function House2(){
addFrameScript(9, frame10);
hitNumber = 5;
worth = 50;
}
function frame10(){
stop();
}
}
}//package
Section 38
//house2Mask (house2Mask)
package {
import flash.display.*;
public dynamic class house2Mask extends MovieClip {
}
}//package
Section 39
//House3 (House3)
package {
public class House3 extends House {
public var maskclip:MaskClip;
public var masklayer:SkyscraperMask;
public function House3(){
addFrameScript(9, frame10);
hitNumber = 10;
worth = 75;
}
function frame10(){
stop();
}
}
}//package
Section 40
//LoseScreen (LoseScreen)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.text.*;
public class LoseScreen extends MovieClip {
private var beepSound:BeepSound;
public var theEndScore:MovieClip;
public var mainmenuButton:SimpleButton;
private var bSoundChannel:SoundChannel;
public var EndScore:TextField;
public var retryButton:SimpleButton;
public function LoseScreen(){
var _local2:*;
super();
addFrameScript(14, frame15);
var _local1:int = (this.numChildren - 1);
while (_local1 > -1) {
_local2 = this.getChildAt(_local1);
if ((_local2 is SimpleButton)){
_local2.addEventListener(MouseEvent.ROLL_OVER, playBeep);
};
_local1--;
};
}
private function playBeep(_arg1:MouseEvent):void{
beepSound = new BeepSound();
bSoundChannel = beepSound.play();
var _local2:SoundTransform = new SoundTransform(5);
bSoundChannel.soundTransform = _local2;
}
function frame15(){
stop();
}
public function setScore(_arg1:int):void{
theEndScore.EndScore.text = _arg1.toString();
}
}
}//package
Section 41
//MainMenu (MainMenu)
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.media.*;
public class MainMenu extends MovieClip {
private var beepSound:BeepSound;
public var scorebutton:SimpleButton;
public var OptionsButton:SimpleButton;
public var adamButton:SimpleButton;
public var tomButton:SimpleButton;
private var mmMusic:MainMenuMusic;
public var playbutton:SimpleButton;
public var mainmenuButton:SimpleButton;
public var sponsorButton:SimpleButton;
private var mmSoundChannel:SoundChannel;
private var bSoundChannel:SoundChannel;
public function MainMenu(){
var _local3:*;
super();
addFrameScript(24, frame25, 35, frame36, 49, frame50);
var _local1:SoundTransform = new SoundTransform(0.5);
if (mmMusic == null){
mmMusic = new MainMenuMusic();
mmSoundChannel = mmMusic.play();
mmSoundChannel.soundTransform = _local1;
};
var _local2:int = (this.numChildren - 1);
while (_local2 > -1) {
_local3 = this.getChildAt(_local2);
if ((_local3 is SimpleButton)){
_local3.addEventListener(MouseEvent.ROLL_OVER, playBeep);
};
_local2--;
};
addEventListener(MouseEvent.CLICK, checkLink);
}
public function onRemove():void{
mmSoundChannel.stop();
}
private function playBeep(_arg1:MouseEvent):void{
beepSound = new BeepSound();
bSoundChannel = beepSound.play();
var _local2:SoundTransform = new SoundTransform(5);
bSoundChannel.soundTransform = _local2;
}
function frame36(){
stop();
}
private function checkLink(_arg1:MouseEvent):void{
if (_arg1.target == tomButton){
navigateToURL(new URLRequest("http://tomdeaap.newgrounds.com/"));
} else {
if (_arg1.target == adamButton){
navigateToURL(new URLRequest("http://adman1993.newgrounds.com/"));
} else {
if (_arg1.target == sponsorButton){
navigateToURL(new URLRequest("http://www.ugotgames.com/"));
};
};
};
}
function frame25(){
stop();
}
function frame50(){
stop();
}
}
}//package
Section 42
//MainMenuMusic (MainMenuMusic)
package {
import flash.media.*;
public dynamic class MainMenuMusic extends Sound {
}
}//package
Section 43
//MaskClip (MaskClip)
package {
import flash.display.*;
public dynamic class MaskClip extends MovieClip {
}
}//package
Section 44
//MochiScreen (MochiScreen)
package {
import flash.display.*;
public dynamic class MochiScreen extends Sprite {
}
}//package
Section 45
//NavigationEvent (NavigationEvent)
package {
import flash.events.*;
public class NavigationEvent extends Event {
public static const WIN:String = "win";
public static const LOSE:String = "lose";
public function NavigationEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
override public function toString():String{
return (formatToString("NavigationEvent", "type", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new NavigationEvent(type, bubbles, cancelable));
}
}
}//package
Section 46
//PlaneSplat (PlaneSplat)
package {
import flash.display.*;
public class PlaneSplat extends MovieClip {
}
}//package
Section 47
//planesplat (planesplat)
package {
public dynamic class planesplat extends PlaneSplat {
}
}//package
Section 48
//PlayerBullet (PlayerBullet)
package {
public class PlayerBullet extends Bullet {
public function PlayerBullet(_arg1){
speed = 12;
var _local2:* = ((_arg1 * Math.PI) / 180);
xspeed = (Math.cos(_local2) * speed);
yspeed = (Math.sin(_local2) * speed);
}
override public function getColor(){
color = (Math.random() * 268435455);
return (color);
}
}
}//package
Section 49
//PlayerPlane (PlayerPlane)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.media.*;
import flash.geom.*;
import flash.ui.*;
public class PlayerPlane extends MovieClip {
private const speed:int = 2;
public var smokepoint:SmokePoint;
private var bombTimer:int;// = 0
private var xspeed:Number;// = 0
private var splatterSound:SplatterSound;
public var splats:Array;
private var smokeTimer:Timer;
public var bombs:Array;
private var smokes:Array;
private var shootTimer:int;// = 0
public var dead:Boolean;
private var yspeed:Number;// = 0
private var smoke:Smoke;
public var bullets:Array;
private var keys:Array;
public var stageRef:Sprite;
public var hitBox:MovieClip;
public function PlayerPlane(_arg1:Sprite){
splatterSound = new SplatterSound();
super();
addFrameScript(0, frame1, 90, frame91);
addEventListener(Event.ADDED_TO_STAGE, initPlane);
this.stageRef = _arg1;
}
function frame91(){
gotoAndStop(1);
}
public function update():void{
updatePos();
checkShoot();
updateProjectile();
}
private function updatePos():void{
xspeed = (xspeed * 0.8);
x = (x + xspeed);
yspeed = (0.7 * this.rotation);
yspeed = (yspeed * 0.8);
y = (y + yspeed);
if (keys[Keyboard.LEFT]){
if (this.x > (this.width / 2)){
xspeed = (xspeed - speed);
};
};
if (keys[Keyboard.RIGHT]){
if (this.x < 450){
xspeed = (xspeed + speed);
};
};
if (((keys[Keyboard.UP]) && ((this.y > 50)))){
if (this.rotation > -12){
this.rotation--;
};
} else {
if (((keys[Keyboard.DOWN]) && ((this.y < 250)))){
if (this.rotation < 12){
this.rotation++;
};
} else {
this.rotation = (this.rotation * 0.8);
};
};
}
private function updateProjectile():void{
var _local4:Bullet;
var _local5:BulletSplat;
var _local6:SoundTransform;
var _local7:SoundChannel;
var _local8:Bomb;
var _local9:BombSplat;
var _local10:SoundTransform;
var _local11:SoundChannel;
var _local12:Splat;
var _local1:int = (bullets.length - 1);
while (_local1 > -1) {
_local4 = bullets[_local1];
_local4.move();
if (_local4.x > 620){
if (stageRef.contains(_local4)){
stageRef.removeChild(_local4);
bullets.splice(_local1, 1);
};
};
if (_local4.y > 330){
_local4.y = 330;
_local5 = new BulletSplat(_local4, _local4.x, _local4.y);
splats.push(_local5);
stageRef.addChild(_local5);
_local6 = new SoundTransform(0.35);
_local7 = splatterSound.play();
_local7.soundTransform = _local6;
if (stageRef.contains(_local4)){
stageRef.removeChild(_local4);
bullets.splice(_local1, 1);
};
};
_local1--;
};
var _local2:int = (bombs.length - 1);
while (_local2 > -1) {
_local8 = bombs[_local2];
_local8.move();
if (_local8.y > 316){
_local9 = new BombSplat(bombs[_local2], 1.5, _local8.x, 316);
splats.push(_local9);
stageRef.addChild(_local9);
_local10 = new SoundTransform(0.35);
_local11 = splatterSound.play();
_local11.soundTransform = _local10;
stageRef.removeChild(_local8);
bombs.splice(_local2, 1);
};
_local2--;
};
var _local3:int = (splats.length - 1);
while (_local3 > -1) {
_local12 = splats[_local3];
_local12.move();
if (_local12.x < -60){
stageRef.removeChild(_local12);
splats.splice(_local3, 1);
};
_local3--;
};
}
public function addSmoke(_arg1:TimerEvent):void{
var _local2:Point;
var _local3:Point;
var _local4:int;
var _local5:*;
if (!dead){
_local2 = new Point(smokepoint.x, smokepoint.y);
_local3 = localToGlobal(_local2);
smoke = new Smoke();
smoke.x = _local3.x;
smoke.y = _local3.y;
smokes.push(smoke);
stageRef.addChild(smoke);
_local4 = (smokes.length - 1);
while (_local4 > -1) {
_local5 = smokes[_local4];
if (_local5.alpha < 0.1){
stageRef.removeChild(_local5);
smokes.splice(_local4, 1);
_local5 = null;
};
_local4--;
};
};
}
private function shootBullet():void{
var _local1:PlayerBullet = new PlayerBullet(this.rotation);
_local1.x = (x + (this.width / 2));
_local1.y = y;
bullets.push(_local1);
stageRef.addChild(_local1);
var _local2:ShotSound = new ShotSound();
var _local3:SoundChannel = _local2.play();
var _local4:SoundTransform = new SoundTransform(3);
_local3.soundTransform = _local4;
}
private function onKeyPressed(_arg1:KeyboardEvent):void{
keys[_arg1.keyCode] = true;
}
private function onKeyReleased(_arg1:KeyboardEvent):void{
keys[_arg1.keyCode] = false;
}
private function shootBomb():void{
var _local1:Bomb = new Bomb();
_local1.x = this.x;
_local1.y = (this.y + 20);
bombs.push(_local1);
stageRef.addChild(_local1);
}
private function checkShoot():void{
shootTimer++;
if (((((keys[90]) && ((shootTimer > 8)))) && (!(dead)))){
shootBullet();
shootTimer = 0;
};
bombTimer++;
if (((((keys[88]) && ((bombTimer > 35)))) && (!(dead)))){
shootBomb();
bombTimer = 0;
};
}
public function initPlane(_arg1:Event):void{
keys = new Array(300);
bullets = [];
bombs = [];
splats = [];
smokes = [];
this.scaleX = (this.scaleY = 0.4);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyReleased);
smokeTimer = new Timer(200);
smokeTimer.addEventListener(TimerEvent.TIMER, addSmoke);
smokeTimer.start();
}
function frame1(){
stop();
}
}
}//package
Section 50
//PlayScreen (PlayScreen)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.media.*;
import flash.geom.*;
public class PlayScreen extends Sprite {
private var bigtimer:GameTimer;
private var ObjectSpawnList:Array;
private var spawnTimer:Timer;
private var lifemeter:HealthMeter;
private var waveMessage:WaveMessage;
private var houses:Array;
private var inGameSound:GameSound;
public var scoreBox:Score;
public var eBullets:Array;
private var smalltimer:GameTimer;
private var player:PlayerPlane;
private var tickTimer:Timer;
public var IGSSoundchannel:SoundChannel;
private var exploded:Boolean;
private var eShootTimer:Timer;
private var enemies:Array;
private var background:DoublePanel;
private var explosions:Array;
public function getScore():int{
return (scoreBox.score);
}
private function tryEShoot(_arg1:TimerEvent):void{
var _local3:Enemy;
var _local2:int = (enemies.length - 1);
while (_local2 > -1) {
_local3 = enemies[_local2];
if (_local3.tryShoot()){
addBullet(_local3);
};
_local2--;
};
}
private function checkHouseCollision():void{
var _local2:House;
var _local3:int;
var _local4:int;
var _local5:Bomb;
var _local6:Point;
var _local7:BombSplat;
var _local8:Bullet;
var _local9:Point;
var _local10:BulletSplat;
var _local1:int = (houses.length - 1);
while (_local1 > -1) {
_local2 = houses[_local1];
if ((((_local2.changed == true)) && ((_local2.pointsGiven == false)))){
scoreBox.updateScore(_local2.worth);
_local2.pointsGiven = true;
};
_local3 = (player.bombs.length - 1);
while (_local3 > -1) {
_local5 = player.bombs[_local3];
if (((((_local2.hitTestPoint((_local5.x - 14.1), (_local5.y + _local5.yspeed), true)) && ((_local2.changed == false)))) || (((_local2.hitTestPoint((_local5.x + 14.1), (_local5.y + _local5.yspeed), true)) && ((_local2.changed == false)))))){
_local5.y = (_local5.y + (_local5.yspeed / 2));
_local2.getHit(_local5);
if (!_local2.changed){
_local6 = _local2.globalToLocal(new Point(_local5.x, _local5.y));
_local7 = new BombSplat(_local5, 3, _local6.x, _local6.y);
_local2.maskclip.addChild(_local7);
};
removeChild(_local5);
player.bombs.splice(_local3, 1);
};
_local3--;
};
_local4 = (player.bullets.length - 1);
while (_local4 > -1) {
_local8 = player.bullets[_local4];
if (((_local2.hitTestPoint((_local8.x + 2), (_local8.y + 2), true)) && (!(_local2.changed)))){
_local2.getHit(_local8);
_local9 = _local2.globalToLocal(new Point(_local8.x, _local8.y));
_local10 = new BulletSplat(_local8, _local9.x, _local9.y);
_local2.maskclip.addChild(_local10);
removeChild(_local8);
player.bullets.splice(_local4, 1);
};
_local4--;
};
_local1--;
};
}
public function initGame():void{
scoreBox = new Score();
scoreBox.x = 300;
addChild(scoreBox);
inGameSound = new GameSound();
IGSSoundchannel = inGameSound.play();
IGSSoundchannel.addEventListener(Event.SOUND_COMPLETE, loop);
var _local1:SoundTransform = new SoundTransform(0.2);
IGSSoundchannel.soundTransform = _local1;
ObjectSpawnList = [0, 0, 0, 0, 11, 4, 1, 0, 0, 0, 0, 12, 1, 1, 4, 1, 0, 0, 0, 0, 13, 6, 1, 1, 1, 5, 0, 0, 0, 0, 14, 6, 1, 4, 1, 1, 6, 1, 0, 0, 0, 0, 15, 1, 2, 5, 2, 4, 0, 0, 0, 0, 16, 4, 2, 1, 6, 2, 1, 0, 0, 0, 0, 17, 2, 5, 2, 1, 6, 2, 0, 0, 0, 0, 18, 1, 4, 2, 2, 6, 1, 1, 0, 0, 0, 0, 19, 4, 1, 6, 2, 2, 1, 5, 2, 0, 0, 0, 0, 20, 3, 1, 1, 6, 3, 2, 1, 4, 0, 0, 0, 0, 21, 1, 5, 2, 4, 1, 6, 3, 3, 3, 0, 0, 0, 0, 22, 4, 1, 3, 4, 2, 4, 1, 2, 6, 0, 0, 0, 0, 23, 1, 5, 2, 2, 6, 3, 1, 2, 6, 1, 0, 0, 0, 24, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 25, 4, 1, 2, 3, 6, 2, 1, 5, 1, 6, 0, 0, 0, 0, 26, 3, 2, 4, 2, 6, 3, 5, 2, 6, 3, 3, 0, 0, 0, 0, 27, 3, 2, 6, 1, 3, 4, 6, 6, 3, 3, 6, 0, 0, 0, 0, 28, 3, 6, 3, 3, 5, 6, 3, 2, 5, 1, 3, 0, 0, 0, 0, 29, 3, 3, 3, 3, 3, 3];
houses = [];
enemies = [];
explosions = [];
eBullets = [];
smalltimer = new GameTimer(250);
smalltimer.y = 10;
smalltimer.x = 540;
smalltimer.scaleX = (smalltimer.scaleY = 0.1);
addChild(smalltimer);
bigtimer = new GameTimer(250);
bigtimer.y = -100;
bigtimer.x = 10;
bigtimer.alpha = 0.3;
addChild(bigtimer);
var _local2:usezx = new usezx();
_local2.x = 545;
_local2.y = 10;
addChild(_local2);
background = new DoublePanel();
background.x = 0;
background.y = 330;
addChild(background);
player = new PlayerPlane(this);
player.x = 300;
player.y = 150;
addChild(player);
var _local3:FloorBar = new FloorBar();
_local3.y = 350;
addChild(_local3);
lifemeter = new HealthMeter();
addChild(lifemeter);
waveMessage = new WaveMessage();
waveMessage.gotoAndStop(49);
waveMessage.x = 595;
waveMessage.y = 260;
addChild(waveMessage);
tickTimer = new Timer((1000 / 30));
tickTimer.addEventListener(TimerEvent.TIMER, updateChildren);
tickTimer.start();
spawnTimer = new Timer(1000);
spawnTimer.addEventListener(TimerEvent.TIMER, spawnObject);
spawnTimer.start();
eShootTimer = new Timer(1000);
eShootTimer.addEventListener(TimerEvent.TIMER, tryEShoot);
eShootTimer.start();
}
private function loop(_arg1:Event):void{
IGSSoundchannel = inGameSound.play();
IGSSoundchannel.addEventListener(Event.SOUND_COMPLETE, loop);
var _local2:SoundTransform = new SoundTransform(0.2);
IGSSoundchannel.soundTransform = _local2;
}
private function addBullet(_arg1:Enemy):void{
var _local2:EnemyBullet = new EnemyBullet();
_local2.x = _arg1.x;
_local2.y = _arg1.y;
_local2.xspeed = -10;
_local2.yspeed = 0;
eBullets.push(_local2);
addChild(_local2);
var _local3:ShotSound = new ShotSound();
var _local4:SoundChannel = _local3.play();
}
private function moveBullets():void{
var _local1:int = (eBullets.length - 1);
while (_local1 > -1) {
eBullets[_local1].move();
_local1--;
};
}
private function updateChildren(_arg1:TimerEvent):void{
var _local5:EnemyDie;
var _local6:House;
var _local7:Enemy;
player.update();
checkHouseCollision();
moveBullets();
checkBulletCollision();
checkWin();
background.move();
var _local2:int = (explosions.length - 1);
while (_local2 > -1) {
_local5 = explosions[_local2];
if (_local5.currentFrame == _local5.totalFrames){
removeChild(_local5);
explosions.splice(_local2, 1);
};
_local2--;
};
var _local3:int = (houses.length - 1);
while (_local3 > -1) {
_local6 = houses[_local3];
_local6.move();
if (_local6.x < -50){
removeChild(_local6);
houses.splice(_local3, 1);
};
_local3--;
};
var _local4:int = (enemies.length - 1);
while (_local4 > -1) {
_local7 = enemies[_local4];
_local7.move();
if (_local7.x < -50){
removeChild(_local7);
enemies.splice(_local4, 1);
};
_local4--;
};
}
private function checkBulletCollision():void{
var _local2:int;
var _local3:Enemy;
var _local4:Boolean;
var _local5:int;
var _local6:int;
var _local7:Bullet;
var _local8:Bomb;
var _local9:Bullet;
var _local1:int = (enemies.length - 1);
while (_local1 > -1) {
_local3 = enemies[_local1];
_local4 = false;
_local5 = (player.bullets.length - 1);
while (_local5 > -1) {
_local7 = player.bullets[_local5];
if (_local7.hitTestObject(_local3)){
_local3.getHit(_local7);
removeChild(_local7);
player.bullets.splice(_local5, 1);
};
_local5--;
};
_local6 = (player.bombs.length - 1);
while (_local6 > -1) {
_local8 = player.bombs[_local2];
if (_local8.hitTestObject(_local3)){
_local3.getHit(_local8);
removeChild(_local8);
player.bombs.splice(_local2, 1);
};
_local6--;
};
if (((((_local3.hitTestObject(player.hitBox)) && ((player.currentFrame == 1)))) && (!(_local4)))){
_local4 = true;
lifemeter.nextFrame();
player.play();
_local3.playerHit();
};
if (_local3.getDie()){
explosions.push(_local3.explosion);
scoreBox.updateScore(_local3.worth);
removeChild(_local3);
enemies.splice(_local1, 1);
};
_local1--;
};
_local2 = (eBullets.length - 1);
while (_local2 > -1) {
_local9 = eBullets[_local2];
if (((_local9.hitTestObject(player.hitBox)) && ((player.currentFrame == 1)))){
removeChild(_local9);
eBullets.splice(_local2, 1);
lifemeter.nextFrame();
player.play();
};
_local2--;
};
}
private function checkWin():void{
var _local1:EnemyDie;
var _local2:ShotSound;
var _local3:SoundChannel;
var _local4:ColorTransform;
if (lifemeter.currentFrame == 6){
spawnTimer.removeEventListener(TimerEvent.TIMER, spawnObject);
eShootTimer.removeEventListener(TimerEvent.TIMER, tryEShoot);
if (!exploded){
exploded = true;
_local1 = new EnemyDie();
_local1.x = player.x;
_local1.y = player.y;
_local1.scaleX = (_local1.scaleY = 1.3);
_local2 = new ShotSound();
_local3 = _local2.play();
player.alpha = 0.01;
player.dead = true;
addChild(_local1);
_local4 = _local1.transform.colorTransform;
_local4.color = 0;
_local1.transform.colorTransform = _local4;
};
this.alpha = (this.alpha - 0.01);
if (this.alpha < 0.05){
tickTimer.removeEventListener(TimerEvent.TIMER, updateChildren);
dispatchEvent(new NavigationEvent(NavigationEvent.LOSE));
};
};
if (bigtimer.getComplete()){
spawnTimer.removeEventListener(TimerEvent.TIMER, spawnObject);
eShootTimer.removeEventListener(TimerEvent.TIMER, tryEShoot);
this.alpha = (this.alpha - 0.01);
if (this.alpha < 0.05){
tickTimer.removeEventListener(TimerEvent.TIMER, updateChildren);
dispatchEvent(new NavigationEvent(NavigationEvent.WIN));
};
};
}
private function spawnObject(_arg1:TimerEvent):void{
var _local2:*;
var _local3:int = int(ObjectSpawnList.shift());
if (_local3 == 1){
_local2 = new EnemyPlane(this);
enemies.push(_local2);
addChild(_local2);
} else {
if (_local3 == 2){
_local2 = new EnemyBalloon(this);
enemies.push(_local2);
addChild(_local2);
} else {
if (_local3 == 3){
_local2 = new EnemyCopter(this);
enemies.push(_local2);
addChild(_local2);
} else {
if (_local3 == 4){
_local2 = new House1();
houses.push(_local2);
addChild(_local2);
} else {
if (_local3 == 5){
_local2 = new House2();
houses.push(_local2);
addChild(_local2);
} else {
if (_local3 == 6){
_local2 = new House3();
houses.push(_local2);
addChild(_local2);
};
};
};
};
};
};
if (_local3 > 10){
waveMessage.changeText((_local3 - 10));
};
}
}
}//package
Section 51
//PreLoader (PreLoader)
package {
import flash.display.*;
public dynamic class PreLoader extends MovieClip {
public var loaderBar:MovieClip;
}
}//package
Section 52
//Score (Score)
package {
import flash.display.*;
import flash.geom.*;
import flash.text.*;
public class Score extends Sprite {
public var score:int;
public var ScoreText:TextField;
public function Score(){
ScoreText.text = "0";
}
public function updateScore(_arg1:int):void{
var _local2:ColorTransform = this.transform.colorTransform;
_local2.color = (Math.random() * 268435455);
this.transform.colorTransform = _local2;
score = (score + _arg1);
ScoreText.text = score.toString();
}
public function getScore():int{
return (score);
}
}
}//package
Section 53
//ShotSound (ShotSound)
package {
import flash.media.*;
public dynamic class ShotSound extends Sound {
}
}//package
Section 54
//SkyscraperMask (SkyscraperMask)
package {
import flash.display.*;
public dynamic class SkyscraperMask extends MovieClip {
}
}//package
Section 55
//Smoke (Smoke)
package {
import flash.display.*;
import flash.events.*;
public class Smoke extends Sprite {
private var thisParent:Sprite;
public function Smoke(){
addEventListener(Event.ENTER_FRAME, fadeOut);
}
private function fadeOut(_arg1:Event):void{
this.alpha = (this.alpha - 0.05);
this.scaleX = (this.scaleX * 0.7);
this.scaleY = (this.scaleY * 0.7);
this.x = (this.x - 5);
}
}
}//package
Section 56
//SmokePoint (SmokePoint)
package {
import flash.display.*;
public dynamic class SmokePoint extends MovieClip {
}
}//package
Section 57
//Splat (Splat)
package {
import flash.display.*;
public class Splat extends MovieClip {
public function move():void{
this.x = (this.x - 4);
this.scaleX = (this.scaleY = 0.8);
}
}
}//package
Section 58
//SplatterSound (SplatterSound)
package {
import flash.media.*;
public dynamic class SplatterSound extends Sound {
}
}//package
Section 59
//TheEndScore (TheEndScore)
package {
import flash.display.*;
import flash.text.*;
public dynamic class TheEndScore extends MovieClip {
public var EndScore:TextField;
}
}//package
Section 60
//usezx (usezx)
package {
import flash.display.*;
public dynamic class usezx extends MovieClip {
}
}//package
Section 61
//WaveMessage (WaveMessage)
package {
import flash.display.*;
import flash.text.*;
public class WaveMessage extends MovieClip {
public var waveText:TextField;
public var theText:MovieClip;
public function WaveMessage(){
addFrameScript(14, frame15, 48, frame49);
}
function frame15(){
}
function frame49(){
stop();
}
public function changeText(_arg1:int):void{
if (_arg1 == 1){
theText.waveText.text = "Your Very First Home.";
} else {
if (_arg1 == 2){
theText.waveText.text = "You're just getting started.";
} else {
if (_arg1 == 3){
theText.waveText.text = "Three's a lady.";
} else {
if (_arg1 == 4){
theText.waveText.text = "Only 16 more waves to go!";
} else {
if (_arg1 == 5){
theText.waveText.text = "A new enemy!";
} else {
if (_arg1 == 6){
theText.waveText.text = "Getting the swing of things.";
} else {
if (_arg1 == 7){
theText.waveText.text = "I think you've got it!";
} else {
if (_arg1 == 8){
theText.waveText.text = "Nice colouring there.";
} else {
if (_arg1 == 9){
theText.waveText.text = "You're getting worse.";
} else {
if (_arg1 == 10){
theText.waveText.text = "Or maybe it's getting harder?";
} else {
if (_arg1 == 11){
theText.waveText.text = "That definitly made it harder.";
} else {
if (_arg1 == 12){
theText.waveText.text = "You're colouring like a 5 year old!";
} else {
if (_arg1 == 13){
theText.waveText.text = "More than half way now!";
} else {
if (_arg1 == 14){
theText.waveText.text = "Fly pretty birdy.";
} else {
if (_arg1 == 15){
theText.waveText.text = "Incoming wave! FIRE!";
} else {
if (_arg1 == 16){
theText.waveText.text = "Closing to the final quarter";
} else {
if (_arg1 == 17){
theText.waveText.text = "The last few waves are the hardest.";
} else {
if (_arg1 == 18){
theText.waveText.text = "PARTY TIME!";
} else {
if (_arg1 == 19){
theText.waveText.text = "UH NOES! LAST WAVE!";
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
gotoAndPlay(1);
}
}
}//package
Section 62
//WinScreen (WinScreen)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.text.*;
public class WinScreen extends MovieClip {
private var beepSound:BeepSound;
public var theEndScore:MovieClip;
public var mainmenuButton:SimpleButton;
private var bSoundChannel:SoundChannel;
public var EndScore:TextField;
public function WinScreen(){
var _local2:*;
super();
addFrameScript(14, frame15);
var _local1:int = (this.numChildren - 1);
while (_local1 > -1) {
_local2 = this.getChildAt(_local1);
if ((_local2 is SimpleButton)){
_local2.addEventListener(MouseEvent.ROLL_OVER, playBeep);
};
_local1--;
};
}
private function playBeep(_arg1:MouseEvent):void{
beepSound = new BeepSound();
bSoundChannel = beepSound.play();
var _local2:SoundTransform = new SoundTransform(5);
bSoundChannel.soundTransform = _local2;
}
function frame15(){
stop();
}
public function setScore(_arg1:int):void{
theEndScore.EndScore.text = _arg1.toString();
}
}
}//package