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 DEFAULTS:Object;
var clip:Object;
var ad_timeout:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var sendHostProgress:Boolean;
var options = _arg1;
DEFAULTS = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
sendHostProgress = false;
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
_local3 = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.root == null){
_local3 = true;
};
if (_local3){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(_arg1:String):String{
var _local2:String;
_local2 = _arg1.split("/")[2].split(":")[0];
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 DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (_local2 > chk.ad_msec){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local3:Object;
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
_local3 = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _cleanup(_arg1:Object):void{
var idx:Number;
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
idx = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(_arg1:Object):MovieClip{
var DEFAULTS:Object;
var clip:Object;
var depth:Number;
var mc:MovieClip;
var wh:Array;
var lv:URLVariables;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
DEFAULTS = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
wh = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
} else {
trace("[MochiAd] NOTE: Security Sandbox Violation errors below are normal");
};
lv = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest(((server + ".swf?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");
});
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(_arg1:Object, _arg2:String, _arg3:Array):Object{
var _local4:Array;
var _local5:Number;
_local4 = _arg2.split(".");
_local5 = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
if (typeof(_arg1[_local4[_local5]]) == "function"){
return (_arg1[_local4[_local5]].apply(_arg1, _arg3));
};
return (undefined);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip;
_local4 = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local3:Object;
var _local4:Number;
var _local5:Number;
var _local6:Array;
_local3 = _arg2.getBounds(_arg2.root);
_local4 = 0;
_local5 = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function adShowing(_arg1:Object):void{
_arg1.origFrameRate = _arg1.stage.frameRate;
_arg1.stage.frameRate = 30;
}
public static function getValue(_arg1:Object, _arg2:String):Object{
var _local3:Array;
var _local4:Number;
_local3 = _arg2.split(".");
_local4 = 0;
while (_local4 < (_local3.length - 1)) {
if ((((_arg1[_local3[_local4]] == undefined)) || ((_arg1[_local3[_local4]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local3[_local4]];
_local4++;
};
return (_arg1[_local3[_local4]]);
}
public static function rpc(_arg1:Object, _arg2:Number, _arg3:Object):void{
var _local4:Object;
var _local5:Object;
switch (_arg3.id){
case "setValue":
MochiAd.setValue(_arg1, _arg3.objectName, _arg3.value);
break;
case "getValue":
_local4 = MochiAd.getValue(_arg1, _arg3.objectName);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(_arg1, _arg3.method, _arg3.args);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + _arg3.id));
};
}
public static function setValue(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Array;
var _local5:Number;
_local4 = _arg2.split(".");
_local5 = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return;
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
_arg1[_local4[_local5]] = _arg3;
}
public static function showPreGameAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var bar:MovieClip;
var bar_w:Number;
var bar_color:Number;
var bar_background:Number;
var bar_outline:Number;
var backing_mc:MovieClip;
var backing:Object;
var inside_mc:MovieClip;
var inside:Object;
var outline_mc:MovieClip;
var outline:Object;
var complete:Boolean;
var unloaded:Boolean;
var progress:Number;
var f:Function;
var sendHostProgress:Boolean;
var fn:Function;
var r:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (_arg1:Number):void{
}, 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;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
var fn:Function;
MochiAd._cleanup(mc);
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
bar = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = (10 + options.bar_offset);
bar.y = (h - 20);
};
bar_w = ((w - bar.x) - 10);
bar_color = options.color;
delete options.color;
bar_background = options.background;
delete options.background;
bar_outline = options.outline;
delete options.outline;
backing_mc = createEmptyMovieClip(bar, "_outline", 1);
backing = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo(bar_w, 0);
backing.lineTo(bar_w, 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
inside_mc = createEmptyMovieClip(bar, "_inside", 2);
inside = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo(bar_w, 0);
inside.lineTo(bar_w, 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
outline_mc = createEmptyMovieClip(bar, "_outline", 3);
outline = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo(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;
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
progress = Math.min(1, options.progress_override(clip));
f = 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;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
mc.rpcTestFn = function (_arg1:String):Object{
trace(("[MOCHIAD rpcTestFn] " + _arg1));
return (_arg1);
};
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (_arg1:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Object;
var _local3:Number;
var _local4:Boolean;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Object;
var _local11:Number;
var _local12:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
_local1 = this.parent.parent.root;
_local2 = this.parent._mochiad_ctr;
_local3 = (getTimer() - this.started);
_local4 = false;
_local5 = _local1.loaderInfo.bytesTotal;
_local6 = _local1.loaderInfo.bytesLoaded;
_local7 = Math.min(1, options.progress_override(_local1));
if (_local7 == 1){
complete = true;
};
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
_local8 = ((100 * _local6) / _local5);
if (!isNaN(_local7)){
_local8 = (100 * _local7);
};
_local9 = ((100 * _local3) / chk.ad_msec);
_local10 = this._mochiad_bar._inside;
_local11 = 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 f:Function;
var mc = _arg1;
f = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package mochi.as3
Section 2
//MochiCoins (mochi.as3.MochiCoins)
package mochi.as3 {
public class MochiCoins {
public static const STORE_HIDE:String = "StoreHide";
public static const LOGGED_IN:String = "LoggedIn";
public static const STORE_ITEMS:String = "StoreItems";
public static const NO_USER:String = "NoUser";
public static const PROPERTIES_SIZE:String = "PropertiesSize";
public static const ITEM_NEW:String = "ItemNew";
public static const USER_INFO:String = "UserInfo";
public static const IO_ERROR:String = "IOError";
public static const ITEM_OWNED:String = "ItemOwned";
public static const PROPERTIES_SAVED:String = "PropertySaved";
public static const WIDGET_LOADED:String = "WidgetLoaded";
public static const ERROR:String = "Error";
public static const LOGGED_OUT:String = "LoggedOut";
public static const PROFILE_SHOW:String = "ProfileShow";
public static const LOGIN_HIDE:String = "LoginHide";
public static const LOGIN_SHOW:String = "LoginShow";
public static const STORE_SHOW:String = "StoreShow";
public static const PROFILE_HIDE:String = "ProfileHide";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
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 saveUserProperties(_arg1:Object):void{
MochiServices.send("coins_saveUserProperties", _arg1);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function showLoginWidget(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showLoginWidget", {options:_arg1});
}
public static function getStoreItems():void{
MochiServices.send("coins_getStoreItems");
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showStore(_arg1:Object=null):void{
MochiServices.bringToTop();
MochiServices.send("coins_showStore", {options:_arg1}, null, null);
}
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 hideLoginWidget():void{
MochiServices.send("coins_hideLoginWidget");
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
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);
}
}
}//package mochi.as3
Section 3
//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 4
//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 _local3:Object;
var _local4:Object;
_local3 = {};
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;
_local1 = (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 arguements 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;
_local1 = (new Date().time - levelStart);
trigger("end_level", {time:_local1});
}
}
}//package mochi.as3
Section 5
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
private static var _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 cb:String;
var cblst:Object;
var method:*;
var methodName:String;
var obj:Object;
var pkg = _arg1;
cb = pkg.callbackID;
cblst = _clip._callbacks[cb];
if (!cblst){
return;
};
method = cblst.callbackMethod;
methodName = "";
obj = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete _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 _local3:Array;
var _local4:int;
var _local5:Array;
var _local6:Array;
var _local7:MovieClip;
var _local8:LocalConnection;
var _local9:String;
var _local10:ByteArray;
var _local11:ByteArray;
var _local12:uint;
var _local13:uint;
var _local14:Loader;
_local3 = [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];
_local5 = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
_local6 = [0, 64, 0, 0, 0];
_local7 = new MovieClip();
_local8 = new LocalConnection();
_local9 = ((("_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);
_local10 = new ByteArray();
_local11 = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
_local12 = ((_local3.length + _local11.length) + 4);
_local13 = (_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 vars:Object;
var avm1Click:DisplayObject;
var s:String;
var i:Number;
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;
vars = 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);
s = "?";
i = 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{
var _local2:Rectangle;
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
_local2 = 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{
var _local3:Number;
_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;
};
};
};
_local3 = 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.3 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;
var _local3:String;
_local2 = _arg1.target;
_local3 = _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 _local2:Object;
var _local3:String;
var _local4:Array;
var _local5:Number;
var _local6:Array;
_local2 = {};
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, clip:_container, 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 mochiLCURL:String;
var req:URLRequest;
var complete:Function;
var clip = _arg1;
loader = new Loader();
mochiLCURL = (_servURL + _mochiLC);
req = new URLRequest(mochiLCURL);
complete = 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;
var _local4:String;
var _local5:URLRequest;
var _local6:URLVariables;
_local3 = ("_mochiservices_com_" + _arg1);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(_arg2).servURL){
_servURL = urlOptions(_arg2).servURL;
};
_local4 = (_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);
_local5 = new URLRequest(_local4);
_local6 = 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 (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var mc:MovieClip;
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
mc = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function 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 6
//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 = {};
}
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;
};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
return (_syncContainer[_arg1]);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
var _local3:String;
if (_syncContainer[_arg1] == _arg2){
return;
};
_local3 = _arg1.toString();
_syncContainer[_local3] = _arg2;
MochiServices.send("sync_propUpdate", {name:_local3, value:_arg2});
}
}
}//package mochi.as3
Section 7
//dialogPause_34 (SubmarineFighter_fla.dialogPause_34)
package SubmarineFighter_fla {
import flash.display.*;
import utils.*;
import flash.events.*;
public dynamic class dialogPause_34 extends MovieClip {
public var back:SimpleButton;
public function dialogPause_34(){
addFrameScript(0, frame1, 29, frame30, 59, frame60);
}
function frame1(){
stop();
}
function frame30(){
stop();
back.addEventListener(MouseEvent.CLICK, makePause);
}
public function makePause(_arg1:MouseEvent):void{
MySound.play(Utils.getSoundFromLibrary("click"));
gotoAndPlay("pauseOut");
}
function frame60(){
back.removeEventListener(MouseEvent.CLICK, makePause);
Game.getInstance().pauseGame(false);
gotoAndStop(1);
}
}
}//package SubmarineFighter_fla
Section 8
//gameOver_33 (SubmarineFighter_fla.gameOver_33)
package SubmarineFighter_fla {
import flash.display.*;
import flash.text.*;
public dynamic class gameOver_33 extends MovieClip {
public var txt1:TextField;
public var txt2:TextField;
public function gameOver_33(){
addFrameScript(0, frame1, 19, frame20, 39, frame40);
}
function frame1(){
stop();
txt1.selectable = false;
txt2.selectable = false;
}
function frame20(){
stop();
}
function frame40(){
gotoAndStop(1);
Game.getInstance().gotoMenu(null);
}
}
}//package SubmarineFighter_fla
Section 9
//GUI_ships_27 (SubmarineFighter_fla.GUI_ships_27)
package SubmarineFighter_fla {
import flash.display.*;
public dynamic class GUI_ships_27 extends MovieClip {
public function GUI_ships_27(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame5(){
stop();
}
function frame2(){
stop();
}
}
}//package SubmarineFighter_fla
Section 10
//MainTimeline (SubmarineFighter_fla.MainTimeline)
package SubmarineFighter_fla {
import flash.display.*;
import utils.*;
import flash.events.*;
import flash.geom.*;
import flash.text.*;
import flash.media.*;
import mochi.as3.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
import flash.filters.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip {
public const MENU_POS_X:int = 281;
public const MENU_POS_Y:Array;
public var left:SimpleButton;
public var logoT:Timer;
public var right:SimpleButton;
public var panelLeft:MovieClip;
public var menuInitOnce:Boolean;
public var title:MovieClip;
public var t:Timer;
public var panelRight:MovieClip;
public var posX:int;
public var movement:TextField;
public var mrak2Rychlost:int;
public var ponorkaMenu:ponorka;
public var back:SimpleButton;
public var vlna:MovieClip;
public var story:TextField;
public var menuSound:MovieClip;
public var space:TextField;
public var menuSelected:int;
public var sound:MovieClip;
public var toLeft:Boolean;
public var dno:MovieClip;
public var txtPage:TextField;
public var aimia:SimpleButton;
public var menu:MovieClip;
public var startGame:SimpleButton;
public var mrak1:MovieClip;
public var mrak2:MovieClip;
public var mrak3:MovieClip;
public var dialogPause:MovieClip;
public var titleInstr:SimpleButton;
public var instructions:SimpleButton;
public var currentPage:int;
public var mrak1Rychlost:int;
public var mrak3Rychlost:int;
public var txt1:TextField;
public var txt2:TextField;
public var txt3:TextField;
public var txt5:TextField;
public var txt8:TextField;
public var txt9:TextField;
public var gameInitOnce:Boolean;
public var txt6:TextField;
public var txt7:TextField;
public var txt4:TextField;
public var upgrades:TextField;
public var gameOver:MovieClip;
public var game:Game;
public var tMenu:Timer;
public var pause:MovieClip;
public function MainTimeline(){
MENU_POS_Y = [203, 246];
super();
addFrameScript(0, frame1, 2, frame3, 3, frame4, 4, frame5, 5, frame6, 6, frame7, 7, frame8, 8, frame9, 18, frame19);
}
public function keyPressedInstructions(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.LEFT){
instructionsLeft(null);
};
if (_arg1.keyCode == Keyboard.RIGHT){
instructionsRight(null);
};
if ((((_arg1.keyCode == Keyboard.SPACE)) || ((_arg1.keyCode == Keyboard.ENTER)))){
backToMenu(null);
};
}
public function switchSound(_arg1:MouseEvent):void{
if (Game._soundActive){
setSound(false);
} else {
setSound(true);
};
}
public function backToMenu(_arg1:MouseEvent):void{
back.removeEventListener(MouseEvent.CLICK, backToMenu);
left.removeEventListener(MouseEvent.CLICK, instructionsLeft);
right.removeEventListener(MouseEvent.CLICK, instructionsRight);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressedInstructions);
gotoAndStop(1, "Menu");
MySound.play(Utils.getSoundFromLibrary("click"));
}
function frame3(){
gotoAndStop(1, "Logo");
}
function frame4(){
logoT = new Timer(4000, 1);
logoT.addEventListener(TimerEvent.TIMER, gotoMenu);
logoT.start();
}
function frame5(){
title.txt1.selectable = false;
title.txt2.selectable = false;
menuSound.addEventListener(MouseEvent.CLICK, switchSound);
setSound(Game._soundActive);
menuSelected = 0;
posX = 0;
if (menuInitOnce){
menuInitOnce = false;
};
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
startGame.addEventListener(MouseEvent.CLICK, runGame);
instructions.addEventListener(MouseEvent.CLICK, gotoInstructions);
aimia.addEventListener(MouseEvent.CLICK, gotoAimia);
t = null;
t = new Timer(100);
t.addEventListener(TimerEvent.TIMER, pohybPonorka);
t.start();
updateMenu();
Game.initNeutralObjects(stage);
}
function frame6(){
stop();
titleInstr.enabled = false;
story.selectable = false;
txtPage.selectable = false;
txt1.selectable = false;
back.addEventListener(MouseEvent.CLICK, backToMenu);
left.addEventListener(MouseEvent.CLICK, instructionsLeft);
right.addEventListener(MouseEvent.CLICK, instructionsRight);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedInstructions);
currentPage = 1;
updatePage();
}
function frame7(){
movement.selectable = false;
txt2.selectable = false;
txt3.selectable = false;
space.selectable = false;
}
function frame1(){
if (Constants.DEBUG){
afterProgressBar();
} else {
MochiAd.showPreGameAd({id:"84993a1de4031cd8", res:"550x400", clip:root, ad_finished:function ():void{
afterProgressBar();
}});
};
gameInitOnce = true;
menuInitOnce = true;
stop();
}
function frame19(){
stop();
}
function frame9(){
if (gameInitOnce){
game = new Game(stage, this);
toLeft = true;
vlna.x = -40;
tMenu = new Timer(50);
tMenu.addEventListener(TimerEvent.TIMER, vlneni);
tMenu.start();
gameInitOnce = false;
};
game.setScoreTextField(panelRight.txtScore);
game.setInfoLevel1TextField(panelLeft.infoLevel1.txt);
game.newGame();
game.init();
mrak1Rychlost = ((Math.random() * 5) + 1);
mrak2Rychlost = ((Math.random() * 6) + 1);
mrak3Rychlost = ((Math.random() * 3) + 1);
panelRight.txtScoreLabel.selectable = false;
panelRight.txtScore.selectable = false;
}
function frame8(){
upgrades.selectable = false;
txt4.selectable = false;
txt5.selectable = false;
txt6.selectable = false;
txt7.selectable = false;
txt8.selectable = false;
txt9.selectable = false;
}
public function gotoInstructions(_arg1:MouseEvent):void{
exitMenu();
MySound.play(Utils.getSoundFromLibrary("click"));
gotoAndStop(1, "Instructions");
}
public function keyPressed(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.UP){
if (--menuSelected < 0){
menuSelected = (MENU_POS_Y.length - 1);
};
};
if (_arg1.keyCode == Keyboard.DOWN){
if (++menuSelected > (MENU_POS_Y.length - 1)){
menuSelected = 0;
};
};
if ((((_arg1.keyCode == Keyboard.SPACE)) || ((_arg1.keyCode == Keyboard.ENTER)))){
switch (menuSelected){
case 0:
runGame(null);
break;
case 1:
gotoInstructions(null);
break;
};
};
updateMenu();
}
public function updatePage():void{
txtPage.text = (("" + currentPage) + "/3");
gotoAndStop(currentPage);
}
public function afterProgressBar():void{
var _local1:Timer;
if (Constants.DEBUG){
_local1 = new Timer(100, 1);
_local1.addEventListener(TimerEvent.TIMER, cont);
_local1.start();
} else {
cont(null);
};
}
public function cont(_arg1:Event):void{
gotoAndPlay(3);
}
public function runGame(_arg1:MouseEvent):void{
exitMenu();
MySound.play(Utils.getSoundFromLibrary("click"));
gotoAndPlay(1, "Game");
}
public function instructionsLeft(_arg1:MouseEvent):void{
if (--currentPage < 1){
currentPage = 3;
};
updatePage();
}
public function onError(_arg1:String):void{
trace(("[GAME] Connect onError called " + _arg1));
}
public function vlneni(_arg1:Event):void{
if (toLeft){
vlna.x = (vlna.x - 2);
if (vlna.x < -70){
toLeft = false;
};
} else {
vlna.x = (vlna.x + 2);
if (vlna.x > -50){
toLeft = true;
};
};
mrak1.x = (mrak1.x + mrak1Rychlost);
if (mrak1.x > (Constants.SCR_WIDTH + mrak1.width)){
mrak1Rychlost = ((Math.random() * 5) + 1);
mrak1.x = -(mrak1.width);
};
mrak2.x = (mrak2.x + mrak2Rychlost);
if (mrak2.x > (Constants.SCR_WIDTH + mrak2.width)){
mrak2Rychlost = ((Math.random() * 6) + 1);
mrak2.x = -(mrak2.width);
};
mrak3.x = (mrak3.x + mrak3Rychlost);
if (mrak3.x > (Constants.SCR_WIDTH + mrak3.width)){
mrak3Rychlost = ((Math.random() * 3) + 1);
mrak3.x = -(mrak3.width);
};
}
public function gotoMenu(_arg1:Event):void{
gotoAndStop(1, "Menu");
}
public function instructionsRight(_arg1:MouseEvent):void{
if (++currentPage > 3){
currentPage = 1;
};
updatePage();
}
public function gotoAimia(_arg1:MouseEvent):void{
var url:String;
var request:URLRequest;
var e = _arg1;
url = "http://www.aimia.cz/index.php";
request = new URLRequest(url);
Security.allowDomain("*.aimia.cz");
try {
navigateToURL(request, "_blank");
} catch(e:Error) {
trace("Error occurred!");
};
}
public function exitMenu():void{
t.stop();
t = null;
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
Game.releaseFishes();
}
public function updateMenu():void{
if (ponorkaMenu != null){
ponorkaMenu.x = (MENU_POS_X + posX);
ponorkaMenu.y = MENU_POS_Y[menuSelected];
};
}
public function setSound(_arg1:Boolean):void{
Game._soundActive = _arg1;
MySound.soundActive = Game._soundActive;
if (Game._soundActive){
menuSound.gotoAndStop(1);
MySound.playMusic(Utils.getSoundFromLibrary("music"));
} else {
menuSound.gotoAndStop(2);
MySound.stopAllSounds();
};
}
public function pohybPonorka(_arg1:Event):void{
posX++;
if (posX > 5){
posX = 0;
};
updateMenu();
}
}
}//package SubmarineFighter_fla
Section 11
//mcInfoLevel1_25 (SubmarineFighter_fla.mcInfoLevel1_25)
package SubmarineFighter_fla {
import flash.display.*;
import flash.text.*;
public dynamic class mcInfoLevel1_25 extends MovieClip {
public var txt:TextField;
}
}//package SubmarineFighter_fla
Section 12
//menu_37 (SubmarineFighter_fla.menu_37)
package SubmarineFighter_fla {
import flash.display.*;
import flash.text.*;
public dynamic class menu_37 extends MovieClip {
public var txt:TextField;
public function menu_37(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package SubmarineFighter_fla
Section 13
//MenuPanel_24 (SubmarineFighter_fla.MenuPanel_24)
package SubmarineFighter_fla {
import flash.display.*;
public dynamic class MenuPanel_24 extends MovieClip {
public var life:MovieClip;
public var ship:MovieClip;
public var infoLevel1:MovieClip;
}
}//package SubmarineFighter_fla
Section 14
//pause_36 (SubmarineFighter_fla.pause_36)
package SubmarineFighter_fla {
import flash.display.*;
import flash.text.*;
public dynamic class pause_36 extends MovieClip {
public var txt:TextField;
public function pause_36(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package SubmarineFighter_fla
Section 15
//progressBar_26 (SubmarineFighter_fla.progressBar_26)
package SubmarineFighter_fla {
import flash.display.*;
import flash.text.*;
public dynamic class progressBar_26 extends MovieClip {
public var txtLife:TextField;
public function progressBar_26(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package SubmarineFighter_fla
Section 16
//ScorePanel_32 (SubmarineFighter_fla.ScorePanel_32)
package SubmarineFighter_fla {
import flash.display.*;
import flash.text.*;
public dynamic class ScorePanel_32 extends MovieClip {
public var txtScore:TextField;
public var txtScoreLabel:TextField;
}
}//package SubmarineFighter_fla
Section 17
//sound_11 (SubmarineFighter_fla.sound_11)
package SubmarineFighter_fla {
import flash.display.*;
public dynamic class sound_11 extends MovieClip {
public function sound_11(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package SubmarineFighter_fla
Section 18
//Title_10 (SubmarineFighter_fla.Title_10)
package SubmarineFighter_fla {
import flash.display.*;
import flash.text.*;
public dynamic class Title_10 extends MovieClip {
public var txt1:TextField;
public var txt2:TextField;
}
}//package SubmarineFighter_fla
Section 19
//Array2 (utils.Array2)
package utils {
public class Array2 {
private var _array:Array;
private var _actualSize:int;
public function Array2(_arg1:int){
var _local2:int;
super();
_array = new Array(_arg1);
_local2 = 0;
while (_local2 < _arg1) {
_array[_local2] = null;
_local2++;
};
_actualSize = 0;
}
public function remove(_arg1:Object):void{
var _local2:int;
_local2 = 0;
while (_local2 < _array.length) {
if (_array[_local2] == _arg1){
_array[_local2] = null;
_actualSize--;
return;
};
_local2++;
};
}
public function isSlotEmpty(_arg1:int):Boolean{
if (_array[_arg1] == null){
return (true);
};
return (false);
}
public function get length():int{
return (_array.length);
}
public function pushAt(_arg1:int, _arg2:Object):void{
if (_array[_arg1] == null){
_array[_arg1] = _arg2;
_actualSize++;
};
}
public function get actualSize():int{
return (_actualSize);
}
public function getObject(_arg1:int):Object{
return (_array[_arg1]);
}
public function push(_arg1:Object):void{
var _local2:int;
_local2 = 0;
while (_local2 < _array.length) {
if (_array[_local2] == null){
_array[_local2] = _arg1;
_actualSize++;
return;
};
_local2++;
};
}
public function isFreeSlot():Boolean{
if (_actualSize < _array.length){
return (true);
};
return (false);
}
public function contains(_arg1:Object):Boolean{
var _local2:int;
_local2 = 0;
while (_local2 < _array.length) {
if (_array[_local2] == _arg1){
return (true);
};
_local2++;
};
return (false);
}
}
}//package utils
Section 20
//Cursor (utils.Cursor)
package utils {
import flash.display.*;
import flash.events.*;
import flash.ui.*;
public class Cursor extends MovieClip {
private var _dontShowCursor:Boolean;
private var hideCursorCalledOnce:Boolean;// = false
private static var _root:DisplayObjectContainer;
private static var _instance:Cursor;
private static var _cursor:DisplayObject;
private static var _cursorBeforeOutVisibility:Boolean;
public function Cursor(){
hideCursorCalledOnce = false;
super();
_instance = this;
_dontShowCursor = false;
}
public function activate():void{
_root.addEventListener(MouseEvent.MOUSE_MOVE, setPosition);
_cursorBeforeOutVisibility = true;
}
public function hideCursor(_arg1:Event):void{
if (!hideCursorCalledOnce){
hideCursorCalledOnce = true;
Mouse.hide();
_cursorBeforeOutVisibility = _cursor.visible;
_cursor.visible = false;
};
}
public function set dontShowCursor(_arg1:Boolean):void{
_dontShowCursor = _arg1;
}
public function setCursor(_arg1:DisplayObjectContainer, _arg2:DisplayObject):void{
_cursor = null;
_root = _arg1;
_cursor = _arg2;
}
public function deactivate():void{
Mouse.show();
setPosition(null);
_root.removeEventListener(MouseEvent.MOUSE_MOVE, setPosition);
}
public function setPosition(_arg1:MouseEvent):void{
if (_dontShowCursor){
return;
};
hideCursorCalledOnce = false;
_cursor.visible = _cursorBeforeOutVisibility;
if (((!((_cursor == null))) && (_cursor.visible))){
allowCursor(true);
_cursor.x = _arg1.stageX;
_cursor.y = _arg1.stageY;
};
}
public function gotoTop():void{
if (_dontShowCursor){
return;
};
if (_root.contains(this)){
_root.removeChild(this);
};
if (_cursor != null){
_root.addChild(_cursor);
};
}
public function allowCursor(_arg1:Boolean):void{
_cursor.visible = _arg1;
_cursorBeforeOutVisibility = _arg1;
if (_arg1){
gotoTop();
};
}
public static function getInstance():Cursor{
if (_instance == null){
_instance = new (Cursor);
};
return (_instance);
}
}
}//package utils
Section 21
//MySound (utils.MySound)
package utils {
import flash.media.*;
public class MySound {
private static var _music:Sound;
private static var _musicPlaying:int;
private static var _soundActive:Boolean;
private static var _volume:Number = 1;
public function MySound(){
_soundActive = true;
}
public static function stopAllSounds():void{
SoundMixer.stopAll();
_music = null;
}
public static function set soundActive(_arg1:Boolean):void{
_soundActive = _arg1;
}
public static function playMusic(_arg1:Sound):void{
var _local2:SoundChannel;
var _local3:SoundTransform;
if (_music != null){
return;
};
_music = _arg1;
if (!_soundActive){
return;
};
_local2 = _arg1.play(0, int.MAX_VALUE);
_local3 = _local2.soundTransform;
_local3.volume = (_volume / 4);
_local2.soundTransform = _local3;
}
public static function set volume(_arg1:Number):void{
_volume = _arg1;
}
public static function get volume():Number{
return (_volume);
}
public static function play(_arg1:Sound):void{
var _local2:SoundChannel;
var _local3:SoundTransform;
if (!_soundActive){
return;
};
_local2 = _arg1.play();
_local3 = _local2.soundTransform;
_local3.volume = _volume;
_local3.pan = -1;
_local3.leftToLeft = 1;
_local3.leftToRight = 1;
_local3.rightToRight = 1;
_local3.rightToLeft = 1;
_local2.soundTransform = _local3;
}
}
}//package utils
Section 22
//RandomMove (utils.RandomMove)
package utils {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
public class RandomMove {
private var _direction:Point;
private var _rect:Rectangle;
private var _position:Point;
private var _loop:int;
private var _flip:Boolean;
private var _timer:Timer;
private var _speed:int;
private var _object:DisplayObject;
private var _targetPosition:Point;
private var _counter:int;
public function RandomMove(_arg1:int, _arg2:Rectangle, _arg3:int, _arg4:DisplayObject, _arg5:Boolean){
_speed = _arg1;
_loop = _arg3;
if (_loop < 0){
_loop = 0;
};
_rect = _arg2;
_object = _arg4;
_direction = new Point();
_targetPosition = new Point();
_flip = _arg5;
}
private function update(_arg1:Event):void{
if (--_counter <= 0){
start();
};
_position = _position.add(_direction);
_object.x = _position.x;
_object.y = _position.y;
}
public function start():void{
init();
_object.x = _position.x;
_object.y = _position.y;
_timer = new Timer(_speed, _loop);
_timer.addEventListener(TimerEvent.TIMER, update);
_timer.start();
}
public function init():void{
var _local1:Number;
if (_position == null){
_position = new Point();
_position.x = (_rect.x + (Math.random() * _rect.width));
_position.y = (_rect.y + (Math.random() * _rect.height));
} else {
_timer.removeEventListener(TimerEvent.TIMER, update);
};
_targetPosition.x = (_rect.x + (Math.random() * _rect.width));
_targetPosition.y = (_rect.y + (Math.random() * _rect.height));
_local1 = Point.distance(_position, _targetPosition);
_direction.x = ((_targetPosition.x - _position.x) / _local1);
_direction.y = ((_targetPosition.y - _position.y) / _local1);
_counter = _local1;
if (_flip){
if (_position.x < _targetPosition.x){
_object.scaleX = -1;
} else {
_object.scaleX = 1;
};
};
}
public function get object():DisplayObject{
return (_object);
}
}
}//package utils
Section 23
//bomb (bomb)
package {
import flash.display.*;
public dynamic class bomb extends MovieClip {
public function bomb(){
addFrameScript(19, frame20, 35, frame36);
}
function frame20(){
gotoAndPlay(1);
}
function frame36(){
stop();
if (parent.contains(this)){
parent.removeChild(this);
};
}
}
}//package
Section 24
//bomba1 (bomba1)
package {
import flash.display.*;
public dynamic class bomba1 extends MovieClip {
public function bomba1(){
addFrameScript(23, frame24, 39, frame40);
}
function frame24(){
gotoAndPlay(1);
}
function frame40(){
stop();
if (parent.contains(this)){
parent.removeChild(this);
};
}
}
}//package
Section 25
//bomber (bomber)
package {
import flash.display.*;
public dynamic class bomber extends MovieClip {
}
}//package
Section 26
//bonus (bonus)
package {
import flash.media.*;
public dynamic class bonus extends Sound {
}
}//package
Section 27
//Bonus (Bonus)
package {
import flash.display.*;
import utils.*;
import flash.geom.*;
public class Bonus {
private var _bonus:GameObject;
private var _elapsedTime:int;
private var _living:int;
private var _doc:DisplayObjectContainer;
private var _player:Player;
private var _type:int;
public function Bonus(_arg1:DisplayObjectContainer, _arg2:Player){
_doc = _arg1;
_player = _arg2;
reset();
}
public function update(_arg1:int):void{
var _local2:int;
var _local3:int;
var _local4:MovieClip;
_elapsedTime = (_elapsedTime + _arg1);
if (_bonus != null){
_living = (_living + _arg1);
if (_living >= Constants.BONUS_LIVING){
kill();
return;
};
_bonus.update(_arg1);
if (_bonus.object.hitTestObject(_player.object)){
_player.addBonus(_type);
MySound.play(Utils.getSoundFromLibrary("bonus"));
kill();
};
return;
};
if (_elapsedTime >= Constants.BONUS_INTERVAL[Game._level]){
_local2 = (Math.random() * 100);
_type = -1;
_local3 = 0;
while (_local3 < Constants.BONUS_PROBABILITY.length) {
if (_local2 < Constants.BONUS_PROBABILITY[_local3]){
_type = _local3;
break;
};
_local3++;
};
_local4 = null;
_type = correctBonus(_type);
_local4 = Utils.getMovieClipFromLibrary(Constants.BONUS_LIBRARY_NAMES[_type]);
if (_local4 != null){
_bonus = new GameObject(_doc, _local4, (Constants.BONUS_CLIP_RECT[0] + (Math.random() * Constants.BONUS_CLIP_RECT[2])), (Constants.BONUS_CLIP_RECT[1] + (Math.random() * Constants.BONUS_CLIP_RECT[3])));
_bonus.clipRect = new Rectangle(Constants.BONUS_CLIP_RECT[0], Constants.BONUS_CLIP_RECT[1], Constants.BONUS_CLIP_RECT[2], Constants.BONUS_CLIP_RECT[3]);
};
};
}
private function correctBonus(_arg1:int):int{
switch (_arg1){
case Constants.BONUS_LIFE:
if (_player._life >= Player._armor){
_arg1 = Constants.BONUS_POINTS;
};
break;
case Constants.BONUS_ARMOR:
if (Player._armor >= Constants.PLAYER_MAX_ARMOR[Game._level]){
_arg1 = Constants.BONUS_POINTS;
};
break;
case Constants.BONUS_SPEED:
if (Player._speed >= Constants.PLAYER_MAX_SPEED[Game._level]){
_arg1 = Constants.BONUS_POINTS;
};
break;
case Constants.BONUS_ROCKET:
if (Player._rocket >= Constants.PLAYER_MAX_ROCKET[Game._level]){
_arg1 = Constants.BONUS_POINTS;
};
break;
default:
_arg1 = Constants.BONUS_POINTS;
};
return (_arg1);
}
private function reset():void{
_elapsedTime = 0;
_living = 0;
}
public function hit():void{
if (_bonus != null){
_bonus.object.gotoAndPlay("hit");
};
}
public function kill():void{
reset();
if (_bonus != null){
_bonus.release();
};
_bonus = null;
}
}
}//package
Section 28
//bonus_armor (bonus_armor)
package {
import flash.display.*;
public dynamic class bonus_armor extends MovieClip {
}
}//package
Section 29
//bonus_life (bonus_life)
package {
import flash.display.*;
public dynamic class bonus_life extends MovieClip {
}
}//package
Section 30
//bonus_points (bonus_points)
package {
import flash.display.*;
import flash.text.*;
public dynamic class bonus_points extends MovieClip {
public var txt:TextField;
}
}//package
Section 31
//bonus_rocket (bonus_rocket)
package {
import flash.display.*;
public dynamic class bonus_rocket extends MovieClip {
}
}//package
Section 32
//bonus_speed (bonus_speed)
package {
import flash.display.*;
public dynamic class bonus_speed extends MovieClip {
}
}//package
Section 33
//boss (boss)
package {
import flash.display.*;
public dynamic class boss extends MovieClip {
public function boss(){
addFrameScript(0, frame1, 32, frame33);
}
function frame1(){
stop();
}
function frame33(){
parent.removeChild(this);
}
}
}//package
Section 34
//btnOK (btnOK)
package {
import flash.display.*;
public dynamic class btnOK extends SimpleButton {
}
}//package
Section 35
//bublina (bublina)
package {
import flash.display.*;
public dynamic class bublina extends MovieClip {
public function bublina(){
addFrameScript(16, frame17);
}
function frame17(){
if (parent != null){
parent.removeChild(this);
};
}
}
}//package
Section 36
//Bullet (Bullet)
package {
import flash.display.*;
import flash.geom.*;
public class Bullet extends GameObject {
private var _direction:Point;
private var _collisionObject:Array;
public function Bullet(_arg1:DisplayObjectContainer, _arg2:MovieClip, _arg3:int, _arg4:int, _arg5:Point):void{
super(_arg1, _arg2, _arg3, _arg4);
_direction = _arg5;
_arg1.addChild(object);
}
private function removeBullet():void{
}
override public function update(_arg1:int):void{
var _local2:DisplayObject;
var _local3:String;
object.x = (object.x + _direction.x);
object.y = (object.y + _direction.y);
for (_local3 in _collisionObject) {
_local2 = (_collisionObject[_local3] as DisplayObject);
if (object.hitTestObject(_local2)){
};
};
}
public function toString():String{
return (((((((("obj=" + object) + ", pos x=") + object.x) + ", y=") + object.y) + ", direction=") + _direction));
}
override public function release():void{
if (_doc.contains(object)){
_doc.removeChild(object);
};
}
private function addCollisionObject(_arg1:DisplayObject):void{
if (_collisionObject == null){
_collisionObject = new Array();
};
if (_arg1 != null){
_collisionObject.push(_arg1);
};
}
public function hit():void{
object.gotoAndPlay("hit");
}
}
}//package
Section 37
//click (click)
package {
import flash.media.*;
public dynamic class click extends Sound {
}
}//package
Section 38
//Constants (Constants)
package {
public class Constants {
public static const SCR_HEIGHT:int = 400;
public static const BONUS_INTERVAL:Array = [5000, 5000, 5000, 5000, 5000];
public static const PLAYER_MAX_ARMOR:Array = [4, 5, 7, 9, 10];
public static const DIALOG_LEVEL_COMPLETE:int = 1;
public static const BOSS_LIFE:int = 100;
public static const SHIP_TORPEDOBOREC:int = 1;
public static const SHIP_BOSS:int = 5;
public static const LEVEL_NUM:int = 5;
public static const BONUS_ROCKET:int = 1;
public static const PLAYER_MAX_SPEED:Array = [3, 3, 4, 4, 5];
public static const SHIP_CRUISER:int = 2;
public static const SHIP_SUBMARINE:int = 3;
public static const FIRE_DELAY:int = 1000;
public static const BONUS_POINTS:int = 4;
public static const DIALOG_LEVEL1:int = 3;
public static const DIALOG_LEVEL2:int = 4;
public static const DIALOG_LEVEL4:int = 6;
public static const SCR_WIDTH:int = 550;
public static const DIALOG_DEFAULT:int = 0;
public static const BOSS_FIRE_DELAY:int = 450;
public static const DIALOG_LEVEL3:int = 5;
public static const DIALOG_GAME_COMPLETE:int = 2;
public static const SHIP_BOMBER:int = 4;
public static const BONUS_POINTS_VALUE:int = 100;
public static const BONUS_LIFE:int = 0;
public static const LEVEL_DATA:Array = [[5, 30, 100, 0, 0, 0], [6, 0, 40, 100, 0, 0], [8, 0, 20, 60, 100, 0], [10, 0, 10, 40, 80, 100, 0], [1, 0, 0, 0, 0, 0, 100]];
public static const BONUS_LIBRARY_NAMES:Array = ["bonus_life", "bonus_rocket", "bonus_speed", "bonus_armor", "bonus_points"];
public static const SCORE_LIST:Array = [10, 25, 30, 50, 0, 20];
public static const PLAYER_MAX_ROCKET:Array = [2, 3, 4, 5, 6];
public static const LEVEL_LIMITS:Array = [15, 15, 25, 60, BOSS_LIFE];
public static const BONUS_PROBABILITY:Array = [40, 60, 80, 100, 100];
public static const FISH_LIBRARY_NAMES:Array = ["ryba", "ryba2", "zralok_anim"];
public static const BONUS_ARMOR:int = 3;
public static const BONUS_CLIP_RECT:Array = [30, 88, 520, 290];
public static const MAX_FISHES:int = 8;
public static const SHIP_DANGEROUS:Array = [40, 45, 50, 60, 65];
public static const BONUS_LIVING:int = 10000;
public static const BONUS_SPEED:int = 2;
public static const SHIP_TRANSPORTER:int = 0;
public static const LEVEL_DATA_MAXMINES:Array = [5, 15, 20, 25, 25];
public static var DEBUG:Boolean = false;
}
}//package
Section 39
//cruiser (cruiser)
package {
import flash.display.*;
public dynamic class cruiser extends MovieClip {
public function cruiser(){
addFrameScript(0, frame1, 21, frame22);
}
function frame1(){
stop();
}
function frame22(){
if (((!((parent == null))) && (parent.contains(this)))){
parent.removeChild(this);
};
}
}
}//package
Section 40
//cursor (cursor)
package {
import flash.display.*;
public dynamic class cursor extends MovieClip {
}
}//package
Section 41
//dialog (dialog)
package {
import flash.display.*;
import flash.text.*;
public dynamic class dialog extends MovieClip {
public var ok:btnOK;
public var txt:TextField;
public var txtTitle:TextField;
}
}//package
Section 42
//dialogYesNo (dialogYesNo)
package {
import flash.display.*;
import flash.text.*;
public dynamic class dialogYesNo extends MovieClip {
public var txt:TextField;
public var no:SimpleButton;
public var txtTitle:TextField;
public var yes:SimpleButton;
}
}//package
Section 43
//Game (Game)
package {
import flash.display.*;
import utils.*;
import flash.events.*;
import flash.geom.*;
import flash.text.*;
import flash.utils.*;
import flash.ui.*;
public class Game {
private var _pausedByPlayer:Boolean;
private var _mines:Array2;
private var _ponorka:Player;
private var _sound:MovieClip;
public var _dialogBtnOK:SimpleButton;
private var _isLevelComplete:Boolean;
public var _dialogBtnNo:SimpleButton;
private var _showDialogCounter:int;
public var _dialogYesNoSelected:int;
private var _pauseDialog:MovieClip;
private var _bonus:Bonus;
public var _dialogBtnYes:SimpleButton;
private var _levelLimit:int;
private var _ships:Array2;
private var _menu:MovieClip;
public var _dialogType:int;
private var _gotoMenu:Boolean;
private var _infoLevel1TextField:TextField;
public var _dialogYesNo:MovieClip;
public var _dialog:MovieClip;
private var _last:uint;
private var _pause:MovieClip;
private var _doc:DisplayObjectContainer;
private var mcDialog:MovieClip;
private var _stage:Stage;
private static var _scoreTextField:TextField;
public static var _level:int;
private static var _fishes:Array;
public static var _paused:Boolean;
public static var _score:int = 0;
public static var _instance:Game;
public static var _soundActive:Boolean = true;
public function Game(_arg1:Stage, _arg2:DisplayObjectContainer){
_last = getTimer();
super();
_instance = this;
_stage = _arg1;
_doc = _arg2;
}
public function release():void{
_ponorka.release();
_ponorka = null;
releaseArray2(_ships);
releaseArray2(_mines);
releaseFishes();
if (_bonus != null){
_bonus.kill();
};
_stage.removeEventListener(Event.ENTER_FRAME, update);
_stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
_stage.removeEventListener(KeyboardEvent.KEY_UP, keyReleased);
}
public function init():void{
_showDialogCounter = 0;
_gotoMenu = false;
_isLevelComplete = false;
_ponorka = new Player(_doc, Utils.getMovieClipFromLibrary("ponorka"), 100, 100);
_stage.addEventListener(Event.ENTER_FRAME, update);
_stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
_stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
_sound = Utils.getSubClip(_doc, "sound");
_sound.addEventListener(MouseEvent.CLICK, switchSound);
setSound(Game._soundActive);
_pause = Utils.getSubClip(_doc, "pause");
Utils.noSelectableTextField(_pause, "txt");
_pause.addEventListener(MouseEvent.CLICK, pauseByPlayer);
_menu = Utils.getSubClip(_doc, "menu");
Utils.noSelectableTextField(_menu, "txt");
_menu.addEventListener(MouseEvent.CLICK, backToMenu);
_pauseDialog = Utils.getSubClip(_doc, "dialogPause");
initLevel();
}
public function addMine(_arg1:int, _arg2:int):void{
var _local3:MovieClip;
var _local4:Bullet;
if (_mines.isFreeSlot()){
_local3 = Utils.getMovieClipFromLibrary("bomba1");
_local4 = new Bullet(_doc, _local3, _arg1, _arg2, new Point(0, 2));
_local4.clipRect = new Rectangle(0, 0, Constants.SCR_WIDTH, Constants.SCR_HEIGHT);
_mines.push(_local4);
MySound.play(Utils.getSoundFromLibrary("water"));
};
}
private function updateLevelInfo():void{
_infoLevel1TextField.text = ("x " + _levelLimit);
}
public function setScoreTextField(_arg1:TextField):void{
_scoreTextField = _arg1;
}
public function showDialog(_arg1:int, _arg2:String, _arg3:String):void{
if (_dialog == null){
_dialog = Utils.getMovieClipFromLibrary("dialog");
_dialog.x = (Constants.SCR_WIDTH >> 1);
_dialog.y = (Constants.SCR_HEIGHT >> 1);
_dialogBtnOK = Utils.getButton(_dialog, "ok");
if (_showDialogCounter > 0){
_dialogBtnOK.visible = false;
};
_dialogBtnOK.addEventListener(MouseEvent.CLICK, hideDialog);
};
_dialog.visible = true;
_doc.addChild(_dialog);
Utils.setTextField(_dialog, "txt", _arg3);
Utils.setTextField(_dialog, "txtTitle", _arg2);
_dialogType = _arg1;
}
public function pauseGame(_arg1:Boolean):void{
_paused = _arg1;
if (_paused == false){
_last = getTimer();
_stage.focus = _doc;
_pause.enabled = true;
_pause.addEventListener(MouseEvent.CLICK, pauseByPlayer);
_sound.enabled = true;
_sound.addEventListener(MouseEvent.CLICK, switchSound);
} else {
if (_pause != null){
_pause.enabled = false;
_pause.removeEventListener(MouseEvent.CLICK, pauseByPlayer);
};
if (_sound != null){
_pause.enabled = false;
_sound.removeEventListener(MouseEvent.CLICK, switchSound);
};
};
}
public function gameOverIn():void{
var _local1:Timer;
mcDialog = Utils.getSubClip(_doc, "gameOver");
_doc.removeChild(mcDialog);
_doc.addChild(mcDialog);
mcDialog.gotoAndPlay("gameOverIn");
_local1 = new Timer(4000, 1);
_local1.addEventListener(TimerEvent.TIMER, gameOverOut);
_local1.start();
}
private function pauseByPlayer(_arg1:MouseEvent):void{
MySound.play(Utils.getSoundFromLibrary("click"));
pauseGame(true);
_doc.removeChild(_pauseDialog);
_doc.addChild(_pauseDialog);
_pauseDialog.gotoAndPlay("pauseIn");
}
public function hideDialog(_arg1:MouseEvent):void{
if (_dialog != null){
MySound.play(Utils.getSoundFromLibrary("click"));
if (_doc.contains(_dialog)){
_doc.removeChild(_dialog);
};
_dialog.visible = false;
_dialogBtnOK.removeEventListener(MouseEvent.CLICK, hideDialog);
};
_dialog = null;
switch (_dialogType){
case Constants.DIALOG_GAME_COMPLETE:
gotoMenu(null);
break;
case Constants.DIALOG_LEVEL_COMPLETE:
nextLevel();
break;
default:
pauseGame(false);
};
}
private function gameOverOut(_arg1:Event):void{
mcDialog.gotoAndPlay("gameOverOut");
}
public function updateMines(_arg1:int):void{
var _local2:Bullet;
var _local3:int;
while (_local3 < _mines.length) {
_local2 = (_mines.getObject(_local3) as Bullet);
if (_local2 == null){
} else {
_local2.update(_arg1);
if (!_local2.isInClipRect()){
_mines.remove(_local2);
_local2.removeChild();
};
if (_ponorka.object.hitTestPoint(_local2.object.x, _local2.object.y)){
_ponorka.hit();
if (!_ponorka.isAlive()){
gameOver();
};
_local2.hit();
_mines.remove(_local2);
};
};
_local3++;
};
}
public function newGame():void{
_level = 0;
_score = 0;
_dialogYesNoSelected = 0;
Player.initPlayerAttributes();
}
public function testBulletsCollision(_arg1:Array2, _arg2:Ship):void{
var _local3:Bullet;
var _local4:int;
_local4 = 0;
while (_local4 < _arg1.length) {
_local3 = (_arg1.getObject(_local4) as Bullet);
if (_local3 == null){
} else {
if (((((_arg2.isAlive()) && (!((_arg2.type == Constants.SHIP_BOMBER))))) && (_arg2.object.hitTestPoint(_local3.object.x, _local3.object.y)))){
_arg2.hit();
if ((((_arg2.type == Constants.SHIP_TRANSPORTER)) && ((_level == 0)))){
if (!_arg2.isAlive()){
decreaseLimit();
};
};
if ((((_arg2.type == Constants.SHIP_CRUISER)) && ((_level == 1)))){
if (!_arg2.isAlive()){
decreaseLimit();
};
};
if ((((_arg2.type == Constants.SHIP_SUBMARINE)) && ((_level == 2)))){
if (!_arg2.isAlive()){
decreaseLimit();
};
};
if (_level == 3){
if (!_arg2.isAlive()){
decreaseLimit();
};
};
if (_level == 4){
MySound.play(Utils.getSoundFromLibrary("implosionSmall"));
decreaseLimit();
};
_ponorka.removeBullet(_local3);
};
};
_local4++;
};
if (!_arg2.isAlive()){
addScore(Constants.SCORE_LIST[_arg2.type]);
_ships.remove(_arg2);
if (_level != 4){
generateShips();
};
};
if (_isLevelComplete){
levelComplete();
};
}
private function switchSound(_arg1:MouseEvent):void{
if (_soundActive){
setSound(false);
} else {
setSound(true);
};
}
private function keyReleased(_arg1:KeyboardEvent):void{
_ponorka.keyReleased(_arg1);
}
public function addTorpedo(_arg1:int, _arg2:int, _arg3:Point):void{
var _local4:MovieClip;
var _local5:Bullet;
if (_mines.isFreeSlot()){
_local4 = Utils.getMovieClipFromLibrary("torpedo");
if (_arg3.x < 0){
_local4.scaleX = (_local4.scaleX * -1);
};
_local5 = new Bullet(_doc, _local4, _arg1, _arg2, _arg3);
_local5.clipRect = new Rectangle(0, 0, Constants.SCR_WIDTH, Constants.SCR_HEIGHT);
_mines.push(_local5);
MySound.play(Utils.getSoundFromLibrary("torpedoSnd"));
};
}
private function keyPressed(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
if (((!((_dialog == null))) && ((_showDialogCounter <= 0)))){
MySound.play(Utils.getSoundFromLibrary("click"));
hideDialog(null);
return;
};
};
if (_dialogYesNo != null){
if (_arg1.keyCode == Keyboard.LEFT){
_dialogYesNoSelected = 0;
};
if (_arg1.keyCode == Keyboard.RIGHT){
_dialogYesNoSelected = 1;
};
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
if (_dialogYesNoSelected == 0){
gotoMenu(null);
} else {
hideDialogYesNo(null);
};
};
};
if (_paused){
return;
};
if (Constants.DEBUG){
if (_arg1.keyCode == 68){
nextLevel();
};
};
if (Constants.DEBUG){
if (_arg1.keyCode == 77){
gotoMenu(null);
return;
};
};
if (_ponorka != null){
_ponorka.keyPressed(_arg1);
};
}
private function decreaseLimit():void{
if (--_levelLimit <= 0){
_isLevelComplete = true;
};
updateLevelInfo();
}
private function getNewShip():Ship{
var _local1:int;
var _local2:int;
var _local3:Array;
var _local4:int;
_local2 = (Math.random() * 100);
_local3 = Constants.LEVEL_DATA[_level];
_local1 = 1;
while (_local1 < _local3.length) {
if (_local2 < _local3[_local1]){
break;
};
_local1++;
};
_local4 = (_local1 - 1);
return (getShip(_local4));
}
public function get doc():DisplayObjectContainer{
return (_doc);
}
private function update(_arg1:Event):void{
var _local2:uint;
var _local3:int;
var _local4:Ship;
var _local5:int;
if (_paused){
if (_dialogYesNo != null){
if (_dialogYesNoSelected == 0){
_dialogBtnYes.upState = _dialogBtnYes.overState;
_dialogBtnNo.upState = _dialogBtnNo.downState;
} else {
_dialogBtnYes.upState = _dialogBtnYes.downState;
_dialogBtnNo.upState = _dialogBtnNo.overState;
};
};
if (_showDialogCounter > 0){
_showDialogCounter--;
};
if (_showDialogCounter == 0){
_dialogBtnOK.visible = true;
};
return;
};
_local2 = getTimer();
_local3 = (_local2 - _last);
_last = _local2;
_ponorka.update(_local3);
while (_local5 < _ships.length) {
_local4 = (_ships.getObject(_local5) as Ship);
if (_local4 == null){
} else {
_local4.update(_local3);
if (!_local4.isInClipRect()){
_ships.remove(_local4);
_local4.removeChild();
generateShips();
};
testBulletsCollision(_ponorka.bullets, _local4);
};
_local5++;
};
updateMines(_local3);
if (_bonus != null){
_bonus.update(_local3);
};
if (_gotoMenu){
gotoMenu(null);
};
}
private function getShip(_arg1:int):Ship{
var _local2:MovieClip;
var _local3:Point;
var _local4:Point;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:Ship;
var _local12:Timer;
_local7 = (Math.random() * 2);
if (_local7 == 0){
_local4 = new Point(1, 0);
} else {
_local4 = new Point(-1, 0);
};
switch (_arg1){
case Constants.SHIP_TRANSPORTER:
_local2 = Utils.getMovieClipFromLibrary("transporter");
_local5 = 1;
break;
case Constants.SHIP_TORPEDOBOREC:
_local2 = Utils.getMovieClipFromLibrary("torpedoborec");
_local5 = 1;
_local6 = (2 + (Math.random() * 3));
_local4.x = (_local4.x * _local6);
_local4.y = (_local4.y * _local6);
break;
case Constants.SHIP_CRUISER:
_local2 = Utils.getMovieClipFromLibrary("cruiser");
_local5 = 2;
_local6 = 2;
_local4.x = (_local4.x * _local6);
_local4.y = (_local4.y * _local6);
break;
case Constants.SHIP_SUBMARINE:
_local2 = Utils.getMovieClipFromLibrary("submarine");
_local5 = 1;
_local6 = (2 + (Math.random() * 2));
_local4.x = (_local4.x * _local6);
_local4.y = (_local4.y * _local6);
break;
case Constants.SHIP_BOMBER:
_local2 = Utils.getMovieClipFromLibrary("bomber");
_local5 = 1;
_local6 = 3;
_local4.x = (_local4.x * _local6);
_local4.y = (_local4.y * _local6);
break;
case Constants.SHIP_BOSS:
_local2 = Utils.getMovieClipFromLibrary("boss");
_local5 = Constants.BOSS_LIFE;
_local6 = 2;
_local4.x = -(_local6);
_local4.y = 0;
break;
};
_local8 = 73;
if (_arg1 == Constants.SHIP_SUBMARINE){
_local8 = (94 + (Math.random() * 260));
};
if (_arg1 == Constants.SHIP_BOMBER){
_local8 = 30;
};
if (_arg1 != Constants.SHIP_BOSS){
if (_local4.x > 0){
_local9 = (0 - _local2.width);
_local2.scaleX = (_local2.scaleX * -1);
} else {
_local9 = (Constants.SCR_WIDTH + _local2.width);
};
} else {
_local9 = ((Constants.SCR_WIDTH - _local2.width) >> 1);
};
_local3 = new Point(_local9, _local8);
_local10 = (500 + (Math.random() * 3000));
_local11 = new Ship(_doc, _local2, _local3, _local4, _local5, _arg1, this);
_local11.clipRect = new Rectangle((0 - _local2.width), 0, (Constants.SCR_WIDTH + (_local2.width * 2)), Constants.SCR_HEIGHT);
_local12 = new Timer(_local10, 1);
_local12.addEventListener(TimerEvent.TIMER, _local11.start);
_local12.start();
return (_local11);
}
public function setSound(_arg1:Boolean):void{
_soundActive = _arg1;
MySound.soundActive = _soundActive;
if (_soundActive){
_sound.gotoAndStop(1);
MySound.playMusic(Utils.getSoundFromLibrary("music"));
} else {
_sound.gotoAndStop(2);
MySound.stopAllSounds();
};
}
public function gotoAndPlay():void{
(_doc as MovieClip).gotoAndStop(1, "Menu");
}
public function setInfoLevel1TextField(_arg1:TextField):void{
_infoLevel1TextField = _arg1;
_infoLevel1TextField.selectable = false;
}
private function generateShips():void{
var _local1:int;
var _local2:Ship;
if (!_ships.isFreeSlot()){
return;
};
_local1 = 0;
while (_local1 < _ships.length) {
if (_ships.isSlotEmpty(_local1)){
_local2 = getNewShip();
_ships.pushAt(_local1, _local2);
};
_local1++;
};
}
public function hideDialogYesNo(_arg1:MouseEvent):void{
if (_dialogYesNo != null){
MySound.play(Utils.getSoundFromLibrary("click"));
if (_doc.contains(_dialogYesNo)){
_doc.removeChild(_dialogYesNo);
};
_dialogYesNo.visible = false;
_dialogBtnYes.removeEventListener(MouseEvent.CLICK, gotoMenu);
_dialogBtnNo.removeEventListener(MouseEvent.CLICK, hideDialogYesNo);
};
_dialogYesNo = null;
pauseGame(false);
}
private function initLevel():void{
var _local1:MovieClip;
pauseGame(true);
_ponorka.object.visible = true;
_ponorka.object.x = 250;
_ponorka.object.y = 200;
_ships = new Array2(Constants.LEVEL_DATA[_level][0]);
generateShips();
_mines = new Array2(Constants.LEVEL_DATA_MAXMINES[_level]);
initNeutralObjects(_doc);
_bonus = new Bonus(_doc, _ponorka);
_levelLimit = Constants.LEVEL_LIMITS[_level];
_local1 = Utils.getSubClip(_doc, "panelLeft.ship");
_local1.visible = true;
switch (_level){
case 0:
updateLevelInfo();
showDialog(Constants.DIALOG_LEVEL1, "Level 1", "General Sarathi is preparing for attack! Destroy all his transporters! Be careful, transporters are protected!");
_local1.gotoAndStop(1);
break;
case 1:
updateLevelInfo();
showDialog(Constants.DIALOG_LEVEL1, "Level 2", "After destroying transporters, general sent battleships towards You. Be careful, battleships have torpedoes. Good luck!");
_local1.gotoAndStop(2);
break;
case 2:
updateLevelInfo();
showDialog(Constants.DIALOG_LEVEL1, "Level 3", "You are entering area protected by submarines. Enemy have airfield on nearby island. Be careful, bombers and submarines are very dangerous!");
_local1.gotoAndStop(3);
break;
case 3:
updateLevelInfo();
showDialog(Constants.DIALOG_LEVEL1, "Level 4", "You are too close! It looks like General Sarathi is afraid. He is sending huge fleet! Radar is full of enemy floats!");
_local1.gotoAndStop(4);
break;
case 4:
updateLevelInfo();
showDialog(Constants.DIALOG_LEVEL1, "Level 5", "Flag ship of Sarathi forces was spotted! Prepare for final battle!");
_local1.gotoAndStop(5);
break;
};
}
public function nextLevel():void{
if (++_level >= Constants.LEVEL_NUM){
showDialog(Constants.DIALOG_GAME_COMPLETE, "Congratulations", "Well done! Enemy was destroyed. Now peace is in the world again!");
return;
};
release();
init();
}
private function backToMenu(_arg1:MouseEvent):void{
if (!_paused){
MySound.play(Utils.getSoundFromLibrary("click"));
pauseGame(true);
showDialogYesNo("Back to Menu", "Are you sure? You will lost your current game.");
};
}
private function levelComplete():void{
pauseGame(true);
_ponorka.removeAllBullets();
_showDialogCounter = 75;
showDialog(Constants.DIALOG_LEVEL_COMPLETE, "Level Complete", ("Great. You are victorious!\n\nYour score: " + _score));
}
private function debugBullets(_arg1:Array2):void{
var _local2:Bullet;
var _local3:int;
_local3 = 0;
while (_local3 < _arg1.length) {
_local2 = (_arg1.getObject(_local3) as Bullet);
if (_local2 != null){
trace(((("" + _local3) + ".=") + _local2.toString()));
};
_local3++;
};
trace("**** doc ****");
_local3 = 0;
while (_local3 < _doc.numChildren) {
trace(("child=" + _doc.getChildAt(_local3)));
_local3++;
};
trace("******");
}
public function gotoMenu(_arg1:Event):void{
hideDialogYesNo(null);
release();
(_doc as MovieClip).gotoAndStop(1, "Menu");
}
public function addBomb(_arg1:int, _arg2:int, _arg3:Point):void{
var _local4:MovieClip;
var _local5:Bullet;
if (_mines.isFreeSlot()){
_local4 = Utils.getMovieClipFromLibrary("bomb");
_local5 = new Bullet(_doc, _local4, _arg1, _arg2, _arg3);
_local5.clipRect = new Rectangle(0, 0, Constants.SCR_WIDTH, Constants.SCR_HEIGHT);
_mines.push(_local5);
};
}
private function gameOver():void{
pauseGame(true);
_ponorka.removeAllBullets();
_ponorka.object.gotoAndPlay("destroyed");
}
private function debugShips():void{
var _local1:Ship;
var _local2:int;
while (_local2 < _ships.length) {
_local1 = (_ships.getObject(_local2) as Ship);
if (_local1 != null){
trace(((("" + _local2) + ".=") + _local1.toString()));
};
_local2++;
};
}
public function showDialogYesNo(_arg1:String, _arg2:String):void{
if (_dialogYesNo == null){
_dialogYesNo = Utils.getMovieClipFromLibrary("dialogYesNo");
_dialogYesNo.x = (Constants.SCR_WIDTH >> 1);
_dialogYesNo.y = (Constants.SCR_HEIGHT >> 1);
_dialogBtnYes = Utils.getButton(_dialogYesNo, "yes");
_dialogBtnYes.addEventListener(MouseEvent.CLICK, gotoMenu);
_dialogBtnNo = Utils.getButton(_dialogYesNo, "no");
_dialogBtnNo.addEventListener(MouseEvent.CLICK, hideDialogYesNo);
};
_dialogYesNo.visible = true;
_doc.addChild(_dialogYesNo);
Utils.setTextField(_dialogYesNo, "txt", _arg2);
Utils.setTextField(_dialogYesNo, "txtTitle", _arg1);
}
public static function releaseArray2(_arg1:Array2):void{
var _local2:GameObject;
var _local3:int;
_local3 = 0;
while (_local3 < _arg1.length) {
_local2 = (_arg1.getObject(_local3) as GameObject);
if (_local2 != null){
_local2.release();
_local2 = null;
};
_local3++;
};
_arg1 = null;
}
public static function insertBubble(_arg1:int, _arg2:int, _arg3:DisplayObjectContainer):void{
var _local4:int;
var _local5:MovieClip;
_local4 = 8;
_local5 = Utils.getMovieClipFromLibrary("bublina");
_local5.x = ((_arg1 - (_local4 >> 1)) + (Math.random() * _local4));
_local5.y = ((_arg2 - (_local4 >> 1)) + (Math.random() * _local4));
_arg3.addChild(_local5);
}
public static function activateCursor(_arg1:DisplayObjectContainer):void{
Cursor.getInstance().setCursor(_arg1, Utils.getMovieClipFromLibrary("cursor"));
Cursor.getInstance().gotoTop();
Cursor.getInstance().activate();
}
public static function getInstance():Game{
return (_instance);
}
public static function addScore(_arg1:int):void{
_score = (_score + _arg1);
_scoreTextField.text = ("" + _score);
}
public static function releaseFishes():void{
var _local1:RandomMove;
var _local2:int;
_local2 = 0;
while (_local2 < _fishes.length) {
_local1 = (_fishes[_local2] as RandomMove);
if (_local1 != null){
_local1.object.parent.removeChild(_local1.object);
_local1 = null;
};
_local2++;
};
_fishes = null;
}
public static function initNeutralObjects(_arg1:DisplayObjectContainer):void{
var _local2:Rectangle;
var _local3:String;
var _local4:int;
var _local5:int;
var _local6:MovieClip;
var _local7:RandomMove;
if (_fishes == null){
_fishes = new Array();
};
_local2 = new Rectangle(2, 150, 548, 250);
_local4 = 0;
while (_local4 < Constants.MAX_FISHES) {
_local5 = (Math.random() * Constants.FISH_LIBRARY_NAMES.length);
_local3 = Constants.FISH_LIBRARY_NAMES[_local5];
_local6 = Utils.getMovieClipFromLibrary(_local3);
_local7 = new RandomMove((60 + (Math.random() * 40)), _local2, 0, _local6, true);
_arg1.addChild(_local7.object);
_local7.start();
_fishes.push(_local7);
_local4++;
};
}
}
}//package
Section 44
//GameObject (GameObject)
package {
import flash.display.*;
import flash.geom.*;
public class GameObject {
private var _clipRect:Rectangle;
public var _doc:DisplayObjectContainer;
private var _object:MovieClip;
public function GameObject(_arg1:DisplayObjectContainer, _arg2:MovieClip, _arg3:int, _arg4:int){
_doc = _arg1;
_object = _arg2;
_object.x = _arg3;
_object.y = _arg4;
_doc.addChild(_object);
}
public function correctObjectInClipRect():void{
if (_object.x < _clipRect.x){
_object.x = _clipRect.x;
};
if (_object.x > (_clipRect.x + _clipRect.width)){
_object.x = (_clipRect.x + _clipRect.width);
};
if (_object.y < _clipRect.y){
_object.y = _clipRect.y;
};
if (_object.y > (_clipRect.y + _clipRect.height)){
_object.y = (_clipRect.y + _clipRect.height);
};
}
public function isInClipRect():Boolean{
return (_clipRect.contains(_object.x, _object.y));
}
public function set clipRect(_arg1:Rectangle):void{
_clipRect = _arg1;
}
public function update(_arg1:int):void{
}
public function release():void{
object.stop();
removeChild();
}
public function removeChild():void{
_doc.removeChild(_object);
}
public function get object():MovieClip{
return (_object);
}
}
}//package
Section 45
//implosion (implosion)
package {
import flash.media.*;
public dynamic class implosion extends Sound {
}
}//package
Section 46
//implosionSmall (implosionSmall)
package {
import flash.media.*;
public dynamic class implosionSmall extends Sound {
}
}//package
Section 47
//logo (logo)
package {
import flash.display.*;
public dynamic class logo extends MovieClip {
public function logo(){
addFrameScript(89, frame90);
}
function frame90(){
stop();
}
}
}//package
Section 48
//music (music)
package {
import flash.media.*;
public dynamic class music extends Sound {
}
}//package
Section 49
//Player (Player)
package {
import flash.display.*;
import utils.*;
import flash.events.*;
import flash.geom.*;
import flash.ui.*;
public class Player extends Submarine {
private var _flipped:Boolean;
private var _bullets:Array2;
private var firePressed:Boolean;// = false
private var upPressed:Boolean;// = false
private var leftPressed:Boolean;// = false
private var downPressed:Boolean;// = false
private var toRight:Boolean;// = true
public var _life:int;
private var rightPressed:Boolean;// = false
private var fireHolded:Boolean;// = false
private var _guiPanel:DisplayObjectContainer;
public static var _armor:int;
public static var _rocket:int;
public static var _speed:int;
public function Player(_arg1:DisplayObjectContainer, _arg2:MovieClip, _arg3:int, _arg4:int){
leftPressed = false;
rightPressed = false;
upPressed = false;
downPressed = false;
firePressed = false;
toRight = true;
fireHolded = false;
super(_arg1, _arg2, _arg3, _arg4);
clipRect = new Rectangle(30, 93, (Constants.SCR_WIDTH - 60), (Constants.SCR_HEIGHT - 120));
_life = _armor;
_bullets = new Array2(_rocket);
_flipped = false;
createGUI();
updateLifeProgressBar();
}
public function updateLifeProgressBar():void{
var _local1:MovieClip;
var _local2:Number;
var _local3:int;
_local1 = Utils.getSubClip(_doc, "panelLeft.life");
_local2 = (100 / _armor);
_local3 = (100 - (_local2 * _life));
_local1.gotoAndStop(_local3);
Utils.setTextField(_local1, "txtLife", ("" + _life));
}
override public function update(_arg1:int):void{
var _local2:Bullet;
var _local3:int;
var _local4:MovieClip;
var _local5:int;
var _local6:Bullet;
if (leftPressed){
object.x = (object.x - _speed);
Game.insertBubble(((object.x + (object.width / 2)) + 6), (object.y + 4), _doc);
if (!_flipped){
object.scaleX = (object.scaleX * -1);
_flipped = true;
};
};
if (rightPressed){
object.x = (object.x + _speed);
Game.insertBubble(((object.x - (object.width / 2)) - 6), (object.y + 4), _doc);
if (_flipped){
object.scaleX = (object.scaleX * -1);
_flipped = false;
};
};
if (upPressed){
object.y = (object.y - _speed);
};
if (downPressed){
object.y = (object.y + _speed);
};
correctObjectInClipRect();
if (((firePressed) && (!(fireHolded)))){
fireHolded = true;
if (_bullets.isFreeSlot()){
MySound.play(Utils.getSoundFromLibrary("rocket"));
_local4 = Utils.getMovieClipFromLibrary("raketa");
if (_flipped){
_local5 = (object.x - 20);
} else {
_local5 = (object.x + 20);
};
_local6 = new Bullet(_doc, _local4, _local5, (object.y - 10), new Point(0, -6));
_local6.clipRect = new Rectangle(0, 0, Constants.SCR_WIDTH, Constants.SCR_HEIGHT);
_bullets.push(_local6);
updateGUI();
};
};
_local3 = 0;
while (_local3 < _bullets.length) {
_local2 = (_bullets.getObject(_local3) as Bullet);
if (_local2 == null){
} else {
_local2.update(_arg1);
if (!_local2.isInClipRect()){
_bullets.remove(_local2);
_local2.removeChild();
updateGUI();
};
};
_local3++;
};
}
override public function release():void{
var _local1:Bullet;
var _local2:int;
_local2 = 0;
while (_local2 < _bullets.length) {
_local1 = (_bullets.getObject(_local2) as Bullet);
if (_local1 == null){
} else {
_bullets.remove(_local1);
_local1.removeChild();
};
_local2++;
};
if (_doc.contains(object)){
_doc.removeChild(object);
};
if (_doc.contains(_guiPanel)){
_doc.removeChild(_guiPanel);
_guiPanel = null;
};
}
public function keyPressed(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.LEFT){
leftPressed = true;
};
if (_arg1.keyCode == Keyboard.RIGHT){
rightPressed = true;
};
if (_arg1.keyCode == Keyboard.UP){
upPressed = true;
};
if (_arg1.keyCode == Keyboard.DOWN){
downPressed = true;
};
if (_arg1.keyCode == Keyboard.SPACE){
firePressed = true;
};
}
private function updateGUI():void{
var _local1:int;
var _local2:MovieClip;
if (_guiPanel == null){
createGUI();
};
_local1 = 0;
while (_local1 < _bullets.length) {
_local2 = (_guiPanel.getChildAt(_local1) as MovieClip);
if (_local1 < _bullets.actualSize){
_local2.gotoAndStop("off");
} else {
_local2.gotoAndStop("on");
};
_local1++;
};
}
public function hit():void{
_life--;
if (_life < 0){
_life = 0;
};
if (isAlive()){
MySound.play(Utils.getSoundFromLibrary("implosionSmall"));
} else {
MySound.play(Utils.getSoundFromLibrary("implosion"));
};
object.gotoAndPlay("hit");
updateLifeProgressBar();
}
private function createGUI():void{
var _local1:int;
var _local2:MovieClip;
if (((!((_guiPanel == null))) && (_doc.contains(_guiPanel)))){
_doc.removeChild(_guiPanel);
};
_guiPanel = null;
_guiPanel = (new MovieClip() as DisplayObjectContainer);
_guiPanel.x = 380;
_guiPanel.y = 6;
_local1 = 0;
while (_local1 < _rocket) {
_local2 = Utils.getMovieClipFromLibrary("raketa_gui");
_local2.y = 0;
_local2.x = (_local1 * (-(_local2.width) - 3));
_guiPanel.addChild(_local2);
_local1++;
};
_doc.addChild(_guiPanel);
}
public function isAlive():Boolean{
return (((_life)<=0) ? false : true);
}
public function removeBullet(_arg1:Bullet):void{
_arg1.object.gotoAndPlay("hit");
_bullets.remove(_arg1);
updateGUI();
}
public function get bullets():Array2{
return (_bullets);
}
public function removeAllBullets():void{
var _local1:Bullet;
var _local2:int;
_local2 = 0;
while (_local2 < _bullets.length) {
_local1 = (_bullets.getObject(_local2) as Bullet);
if (_local1 != null){
removeBullet(_local1);
};
_local2++;
};
}
public function keyReleased(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.LEFT){
leftPressed = false;
toRight = false;
};
if (_arg1.keyCode == Keyboard.RIGHT){
rightPressed = false;
toRight = true;
};
if (_arg1.keyCode == Keyboard.UP){
upPressed = false;
};
if (_arg1.keyCode == Keyboard.DOWN){
downPressed = false;
};
if (_arg1.keyCode == Keyboard.SPACE){
firePressed = false;
fireHolded = false;
};
}
public function addBonus(_arg1:int):void{
var _local2:int;
var _local3:Bullet;
if (_arg1 == Constants.BONUS_LIFE){
_life++;
updateLifeProgressBar();
return;
};
if (_arg1 == Constants.BONUS_ARMOR){
_armor++;
_life++;
updateLifeProgressBar();
return;
};
if (_arg1 == Constants.BONUS_SPEED){
_speed++;
return;
};
if (_arg1 == Constants.BONUS_ROCKET){
_rocket++;
createGUI();
_local2 = 0;
while (_local2 < _bullets.length) {
_local3 = (_bullets.getObject(_local2) as Bullet);
if (_local3 != null){
_local3.release();
};
_local2++;
};
_bullets = null;
_bullets = new Array2(_rocket);
return;
};
if (_arg1 == Constants.BONUS_POINTS){
Game.addScore(Constants.BONUS_POINTS_VALUE);
};
}
public static function initPlayerAttributes():void{
_rocket = 1;
_speed = 2;
_armor = 3;
}
}
}//package
Section 50
//ponorka (ponorka)
package {
import flash.display.*;
public dynamic class ponorka extends MovieClip {
public function ponorka(){
addFrameScript(0, frame1, 3, frame4, 25, frame26);
}
function frame1(){
stop();
}
function frame26(){
visible = false;
Game.getInstance().gameOverIn();
}
function frame4(){
gotoAndStop(1);
}
}
}//package
Section 51
//raketa (raketa)
package {
import flash.display.*;
public dynamic class raketa extends MovieClip {
public function raketa(){
addFrameScript(5, frame6, 14, frame15);
}
function frame6(){
gotoAndPlay(1);
}
function frame15(){
stop();
if (parent.contains(this)){
parent.removeChild(this);
};
}
}
}//package
Section 52
//raketa_gui (raketa_gui)
package {
import flash.display.*;
public dynamic class raketa_gui extends MovieClip {
public function raketa_gui(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 53
//rocket (rocket)
package {
import flash.media.*;
public dynamic class rocket extends Sound {
}
}//package
Section 54
//ryba (ryba)
package {
import flash.display.*;
public dynamic class ryba extends MovieClip {
}
}//package
Section 55
//ryba2 (ryba2)
package {
import flash.display.*;
public dynamic class ryba2 extends MovieClip {
}
}//package
Section 56
//Ship (Ship)
package {
import flash.display.*;
import utils.*;
import flash.events.*;
import flash.geom.*;
public class Ship extends GameObject {
private var _direction:Point;
private var _game:Game;
private var _type:int;
public var _life:int;
private var _active:Boolean;
private var _fireDelay:int;
public function Ship(_arg1:DisplayObjectContainer, _arg2:MovieClip, _arg3:Point, _arg4:Point, _arg5:int, _arg6:int, _arg7:Game):void{
super(_arg1, _arg2, _arg3.x, _arg3.y);
_direction = _arg4;
_life = _arg5;
_active = false;
_type = _arg6;
_game = _arg7;
_fireDelay = Constants.FIRE_DELAY;
}
public function isAlive():Boolean{
return (((_life)<=0) ? false : true);
}
override public function update(_arg1:int):void{
if (!_active){
return;
};
object.x = (object.x + _direction.x);
object.y = (object.y + _direction.y);
if (_type == Constants.SHIP_BOSS){
if ((object.x - (object.width / 2)) < 0){
_direction.x = -(_direction.x);
object.scaleX = (object.scaleX * -1);
};
if ((object.x + (object.width / 2)) > Constants.SCR_WIDTH){
object.scaleX = (object.scaleX * -1);
_direction.x = -(_direction.x);
};
};
if (_type == Constants.SHIP_SUBMARINE){
if (_direction.x > 0){
Game.insertBubble(((object.x - (object.width >> 1)) - 6), (object.y + 3), _doc);
} else {
Game.insertBubble(((object.x + (object.width >> 1)) + 6), (object.y + 3), _doc);
};
};
fire(_arg1);
}
override public function release():void{
if (_doc.contains(object)){
_doc.removeChild(object);
};
}
public function hit():void{
_life--;
if (!isAlive()){
MySound.play(Utils.getSoundFromLibrary("implosion"));
(object as MovieClip).gotoAndPlay("hit");
};
}
public function start(_arg1:Event):void{
_active = true;
}
public function toString():String{
return (((((((((("obj=" + object) + ", pos x=") + object.x) + ", y=") + object.y) + ", direction=") + _direction) + ", type=") + _type));
}
public function get type():int{
return (_type);
}
public function fire(_arg1:int):void{
var _local2:int;
var _local3:int;
var _local4:Point;
if (!isAlive()){
return;
};
_fireDelay = (_fireDelay - _arg1);
if (_fireDelay > 0){
return;
};
if (type == Constants.SHIP_BOSS){
_fireDelay = Constants.BOSS_FIRE_DELAY;
} else {
_fireDelay = Constants.FIRE_DELAY;
};
_local2 = (Math.random() * 100);
switch (type){
case Constants.SHIP_TORPEDOBOREC:
if (_local2 < Constants.SHIP_DANGEROUS[Game._level]){
_game.addMine(object.x, object.y);
};
break;
case Constants.SHIP_CRUISER:
if (_local2 < Constants.SHIP_DANGEROUS[Game._level]){
_local3 = (Math.random() * 3);
if (_local3 < 2){
_game.addMine(object.x, object.y);
} else {
_local4 = new Point((_direction.x + (Math.random() * 3)), (1 + (Math.random() * 3)));
_game.addTorpedo(object.x, object.y, _local4);
};
};
break;
case Constants.SHIP_SUBMARINE:
if (_local2 < Constants.SHIP_DANGEROUS[Game._level]){
_game.addTorpedo(object.x, object.y, new Point((_direction.x * 3), _direction.y));
};
break;
case Constants.SHIP_BOMBER:
if (_local2 < Constants.SHIP_DANGEROUS[Game._level]){
_game.addBomb(object.x, (object.y + 5), new Point(0, 2));
};
break;
case Constants.SHIP_BOSS:
if (_local2 < Constants.SHIP_DANGEROUS[Game._level]){
_local3 = (Math.random() * 100);
if (_local3 < 50){
_game.addMine(object.x, object.y);
} else {
_local4 = new Point((_direction.x + (Math.random() * 3)), (1 + (Math.random() * 3)));
_game.addTorpedo(object.x, object.y, _local4);
};
};
break;
};
}
}
}//package
Section 57
//submarine (submarine)
package {
import flash.display.*;
public dynamic class submarine extends MovieClip {
public function submarine(){
addFrameScript(0, frame1, 14, frame15);
}
function frame15(){
parent.removeChild(this);
}
function frame1(){
stop();
}
}
}//package
Section 58
//Submarine (Submarine)
package {
import flash.display.*;
public class Submarine extends GameObject {
public function Submarine(_arg1:DisplayObjectContainer, _arg2:MovieClip, _arg3:int, _arg4:int){
super(_arg1, _arg2, _arg3, _arg4);
}
}
}//package
Section 59
//torpedo (torpedo)
package {
import flash.display.*;
public dynamic class torpedo extends MovieClip {
public function torpedo(){
addFrameScript(0, frame1, 8, frame9);
}
function frame1(){
stop();
}
function frame9(){
stop();
if (parent.contains(this)){
parent.removeChild(this);
};
}
}
}//package
Section 60
//torpedoborec (torpedoborec)
package {
import flash.display.*;
public dynamic class torpedoborec extends MovieClip {
public function torpedoborec(){
addFrameScript(0, frame1, 21, frame22);
}
function frame1(){
stop();
}
function frame22(){
parent.removeChild(this);
}
}
}//package
Section 61
//torpedoSnd (torpedoSnd)
package {
import flash.media.*;
public dynamic class torpedoSnd extends Sound {
}
}//package
Section 62
//transporter (transporter)
package {
import flash.display.*;
public dynamic class transporter extends MovieClip {
public function transporter(){
addFrameScript(0, frame1, 19, frame20);
}
function frame1(){
stop();
}
function frame20(){
parent.removeChild(this);
}
}
}//package
Section 63
//Utils (Utils)
package {
import flash.display.*;
import flash.text.*;
import flash.media.*;
import flash.utils.*;
import flash.filters.*;
public class Utils {
public static function addShadow(_arg1:DisplayObject):void{
var _local2:Array;
var _local3:DropShadowFilter;
_local2 = new Array();
_local3 = new DropShadowFilter();
_local3.quality = 2;
_local3.alpha = 0.6;
_local3.blurX = 6;
_local3.blurY = 6;
_local3.distance = 3;
_local2.push(_local3);
_arg1.filters = _local2;
}
public static function removeAllChilds(_arg1:DisplayObjectContainer):void{
while (_arg1.numChildren > 0) {
trace(("child=" + _arg1.getChildAt(0)));
_arg1.removeChildAt(0);
};
trace("***");
}
public static function noSelectableTextField(_arg1:DisplayObjectContainer, _arg2:String):void{
var _local3:TextField;
_local3 = getTextField(_arg1, _arg2);
_local3.selectable = false;
}
public static function getTextField(_arg1:DisplayObjectContainer, _arg2:String):TextField{
var _local3:MovieClip;
var _local4:TextField;
var _local5:Array;
var _local6:int;
_local3 = (_arg1 as MovieClip);
_local5 = _arg2.split(".");
_local6 = 0;
while (_local6 < (_local5.length - 1)) {
_local3 = (_local3.getChildByName((_local5[_local6] as String)) as MovieClip);
_local6++;
};
_local4 = (_local3.getChildByName((_local5[(_local5.length - 1)] as String)) as TextField);
return (_local4);
}
public static function getSoundFromLibrary(_arg1:String):Sound{
var _local2:Class;
_local2 = (getDefinitionByName(_arg1) as Class);
return ((new (_local2) as Sound));
}
public static function getSubClip(_arg1:DisplayObjectContainer, _arg2:String):MovieClip{
var _local3:MovieClip;
var _local4:Array;
var _local5:int;
_local3 = (_arg1 as MovieClip);
_local4 = _arg2.split(".");
_local5 = 0;
while (_local5 < _local4.length) {
_local3 = (_local3.getChildByName((_local4[_local5] as String)) as MovieClip);
_local5++;
};
return (_local3);
}
public static function setTextField(_arg1:DisplayObjectContainer, _arg2:String, _arg3:String):void{
var _local4:MovieClip;
var _local5:TextField;
var _local6:Array;
var _local7:int;
_local4 = (_arg1 as MovieClip);
_local6 = _arg2.split(".");
_local7 = 0;
while (_local7 < (_local6.length - 1)) {
_local4 = (_local4.getChildByName((_local6[_local7] as String)) as MovieClip);
_local7++;
};
_local5 = (_local4.getChildByName((_local6[(_local6.length - 1)] as String)) as TextField);
_local5.text = _arg3;
_local5.selectable = false;
addShadow(_local5);
}
public static function getMovieClipFromLibrary(_arg1:String):MovieClip{
var _local2:Class;
_local2 = (getDefinitionByName(_arg1) as Class);
return ((new (_local2) as MovieClip));
}
public static function getButton(_arg1:DisplayObjectContainer, _arg2:String):SimpleButton{
var _local3:MovieClip;
var _local4:Array;
var _local5:int;
_local3 = (_arg1 as MovieClip);
_local4 = _arg2.split(".");
_local5 = 0;
while (_local5 < (_local4.length - 1)) {
_local3 = (_local3.getChildByName((_local4[_local5] as String)) as MovieClip);
_local5++;
};
return ((_local3.getChildByName((_local4[(_local4.length - 1)] as String)) as SimpleButton));
}
}
}//package
Section 64
//water (water)
package {
import flash.media.*;
public dynamic class water extends Sound {
}
}//package
Section 65
//zralok_anim (zralok_anim)
package {
import flash.display.*;
public dynamic class zralok_anim extends MovieClip {
}
}//package