Section 1
//KongregateEvent (com.kongregate.as3.client.events.KongregateEvent)
package com.kongregate.as3.client.events {
import flash.events.*;
public class KongregateEvent extends Event {
public static const COMPLETE:String = "component_api_available";
public function KongregateEvent(_arg1:String){
super(_arg1);
}
}
}//package com.kongregate.as3.client.events
Section 2
//AbstractShadowService (com.kongregate.as3.client.services.AbstractShadowService)
package com.kongregate.as3.client.services {
import flash.events.*;
public class AbstractShadowService extends EventDispatcher {
protected function alert(_arg1:String, _arg2:String, _arg3="", _arg4:String=""):void{
trace(((((((("Kongregate API: " + _arg1) + ".") + _arg2) + "(") + _arg3) + ") ") + _arg4));
}
}
}//package com.kongregate.as3.client.services
Section 3
//HighScoreServiceShadow (com.kongregate.as3.client.services.HighScoreServiceShadow)
package com.kongregate.as3.client.services {
public class HighScoreServiceShadow extends AbstractShadowService implements IHighScoreServices {
private var mode:String;
public function HighScoreServiceShadow(){
mode = "";
}
public function submit(_arg1:Number, _arg2:String=null):void{
alert("IHighScoreServices", "submit", arguments);
}
public function connect():Boolean{
alert("IKongregateServices", "connect");
return (true);
}
public function requestList(_arg1:Function):void{
alert("IHighScoreServices", "requestList", "", (("[Mode: " + mode) + "]"));
_arg1({success:false});
}
public function setMode(_arg1:String):void{
alert("IHighScoreServices", "setMode", arguments);
this.mode = _arg1;
}
}
}//package com.kongregate.as3.client.services
Section 4
//IHighScoreServices (com.kongregate.as3.client.services.IHighScoreServices)
package com.kongregate.as3.client.services {
public interface IHighScoreServices {
function setMode(_arg1:String):void;
function submit(_arg1:Number, _arg2:String=null):void;
function requestList(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 5
//IKongregateServices (com.kongregate.as3.client.services.IKongregateServices)
package com.kongregate.as3.client.services {
import flash.events.*;
public interface IKongregateServices extends IEventDispatcher {
function getPlayerInfo(_arg1:Function):void;
function connect(_arg1:Number=-1):Boolean;
}
}//package com.kongregate.as3.client.services
Section 6
//IStatServices (com.kongregate.as3.client.services.IStatServices)
package com.kongregate.as3.client.services {
public interface IStatServices {
function submitArray(_arg1:Array):void;
function submit(_arg1:String, _arg2:Number):void;
}
}//package com.kongregate.as3.client.services
Section 7
//IUserServices (com.kongregate.as3.client.services.IUserServices)
package com.kongregate.as3.client.services {
public interface IUserServices {
function getName():String;
function getPlayerInfo(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 8
//KongregateServiceShadow (com.kongregate.as3.client.services.KongregateServiceShadow)
package com.kongregate.as3.client.services {
public class KongregateServiceShadow extends AbstractShadowService implements IKongregateServices {
public function getName():String{
alert("IKongregateServices", "getName");
return ("Guest");
}
public function connect(_arg1:Number=-1):Boolean{
alert("IKongregateServices", "connect", arguments);
return (true);
}
public function getPlayerInfo(_arg1:Function):void{
alert("IKongregateServices", "getPlayerInfo");
_arg1(new Object());
}
}
}//package com.kongregate.as3.client.services
Section 9
//StatServiceShadow (com.kongregate.as3.client.services.StatServiceShadow)
package com.kongregate.as3.client.services {
public class StatServiceShadow extends AbstractShadowService implements IStatServices {
public function submitArray(_arg1:Array):void{
alert("IStatServices", "submitArray", arguments);
}
public function submit(_arg1:String, _arg2:Number):void{
alert("IStatServices", "submitStat", arguments);
}
}
}//package com.kongregate.as3.client.services
Section 10
//UserServiceShadow (com.kongregate.as3.client.services.UserServiceShadow)
package com.kongregate.as3.client.services {
public class UserServiceShadow extends AbstractShadowService implements IUserServices {
public function getName():String{
alert("UserService", "getName");
return ("Guest");
}
public function getPlayerInfo(_arg1:Function):void{
alert("UserService", "getPlayerInfo");
_arg1({isGuest:true, name:"Guest", points:0, level:0, isMode:false, isAdmin:false, isDeveloper:false, avatarPath:"", chatAvatarPath:""});
}
}
}//package com.kongregate.as3.client.services
Section 11
//IAPIBootstrap (com.kongregate.as3.client.IAPIBootstrap)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
public interface IAPIBootstrap {
function init(_arg1:Event=null, _arg2:Stage=null):void;
function hideLog():void;
function showLog(_arg1:int=0):void;
}
}//package com.kongregate.as3.client
Section 12
//KongregateAPI (com.kongregate.as3.client.KongregateAPI)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
import com.kongregate.as3.client.events.*;
import com.kongregate.as3.client.services.*;
import flash.system.*;
import flash.net.*;
import flash.utils.*;
import flash.errors.*;
public class KongregateAPI extends Sprite {
private const VERSION:Number = 1;
private var loader:Loader;
private var loadedDomain:ApplicationDomain;
private static const CLASS_USER:String = "com.kongregate.as3.client.services.UserServices";
private static const CLASS_STATS:String = "com.kongregate.as3.client.services.StatServices";
private static const CLASS_SERVICES:String = "com.kongregate.as3.client.services.KongregateServices";
private static const CLASS_SCORES:String = "com.kongregate.as3.client.services.HighScoreServices";
private static const DEBUG_API_URL:String = "//Linuxpc/kongregate/public/flash/API_AS3.swf";
private static var _connected:Boolean;
private static var kUser:IUserServices;
private static var _loaded:Boolean;
private static var kServices:IKongregateServices;
private static var kScores:IHighScoreServices;
private static var mInstance:KongregateAPI;
private static var kStats:IStatServices;
private static var kAPI:IAPIBootstrap;
public function KongregateAPI(){
if (mInstance != null){
throw (new Error("Warning: KongregateAPI has been added to stage more than once or accessed improperly. Use getInstance() or a stage reference to access."));
};
mInstance = this;
this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
}
public function get loaded():Boolean{
return (_loaded);
}
public function get connected():Boolean{
return (_connected);
}
private function alertConnected(_arg1:TimerEvent=null):void{
var _local2:KongregateEvent;
var _local3:Boolean;
_local2 = new KongregateEvent(KongregateEvent.COMPLETE);
_local3 = this.dispatchEvent(_local2);
}
private function init(_arg1:Event):void{
var _local2:Object;
var _local3:String;
var _local4:URLRequest;
var _local5:LoaderContext;
this.removeEventListener(Event.ADDED_TO_STAGE, init);
_loaded = false;
_connected = false;
_local2 = LoaderInfo(root.loaderInfo).parameters;
_local3 = _local2.api_path;
if (_local3 == null){
trace("Alert: Kongregate API could not be loaded, due to local testing. API will load when the game is uploaded.");
createShadowServices();
return;
};
Security.allowDomain("*.kongregate.com");
Security.allowDomain("kongregatetrunk.com");
_local4 = new URLRequest(_local3);
_local5 = new LoaderContext(false);
_local5.applicationDomain = ApplicationDomain.currentDomain;
_local5.securityDomain = SecurityDomain.currentDomain;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(_local4, _local5);
}
public function get api():IAPIBootstrap{
return (kAPI);
}
private function loadComplete(_arg1:Event):void{
getServices();
}
public function get scores():IHighScoreServices{
return (kScores);
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
throw (new IOError(("API file not found. " + _arg1)));
}
public function get services():IKongregateServices{
return (kServices);
}
public function get stats():IStatServices{
return (kStats);
}
private function createShadowServices():void{
var _local1:Timer;
trace(">>> Kongregate Shadow Services instantiated for local development..");
kServices = new KongregateServiceShadow();
kScores = new HighScoreServiceShadow();
kStats = new StatServiceShadow();
kUser = new UserServiceShadow();
_local1 = new Timer(200, 1);
_local1.addEventListener(TimerEvent.TIMER_COMPLETE, alertConnected);
_local1.start();
_connected = true;
}
public function get user():IUserServices{
return (kUser);
}
private function getServices():void{
var _local1:ApplicationDomain;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local1 = ApplicationDomain.currentDomain;
kAPI = IAPIBootstrap(loader.getChildAt(0));
this.addChild(loader);
_local2 = _local1.getDefinition(CLASS_SERVICES);
trace(_local2);
kServices = _local2.getInstance();
_local3 = _local1.getDefinition(CLASS_SCORES);
kScores = _local3.getInstance();
_local4 = _local1.getDefinition(CLASS_STATS);
kStats = _local4.getInstance();
_local5 = _local1.getDefinition(CLASS_USER);
kUser = _local5.getInstance();
kServices.connect(VERSION);
_loaded = true;
_connected = true;
alertConnected();
}
public static function getInstance():KongregateAPI{
if (!mInstance){
throw (new IllegalOperationError("You must add the Kongregate API component to the stage before attempting to access it."));
};
return (mInstance);
}
}
}//package com.kongregate.as3.client
Section 13
//MochiScores (mochi.MochiScores)
package mochi {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var options = _arg1;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local2:Object;
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
_local2 = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (_arg1 != null){
if (_arg1.error != null){
if (_arg1.error == true){
if (onErrorHandler != null){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi
Section 14
//MochiServices (mochi.MochiServices)
package mochi {
import flash.events.*;
import flash.display.*;
import flash.system.*;
import flash.net.*;
import flash.utils.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
private static var _sendChannel:LocalConnection;
private static var _rcvChannelName:String;
private static var _gatewayURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _startTime:Number;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__mochiservices";
private static var _rcvChannel:LocalConnection;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (_clip != null){
if (_clip._queue != null){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function get childClip():Object{
return (_clip);
}
public static function get id():String{
return (_id);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function getVersion():String{
return ("1.31");
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_listenChannel.close();
_rcvChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
Security.allowDomain("*");
Security.allowInsecureDomain("*");
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
return (_local2);
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
private static function initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion()});
_rcvChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var cb:String;
var cblst:Object;
var method:*;
var methodName:String;
var obj:Object;
var pkg = _arg1;
cb = pkg.callbackID;
cblst = this.client._callbacks[cb];
if (!cblst){
return;
};
method = cblst.callbackMethod;
methodName = "";
obj = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
_rcvChannel.connect(_rcvChannelName);
trace("connected!");
_connecting = false;
_connected = true;
_listenChannel.close();
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
public static function get clip():Object{
return (_container);
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
_rcvChannelName = _arg1;
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var clipname:String;
var f:Function;
var req:URLRequest;
var id = _arg1;
var clip = _arg2;
clipname = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
MochiServices.allowDomains(_gatewayURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
_timer = new Timer(1000, 0);
_startTime = getTimer();
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
f = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
req = new URLRequest(_gatewayURL);
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_rcvChannel = new LocalConnection();
_rcvChannel.allowDomain("*", "localhost");
_rcvChannel.allowInsecureDomain("*", "localhost");
_rcvChannel.client = _clip;
_clip._nextcallbackID = 0;
_clip._callbacks = {};
listen();
return (_clip);
}
public static function bringToTop(_arg1:Event):void{
var e = _arg1;
if (MochiServices.clip != null){
if (MochiServices.childClip != null){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
if ((clip is DisplayObject)){
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var mc:MovieClip;
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
mc = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function connectWait(_arg1:TimerEvent):void{
if ((getTimer() - _startTime) > 10000){
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_timer.stop();
};
}
}
}//package mochi
Section 15
//MainTimeline (Swarm_fla.MainTimeline)
package Swarm_fla {
import flash.display.*;
import mochi.*;
public dynamic class MainTimeline extends MovieClip {
public const C_LEVELS:int = 1;
public var dead:DeadScreen;
public var m:MochiBot;
public var logic:GameLogic;
public var but:ButtonPane;
public var stats:Stats;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6);
}
function frame3(){
if (!logic.menuMode){
logic.startMusic();
};
but.visible = logic.menuMode;
logic.clearAll();
logic.control.visible = !(logic.menuMode);
logic.initAll();
}
function frame6(){
dead = new DeadScreen(logic, this);
this.addChild(dead);
}
function frame5(){
gotoAndPlay(Constants.F_PLAY);
}
function frame1(){
MochiAd.showPreGameAd({clip:root, id:"060342e36ac053bb", res:"550x400"});
m = MochiBot.track(this, "01800122");
MochiServices.connect("060342e36ac053bb", this);
}
function frame4(){
logic.step();
if (logic.won){
logic.sound.stopSounds();
logic.updateStats();
logic.control.visible = false;
gotoAndStop(Constants.F_WON);
};
}
function frame2(){
trace(2);
stats = new Stats();
this.addChild(stats.kong);
logic = new GameLogic(stats, 0);
logic.control.visible = false;
this.addChild(logic.board);
this.addChild(logic.control);
but = new ButtonPane(logic, this);
this.addChild(but);
Key.initialize(stage);
gotoAndPlay(Constants.F_PLAY);
}
}
}//package Swarm_fla
Section 16
//AgainBut (AgainBut)
package {
import flash.display.*;
public dynamic class AgainBut extends SimpleButton {
}
}//package
Section 17
//bang_1 (bang_1)
package {
import flash.media.*;
public dynamic class bang_1 extends Sound {
}
}//package
Section 18
//Bonus (Bonus)
package {
public class Bonus extends GObject {
public var type:int;
public static const T_SLOW = 3;
public static const T_ADD = 0;
public static const T_SPEED = 1;
public static const C_TYPES = 3;
public static const T_POINTS = 2;
public function Bonus(_arg1:GameBoard, _arg2:int){
speed = 40;
this.board = _arg1;
this.type = _arg2;
this.acc = new Vec2f();
alive = true;
if (_arg2 == T_ADD){
this.addChild(new BonusSwarm());
} else {
if (_arg2 == T_SPEED){
this.addChild(new BonusSpeed());
} else {
if (_arg2 == T_POINTS){
this.addChild(new BonusPoints());
} else {
if (_arg2 == T_SLOW){
this.addChild(new BonusSlow());
};
};
};
};
}
override public function update(_arg1:Number){
var _local2:int;
super.update(_arg1);
if ((((((((this.x < 0)) || ((this.y < 0)))) || ((this.x > board.wid)))) || ((this.y > board.hgt)))){
this.alive = false;
};
_local2 = 0;
while (_local2 < board.swarmers.length) {
if (this.hitTestObject(board.swarmers[_local2])){
this.alive = false;
board.logic.useBonus(this);
break;
};
_local2++;
};
}
}
}//package
Section 19
//BonusPoints (BonusPoints)
package {
import flash.display.*;
public dynamic class BonusPoints extends MovieClip {
}
}//package
Section 20
//BonusSlow (BonusSlow)
package {
import flash.display.*;
public dynamic class BonusSlow extends MovieClip {
}
}//package
Section 21
//BonusSpeed (BonusSpeed)
package {
import flash.display.*;
public dynamic class BonusSpeed extends MovieClip {
}
}//package
Section 22
//BonusSwarm (BonusSwarm)
package {
import flash.display.*;
public dynamic class BonusSwarm extends MovieClip {
}
}//package
Section 23
//Bullet (Bullet)
package {
public class Bullet extends GObject {
public function Bullet(_arg1:GameBoard){
life = 1;
speed = 100;
this.board = _arg1;
this.addChild(new BulletImg());
this.acc = new Vec2f();
}
public function addHitEffect(){
board.addEffect(Effect.T_BULLET_HIT, this.loc);
}
override public function update(_arg1:Number){
var _local2:int;
super.update(_arg1);
if (life < 0){
this.alive = false;
};
this.rotation = vel.getAngle();
if ((((((((this.x < 0)) || ((this.y < 0)))) || ((this.x > board.wid)))) || ((this.y > board.hgt)))){
this.alive = false;
};
_local2 = 0;
while (_local2 < board.enemies.length) {
if (this.hits(board.enemies[_local2])){
board.enemies[_local2].health--;
if (board.enemies[_local2].health <= 0){
board.enemies[_local2].addDeathEffect();
if (board.enemies[_local2].alive){
board.logic.addKill();
};
};
this.addHitEffect();
this.alive = false;
break;
};
_local2++;
};
}
}
}//package
Section 24
//BulletHit (BulletHit)
package {
import flash.display.*;
public dynamic class BulletHit extends MovieClip {
public function BulletHit(){
addFrameScript(5, frame6);
}
function frame6(){
this.visible = false;
}
}
}//package
Section 25
//BulletImg (BulletImg)
package {
import flash.display.*;
public dynamic class BulletImg extends MovieClip {
}
}//package
Section 26
//ButtonPane (ButtonPane)
package {
import flash.events.*;
import flash.display.*;
import mochi.*;
public class ButtonPane extends Sprite {
public var cred:CredPane;
public var logic:GameLogic;
public var inst:InstructPane;
public var buttons:Array;
public var lvls:int;
public var score:ScorePane;
public var main:MovieClip;
public var menuP:MenuPane;
public function ButtonPane(_arg1:GameLogic, _arg2:MovieClip, _arg3:int=0){
buttons = new Array();
this.logic = _arg1;
menuP = new MenuPane();
cred = new CredPane();
inst = new InstructPane();
score = new ScorePane();
this.addChild(menuP);
this.addChild(cred);
this.addChild(inst);
this.addChild(score);
menuP.start.addEventListener(MouseEvent.MOUSE_UP, start);
menuP.instruct.addEventListener(MouseEvent.MOUSE_UP, instruct);
menuP.sc.addEventListener(MouseEvent.MOUSE_UP, viewScores);
cred.menu.addEventListener(MouseEvent.MOUSE_UP, menu);
inst.menu.addEventListener(MouseEvent.MOUSE_UP, menu);
score.menu.addEventListener(MouseEvent.MOUSE_UP, menu);
menuP.credBut.addEventListener(MouseEvent.MOUSE_UP, showCredits);
this.inst.visible = false;
this.cred.visible = false;
this.score.visible = false;
this.lvls = _arg3;
this.main = _arg2;
init();
}
public function init(){
}
public function viewScores(_arg1:MouseEvent){
MochiScores.showLeaderboard({boardID:"eae4d554a020ba02"});
}
public function instruct(_arg1:MouseEvent){
menuP.visible = false;
inst.visible = true;
}
public function menu(_arg1:MouseEvent){
menuP.visible = true;
inst.visible = false;
cred.visible = false;
score.visible = false;
}
public function start(_arg1:MouseEvent){
main.gotoAndPlay(Constants.F_START);
logic.menuMode = false;
this.visible = false;
}
public function update(_arg1:Stats){
}
public function showCredits(_arg1:MouseEvent){
menuP.visible = false;
cred.visible = true;
}
}
}//package
Section 27
//Constants (Constants)
package {
public class Constants {
public static const F_START:int = 3;
public static const F_PLAY:int = 4;
public static const C_GAME:int = 4;
public static const C_GAMEID:String = "060342e36ac053bb";
public static const C_DATABASE:String = "askorul_gameScores";
public static const F_MAIN:int = 2;
public static const F_WON:int = 6;
public static function getScoreId(_arg1:String):String{
return (((C_GAMEID + "-") + _arg1));
}
}
}//package
Section 28
//ControlPanel (ControlPanel)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class ControlPanel extends MovieClip {
public var logic:GameLogic;
public var score:TextField;
public var muteBut:SoundBut;
public var pText:TextField;
public var time:TextField;
public var swarmers:TextField;
public function ControlPanel(_arg1:GameLogic){
this.logic = _arg1;
this.x = 300;
this.y = 100;
this.muteBut.addEventListener(MouseEvent.MOUSE_UP, muteSound);
pText.visible = false;
}
public function muteSound(_arg1:MouseEvent){
logic.sound.muteAll();
if (logic.sound.mute){
this.muteBut.gotoAndStop(2);
} else {
this.muteBut.gotoAndStop(1);
};
}
public function update(){
this.time.text = ("Time: " + logic.iTime.toString());
this.score.text = ("Score: " + logic.score.toString());
this.swarmers.text = ("Swarmers: " + logic.board.swarmers.length.toString());
}
}
}//package
Section 29
//CredBut (CredBut)
package {
import flash.display.*;
public dynamic class CredBut extends SimpleButton {
}
}//package
Section 30
//CredPane (CredPane)
package {
import flash.display.*;
public dynamic class CredPane extends MovieClip {
public var menu:MenuBut;
}
}//package
Section 31
//DeadScreen (DeadScreen)
package {
import flash.events.*;
import flash.display.*;
import mochi.*;
import flash.text.*;
public class DeadScreen extends MovieClip {
public var submit:SubmitBut;
public var menu:MenuBut;
public var logic:GameLogic;
public var sb:scoreBox;
public var score:TextField;
public var again:AgainBut;
public var main:MovieClip;
public var time:TextField;
public var kills:TextField;
public var nameTxt:TextField;
public function DeadScreen(_arg1:GameLogic, _arg2:MovieClip){
this.time.text = _arg1.iTime.toString();
this.score.text = _arg1.score.toString();
this.kills.text = _arg1.kills.toString();
this.logic = _arg1;
this.main = _arg2;
menu.addEventListener(MouseEvent.MOUSE_UP, toMenu);
again.addEventListener(MouseEvent.MOUSE_UP, playAgain);
submit.addEventListener(MouseEvent.MOUSE_UP, submitScore);
}
public function myOnClose(){
}
public function submitScore(_arg1:MouseEvent){
logic.stats.setStat(main, logic.score, logic.iTime, logic.kills, sb.username.text);
MochiScores.showLeaderboard({boardID:"eae4d554a020ba02", score:logic.score, name:sb.username.text, onClose:myOnClose});
submit.visible = false;
nameTxt.visible = false;
sb.visible = false;
}
public function toMenu(_arg1:MouseEvent){
logic.menuMode = true;
main.gotoAndPlay(Constants.F_START);
this.visible = false;
}
public function playAgain(_arg1:MouseEvent){
logic.menuMode = false;
main.gotoAndPlay(Constants.F_START);
this.visible = false;
}
}
}//package
Section 32
//Effect (Effect)
package {
import flash.display.*;
public class Effect extends GObject {
public var type:int;
public var mc:MovieClip;
public static const T_BULLET_HIT:int = 1;
public static const T_ENEMY_DEAD:int = 0;
public function Effect(_arg1:int){
this.type = _arg1;
switch (_arg1){
case T_ENEMY_DEAD:
mc = new EnemyImgDead();
break;
case T_BULLET_HIT:
mc = new BulletHit();
break;
};
this.addChild(mc);
}
override public function update(_arg1:Number){
if (!mc.visible){
this.alive = false;
};
}
}
}//package
Section 33
//Enemy (Enemy)
package {
public class Enemy extends GObject {
public var canKill:Boolean;
public var health:int;
public var skimTime:Number;
public var type:int;
public static const C_TYPES = 4;
public static const T_CHASER = 4;
public static const T_INVINCI = 3;
public static const T_SPLITTER = 1;
public static const T_SKIMMER = 2;
public static const T_SPLIT = 25;
public static const C_OUTDIST = 40;
public static const T_SPAWNER = 5;
public static const T_PLAIN = 0;
public function Enemy(_arg1:GameBoard, _arg2:int){
speed = 50;
health = 5;
skimTime = 3;
canKill = true;
this.type = _arg2;
this.board = _arg1;
this.acc = new Vec2f();
alive = true;
if (this.type == T_PLAIN){
this.addChild(new EnemyImg());
} else {
if (this.type == T_SPLITTER){
this.addChild(new EnemySplitter());
this.life = 3;
} else {
if (this.type == T_SPLIT){
this.health = 2;
this.addChild(new EnemySplit());
} else {
if (this.type == T_SKIMMER){
this.addChild(new EnemySkimmer());
speed = 75;
} else {
if (this.type == T_INVINCI){
this.addChild(new EnemyInv());
this.health = 800;
} else {
if (this.type == T_CHASER){
this.addChild(new EnemyChaser());
this.health = 3;
this.speed = 30;
} else {
if (this.type == T_SPAWNER){
this.addChild(new EnemySpawner());
skimTime = 4;
canKill = false;
};
};
};
};
};
};
};
this.setBitmapData();
}
public function skim(){
var _local1:int;
_local1 = Math.round((Math.random() * 3));
this.skimTime = 3;
if (_local1 == 0){
this.setVel(new Vec2f(0, 1));
} else {
if (_local1 == 1){
this.setVel(new Vec2f(0, -1));
} else {
if (_local1 == 2){
this.setVel(new Vec2f(1, 0));
} else {
if (_local1 == 3){
this.setVel(new Vec2f(-1, 0));
};
};
};
};
this.acc = vel.mult(-0.3);
}
public function spawn(){
}
public function findClosest():Swarmer{
var _local1:Swarmer;
var _local2:int;
var _local3:int;
_local1 = null;
_local2 = 4000;
_local3 = 0;
while (_local3 < board.swarmers.length) {
if (this.dist(board.swarmers[_local3]) < _local2){
_local2 = this.dist(board.swarmers[_local3]);
_local1 = board.swarmers[_local3];
};
_local3++;
};
return (_local1);
}
public function addSplits(){
var _local1:int;
var _local2:Enemy;
_local1 = 0;
while (_local1 < 4) {
_local2 = new Enemy(board, T_SPLIT);
if (_local1 == 0){
_local2.setVel(new Vec2f(1, 1));
} else {
if (_local1 == 1){
_local2.setVel(new Vec2f(1, -1));
} else {
if (_local1 == 2){
_local2.setVel(new Vec2f(-1, -1));
} else {
if (_local1 == 3){
_local2.setVel(new Vec2f(-1, 1));
};
};
};
};
_local2.setLoc(this.loc.copy());
board.enemies.push(_local2);
board.addChild(_local2);
_local1++;
};
}
override public function update(_arg1:Number){
var _local2:int;
var _local3:Swarmer;
super.update(_arg1);
if ((((type == T_SKIMMER)) || (T_SPAWNER))){
skimTime = (skimTime - _arg1);
if ((((skimTime <= 0)) && ((type == T_SKIMMER)))){
skim();
} else {
if ((((skimTime <= 0)) && ((type == T_SPAWNER)))){
spawn();
};
};
};
if (this.type == T_CHASER){
_local3 = findClosest();
if (_local3 != null){
this.setVel(_local3.loc.minus(this.loc).normalise());
};
};
this.rotation = vel.getAngle();
if (((this.alive) && ((life <= 0)))){
alive = false;
addSplits();
};
if (health <= 0){
this.alive = false;
};
if ((((((((this.x < -(C_OUTDIST))) || ((this.y < -(C_OUTDIST))))) || ((this.x > (board.wid + C_OUTDIST))))) || ((this.y > (board.hgt + C_OUTDIST))))){
this.alive = false;
};
_local2 = 0;
while (_local2 < board.swarmers.length) {
if (this.hits(board.swarmers[_local2])){
board.logic.sound.playSoundClass(new sound4());
board.swarmers[_local2].alive = false;
};
_local2++;
};
}
public function addDeathEffect(){
board.addEffect(Effect.T_ENEMY_DEAD, this.loc);
}
}
}//package
Section 34
//EnemyChaser (EnemyChaser)
package {
import flash.display.*;
public dynamic class EnemyChaser extends MovieClip {
}
}//package
Section 35
//EnemyImg (EnemyImg)
package {
import flash.display.*;
public dynamic class EnemyImg extends MovieClip {
}
}//package
Section 36
//EnemyImgDead (EnemyImgDead)
package {
import flash.display.*;
public dynamic class EnemyImgDead extends MovieClip {
public function EnemyImgDead(){
addFrameScript(9, frame10);
}
function frame10(){
this.visible = false;
}
}
}//package
Section 37
//EnemyInv (EnemyInv)
package {
import flash.display.*;
public dynamic class EnemyInv extends MovieClip {
}
}//package
Section 38
//EnemySkimmer (EnemySkimmer)
package {
import flash.display.*;
public dynamic class EnemySkimmer extends MovieClip {
}
}//package
Section 39
//EnemySpawner (EnemySpawner)
package {
import flash.display.*;
public dynamic class EnemySpawner extends MovieClip {
}
}//package
Section 40
//EnemySplit (EnemySplit)
package {
import flash.display.*;
public dynamic class EnemySplit extends MovieClip {
}
}//package
Section 41
//EnemySplitter (EnemySplitter)
package {
import flash.display.*;
public dynamic class EnemySplitter extends MovieClip {
}
}//package
Section 42
//GameBoard (GameBoard)
package {
import flash.display.*;
public class GameBoard extends Sprite {
public var effects:Array;
public var bonuses:Array;
public var enemies:Array;
public var logic:GameLogic;
public var hgt:int;
public var bullets:Array;
public var wid;
public var player:Player;
public var swarmers:Array;
public function GameBoard(_arg1:GameLogic){
player = new Player(this);
this.logic = _arg1;
this.addChild(player);
wid = 550;
hgt = 400;
initAll();
}
public function removeObject(_arg1:int, _arg2:Array){
removeChild(_arg2[_arg1]);
delete _arg2[_arg1];
_arg2.splice(_arg1, 1);
}
public function addBullet(_arg1:Swarmer){
var _local2:Bullet;
_local2 = new Bullet(this);
_local2.setLoc(_arg1.loc.copy());
_local2.setVel(_arg1.vel.copy().normalise());
_local2.vel.plusE(_arg1.vel);
bullets.push(_local2);
this.addChild(_local2);
}
public function clearArray(_arg1:Array){
var _local2:int;
_local2 = 0;
while (_local2 < _arg1.length) {
this.removeChild(_arg1[_local2]);
delete _arg1[_local2];
_local2++;
};
}
public function clearAll(){
clearArray(enemies);
clearArray(bonuses);
clearArray(swarmers);
clearArray(bullets);
clearArray(effects);
}
public function addSwarmer(){
var _local1:Swarmer;
_local1 = new Swarmer(this, player);
swarmers.push(_local1);
this.addChild(_local1);
logic.sound.playSoundClass(new sound21());
}
public function initAll(){
swarmers = new Array();
enemies = new Array();
bonuses = new Array();
bullets = new Array();
effects = new Array();
}
public function addEffect(_arg1:int, _arg2:Vec2f){
var _local3:Effect;
_local3 = new Effect(_arg1);
_local3.setLoc(_arg2);
this.addChild(_local3);
effects.push(_local3);
}
}
}//package
Section 43
//GameLogic (GameLogic)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class GameLogic extends Sprite {
public const C_EDIVISOR = 19;
public const C_BONUSRATE = 15;
public const C_STARTSWARM = 10;
public const C_KILLSCORE = 10;
public var canWin:Boolean;
public var mute:Boolean;
public var sound:SoundPlayer;
public var paused:Boolean;
public var enemyGrowRate:Number;
public var deltMultGrow:Number;
public var control:ControlPanel;
public var toBonus:Number;
public var lastTime:Number;
public var level:int;
public var won:Boolean;
public var enemyRate:Number;
public var stats:Stats;
public var score:int;
public var bonusRate:Number;
public var toMenu:Boolean;
public var deltMult:Number;
public var menuMode:Boolean;
public var delt:Number;
public var time:Number;
public var kills:int;
public var iTime:int;
public var bonusGrowRate:Number;
public var toEnemy:Number;
public var board:GameBoard;
public function GameLogic(_arg1:Stats, _arg2:int){
this.stats = _arg1;
this.sound = new SoundPlayer();
this.level = _arg2;
this.menuMode = true;
control = new ControlPanel(this);
board = new GameBoard(this);
board.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
board.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
initAll();
}
public function clearAll(){
board.clearAll();
}
public function mouseUp(_arg1:MouseEvent){
board.player.order = Player.C_DRAW;
}
public function checkKeys(){
if (Key.isDown(80)){
paused = !(paused);
control.pText.visible = paused;
Key.removeKeyDown(80);
};
if (Key.isDown(77)){
control.muteSound(null);
Key.removeKeyDown(77);
};
}
public function startMusic(){
sound.loopSoundClass(new playground());
}
public function loopArray(_arg1:Array){
var _local2:int;
_local2 = 0;
while (_local2 < _arg1.length) {
_arg1[_local2].update(delt);
if (!_arg1[_local2].alive){
board.removeObject(_local2, _arg1);
};
_local2++;
};
}
public function addObject(_arg1:GObject, _arg2:Boolean){
var _local3:Boolean;
var _local4:Boolean;
var _local5:*;
var _local6:Vec2f;
_local3 = (Math.random() > 0.5);
_local4 = (Math.random() > 0.5);
if (_local3){
_local5 = new Vec2f((_local4) ? board.wid : 0, (Math.random() * board.hgt));
_local6 = new Vec2f((_local4) ? -1 : 1, 0);
} else {
_local5 = new Vec2f((Math.random() * board.wid), (_local4) ? board.hgt : 0);
_local6 = new Vec2f(0, (_local4) ? -1 : 1);
};
_local6.multE(deltMult);
_arg1.loc = _local5;
_arg1.setVel(_local6);
if (_arg2){
board.bonuses.push(_arg1);
} else {
board.enemies.push(_arg1);
};
board.addChild(_arg1);
}
public function updateStats(){
}
public function initAll(){
var _local1:int;
board.initAll();
this.time = 0;
this.iTime = 0;
this.score = 0;
this.kills = 0;
enemyRate = 1.5;
toEnemy = enemyRate;
bonusRate = C_BONUSRATE;
toBonus = bonusRate;
deltMult = 1;
deltMultGrow = 0.01;
board.player.x = 200;
board.player.y = 200;
paused = false;
won = false;
_local1 = 0;
while (_local1 < C_STARTSWARM) {
board.addSwarmer();
_local1++;
};
}
public function useBonus(_arg1:Bonus){
var _local2:int;
if (_arg1.type == Bonus.T_ADD){
_local2 = 0;
while (_local2 < 5) {
board.addSwarmer();
sound.playSoundClass(new sound21());
_local2++;
};
} else {
if (_arg1.type == Bonus.T_SPEED){
board.player.speedBonus = (board.player.speedBonus + 0.1);
board.player.accBonus = (board.player.accBonus * 1.25);
sound.playSoundClass(new sound10());
} else {
if (_arg1.type == Bonus.T_POINTS){
score = (score + (time * 5));
} else {
if (_arg1.type == Bonus.T_SLOW){
deltMult = (deltMult - (deltMultGrow * 40));
};
};
};
};
}
public function setDelta(){
delt = ((getTimer() - lastTime) / 1000);
if ((((delt > 1)) || (isNaN(delt)))){
delt = 0;
};
lastTime = getTimer();
}
public function addKill(){
kills++;
this.score = (this.score + C_KILLSCORE);
sound.playSoundClass(new bang_1());
}
public function getEnemyType():int{
return (Math.round((Math.random() * Math.min(Enemy.C_TYPES, (iTime / C_EDIVISOR)))));
}
public function update(){
time = (time + delt);
if (!menuMode){
if ((time - iTime) >= 1){
iTime = time;
score = (score + board.swarmers.length);
if (deltMult < 2){
deltMult = (deltMult + deltMultGrow);
};
};
toEnemy = (toEnemy - (delt * (deltMult * deltMult)));
if (toEnemy <= 0){
toEnemy = (enemyRate + ((Math.random() - 0.5) * enemyRate));
addObject(new Enemy(board, getEnemyType()), false);
};
toBonus = (toBonus - (delt * deltMult));
if (toBonus <= 0){
toBonus = (bonusRate + ((Math.random() - 0.5) * bonusRate));
addObject(new Bonus(board, Math.round((Math.random() * Bonus.C_TYPES))), true);
};
};
loopArray(board.swarmers);
loopArray(board.bullets);
loopArray(board.enemies);
loopArray(board.bonuses);
loopArray(board.effects);
if (board.swarmers.length == 0){
won = true;
};
}
public function step(){
setDelta();
if (delt == 0){
return;
};
checkKeys();
if (paused){
return;
};
control.update();
board.player.update(delt);
update();
}
public function mouseDown(_arg1:MouseEvent){
board.player.order = Player.C_PUSH;
}
}
}//package
Section 44
//GObject (GObject)
package {
import flash.display.*;
public class GObject extends MovieClip {
public var life:Number;
public var speed:Number;
public var loc:Vec2f;
public var acc:Vec2f;
public var vel:Vec2f;
public var bmData:BitmapData;
public var alive:Boolean;
public var board:GameBoard;
public function GObject(){
this.alive = true;
this.acc = new Vec2f(0, 0);
this.vel = new Vec2f(0, 0);
life = 1000;
}
public function setBitmapData(){
bmData = new BitmapData(this.width, this.height);
}
public function dist(_arg1:GObject){
return (this.loc.dist(_arg1.loc));
}
public function hits(_arg1:GObject):Boolean{
if (!this.hitTestObject(_arg1)){
return (false);
};
return (true);
}
public function update(_arg1:Number){
this.vel.plusE(acc.mult(_arg1));
this.loc.plusE(vel.mult(_arg1));
this.x = loc.x;
this.y = loc.y;
life = (life - _arg1);
}
public function setLoc(_arg1:Vec2f){
this.loc = _arg1;
this.x = loc.x;
this.y = loc.y;
}
public function setVel(_arg1:Vec2f){
this.vel = _arg1.multE((speed + (Math.random() * speed)));
}
}
}//package
Section 45
//Impact (Impact)
package {
import flash.text.*;
public dynamic class Impact extends Font {
}
}//package
Section 46
//Inkpen (Inkpen)
package {
import flash.text.*;
public dynamic class Inkpen extends Font {
}
}//package
Section 47
//InstructBut (InstructBut)
package {
import flash.display.*;
public dynamic class InstructBut extends SimpleButton {
}
}//package
Section 48
//InstructPane (InstructPane)
package {
import flash.display.*;
public dynamic class InstructPane extends MovieClip {
public var menu:MenuBut;
}
}//package
Section 49
//Key (Key)
package {
import flash.events.*;
import flash.display.*;
public class Key {
private static var initialized:Boolean = false;
private static var keysDown:Object = new Object();
public static function initialize(_arg1:Stage){
if (!initialized){
_arg1.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
_arg1.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
_arg1.addEventListener(Event.DEACTIVATE, clearKeys);
initialized = true;
};
}
public static function clearKeys(_arg1:Event):void{
keysDown = new Object();
}
public static function isDown(_arg1:uint):Boolean{
if (!initialized){
throw (new Error("Key class has yet been initialized."));
};
return (Boolean((_arg1 in keysDown)));
}
private static function keyPressed(_arg1:KeyboardEvent):void{
keysDown[_arg1.keyCode] = true;
}
private static function keyReleased(_arg1:KeyboardEvent):void{
if ((_arg1.keyCode in keysDown)){
delete keysDown[_arg1.keyCode];
};
}
public static function removeKeyDown(_arg1:uint):void{
if ((_arg1 in keysDown)){
delete keysDown[_arg1];
};
}
}
}//package
Section 50
//LinkButton (LinkButton)
package {
import flash.display.*;
public dynamic class LinkButton extends SimpleButton {
}
}//package
Section 51
//LoadBut (LoadBut)
package {
import flash.display.*;
public dynamic class LoadBut extends SimpleButton {
}
}//package
Section 52
//LoadCircle (LoadCircle)
package {
import flash.display.*;
public dynamic class LoadCircle extends MovieClip {
}
}//package
Section 53
//MenuBut (MenuBut)
package {
import flash.display.*;
public dynamic class MenuBut extends SimpleButton {
}
}//package
Section 54
//MenuPane (MenuPane)
package {
import flash.display.*;
public dynamic class MenuPane extends MovieClip {
public var sc:ScoreBut;
public var start:StartBut;
public var credBut:CredBut;
public var instruct:InstructBut;
}
}//package
Section 55
//MochiAd (MochiAd)
package {
import flash.events.*;
import flash.display.*;
import flash.system.*;
import flash.net.*;
import flash.utils.*;
public class MochiAd {
public static function getVersion():String{
return ("2.3");
}
public static function showTimedAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(_arg1);
}
public static function _allowDomains(_arg1:String):String{
var _local2:String;
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function 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 f:Function;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
DEFAULTS = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
wh = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
};
lv = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
f = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
mc._mochiad_ctr_failed = true;
};
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function sendHighScore(_arg1:Object, _arg2:Object, _arg3:Object=null):Boolean{
var _local4:MovieClip;
_local4 = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local4.doSend(["sendHighScore", _arg1], _arg2, _arg3);
return (true);
}
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 _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
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 unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (!_arg1._mochiad){
return (false);
};
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");
}};
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.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);
};
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 = _local1.loaderInfo.bytesTotal;
if ((((_local4 > 0)) || (("number" == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.parent._mochiad_ctr_failed){
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 _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 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 _loadCommunicator(_arg1:Object):MovieClip{
var DEFAULTS:Object;
var clip:Object;
var clipname:String;
var server:String;
var depth:Number;
var mc:MovieClip;
var lv:URLVariables;
var k:String;
var lc:LocalConnection;
var name:String;
var req:URLRequest;
var loader:Loader;
var options = _arg1;
DEFAULTS = {com_server:"http://x.mochiads.com/com/1/", method:"loadCommunicator", depth:10337, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
clipname = ("_mochiad_com_" + options.id);
if (!MochiAd._isNetworkAvailable()){
return (null);
};
if (clip[clipname]){
return (clip[clipname]);
};
server = (options.com_server + options.id);
MochiAd._allowDomains(server);
delete options.id;
delete options.com_server;
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, clipname, depth);
lv = new URLVariables();
for (k in options) {
lv[k] = options[k];
};
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.name = name;
mc.lc = lc;
lv.lc = name;
mc._id = 0;
mc._queue = [];
mc.rpcResult = function (_arg1:Object):void{
var _local3:Array;
var _local4:Array;
var _local5:Number;
var _local6:Object;
var _local7:Object;
_arg1 = parseInt(_arg1.toString());
_local3 = mc._callbacks[_arg1];
if (typeof(_local3) == "undefined"){
return;
};
delete mc._callbacks[_arg1];
_local4 = [];
_local5 = 2;
while (_local5 < _local3.length) {
_local4.push(_local3[_local5]);
_local5++;
};
_local5 = 1;
while (_local5 < arguments.length) {
_local4.push(arguments[_local5]);
_local5++;
};
_local6 = _local3[1];
_local7 = _local3[0];
if (((_local7) && ((typeof(_local6) == "string")))){
_local6 = _local7[_local6];
};
if (typeof(_local6) == "function"){
_local6.apply(_local7, _local4);
};
};
mc._didConnect = function (_arg1:String):void{
var _local2:Array;
var _local3:Function;
var _local4:Number;
var _local5:Array;
mc._endpoint = _arg1;
_local2 = mc._queue;
delete mc._queue;
_local3 = mc.doSend;
_local4 = 0;
while (_local4 < _local2.length) {
_local5 = _local2[_local4];
_local3.apply(this, _local5);
_local4++;
};
};
mc.doSend = function (_arg1:Array, _arg2:Object, _arg3:Object):void{
var _local5:Number;
var _local6:LocalConnection;
var _local7:Array;
var _local8:Number;
if (mc._endpoint == null){
_local7 = [];
_local8 = 0;
while (_local8 < arguments.length) {
_local7.push(arguments[_local8]);
_local8++;
};
mc._queue.push(_local7);
return;
};
mc._id = (mc._id + 1);
_local5 = mc._id;
mc._callbacks[_local5] = [_arg2, ((_arg3) || (_arg2))];
_local6 = new LocalConnection();
_local6.send(mc._endpoint, "rpc", _local5, _arg1);
};
mc._callbacks = {};
mc._callbacks[0] = [mc, "_didConnect"];
lv.st = getTimer();
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader = new Loader();
loader.load(req);
mc.addChild(loader);
mc._mochiad_com = loader;
return (mc);
}
public static function showPreGameAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var bar:MovieClip;
var bar_color:Number;
var bar_background:Number;
var bar_outline:Number;
var backing_mc:MovieClip;
var backing:Object;
var inside_mc:MovieClip;
var inside:Object;
var outline_mc:MovieClip;
var outline:Object;
var complete:Boolean;
var unloaded:Boolean;
var f:Function;
var r:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, 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");
}};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("5cc6f7dfb67f2f08341c831480f7c2a7".length == 0){
options.ad_started();
options.ad_finished();
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);
bar.x = 10;
bar.y = (h - 20);
bar_color = options.color;
delete options.color;
bar_background = options.background;
delete options.background;
bar_outline = options.outline;
delete options.outline;
backing_mc = createEmptyMovieClip(bar, "_outline", 1);
backing = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
inside_mc = createEmptyMovieClip(bar, "_inside", 2);
inside = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
outline_mc = createEmptyMovieClip(bar, "_outline", 3);
outline = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
f = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.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;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Object;
var _local3:Number;
var _local4:Boolean;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Object;
var _local10:Number;
var _local11:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
_local1 = this.parent.parent.root;
_local2 = this.parent._mochiad_ctr;
_local3 = (getTimer() - this.started);
_local4 = false;
_local5 = _local1.loaderInfo.bytesTotal;
_local6 = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
_local7 = ((100 * _local6) / _local5);
_local8 = ((100 * _local3) / chk.ad_msec);
_local9 = this._mochiad_bar._inside;
_local10 = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
if (!chk.showing){
_local11 = _local2.loaderInfo.bytesTotal;
if ((((_local11 > 0)) || (("number" == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local3 > chk.ad_timeout){
options.ad_failed();
_local4 = true;
};
};
};
if (this.parent._mochiad_ctr_failed){
options.ad_failed();
_local4 = true;
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(_arg1);
}
public static function fetchHighScores(_arg1:Object, _arg2:Object, _arg3:Object=null):Boolean{
var _local4:MovieClip;
_local4 = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local4.doSend(["fetchHighScores", _arg1], _arg2, _arg3);
return (true);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var f:Function;
var mc = _arg1;
f = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package
Section 56
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.system.*;
import flash.net.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
var _local3:MochiBot;
var _local4:String;
var _local5:URLVariables;
var _local6:String;
var _local7:URLRequest;
var _local8:Loader;
if (Security.sandboxType == "localWithFile"){
return (null);
};
_local3 = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
_local4 = "http://core.mochibot.com/my/core.swf";
_local5 = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
_local6 = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
_local7 = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
_local8 = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 57
//MooJooStats (MooJooStats)
package {
import flash.events.*;
import flash.net.*;
public class MooJooStats {
public static const C_SITE:String = "..";
public static const C_ADDSCORE:String = "/phpUtils/addScore.php";
public static const C_ADDPLAY:String = "/phpUtils/addPlayed.php";
public static const C_GETSCORES:String = "/phpUtils/getScores.php";
public static var scoreString:String;
public static function handleResults(_arg1:Event){
var _local2:String;
_local2 = (_arg1.target.data as String);
scoreString = _local2;
trace(("response:" + _local2));
}
public static function getScores(_arg1:String){
var request:URLRequest;
var loader:URLLoader;
var mode = _arg1;
try {
request = new URLRequest((((((C_SITE + C_GETSCORES) + "?game=") + Constants.C_GAME) + "&mode=") + mode));
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handleResults);
loader.load(request);
} catch(e:Error) {
trace(e);
};
}
public static function submit(_arg1:Number, _arg2:String, _arg3:String){
var request:URLRequest;
var loader:URLLoader;
var variables:URLVariables;
var s = _arg1;
var t = _arg2;
var n = _arg3;
try {
request = new URLRequest((C_SITE + C_ADDSCORE));
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
request.method = URLRequestMethod.POST;
variables = new URLVariables();
variables.game = Constants.C_GAME;
variables.score = s;
variables.mode = t;
variables.name = n.replace("\n", "").replace("@", "");
if (variables.name == ""){
return;
};
request.data = variables;
loader.addEventListener(Event.COMPLETE, handleResults);
loader.load(request);
} catch(e:Error) {
trace(e);
};
}
public static function addPlay(_arg1:int){
var request:URLRequest;
var loader:URLLoader;
var time = _arg1;
try {
request = new URLRequest((((((C_SITE + C_ADDPLAY) + "?game=") + Constants.C_GAME) + "&time=") + time));
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handleResults);
loader.load(request);
} catch(e:Error) {
trace(e);
};
}
}
}//package
Section 58
//Player (Player)
package {
import flash.display.*;
public class Player extends MovieClip {
public var accBonus:Number;
public var speedBonus:Number;
public var order:int;
public var loc:Vec2f;
public var maxSwarm:int;
public var timeLeft:Number;
public var cirRad:int;
public var rate:Number;
public var board:GameBoard;
public static const C_DRAW:int = 1;
public static const C_PUSH:int = 2;
public static const C_CIRCLE:int = 3;
public function Player(_arg1:GameBoard){
rate = 10;
speedBonus = 1;
accBonus = 1;
timeLeft = rate;
maxSwarm = 200;
cirRad = 50;
this.board = _arg1;
order = C_DRAW;
loc = new Vec2f();
}
public function update(_arg1:Number){
timeLeft = (timeLeft - _arg1);
if ((((timeLeft <= 0)) && (!(board.logic.menuMode)))){
board.addSwarmer();
timeLeft = rate;
};
this.x = stage.mouseX;
this.y = stage.mouseY;
loc.x = this.x;
loc.y = this.y;
}
}
}//package
Section 59
//playground (playground)
package {
import flash.media.*;
public dynamic class playground extends Sound {
}
}//package
Section 60
//PreLoader (PreLoader)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.net.*;
public class PreLoader extends MovieClip {
public var link:LinkButton;
public var pAdd:Number;
public var loadText:TextField;
public var numCircles:int;
public var main:MovieClip;
public var loadBut:LoadBut;
public var totalCircles:int;
public function PreLoader(_arg1:MovieClip){
this.main = _arg1;
this.x = 275;
this.y = 200;
totalCircles = 16;
numCircles = 1;
pAdd = (1 / totalCircles);
_arg1.loaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress);
_arg1.loaderInfo.addEventListener(Event.COMPLETE, fileLoaded);
this.loadBut.visible = false;
loadBut.addEventListener(MouseEvent.MOUSE_UP, startGame);
link.addEventListener(MouseEvent.MOUSE_UP, visitSite);
}
public function visitSite(_arg1:MouseEvent){
navigateToURL(new URLRequest("http://www.moojoogames.com"));
}
function checkProgress(_arg1:ProgressEvent):void{
var _local2:int;
var _local3:LoadCircle;
var _local4:Vec2f;
_local2 = (_arg1.currentTarget.bytesLoaded / _arg1.currentTarget.bytesTotal);
while ((((_local2 >= (numCircles * pAdd))) && ((_local2 <= 1)))) {
numCircles++;
_local3 = new LoadCircle();
_local4 = Vec2f.FromAngle((((numCircles * pAdd) * 2) * Math.PI), 120);
_local3.x = _local4.x;
_local3.y = _local4.y;
this.addChild(_local3);
};
}
public function startGame(_arg1:MouseEvent){
main.removeChild(this);
main.gotoAndPlay(Constants.F_MAIN);
}
function fileLoaded(_arg1:Event):void{
this.loadBut.visible = true;
this.loadText.visible = false;
}
}
}//package
Section 61
//scoreBox (scoreBox)
package {
import flash.display.*;
import flash.text.*;
public dynamic class scoreBox extends MovieClip {
public var username:TextField;
}
}//package
Section 62
//ScoreBut (ScoreBut)
package {
import flash.display.*;
public dynamic class ScoreBut extends SimpleButton {
}
}//package
Section 63
//ScorePane (ScorePane)
package {
import flash.display.*;
public class ScorePane extends MovieClip {
public var menu:MenuBut;
public function loadScores(){
var _local1:String;
MooJooStats.getScores("SCORE");
_local1 = MooJooStats.scoreString;
}
}
}//package
Section 64
//sound10 (sound10)
package {
import flash.media.*;
public dynamic class sound10 extends Sound {
}
}//package
Section 65
//sound21 (sound21)
package {
import flash.media.*;
public dynamic class sound21 extends Sound {
}
}//package
Section 66
//sound4 (sound4)
package {
import flash.media.*;
public dynamic class sound4 extends Sound {
}
}//package
Section 67
//SoundBut (SoundBut)
package {
import flash.display.*;
public dynamic class SoundBut extends MovieClip {
public function SoundBut(){
addFrameScript(0, frame1);
}
function frame1(){
this.mouseChildren = false;
this.buttonMode = true;
stop();
}
}
}//package
Section 68
//SoundPlayer (SoundPlayer)
package {
import flash.media.*;
import flash.net.*;
public class SoundPlayer {
public var loops:Array;
public var mute:Boolean;
public function SoundPlayer(){
loops = new Array();
mute = false;
}
public function stopSounds(){
var _local1:int;
_local1 = 0;
while (_local1 < loops.length) {
loops[_local1].stop();
_local1++;
};
}
public function muteAll(){
var _local1:SoundTransform;
var _local2:int;
mute = !(mute);
_local1 = new SoundTransform();
_local1.volume = (mute) ? 0 : 1;
_local2 = 0;
while (_local2 < loops.length) {
loops[_local2].soundTransform = _local1;
_local2++;
};
}
public function loopSound(_arg1:String){
var _local2:SoundChannel;
_local2 = new Sound(new URLRequest(_arg1)).play(0, 10000);
loops.push(_local2);
}
public function loopSoundClass(_arg1:Sound){
var _local2:SoundChannel;
var _local3:SoundTransform;
_local2 = _arg1.play(0, 10000);
loops.push(_local2);
_local3 = new SoundTransform();
_local3.volume = (mute) ? 0 : 1;
_local2.soundTransform = _local3;
}
public function playSoundClass(_arg1:Sound){
if (!mute){
_arg1.play();
};
}
}
}//package
Section 69
//StartBut (StartBut)
package {
import flash.display.*;
public dynamic class StartBut extends SimpleButton {
}
}//package
Section 70
//Stats (Stats)
package {
import flash.display.*;
import com.kongregate.as3.client.events.*;
import com.kongregate.as3.client.*;
public class Stats {
public var time:int;
public var score:int;
public var kong:KongregateAPI;
public var apiLoaded:Boolean;
public function Stats(){
score = 0;
time = 0;
apiLoaded = false;
kong = new KongregateAPI();
kong.addEventListener(KongregateEvent.COMPLETE, apiDone);
}
public function setStat(_arg1:MovieClip, _arg2:int, _arg3:int, _arg4:int, _arg5:String=""){
this.score = Math.max(_arg2, this.score);
this.time = Math.max(_arg3, this.time);
MochiAd.sendHighScore({id:Constants.getScoreId("SCORE"), name:_arg5, score:_arg2, clip:_arg1}, null);
}
public function apiDone(_arg1:KongregateEvent):void{
apiLoaded = true;
}
}
}//package
Section 71
//SubmitBut (SubmitBut)
package {
import flash.display.*;
public dynamic class SubmitBut extends SimpleButton {
}
}//package
Section 72
//Swarmer (Swarmer)
package {
public class Swarmer extends GObject {
public var offsetY:Number;
public var offsetX;
public var fireRate:Number;
public var maxAcc:Number;
public var maxVel:Number;
public var tillFire:Number;
public var player:Player;
public function Swarmer(_arg1:GameBoard, _arg2:Player){
this.fireRate = (0.5 + (Math.random() * 0.2));
this.tillFire = fireRate;
maxAcc = (200 + (Math.random() * 100));
maxVel = (100 + (Math.random() * 70));
offsetX = ((Math.random() - 0.5) / 4);
offsetY = ((Math.random() - 0.5) / 4);
this.loc = new Vec2f(_arg2.x, _arg2.y);
this.x = _arg2.x;
this.y = _arg2.y;
this.vel = Vec2f.rand().multE(maxVel);
this.acc = new Vec2f();
this.player = _arg2;
this.board = _arg1;
this.alive = true;
this.addChild(new SwarmerImg());
}
public function ordCircle(){
var _local1:Number;
var _local2:Number;
var _local3:Vec2f;
_local1 = this.loc.minus(player.loc).getR();
if (_local1 < player.cirRad){
ordPush();
return;
};
_local2 = Math.acos((player.cirRad / _local1));
_local3 = Vec2f.FromAngle(_local2, 1);
if (this.loc.plus(_local3).dist(player.loc) > loc.dist(player.loc)){
_local3.multE(-1);
};
if (((((isNaN(_local2)) || (isNaN(_local3.x)))) || (isNaN(_local3.y)))){
_local2 = 0;
};
this.acc = _local3.multE(maxAcc);
}
public function ordPush(){
var _local1:Vec2f;
_local1 = loc.minus(player.loc).normalise();
_local1.x = (_local1.x + offsetX);
_local1.y = (_local1.y + offsetY);
this.acc = _local1.multE((maxAcc * player.accBonus));
}
public function ordDraw(){
var _local1:Vec2f;
_local1 = player.loc.minus(this.loc).normalise();
_local1.x = (_local1.x + offsetX);
_local1.y = (_local1.y + offsetY);
this.acc = _local1.multE((maxAcc * player.accBonus));
}
override public function update(_arg1:Number){
if (!player.board.logic.menuMode){
this.tillFire = (this.tillFire - _arg1);
if (tillFire <= 0){
tillFire = fireRate;
board.addBullet(this);
};
};
this.vel.plusE(acc.mult(_arg1)).limitTo((maxVel * player.speedBonus));
this.loc.plusE(vel.mult(_arg1));
this.rotation = vel.getAngle();
this.x = loc.x;
this.y = loc.y;
checkBounds();
switch (player.order){
case Player.C_DRAW:
ordDraw();
break;
case Player.C_PUSH:
ordPush();
break;
};
}
public function checkBounds(){
if ((((loc.x < 0)) && ((vel.x < 0)))){
vel.x = (vel.x * -1);
loc.x = 0;
};
if ((((loc.y < 0)) && ((vel.y < 0)))){
vel.y = (vel.y * -1);
loc.y = 0;
};
if ((((loc.x > board.wid)) && ((vel.x > 0)))){
vel.x = (vel.x * -1);
loc.x = board.wid;
};
if ((((loc.y > board.hgt)) && ((vel.y > 0)))){
vel.y = (vel.y * -1);
loc.y = board.hgt;
};
}
}
}//package
Section 73
//SwarmerImg (SwarmerImg)
package {
import flash.display.*;
public dynamic class SwarmerImg extends MovieClip {
}
}//package
Section 74
//Vec2f (Vec2f)
package {
public class Vec2f {
public var x:Number;
public var y:Number;
public function Vec2f(_arg1:Number=0, _arg2:Number=0){
this.x = _arg1;
this.y = _arg2;
}
public function getR():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function dist(_arg1:Vec2f):Number{
return (_arg1.minus(this).getR());
}
public function plusE(_arg1:Vec2f):Vec2f{
x = (x + _arg1.x);
y = (y + _arg1.y);
return (this);
}
public function toString():String{
return ((((("(" + x.toString()) + ",") + y.toString()) + ")"));
}
public function normalise():Vec2f{
var _local1:Number;
_local1 = Math.sqrt(((x * x) + (y * y)));
return (new Vec2f((x / _local1), (y / _local1)));
}
public function copy():Vec2f{
return (new Vec2f(this.x, this.y));
}
public function limitTo(_arg1:Number):Vec2f{
var _local2:Number;
_local2 = Math.sqrt(((x * x) + (y * y)));
if (_local2 > _arg1){
x = (x * (_arg1 / _local2));
y = (y * (_arg1 / _local2));
};
return (this);
}
public function minus(_arg1:Vec2f):Vec2f{
return (new Vec2f((x - _arg1.x), (y - _arg1.y)));
}
public function plus(_arg1:Vec2f):Vec2f{
return (new Vec2f((_arg1.x + x), (_arg1.y + y)));
}
public function multE(_arg1:Number):Vec2f{
x = (x * _arg1);
y = (y * _arg1);
return (this);
}
public function getAngle():Number{
var _local1:Number;
if (x == 0){
return (((y > 0)) ? 90 : 270);
//unresolved jump
};
_local1 = ((Math.atan((y / x)) * 180) / Math.PI);
if (x < 0){
_local1 = (_local1 + 180);
};
return (_local1);
}
public function mult(_arg1:Number):Vec2f{
return (new Vec2f((this.x * _arg1), (this.y * _arg1)));
}
public static function FromAngle(_arg1:Number, _arg2:Number):Vec2f{
return (new Vec2f((Math.sin(_arg1) * _arg2), (Math.cos(_arg1) * _arg2)));
}
public static function rand():Vec2f{
return (new Vec2f((Math.random() - 0.5), (Math.random() - 0.5)));
}
}
}//package