initial commit, kind of working.
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
@@ -0,0 +1,15 @@
|
||||
package mochicrypt
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
|
||||
[Embed(source="/_assets/5_mochicrypt.Background.png")]
|
||||
public class Background extends Bitmap
|
||||
{
|
||||
|
||||
public function Background()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package mochicrypt
|
||||
{
|
||||
internal class Config
|
||||
{
|
||||
|
||||
private static const data:Object = new ConfigData().readObject();
|
||||
|
||||
public function Config()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getBool(param1:String, param2:Boolean) : Boolean
|
||||
{
|
||||
return data[param1] is Boolean ? Boolean(data[param1]) : param2;
|
||||
}
|
||||
|
||||
public static function getInt(param1:String, param2:int) : int
|
||||
{
|
||||
return data[param1] is int ? int(data[param1]) : param2;
|
||||
}
|
||||
|
||||
public static function getString(param1:String, param2:String) : String
|
||||
{
|
||||
return data[param1] is String ? data[param1] : param2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package mochicrypt
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
[Embed(source="/_assets/6_mochicrypt.ConfigData.bin", mimeType="application/octet-stream")]
|
||||
public class ConfigData extends ByteArray
|
||||
{
|
||||
|
||||
public function ConfigData()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package mochicrypt
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
[Embed(source="/_assets/assets.swf", symbol="symbol4")]
|
||||
public class LockIcon extends MovieClip
|
||||
{
|
||||
|
||||
public function LockIcon()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package mochicrypt
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
[Embed(source="/_assets/7_mochicrypt.Payload.bin", mimeType="application/octet-stream")]
|
||||
public class Payload extends ByteArray
|
||||
{
|
||||
|
||||
public function Payload()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
package mochicrypt
|
||||
{
|
||||
import flash.display.*;
|
||||
import flash.events.*;
|
||||
import flash.net.*;
|
||||
import flash.system.*;
|
||||
import flash.utils.*;
|
||||
import mochicrypt.as3.MochiAd;
|
||||
|
||||
[SWF(width="720", height="480", backgroundColor="#333333", frameRate="60")]
|
||||
public dynamic class Preloader extends MovieClip
|
||||
{
|
||||
|
||||
private static const VERSION:String = "3.2c";
|
||||
|
||||
private static const PAYLOAD_NAME:String = "mochicrypt.Payload";
|
||||
|
||||
private static const PATCH_URL:String = Config.getString("patchURL","http://cdn.mochiads.com/patch.swf");
|
||||
|
||||
private var payloadLoader:Loader;
|
||||
|
||||
private var patchProgress:Number = 0;
|
||||
|
||||
private var payloadProgress:Number = 0;
|
||||
|
||||
private var payloadDoneTime:Number = -1;
|
||||
|
||||
private var lastProgress:Number = 0;
|
||||
|
||||
private var patchTimeoutMsec:Number = 5000;
|
||||
|
||||
private var patchFailed:Boolean = false;
|
||||
|
||||
public var background:Background;
|
||||
|
||||
private var payloadDone:Boolean = false;
|
||||
|
||||
private var patchDone:Boolean = false;
|
||||
|
||||
public var icon:LockIcon;
|
||||
|
||||
private var patchLoader:Loader = new Loader();
|
||||
|
||||
public function Preloader()
|
||||
{
|
||||
super();
|
||||
loaderInfo.addEventListener(ProgressEvent.PROGRESS,this.progressHandler);
|
||||
loaderInfo.addEventListener(Event.INIT,this.initHandler);
|
||||
loaderInfo.addEventListener(Event.COMPLETE,this.completeHandler);
|
||||
loaderInfo.addEventListener(IOErrorEvent.IO_ERROR,this.ioErrorHandler);
|
||||
}
|
||||
|
||||
public function parse_vsn(param1:String) : Number
|
||||
{
|
||||
var _loc2_:Array = param1.split(" ")[1].split(",");
|
||||
var _loc3_:Number = parseInt(_loc2_[0]);
|
||||
if(_loc3_ < 10)
|
||||
{
|
||||
return _loc3_;
|
||||
}
|
||||
if(_loc3_ === 10)
|
||||
{
|
||||
return _loc3_ + Math.max(0,parseInt(_loc2_[1]) - 1);
|
||||
}
|
||||
return _loc3_ + 2;
|
||||
}
|
||||
|
||||
public function ad_finished() : void
|
||||
{
|
||||
this.finish();
|
||||
}
|
||||
|
||||
public function ad_progress(param1:Number) : void
|
||||
{
|
||||
}
|
||||
|
||||
private function completeHandler(param1:Event) : void
|
||||
{
|
||||
if(this.payloadDone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.payloadDone = true;
|
||||
nextFrame();
|
||||
}
|
||||
|
||||
private function finish() : void
|
||||
{
|
||||
var payloadClass:Class;
|
||||
var data:ByteArray;
|
||||
var S:ByteArray = null;
|
||||
var i:uint = 0;
|
||||
var j:uint = 0;
|
||||
var k:uint = 0;
|
||||
var n:uint = 0;
|
||||
var u:uint = 0;
|
||||
var v:uint = 0;
|
||||
var btn:Button = null;
|
||||
if(this.payloadLoader)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(Config.getBool("showLock",true) && Boolean(this.icon))
|
||||
{
|
||||
removeChild(this.icon);
|
||||
}
|
||||
removeChild(this.background);
|
||||
payloadClass = Class(getDefinitionByName(PAYLOAD_NAME));
|
||||
data = ByteArray(new payloadClass());
|
||||
if(data.length > 0)
|
||||
{
|
||||
S = new ByteArray();
|
||||
n = data.length - 32;
|
||||
i = 0;
|
||||
while(i < 256)
|
||||
{
|
||||
S.writeByte(i);
|
||||
i++;
|
||||
}
|
||||
j = 0;
|
||||
i = 0;
|
||||
while(i < 256)
|
||||
{
|
||||
j = uint(j + S[i] + data[n + (i & 0x1F)] & 0xFF);
|
||||
u = uint(S[i]);
|
||||
S[i] = S[j];
|
||||
S[j] = u;
|
||||
i++;
|
||||
}
|
||||
if(n > 131072)
|
||||
{
|
||||
n = 131072;
|
||||
}
|
||||
i = j = 0;
|
||||
k = 0;
|
||||
while(k < n)
|
||||
{
|
||||
i = uint(i + 1 & 0xFF);
|
||||
u = uint(S[i]);
|
||||
j = uint(j + u & 0xFF);
|
||||
v = uint(S[j]);
|
||||
S[i] = v;
|
||||
S[j] = u;
|
||||
data[k] ^= S[u + v & 0xFF];
|
||||
k++;
|
||||
}
|
||||
data.uncompress();
|
||||
}
|
||||
if(!this.patchFailed)
|
||||
{
|
||||
try
|
||||
{
|
||||
data = this.patchLoader.content["patch"](data);
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
if(data[3] > this.parse_vsn(Capabilities.version))
|
||||
{
|
||||
btn = new Button();
|
||||
btn.x = (loaderInfo.width - btn.width) / 2;
|
||||
btn.y = (loaderInfo.height - btn.height) / 2;
|
||||
addChild(btn);
|
||||
}
|
||||
else if(data.length > 0)
|
||||
{
|
||||
this.payloadLoader = new Loader();
|
||||
addChild(this.payloadLoader);
|
||||
this.payloadLoader.loadBytes(data);
|
||||
}
|
||||
this.patchLoader.unload();
|
||||
loaderInfo.removeEventListener(ProgressEvent.PROGRESS,this.progressHandler);
|
||||
loaderInfo.removeEventListener(Event.INIT,this.initHandler);
|
||||
loaderInfo.removeEventListener(Event.COMPLETE,this.completeHandler);
|
||||
loaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,this.ioErrorHandler);
|
||||
this.patchLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,this.patchIOErrorHandler);
|
||||
this.patchLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,this.patchProgressHandler);
|
||||
this.patchLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,this.patchCompleteHandler);
|
||||
if(this.icon)
|
||||
{
|
||||
this.icon.removeEventListener(MouseEvent.CLICK,this.lockClicked);
|
||||
}
|
||||
this.patchLoader = null;
|
||||
}
|
||||
|
||||
private function update_progress() : void
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
if(this.payloadDone)
|
||||
{
|
||||
this.payloadProgress = 1;
|
||||
if(this.payloadDoneTime < 0)
|
||||
{
|
||||
this.payloadDoneTime = getTimer();
|
||||
}
|
||||
}
|
||||
if(this.patchDone)
|
||||
{
|
||||
this.patchProgress = 1;
|
||||
}
|
||||
else if(this.payloadDone)
|
||||
{
|
||||
if(this.patchProgress > this.lastProgress)
|
||||
{
|
||||
this.payloadDoneTime = getTimer();
|
||||
}
|
||||
else if(getTimer() - this.payloadDoneTime >= this.patchTimeoutMsec)
|
||||
{
|
||||
this.patchDone = true;
|
||||
this.patchFailed = true;
|
||||
}
|
||||
}
|
||||
this.lastProgress = Math.max(this.lastProgress,Math.min(this.payloadProgress,this.patchProgress));
|
||||
}
|
||||
|
||||
public function ad_failed() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function initHandler(param1:Event) : void
|
||||
{
|
||||
var event:Event = param1;
|
||||
var options:Object = {
|
||||
"mochicrypt_version":VERSION,
|
||||
"id":Config.getString("id","test"),
|
||||
"res":"" + loaderInfo.width + "x" + loaderInfo.height,
|
||||
"no_bg":!Config.getBool("adBackground",false),
|
||||
"color":Config.getInt("barForeColor",16747008),
|
||||
"background":Config.getInt("barBackColor",16777161),
|
||||
"outline":Config.getInt("barOutlineColor",13994812),
|
||||
"bar_offset":(Config.getBool("showLock",true) ? 20 : 0),
|
||||
"show_lock":Config.getBool("showLock",true),
|
||||
"no_branding":Config.getBool("noBranding",false),
|
||||
"clip":this,
|
||||
"progress_override":this.progress_override,
|
||||
"ad_started":this.ad_started,
|
||||
"ad_finished":this.ad_finished,
|
||||
"ad_loaded":this.ad_loaded,
|
||||
"ad_failed":this.ad_failed,
|
||||
"ad_skipped":this.ad_skipped,
|
||||
"ad_progress":this.ad_progress
|
||||
};
|
||||
this.patchLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,this.patchIOErrorHandler);
|
||||
this.patchLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,this.patchProgressHandler);
|
||||
this.patchLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.patchCompleteHandler);
|
||||
try
|
||||
{
|
||||
this.patchLoader.load(new URLRequest(PATCH_URL));
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
patchDone = true;
|
||||
patchFailed = true;
|
||||
}
|
||||
this.background = new Background();
|
||||
addChild(this.background);
|
||||
MochiAd.showPreGameAd(options);
|
||||
if(Config.getBool("showLock",true))
|
||||
{
|
||||
this.icon = new LockIcon();
|
||||
this.icon.addFrameScript(49,this.icon.stop);
|
||||
this.icon.x = 10;
|
||||
this.icon.y = loaderInfo.height - 20;
|
||||
this.icon.buttonMode = true;
|
||||
this.icon.useHandCursor = true;
|
||||
this.icon.addEventListener(MouseEvent.CLICK,this.lockClicked);
|
||||
addChild(this.icon);
|
||||
}
|
||||
if(Boolean(loaderInfo.bytesTotal) && loaderInfo.bytesLoaded == loaderInfo.bytesTotal)
|
||||
{
|
||||
this.completeHandler(event);
|
||||
}
|
||||
}
|
||||
|
||||
public function progress_override(param1:Object) : Number
|
||||
{
|
||||
this.update_progress();
|
||||
return this.lastProgress;
|
||||
}
|
||||
|
||||
public function ad_loaded(param1:Number, param2:Number) : void
|
||||
{
|
||||
}
|
||||
|
||||
private function ioErrorHandler(param1:IOErrorEvent) : void
|
||||
{
|
||||
}
|
||||
|
||||
private function patchCompleteHandler(param1:Event) : void
|
||||
{
|
||||
if(this.patchDone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.patchDone = true;
|
||||
this.update_progress();
|
||||
}
|
||||
|
||||
public function ad_skipped() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function ad_started() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function patchProgressHandler(param1:ProgressEvent) : void
|
||||
{
|
||||
if(param1.bytesLoaded == param1.bytesTotal)
|
||||
{
|
||||
this.patchProgress = 1;
|
||||
this.patchDone = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.patchProgress = Number(param1.bytesLoaded) / param1.bytesTotal;
|
||||
}
|
||||
this.update_progress();
|
||||
}
|
||||
|
||||
private function patchIOErrorHandler(param1:IOErrorEvent) : void
|
||||
{
|
||||
this.patchDone = true;
|
||||
this.patchFailed = true;
|
||||
this.update_progress();
|
||||
}
|
||||
|
||||
private function lockClicked(param1:Event) : void
|
||||
{
|
||||
navigateToURL(new URLRequest("https://www.mochimedia.com/r/g/" + Config.getString("slug","example-flash_api-test") + "?d=l"));
|
||||
}
|
||||
|
||||
private function progressHandler(param1:ProgressEvent) : void
|
||||
{
|
||||
if(param1.bytesLoaded == param1.bytesTotal)
|
||||
{
|
||||
this.payloadProgress = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.payloadProgress = Number(param1.bytesLoaded) / param1.bytesTotal;
|
||||
}
|
||||
this.update_progress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import flash.display.Graphics;
|
||||
import flash.display.SimpleButton;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.net.URLRequest;
|
||||
import flash.net.navigateToURL;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFormat;
|
||||
import flash.text.TextFormatAlign;
|
||||
|
||||
class Button extends SimpleButton
|
||||
{
|
||||
|
||||
public function Button()
|
||||
{
|
||||
super();
|
||||
var _loc1_:String = "Download the latest\nAdobe Flash Player";
|
||||
upState = new State(16777215,_loc1_);
|
||||
downState = new State(13421772,_loc1_);
|
||||
hitTestState = upState;
|
||||
overState = upState;
|
||||
addEventListener(MouseEvent.CLICK,this.buttonClicked);
|
||||
width = upState.width;
|
||||
height = upState.height;
|
||||
}
|
||||
|
||||
public function buttonClicked(param1:Event) : void
|
||||
{
|
||||
navigateToURL(new URLRequest("http://get.adobe.com/flashplayer/"));
|
||||
}
|
||||
}
|
||||
|
||||
class State extends Sprite
|
||||
{
|
||||
|
||||
public function State(param1:uint, param2:String)
|
||||
{
|
||||
super();
|
||||
var _loc3_:TextFormat = new TextFormat("Verdana");
|
||||
_loc3_.align = TextFormatAlign.CENTER;
|
||||
var _loc4_:TextField = new TextField();
|
||||
_loc4_.text = param2;
|
||||
_loc4_.multiline = true;
|
||||
_loc4_.x = _loc4_.y = 2;
|
||||
_loc4_.setTextFormat(_loc3_);
|
||||
_loc4_.width = _loc4_.textWidth + 4;
|
||||
_loc4_.height = _loc4_.textHeight + 4;
|
||||
addChild(_loc4_);
|
||||
var _loc5_:Graphics = graphics;
|
||||
_loc5_.beginFill(param1);
|
||||
_loc5_.lineStyle(1,0);
|
||||
_loc5_.drawRoundRect(0,0,_loc4_.width + 4,_loc4_.height + 4,4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package mochicrypt.as3
|
||||
{
|
||||
public class MochiCoins
|
||||
{
|
||||
|
||||
public static const LOGGED_IN:String = "LoggedIn";
|
||||
|
||||
public static const LOGGED_OUT:String = "LoggedOut";
|
||||
|
||||
public static const LOGIN_SHOW:String = "LoginShow";
|
||||
|
||||
public static const LOGIN_HIDE:String = "LoginHide";
|
||||
|
||||
public static const STORE_SHOW:String = "StoreShow";
|
||||
|
||||
public static const STORE_HIDE:String = "StoreHide";
|
||||
|
||||
public static const LOGIN_SHOWN:String = "LoginShown";
|
||||
|
||||
public static const PROFILE_SHOW:String = "ProfileShow";
|
||||
|
||||
public static const PROFILE_HIDE:String = "ProfileHide";
|
||||
|
||||
public static const PROPERTIES_SAVED:String = "PropertySaved";
|
||||
|
||||
public static const WIDGET_LOADED:String = "WidgetLoaded";
|
||||
|
||||
public static const ITEM_OWNED:String = "ItemOwned";
|
||||
|
||||
public static const ITEM_NEW:String = "ItemNew";
|
||||
|
||||
public static const STORE_ITEMS:String = "StoreItems";
|
||||
|
||||
public static const USER_INFO:String = "UserInfo";
|
||||
|
||||
public static const ERROR:String = "Error";
|
||||
|
||||
public static const IO_ERROR:String = "IOError";
|
||||
|
||||
public static const NO_USER:String = "NoUser";
|
||||
|
||||
public static const PROPERTIES_SIZE:String = "PropertiesSize";
|
||||
|
||||
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
|
||||
|
||||
public static var _user_info:Object = null;
|
||||
|
||||
public function MochiCoins()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getUserInfo() : void
|
||||
{
|
||||
MochiServices.send("coins_getUserInfo");
|
||||
}
|
||||
|
||||
public static function showItem(param1:Object = null) : void
|
||||
{
|
||||
if(!param1 || typeof param1.item != "string")
|
||||
{
|
||||
trace("ERROR: showItem call must pass an Object with an item key");
|
||||
return;
|
||||
}
|
||||
MochiServices.bringToTop();
|
||||
MochiServices.send("coins_showItem",{"options":param1},null,null);
|
||||
}
|
||||
|
||||
public static function getVersion() : String
|
||||
{
|
||||
return MochiServices.getVersion();
|
||||
}
|
||||
|
||||
public static function saveUserProperties(param1:Object) : void
|
||||
{
|
||||
MochiServices.send("coins_saveUserProperties",param1);
|
||||
}
|
||||
|
||||
public static function triggerEvent(param1:String, param2:Object) : void
|
||||
{
|
||||
if(param1 == LOGGED_IN)
|
||||
{
|
||||
_user_info = param2;
|
||||
}
|
||||
else if(param1 == LOGGED_OUT)
|
||||
{
|
||||
_user_info = null;
|
||||
}
|
||||
_dispatcher.triggerEvent(param1,param2);
|
||||
}
|
||||
|
||||
public static function removeEventListener(param1:String, param2:Function) : void
|
||||
{
|
||||
_dispatcher.removeEventListener(param1,param2);
|
||||
}
|
||||
|
||||
public static function getStoreItems() : void
|
||||
{
|
||||
MochiServices.send("coins_getStoreItems");
|
||||
}
|
||||
|
||||
public static function showLoginWidget(param1:Object = null) : void
|
||||
{
|
||||
MochiServices.setContainer();
|
||||
MochiServices.bringToTop();
|
||||
MochiServices.send("coins_showLoginWidget",{"options":param1});
|
||||
}
|
||||
|
||||
public static function addEventListener(param1:String, param2:Function) : void
|
||||
{
|
||||
_dispatcher.addEventListener(param1,param2);
|
||||
}
|
||||
|
||||
public static function showStore(param1:Object = null) : void
|
||||
{
|
||||
MochiServices.bringToTop();
|
||||
MochiServices.send("coins_showStore",{"options":param1},null,null);
|
||||
}
|
||||
|
||||
public static function hideLoginWidget() : void
|
||||
{
|
||||
MochiServices.send("coins_hideLoginWidget");
|
||||
}
|
||||
|
||||
public static function getAPIURL() : String
|
||||
{
|
||||
if(!_user_info)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _user_info.api_url;
|
||||
}
|
||||
|
||||
public static function getAPIToken() : String
|
||||
{
|
||||
if(!_user_info)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _user_info.api_token;
|
||||
}
|
||||
|
||||
public static function showVideo(param1:Object = null) : void
|
||||
{
|
||||
if(!param1 || typeof param1.item != "string")
|
||||
{
|
||||
trace("ERROR: showVideo call must pass an Object with an item key");
|
||||
return;
|
||||
}
|
||||
MochiServices.bringToTop();
|
||||
MochiServices.send("coins_showVideo",{"options":param1},null,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package mochicrypt.as3
|
||||
{
|
||||
public class MochiEventDispatcher
|
||||
{
|
||||
|
||||
private var eventTable:Object;
|
||||
|
||||
public function MochiEventDispatcher()
|
||||
{
|
||||
super();
|
||||
this.eventTable = {};
|
||||
}
|
||||
|
||||
public function triggerEvent(param1:String, param2:Object) : void
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
if(this.eventTable[param1] == undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for(_loc3_ in this.eventTable[param1])
|
||||
{
|
||||
this.eventTable[param1][_loc3_](param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeEventListener(param1:String, param2:Function) : void
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
if(this.eventTable[param1] == undefined)
|
||||
{
|
||||
this.eventTable[param1] = [];
|
||||
return;
|
||||
}
|
||||
for(_loc3_ in this.eventTable[param1])
|
||||
{
|
||||
if(this.eventTable[param1][_loc3_] == param2)
|
||||
{
|
||||
this.eventTable[param1].splice(Number(_loc3_),1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addEventListener(param1:String, param2:Function) : void
|
||||
{
|
||||
this.removeEventListener(param1,param2);
|
||||
this.eventTable[param1].push(param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package mochicrypt.as3
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public class MochiEvents
|
||||
{
|
||||
|
||||
private static var gameStart:Number;
|
||||
|
||||
private static var levelStart:Number;
|
||||
|
||||
public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived";
|
||||
|
||||
public static const ALIGN_TOP_LEFT:String = "ALIGN_TL";
|
||||
|
||||
public static const ALIGN_TOP:String = "ALIGN_T";
|
||||
|
||||
public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR";
|
||||
|
||||
public static const ALIGN_LEFT:String = "ALIGN_L";
|
||||
|
||||
public static const ALIGN_CENTER:String = "ALIGN_C";
|
||||
|
||||
public static const ALIGN_RIGHT:String = "ALIGN_R";
|
||||
|
||||
public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL";
|
||||
|
||||
public static const ALIGN_BOTTOM:String = "ALIGN_B";
|
||||
|
||||
public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR";
|
||||
|
||||
public static const FORMAT_SHORT:String = "ShortForm";
|
||||
|
||||
public static const FORMAT_LONG:String = "LongForm";
|
||||
|
||||
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
|
||||
|
||||
public function MochiEvents()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function addEventListener(param1:String, param2:Function) : void
|
||||
{
|
||||
_dispatcher.addEventListener(param1,param2);
|
||||
}
|
||||
|
||||
public static function removeEventListener(param1:String, param2:Function) : void
|
||||
{
|
||||
_dispatcher.removeEventListener(param1,param2);
|
||||
}
|
||||
|
||||
public static function startSession(param1:String) : void
|
||||
{
|
||||
MochiServices.send("events_beginSession",{"achievementID":param1},null,null);
|
||||
}
|
||||
|
||||
public static function triggerEvent(param1:String, param2:Object) : void
|
||||
{
|
||||
_dispatcher.triggerEvent(param1,param2);
|
||||
}
|
||||
|
||||
public static function setNotifications(param1:MovieClip, param2:Object) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc3_:Object = {};
|
||||
for(_loc4_ in param2)
|
||||
{
|
||||
_loc3_[_loc4_] = param2[_loc4_];
|
||||
}
|
||||
_loc3_.clip = param1;
|
||||
MochiServices.send("events_setNotifications",_loc3_,null,null);
|
||||
}
|
||||
|
||||
public static function endGame() : void
|
||||
{
|
||||
var _loc1_:Number = new Date().time - gameStart;
|
||||
trigger("end_game",{"time":_loc1_});
|
||||
}
|
||||
|
||||
public static function startGame() : void
|
||||
{
|
||||
gameStart = new Date().time;
|
||||
trigger("start_game");
|
||||
}
|
||||
|
||||
public static function trigger(param1:String, param2:Object = null) : void
|
||||
{
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = {};
|
||||
}
|
||||
else if(param2["kind"] != undefined)
|
||||
{
|
||||
trace("WARNING: optional arguments package contains key \'id\', it will be overwritten");
|
||||
param2["kind"] = param1;
|
||||
}
|
||||
MochiServices.send("events_triggerEvent",{"eventObject":param2},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 _loc1_:Number = new Date().time - levelStart;
|
||||
trigger("end_level",{"time":_loc1_});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,819 @@
|
||||
package mochicrypt.as3
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Loader;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.net.LocalConnection;
|
||||
import flash.net.URLRequest;
|
||||
import flash.net.URLVariables;
|
||||
import flash.system.Capabilities;
|
||||
import flash.system.Security;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.Endian;
|
||||
import flash.utils.Timer;
|
||||
|
||||
public class MochiServices
|
||||
{
|
||||
|
||||
private static var _container:Object;
|
||||
|
||||
private static var _swfVersion:String;
|
||||
|
||||
private static var _preserved:Object;
|
||||
|
||||
private static var _sendChannel:LocalConnection;
|
||||
|
||||
private static var _clip:MovieClip;
|
||||
|
||||
private static var _id:String;
|
||||
|
||||
private static var _timer:Timer;
|
||||
|
||||
private static var _sendChannelName:String;
|
||||
|
||||
private static var _loader:Loader;
|
||||
|
||||
private static var _mochiLocalConnection:MovieClip;
|
||||
|
||||
public static var onError:Object;
|
||||
|
||||
private static var _servURL:String = "http://www.mochiads.com/static/lib/services/";
|
||||
|
||||
private static var _services:String = "services.swf";
|
||||
|
||||
private static var _mochiLC:String = "MochiLC.swf";
|
||||
|
||||
private static var _listenChannelName:String = "__ms_";
|
||||
|
||||
private static var _connecting:Boolean = false;
|
||||
|
||||
private static var _connected:Boolean = false;
|
||||
|
||||
public static var netup:Boolean = true;
|
||||
|
||||
public static var netupAttempted:Boolean = false;
|
||||
|
||||
public static var widget:Boolean = false;
|
||||
|
||||
public static var servicesSync:MochiSync = new MochiSync();
|
||||
|
||||
public function MochiServices()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function isNetworkAvailable() : Boolean
|
||||
{
|
||||
return Security.sandboxType != "localWithFile";
|
||||
}
|
||||
|
||||
public static function get connected() : Boolean
|
||||
{
|
||||
return _connected;
|
||||
}
|
||||
|
||||
private static function onReceive(param1:Object) : void
|
||||
{
|
||||
var method:*;
|
||||
var obj:Object;
|
||||
var methodName:String = null;
|
||||
var pkg:Object = param1;
|
||||
var cb:String = pkg.callbackID;
|
||||
var cblst:Object = _clip._callbacks[cb];
|
||||
if(!cblst)
|
||||
{
|
||||
return;
|
||||
}
|
||||
method = cblst.callbackMethod;
|
||||
methodName = "";
|
||||
obj = cblst.callbackObject;
|
||||
if(Boolean(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(param1:String, param2:Object = null, param3:Object = null, param4:Object = null) : void
|
||||
{
|
||||
if(_connected)
|
||||
{
|
||||
_mochiLocalConnection.send(_sendChannelName,"onReceive",{
|
||||
"methodName":param1,
|
||||
"args":param2,
|
||||
"callbackID":_clip._nextcallbackID
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_clip == null || !_connecting)
|
||||
{
|
||||
trace("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + param1);
|
||||
handleError(param2,param3,param4);
|
||||
flush(true);
|
||||
return;
|
||||
}
|
||||
_clip._queue.push({
|
||||
"methodName":param1,
|
||||
"args":param2,
|
||||
"callbackID":_clip._nextcallbackID
|
||||
});
|
||||
}
|
||||
if(_clip != null)
|
||||
{
|
||||
if(_clip._callbacks != null && _clip._nextcallbackID != null)
|
||||
{
|
||||
_clip._callbacks[_clip._nextcallbackID] = {
|
||||
"callbackObject":param3,
|
||||
"callbackMethod":param4
|
||||
};
|
||||
++_clip._nextcallbackID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function init(param1:String, param2:Object) : void
|
||||
{
|
||||
_id = param1;
|
||||
if(param2 != null)
|
||||
{
|
||||
_container = param2;
|
||||
loadCommunicator(param1,_container);
|
||||
}
|
||||
}
|
||||
|
||||
private static function clickMovie(param1:String, param2:Function) : MovieClip
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc14_:Loader = null;
|
||||
var _loc3_:Array = [150,21,0,7,1,0,0,0,0,98,116,110,0,7,2,0,0,0,0,116,104,105,115,0,28,150,22,0,0,99,114,101,97,116,101,69,109,112,116,121,77,111,118,105,101,67,108,105,112,0,82,135,1,0,0,23,150,13,0,4,0,0,111,110,82,101,108,101,97,115,101,0,142,8,0,0,0,0,2,42,0,114,0,150,17,0,0,32,0,7,1,0,0,0,8,0,0,115,112,108,105,116,0,82,135,1,0,1,23,150,7,0,4,1,7,0,0,0,0,78,150,8,0,0,95,98,108,97,110,107,0,154,1,0,0,150,7,0,0,99,108,105,99,107,0,150,7,0,4,1,7,1,0,0,0,78,150,27,0,7,2,0,0,0,7,0,0,0,0,0,76,111,99,97,108,67,111,110,110,101,99,116,105,111,110,0,64,150,6,0,0,115,101,110,100,0,82,79,150,15,0,4,0,0,95,97,108,112,104,97,0,7,0,0,0,0,79,150,23,0,7,255,0,255,0,7,1,0,0,0,4,0,0,98,101,103,105,110,70,105,108,108,0,82,23,150,25,0,7,0,0,0,0,7,0,0,0,0,7,2,0,0,0,4,0,0,109,111,118,101,84,111,0,82,23,150,25,0,7,100,0,0,0,7,0,0,0,0,7,2,0,0,0,4,0,0,108,105,110,101,84,111,0,82,23,150,25,0,7,100,0,0,0,7,100,0,0,0,7,2,0,0,0,4,0,0,108,105,110,101,84,111,0,82,23,150,25,0,7,0,0,0,0,7,100,0,0,0,7,2,0,0,0,4,0,0,108
|
||||
,105,110,101,84,111,0,82,23,150,25,0,7,0,0,0,0,7,0,0,0,0,7,2,0,0,0,4,0,0,108,105,110,101,84,111,0,82,23,150,16,0,7,0,0,0,0,4,0,0,101,110,100,70,105,108,108,0,82,23];
|
||||
var _loc5_:Array = [104,0,31,64,0,7,208,0,0,12,1,0,67,2,255,255,255,63,3];
|
||||
var _loc6_:Array = [0,64,0,0,0];
|
||||
var _loc7_:MovieClip = new MovieClip();
|
||||
var _loc8_:LocalConnection = new LocalConnection();
|
||||
var _loc9_:String = "_click_" + Math.floor(Math.random() * 999999) + "_" + Math.floor(new Date().time);
|
||||
_loc8_ = new LocalConnection();
|
||||
_loc7_.lc = _loc8_;
|
||||
_loc7_.click = param2;
|
||||
_loc8_.client = _loc7_;
|
||||
_loc8_.connect(_loc9_);
|
||||
var _loc10_:ByteArray = new ByteArray();
|
||||
var _loc11_:ByteArray = new ByteArray();
|
||||
_loc11_.endian = Endian.LITTLE_ENDIAN;
|
||||
_loc11_.writeShort(1);
|
||||
_loc11_.writeUTFBytes(param1 + " " + _loc9_);
|
||||
_loc11_.writeByte(0);
|
||||
var _loc12_:uint = _loc3_.length + _loc11_.length + 4;
|
||||
var _loc13_:uint = _loc12_ + 35;
|
||||
_loc10_.endian = Endian.LITTLE_ENDIAN;
|
||||
_loc10_.writeUTFBytes("FWS");
|
||||
_loc10_.writeByte(8);
|
||||
_loc10_.writeUnsignedInt(_loc13_);
|
||||
for each(_loc4_ in _loc5_)
|
||||
{
|
||||
_loc10_.writeByte(_loc4_);
|
||||
}
|
||||
_loc10_.writeUnsignedInt(_loc12_);
|
||||
_loc10_.writeByte(136);
|
||||
_loc10_.writeShort(_loc11_.length);
|
||||
_loc10_.writeBytes(_loc11_);
|
||||
for each(_loc4_ in _loc3_)
|
||||
{
|
||||
_loc10_.writeByte(_loc4_);
|
||||
}
|
||||
for each(_loc4_ in _loc6_)
|
||||
{
|
||||
_loc10_.writeByte(_loc4_);
|
||||
}
|
||||
_loc14_ = new Loader();
|
||||
_loc14_.loadBytes(_loc10_);
|
||||
_loc7_.addChild(_loc14_);
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
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(param1:String, param2:String, param3:DisplayObjectContainer, param4:Function = null) : void
|
||||
{
|
||||
var i:Number;
|
||||
var s:String;
|
||||
var avm1Click:DisplayObject = null;
|
||||
var x:String = null;
|
||||
var req:URLRequest = null;
|
||||
var loader:Loader = null;
|
||||
var setURL:Function = null;
|
||||
var err:Function = null;
|
||||
var complete:Function = null;
|
||||
var url:String = param1;
|
||||
var burl:String = param2;
|
||||
var btn:DisplayObjectContainer = param3;
|
||||
var onClick:Function = param4;
|
||||
var vars:Object = new Object();
|
||||
vars["mav"] = getVersion();
|
||||
vars["swfv"] = "9";
|
||||
vars["swfurl"] = btn.loaderInfo.loaderURL;
|
||||
vars["fv"] = Capabilities.version;
|
||||
vars["os"] = Capabilities.os;
|
||||
vars["lang"] = Capabilities.language;
|
||||
vars["scres"] = Capabilities.screenResolutionX + "x" + Capabilities.screenResolutionY;
|
||||
s = "?";
|
||||
i = 0;
|
||||
for(x in vars)
|
||||
{
|
||||
if(i != 0)
|
||||
{
|
||||
s += "&";
|
||||
}
|
||||
i++;
|
||||
s = s + x + "=" + escape(vars[x]);
|
||||
}
|
||||
req = new URLRequest("http://x.mochiads.com/linkping.swf");
|
||||
loader = new Loader();
|
||||
setURL = function(param1:String):void
|
||||
{
|
||||
if(avm1Click)
|
||||
{
|
||||
btn.removeChild(avm1Click);
|
||||
}
|
||||
avm1Click = clickMovie(param1,onClick);
|
||||
var _loc2_:Rectangle = btn.getBounds(btn);
|
||||
btn.addChild(avm1Click);
|
||||
avm1Click.x = _loc2_.x;
|
||||
avm1Click.y = _loc2_.y;
|
||||
avm1Click.scaleX = 0.01 * _loc2_.width;
|
||||
avm1Click.scaleY = 0.01 * _loc2_.height;
|
||||
};
|
||||
err = function(param1:Object):void
|
||||
{
|
||||
netup = false;
|
||||
param1.target.removeEventListener(param1.type,arguments.callee);
|
||||
setURL(burl);
|
||||
};
|
||||
complete = function(param1:Object):void
|
||||
{
|
||||
param1.target.removeEventListener(param1.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(param1:String, param2:Boolean) : void
|
||||
{
|
||||
param1 = param1.toLowerCase();
|
||||
if(param1.length != 16)
|
||||
{
|
||||
trace("WARNING: " + (param2 ? "board" : "game") + " ID is not the appropriate length");
|
||||
return;
|
||||
}
|
||||
if(param1 == "1e113c7239048b3f")
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
trace("WARNING: Using testing board ID");
|
||||
}
|
||||
else
|
||||
{
|
||||
trace("WARNING: Using testing board ID as game ID");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(param1 == "84993a1de4031cd8")
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
trace("WARNING: Using testing game ID as board ID");
|
||||
}
|
||||
else
|
||||
{
|
||||
trace("WARNING: Using testing game ID");
|
||||
}
|
||||
return;
|
||||
}
|
||||
var _loc3_:Number = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
switch(param1.charAt(_loc3_))
|
||||
{
|
||||
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: " + param1);
|
||||
return;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
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(param1:String) : String
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
if(Security.sandboxType != "application")
|
||||
{
|
||||
Security.allowDomain("*");
|
||||
Security.allowInsecureDomain("*");
|
||||
}
|
||||
if(param1.indexOf("http://") != -1)
|
||||
{
|
||||
_loc2_ = param1.split("/")[2].split(":")[0];
|
||||
if(Security.sandboxType != "application")
|
||||
{
|
||||
Security.allowDomain(_loc2_);
|
||||
Security.allowInsecureDomain(_loc2_);
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function getVersion() : String
|
||||
{
|
||||
return "3.4c as3";
|
||||
}
|
||||
|
||||
public static function doClose() : void
|
||||
{
|
||||
_container.removeEventListener(Event.ENTER_FRAME,MochiServices.bringToTop);
|
||||
}
|
||||
|
||||
private static function flush(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc3_:Object = null;
|
||||
if(Boolean(_clip) && Boolean(_clip._queue))
|
||||
{
|
||||
while(_clip._queue.length > 0)
|
||||
{
|
||||
_loc2_ = _clip._queue.shift();
|
||||
_loc3_ = null;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
if(_loc2_.callbackID != null)
|
||||
{
|
||||
_loc3_ = _clip._callbacks[_loc2_.callbackID];
|
||||
}
|
||||
delete _clip._callbacks[_loc2_.callbackID];
|
||||
if(param1 && _loc3_ != null)
|
||||
{
|
||||
handleError(_loc2_.args,_loc3_.callbackObject,_loc3_.callbackMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function get id() : String
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
private static function onEvent(param1:Object) : void
|
||||
{
|
||||
var _loc2_:String = param1.target;
|
||||
var _loc3_:String = param1.event;
|
||||
switch(_loc2_)
|
||||
{
|
||||
case "events":
|
||||
MochiEvents.triggerEvent(param1.event,param1.args);
|
||||
break;
|
||||
case "coins":
|
||||
MochiCoins.triggerEvent(param1.event,param1.args);
|
||||
break;
|
||||
case "sync":
|
||||
servicesSync.triggerEvent(param1.event,param1.args);
|
||||
}
|
||||
}
|
||||
|
||||
private static function urlOptions(param1:Object) : Object
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:Array = null;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc6_:Array = null;
|
||||
var _loc2_:Object = {};
|
||||
if(param1.stage)
|
||||
{
|
||||
_loc3_ = param1.stage.loaderInfo.parameters.mochiad_options;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = param1.loaderInfo.parameters.mochiad_options;
|
||||
}
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc4_ = _loc3_.split("&");
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc4_.length)
|
||||
{
|
||||
_loc6_ = _loc4_[_loc5_].split("=");
|
||||
_loc2_[unescape(_loc6_[0])] = unescape(_loc6_[1]);
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function setContainer(param1:Object = null, param2:Boolean = true) : void
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
if(param1 is Sprite)
|
||||
{
|
||||
_container = param1;
|
||||
}
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
if(_container is Sprite)
|
||||
{
|
||||
Sprite(_container).addChild(_clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleError(param1:Object, param2:Object, param3:Object) : void
|
||||
{
|
||||
var args:Object = param1;
|
||||
var callbackObject:Object = param2;
|
||||
var callbackMethod:Object = param3;
|
||||
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
|
||||
{
|
||||
callbackObject[callbackMethod](args);
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if(callbackMethod != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
callbackMethod.apply(args);
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function loadError(param1: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(param1:Object) : void
|
||||
{
|
||||
var loader:Loader = null;
|
||||
var clip:Object = param1;
|
||||
loader = new Loader();
|
||||
var mochiLCURL:String = _servURL + _mochiLC;
|
||||
var req:URLRequest = new URLRequest(mochiLCURL);
|
||||
var complete:Function = function(param1: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(param1:Object):void
|
||||
{
|
||||
MochiServices.comChannelName = param1.newChannel;
|
||||
};
|
||||
trace("Waiting for MochiAds services to connect...");
|
||||
}
|
||||
|
||||
public static function get clip() : Object
|
||||
{
|
||||
return _container;
|
||||
}
|
||||
|
||||
public static function set comChannelName(param1:String) : void
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
if(param1.length > 3)
|
||||
{
|
||||
_sendChannelName = param1 + "_fromgame";
|
||||
initComChannels();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function loadCommunicator(param1:String, param2:Object) : MovieClip
|
||||
{
|
||||
var _loc3_:String = "_mochiservices_com_" + param1;
|
||||
if(_clip != null)
|
||||
{
|
||||
return _clip;
|
||||
}
|
||||
if(!MochiServices.isNetworkAvailable())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(urlOptions(param2).servURL)
|
||||
{
|
||||
_servURL = urlOptions(param2).servURL;
|
||||
}
|
||||
var _loc4_:String = _servURL + _services;
|
||||
if(urlOptions(param2).servicesURL)
|
||||
{
|
||||
_loc4_ = urlOptions(param2).servicesURL;
|
||||
}
|
||||
_listenChannelName += Math.floor(new Date().time) + "_" + Math.floor(Math.random() * 99999);
|
||||
MochiServices.allowDomains(_loc4_);
|
||||
_clip = createEmptyMovieClip(param2,_loc3_,10336,false);
|
||||
loadLCBridge(_clip);
|
||||
_loader = new Loader();
|
||||
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,loadError);
|
||||
var _loc5_:URLRequest = new URLRequest(_loc4_);
|
||||
var _loc6_:URLVariables = new URLVariables();
|
||||
_loc6_.listenLC = _listenChannelName;
|
||||
_loc6_.mochiad_options = param2.loaderInfo.parameters.mochiad_options;
|
||||
_loc6_.api_version = getVersion();
|
||||
if(widget)
|
||||
{
|
||||
_loc6_.widget = true;
|
||||
}
|
||||
_loc5_.data = _loc6_;
|
||||
_loader.load(_loc5_);
|
||||
_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(param1:String, param2:Object, param3:Object = null) : void
|
||||
{
|
||||
var id:String = param1;
|
||||
var clip:Object = param2;
|
||||
var onError:Object = param3;
|
||||
warnID(id,false);
|
||||
if(clip is DisplayObject)
|
||||
{
|
||||
if(clip.stage == null)
|
||||
{
|
||||
trace("MochiServices connect requires the containing clip be attached to the stage");
|
||||
}
|
||||
if(!_connected && _clip == null)
|
||||
{
|
||||
trace("MochiServices Connecting...");
|
||||
_connecting = true;
|
||||
init(id,clip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
|
||||
}
|
||||
if(onError != null)
|
||||
{
|
||||
MochiServices.onError = onError;
|
||||
}
|
||||
else if(MochiServices.onError == null)
|
||||
{
|
||||
MochiServices.onError = function(param1:String):void
|
||||
{
|
||||
trace(param1);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static function createEmptyMovieClip(param1:Object, param2:String, param3:Number, param4:Boolean = true) : MovieClip
|
||||
{
|
||||
var parent:Object = param1;
|
||||
var name:String = param2;
|
||||
var depth:Number = param3;
|
||||
var doAdd:Boolean = param4;
|
||||
var mc:MovieClip = new MovieClip();
|
||||
if(doAdd)
|
||||
{
|
||||
if(false && Boolean(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(param1:Event = null) : void
|
||||
{
|
||||
var e:Event = param1;
|
||||
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(param1:TimerEvent) : void
|
||||
{
|
||||
if(!_connected)
|
||||
{
|
||||
_clip._mochiad_ctr_failed = true;
|
||||
trace("MochiServices could not load. (timeout)");
|
||||
MochiServices.disconnect();
|
||||
MochiServices.onError("IOError");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package mochicrypt.as3
|
||||
{
|
||||
import flash.utils.Proxy;
|
||||
import flash.utils.flash_proxy;
|
||||
|
||||
use namespace flash_proxy;
|
||||
|
||||
public dynamic class MochiSync extends Proxy
|
||||
{
|
||||
|
||||
public static var SYNC_REQUEST:String = "SyncRequest";
|
||||
|
||||
public static var SYNC_PROPERTY:String = "UpdateProperty";
|
||||
|
||||
private var _syncContainer:Object;
|
||||
|
||||
public function MochiSync()
|
||||
{
|
||||
super();
|
||||
this._syncContainer = {};
|
||||
}
|
||||
|
||||
override flash_proxy function setProperty(param1:*, param2:*) : void
|
||||
{
|
||||
if(this._syncContainer[param1] == param2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc3_:String = param1.toString();
|
||||
this._syncContainer[_loc3_] = param2;
|
||||
MochiServices.send("sync_propUpdate",{
|
||||
"name":_loc3_,
|
||||
"value":param2
|
||||
});
|
||||
}
|
||||
|
||||
override flash_proxy function getProperty(param1:*) : *
|
||||
{
|
||||
return this._syncContainer[param1];
|
||||
}
|
||||
|
||||
public function triggerEvent(param1:String, param2:Object) : void
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case SYNC_REQUEST:
|
||||
MochiServices.send("sync_syncronize",this._syncContainer);
|
||||
break;
|
||||
case SYNC_PROPERTY:
|
||||
this._syncContainer[param2.name] = param2.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns:ffdec="https://www.free-decompiler.com/flash" xmlns:xlink="http://www.w3.org/1999/xlink" ffdec:objectType="shape" height="3.0px" width="12.0px" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="matrix(1.0, 0.0, 0.0, 1.0, 6.0, 1.5)">
|
||||
<path d="M-5.35 -1.3 L-4.0 -1.5 4.0 -1.5 5.35 -1.3 6.0 -0.85 6.0 0.85 5.35 1.3 3.7 1.5 -3.8 1.5 -5.35 1.3 -6.0 0.85 -6.0 -0.85 -5.35 -1.3" fill="#000000" fill-opacity="0.2" fill-rule="evenodd" stroke="none"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 528 B |
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns:ffdec="https://www.free-decompiler.com/flash" xmlns:xlink="http://www.w3.org/1999/xlink" ffdec:objectType="shape" height="19.0px" width="14.0px" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="matrix(1.0, 0.0, 0.0, 1.0, 7.0, 11.5)">
|
||||
<path d="M0.0 -7.5 Q-0.4 -7.5 -0.65 -7.2 L-0.7 -7.2 -1.0 -6.35 -1.0 -5.5 1.0 -5.5 1.0 -6.35 0.7 -7.2 0.0 -7.5 M3.55 -10.0 L3.5 -10.0 3.55 -9.95 Q5.0 -8.55 5.0 -6.35 L5.0 -5.25 6.1 -4.45 Q7.0 -3.4 7.0 -2.1 L7.0 4.15 Q7.0 5.55 6.1 6.5 L6.05 6.5 Q5.1 7.5 3.7 7.5 L-3.8 7.5 Q-5.15 7.5 -6.05 6.5 L-6.1 6.45 Q-7.0 5.55 -7.0 4.15 L-7.0 -2.1 Q-7.0 -3.4 -6.1 -4.45 L-6.05 -4.45 Q-5.6 -5.0 -5.0 -5.25 L-5.0 -6.35 Q-5.0 -8.5 -3.55 -10.0 -2.05 -11.5 0.0 -11.5 2.1 -11.5 3.55 -10.0 M1.4 -2.4 Q0.8 -3.0 0.0 -3.0 -0.8 -3.0 -1.45 -2.4 -2.0 -1.8 -2.0 -1.0 -2.0 -0.15 -1.45 0.4 L-1.0 0.75 -1.0 3.5 1.0 3.5 1.0 0.75 1.4 0.4 Q2.0 -0.15 2.0 -1.0 2.0 -1.8 1.4 -2.4" fill="#000000" fill-rule="evenodd" stroke="none"/>
|
||||
<path d="M2.8 -9.3 L2.85 -9.25 Q4.0 -8.1 4.0 -6.35 L4.0 -4.45 Q4.8 -4.4 5.35 -3.8 6.0 -3.05 6.0 -2.1 L6.0 4.15 Q6.0 5.15 5.35 5.8 4.7 6.5 3.7 6.5 L-3.8 6.5 Q-4.75 6.5 -5.35 5.8 -6.0 5.15 -6.0 4.15 L-6.0 -2.1 Q-6.0 -3.05 -5.35 -3.8 -4.8 -4.4 -4.0 -4.5 L-4.0 -6.35 Q-4.0 -8.1 -2.85 -9.3 -1.65 -10.5 0.0 -10.5 1.65 -10.5 2.8 -9.3 M1.4 -7.9 Q0.8 -8.5 0.0 -8.5 -0.8 -8.5 -1.4 -7.9 -2.0 -7.25 -2.0 -6.35 L-2.0 -4.5 2.0 -4.5 2.0 -6.35 Q2.0 -7.3 1.4 -7.9" fill="url(#gradient0)" fill-rule="evenodd" stroke="none"/>
|
||||
<path d="M2.1 -8.6 Q1.2 -9.5 0.0 -9.5 -1.25 -9.5 -2.15 -8.6 L-2.1 -8.6 Q-3.0 -7.7 -3.0 -6.35 L-3.0 -4.5 -3.25 -3.85 Q-3.5 -3.55 -3.85 -3.5 L-4.6 -3.15 -4.6 -3.1 Q-5.0 -2.65 -5.0 -2.1 L-5.0 4.15 Q-5.0 4.7 -4.65 5.1 L-4.6 5.15 Q-4.3 5.5 -3.8 5.5 L3.7 5.5 Q4.25 5.5 4.65 5.15 L4.65 5.1 Q5.0 4.7 5.0 4.15 L5.0 -2.1 4.65 -3.1 4.6 -3.15 Q4.35 -3.45 3.95 -3.45 3.55 -3.5 3.3 -3.75 3.0 -4.05 3.0 -4.45 L3.0 -6.35 Q3.0 -7.65 2.15 -8.55 L2.1 -8.6 M2.8 -9.3 L2.85 -9.25 Q4.0 -8.1 4.0 -6.35 L4.0 -4.45 Q4.8 -4.4 5.35 -3.8 6.0 -3.05 6.0 -2.1 L6.0 4.15 Q6.0 5.15 5.35 5.8 4.7 6.5 3.7 6.5 L-3.8 6.5 Q-4.75 6.5 -5.35 5.8 -6.0 5.15 -6.0 4.15 L-6.0 -2.1 Q-6.0 -3.05 -5.35 -3.8 -4.8 -4.4 -4.0 -4.5 L-4.0 -6.35 Q-4.0 -8.1 -2.85 -9.3 -1.65 -10.5 0.0 -10.5 1.65 -10.5 2.8 -9.3" fill="#ffffff" fill-rule="evenodd" stroke="none"/>
|
||||
<path d="M1.5 -1.0 Q1.5 -0.4 1.05 0.05 L0.7 0.35 0.55 0.55 0.5 0.75 0.5 3.0 -0.5 3.0 -0.5 0.75 -0.55 0.5 -0.75 0.35 -1.1 0.05 Q-1.5 -0.35 -1.5 -1.0 -1.5 -1.6 -1.1 -2.0 L-1.05 -2.05 0.0 -2.5 1.05 -2.05 1.5 -1.0" fill="#000000" fill-rule="evenodd" stroke="none"/>
|
||||
<path d="M1.5 -1.0 L1.05 -2.05 0.0 -2.5 -1.05 -2.05 -1.1 -2.0 Q-1.5 -1.6 -1.5 -1.0 -1.5 -0.35 -1.1 0.05 L-0.75 0.35 -0.55 0.5 -0.5 0.75 -0.5 3.0 0.5 3.0 0.5 0.75 0.55 0.55 0.7 0.35 1.05 0.05 Q1.5 -0.4 1.5 -1.0 M1.75 -2.75 Q2.5 -2.0 2.5 -1.0 2.5 0.1 1.75 0.8 L1.75 0.75 1.5 1.0 1.5 3.5 1.35 3.85 1.0 4.0 -1.0 4.0 -1.35 3.85 -1.5 3.5 -1.5 1.0 -1.8 0.75 Q-2.5 0.05 -2.5 -1.0 -2.5 -2.0 -1.8 -2.75 -1.0 -3.5 0.0 -3.5 1.0 -3.5 1.75 -2.75" fill="#e7e9ed" fill-rule="evenodd" stroke="none"/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient gradientTransform="matrix(0.0, 0.0089, -0.0073, 0.0, 0.0, -2.2)" gradientUnits="userSpaceOnUse" id="gradient0" spreadMethod="pad" x1="-819.2" x2="819.2">
|
||||
<stop offset="0.00784313725490196" stop-color="#ffffff"/>
|
||||
<stop offset="0.3176470588235294" stop-color="#a4a4a4"/>
|
||||
<stop offset="0.34901960784313724" stop-color="#cccccc"/>
|
||||
<stop offset="1.0" stop-color="#999999"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 496 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 317 B |
|
After Width: | Height: | Size: 364 B |
|
After Width: | Height: | Size: 443 B |
|
After Width: | Height: | Size: 475 B |
|
After Width: | Height: | Size: 543 B |
|
After Width: | Height: | Size: 592 B |
|
After Width: | Height: | Size: 721 B |
|
After Width: | Height: | Size: 735 B |
|
After Width: | Height: | Size: 764 B |
|
After Width: | Height: | Size: 532 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 590 B |
|
After Width: | Height: | Size: 598 B |
|
After Width: | Height: | Size: 680 B |
|
After Width: | Height: | Size: 687 B |
|
After Width: | Height: | Size: 719 B |
|
After Width: | Height: | Size: 717 B |
|
After Width: | Height: | Size: 719 B |
|
After Width: | Height: | Size: 765 B |
|
After Width: | Height: | Size: 753 B |
|
After Width: | Height: | Size: 729 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 753 B |
|
After Width: | Height: | Size: 764 B |
|
After Width: | Height: | Size: 717 B |
|
After Width: | Height: | Size: 719 B |
|
After Width: | Height: | Size: 720 B |
|
After Width: | Height: | Size: 686 B |
|
After Width: | Height: | Size: 682 B |
|
After Width: | Height: | Size: 598 B |
|
After Width: | Height: | Size: 591 B |
|
After Width: | Height: | Size: 532 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 532 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
|
After Width: | Height: | Size: 77 B |
@@ -0,0 +1,5 @@
|
||||
5;"mochicrypt.Background"
|
||||
4;"mochicrypt.LockIcon"
|
||||
6;"mochicrypt.ConfigData"
|
||||
0;"mochicrypt.Preloader"
|
||||
7;"mochicrypt.Payload"
|
||||
|