Section 1
//ColorTools (mochicrypt.util.ColorTools)
package mochicrypt.util {
public class ColorTools {
public static function getGreenComponent(_arg1:uint):uint{
return (((_arg1 >> 8) & 0xFF));
}
public static function getRedComponent(_arg1:uint):uint{
return ((_arg1 >> 16));
}
public static function getBlueOffset(_arg1:uint, _arg2:Number):Number{
var _local3:uint = getBlueComponent(_arg1);
return ((_local3 * _arg2));
}
public static function getGreenOffset(_arg1:uint, _arg2:Number):Number{
var _local3:uint = getGreenComponent(_arg1);
return ((_local3 * _arg2));
}
public static function getTintedColor(_arg1:uint, _arg2:uint, _arg3:Number):uint{
var _local4:uint = getRedComponent(_arg1);
var _local5:uint = getGreenComponent(_arg1);
var _local6:uint = getBlueComponent(_arg1);
var _local7:uint = getRedComponent(_arg2);
var _local8:uint = getGreenComponent(_arg2);
var _local9:uint = getBlueComponent(_arg2);
return (((((_local4 + ((_local7 - _local4) * _arg3)) << 16) | ((_local5 + ((_local8 - _local5) * _arg3)) << 8)) | (_local6 + ((_local9 - _local6) * _arg3))));
}
public static function getBlueComponent(_arg1:uint):uint{
return ((_arg1 & 0xFF));
}
public static function getRedOffset(_arg1:uint, _arg2:Number):Number{
var _local3:uint = getRedComponent(_arg1);
return ((_local3 * _arg2));
}
}
}//package mochicrypt.util
Section 2
//DrawingMethods (mochicrypt.util.DrawingMethods)
package mochicrypt.util {
import flash.display.*;
import flash.geom.*;
public class DrawingMethods {
public static function emptyRect(_arg1:Graphics, _arg2:Boolean, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0, _arg7:Number=0, _arg8:Number=0):void{
if (_arg2 != false){
_arg1.clear();
};
if (_arg7 == 0){
_arg7 = 1;
};
_arg1.beginFill(_arg8, 100);
_arg1.moveTo(_arg3, _arg4);
_arg1.lineTo((_arg3 + _arg5), _arg4);
_arg1.lineTo((_arg3 + _arg5), (_arg4 + _arg6));
_arg1.lineTo(_arg3, (_arg4 + _arg6));
_arg1.lineTo(_arg3, _arg4);
_arg1.lineTo((_arg3 + _arg7), (_arg4 + _arg7));
_arg1.lineTo(((_arg3 + _arg5) - _arg7), (_arg4 + _arg7));
_arg1.lineTo(((_arg3 + _arg5) - _arg7), ((_arg4 + _arg6) - _arg7));
_arg1.lineTo((_arg3 + _arg7), ((_arg4 + _arg6) - _arg7));
_arg1.lineTo((_arg3 + _arg7), (_arg4 + _arg7));
_arg1.endFill();
}
public static function roundedRect(_arg1:Graphics, _arg2:Boolean, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0, _arg7:String="0", _arg8:Array=null, _arg9:Array=null, _arg10:Array=null, _arg11:Matrix=null, _arg12:Number=0, _arg13:Number=0, _arg14:Number=1):void{
var _local20:Number;
var _local15:Array = [];
var _local16:Number = 0;
var _local17:Number = 0;
var _local18:Number = 0;
var _local19:Number = 0;
if (_arg2 != false){
_arg1.clear();
};
if ((((_arg8 == null)) || ((_arg8.length < 1)))){
_arg8 = [0];
};
if ((((_arg9 == null)) || (!((_arg9.length == _arg8.length))))){
_arg9 = [];
_local20 = 0;
while (_local20 < _arg8.length) {
_arg9.push(100);
_local20++;
};
};
if ((((_arg10 == null)) || (!((_arg10.length == _arg8.length))))){
_arg10 = [];
_local20 = 0;
while (_local20 < _arg8.length) {
_arg10.push(((_local20 / (_arg8.length - 1)) * 0xFF));
_local20++;
};
};
if ((((_arg7 == null)) || ((_arg7 == "")))){
_arg7 = "0";
};
_local15 = _arg7.split(" ");
_local16 = parseInt(_local15[0]);
_local17 = ((_local15[1])==undefined) ? _local16 : parseInt(_local15[1]);
_local18 = ((_local15[2])==undefined) ? _local16 : parseInt(_local15[2]);
_local19 = ((_local15[3])==undefined) ? _local17 : parseInt(_local15[3]);
if (_arg12 > 0){
if (((isNaN(_arg14)) || ((_arg14 == 0)))){
_arg14 = 1;
};
_arg1.lineStyle(_arg12, _arg13, _arg14);
};
if (_arg8.length == 1){
_arg1.beginFill(_arg8[0], _arg9[0]);
} else {
if (_arg11 == null){
_arg11 = new Matrix();
_arg11.createGradientBox(_arg5, _arg6, (90 * (Math.PI / 180)), 0, 0);
};
_arg1.beginGradientFill("linear", _arg8, _arg9, _arg10, _arg11);
};
if (_local16 > 0){
_arg1.moveTo((_arg3 + _local16), _arg4);
} else {
_arg1.moveTo(_arg3, _arg4);
};
if (_local17 > 0){
_arg1.lineTo(((_arg3 + _arg5) - _local17), _arg4);
_arg1.curveTo((_arg3 + _arg5), _arg4, (_arg3 + _arg5), (_arg4 + _local17));
_arg1.lineTo((_arg3 + _arg5), (_arg4 + _local17));
} else {
_arg1.lineTo((_arg3 + _arg5), _arg4);
};
if (_local18 > 0){
_arg1.lineTo((_arg3 + _arg5), ((_arg4 + _arg6) - _local18));
_arg1.curveTo((_arg3 + _arg5), (_arg4 + _arg6), ((_arg3 + _arg5) - _local18), (_arg4 + _arg6));
_arg1.lineTo(((_arg3 + _arg5) - _local18), (_arg4 + _arg6));
} else {
_arg1.lineTo((_arg3 + _arg5), (_arg4 + _arg6));
};
if (_local19 > 0){
_arg1.lineTo((_arg3 + _local19), (_arg4 + _arg6));
_arg1.curveTo(_arg3, _arg6, _arg3, ((_arg4 + _arg6) - _local19));
_arg1.lineTo(_arg3, ((_arg4 + _arg6) - _local19));
} else {
_arg1.lineTo(_arg3, (_arg4 + _arg6));
};
if (_local16 > 0){
_arg1.lineTo(_arg3, (_arg4 + _local16));
_arg1.curveTo(_arg3, _arg4, (_arg3 + _local16), _arg4);
_arg1.lineTo((_arg3 + _local16), _arg4);
} else {
_arg1.lineTo(_arg3, _arg4);
};
_arg1.endFill();
}
}
}//package mochicrypt.util
Section 3
//Background (mochicrypt.Background)
package mochicrypt {
import flash.display.*;
public class Background extends Bitmap {
}
}//package mochicrypt
Section 4
//Config (mochicrypt.Config)
package mochicrypt {
import mochicrypt.*;
class Config {
private static const data:Object = new ConfigData().readObject();
public static function getBool(_arg1:String, _arg2:Boolean):Boolean{
return (((data[_arg1] is Boolean)) ? data[_arg1] : _arg2);
}
public static function getInt(_arg1:String, _arg2:int):int{
return (((data[_arg1] is int)) ? data[_arg1] : _arg2);
}
public static function getString(_arg1:String, _arg2:String):String{
return (((data[_arg1] is String)) ? data[_arg1] : _arg2);
}
}
}//package mochicrypt
Section 5
//ConfigData (mochicrypt.ConfigData)
package mochicrypt {
import flash.utils.*;
public class ConfigData extends ByteArray {
}
}//package mochicrypt
Section 6
//LockIcon (mochicrypt.LockIcon)
package mochicrypt {
import flash.display.*;
public class LockIcon extends MovieClip {
}
}//package mochicrypt
Section 7
//Payload (mochicrypt.Payload)
package mochicrypt {
import flash.utils.*;
public class Payload extends ByteArray {
}
}//package mochicrypt
Section 8
//Preloader (mochicrypt.Preloader)
package mochicrypt {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
public dynamic class Preloader extends MovieClip {
private var payloadLoader:Loader;
private var patchLoader:Loader;
private var adDone:Boolean;// = false
private var theme:Theme;
private var adServerControl:Boolean;// = false
private var adLoader:Loader;
private var adDuration:int;// = 11000
private var payloadProgress:Number;// = 0
private var patchProgress:Number;// = 0
private var adStarted:int;
private var lastProgress:Number;// = 0
private var patchDisabled:Boolean;// = false
private var patchDone:Boolean;// = false
private var payloadDone:Boolean;// = false
private var origFrameRate:Number;// = NAN
private var adComplete:Boolean;// = false
private var lc:LocalConnection;
private static const AD_BACKGROUND:Boolean = Config.getBool("adBackground", false);
private static const AD_URL:String = Config.getString("adURL", "http://x.mochiads.com/srv/1/");
private static const PATCH_URL:String = Config.getString("patchURL", "http://cdn.mochiads.com/patch.swf");
private static const ID:String = Config.getString("id", "test");
private static const PAYLOAD_NAME:String = "mochicrypt.Payload";
private static const VERSION:String = "2.3c";
public function Preloader(){
lc = new LocalConnection();
adLoader = new Loader();
patchLoader = new Loader();
adStarted = getTimer();
super();
loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loaderInfo.addEventListener(Event.INIT, initHandler);
loaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
private function patchProgressHandler(_arg1:ProgressEvent):void{
if (_arg1.bytesLoaded == _arg1.bytesTotal){
patchProgress = NaN;
} else {
patchProgress = (Number(_arg1.bytesLoaded) / _arg1.bytesTotal);
};
progress();
}
private function adIOErrorHandler(_arg1:IOErrorEvent):void{
adDone = true;
finish();
}
private function makeLCClient():Object{
var obj:Object = {};
obj.unloadAd = function ():void{
trace("unloadAd");
adDone = true;
finish();
};
obj.adSkipped = function ():void{
trace("adSkipped");
adDone = true;
finish();
};
obj.adLoaded = function (_arg1:Number, _arg2:Number):void{
trace("adLoaded called");
theme.adLoaded(_arg1, _arg2);
};
obj.adjustProgress = function (_arg1:Number):void{
trace("adjustProgress called");
adServerControl = true;
adStarted = getTimer();
adDuration = _arg1;
};
obj.adjustFrameRate = function (_arg1:Number):void{
var newFrameRate = _arg1;
try {
if (!isNaN(origFrameRate)){
stage.frameRate = newFrameRate;
};
} catch(error:Error) {
trace("couldn't adjust stage.frameRate", error);
};
};
obj.disablePatch = function ():void{
patchDisabled = true;
};
return (obj);
}
private function finish():void{
var i:uint;
var j:uint;
var k:uint;
var n:uint;
var u:uint;
var v:uint;
if (((((!(payloadDone)) || (!(adDone)))) || (!(patchDone)))){
return;
};
if (payloadLoader){
trace("unexpected call to finish()");
return;
};
var payloadClass:Class = Class(getDefinitionByName(PAYLOAD_NAME));
var data:ByteArray = ByteArray(new (payloadClass));
trace("data.length", data.length);
var S:ByteArray = new ByteArray();
n = (data.length - 16);
i = 0;
while (i < 0x0100) {
S.writeByte(i);
i = (i + 1);
};
j = 0;
i = 0;
while (i < 0x0100) {
j = (((j + S[i]) + data[(n + (i & 15))]) & 0xFF);
u = S[i];
S[i] = S[j];
S[j] = u;
i = (i + 1);
};
if (n > 131072){
n = 131072;
};
var _local2:int;
j = _local2;
i = _local2;
k = 0;
while (k < n) {
i = ((i + 1) & 0xFF);
u = S[i];
j = ((j + u) & 0xFF);
v = S[j];
S[i] = v;
S[j] = u;
data[k] = (data[k] ^ S[((u + v) & 0xFF)]);
k = (k + 1);
};
data.uncompress();
try {
data = patchLoader.content["patch"](data);
} catch(error:Error) {
trace("patch failed", error);
};
try {
if (!isNaN(origFrameRate)){
stage.frameRate = origFrameRate;
};
} catch(error:Error) {
trace("resetting frameRate failed", error);
};
payloadLoader = new Loader();
addChild(payloadLoader);
payloadLoader.loadBytes(data);
patchLoader.unload();
adLoader.unload();
trace("ad should be gone...");
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
loaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
loaderInfo.removeEventListener(Event.INIT, initHandler);
loaderInfo.removeEventListener(Event.COMPLETE, completeHandler);
loaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
patchLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, patchIOErrorHandler);
patchLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, patchProgressHandler);
patchLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, patchCompleteHandler);
adLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, adIOErrorHandler);
lc.close();
removeChild(theme);
theme.removeChild(adLoader);
lc = null;
adLoader = null;
patchLoader = null;
theme = null;
}
private function enterFrameHandler(_arg1:Event):void{
progress();
if (((!(payloadDone)) && ((currentFrame == 2)))){
payloadDone = true;
finish();
};
}
private function initHandler(_arg1:Event):void{
var event = _arg1;
try {
origFrameRate = stage.frameRate;
} catch(error:Error) {
trace("can't access stage.frameRate in initHandler", error);
};
var lcName:String = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.client = makeLCClient();
lc.allowDomain("*", "x.mochiads.com");
lc.allowInsecureDomain("*", "x.mochiads.com");
lc.connect(lcName);
adLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, adIOErrorHandler);
adLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, adCompleteHandler);
var lv:URLVariables = new URLVariables();
lv.id = ID;
lv.res = ((("" + loaderInfo.width) + "x") + loaderInfo.height);
lv.method = "showPreloaderAd";
lv.swfv = loaderInfo.swfVersion;
lv.mav = VERSION;
lv.lc = lcName;
lv.st = getTimer();
lv.as3_swf = loaderInfo.loaderURL;
lv.no_bg = !(AD_BACKGROUND);
var req:URLRequest = new URLRequest(((AD_URL + ID) + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
adLoader.x = (0.5 * loaderInfo.width);
adLoader.y = (0.5 * loaderInfo.height);
try {
adLoader.load(req);
} catch(error:Error) {
adDone = true;
};
patchLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, patchIOErrorHandler);
patchLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, patchProgressHandler);
patchLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, patchCompleteHandler);
try {
patchLoader.load(new URLRequest(PATCH_URL));
} catch(error:Error) {
patchDone = true;
};
theme = new Theme(adLoader, loaderInfo.width, loaderInfo.height);
addChild(theme);
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
finish();
}
private function progressHandler(_arg1:ProgressEvent):void{
if (_arg1.bytesLoaded == _arg1.bytesTotal){
payloadProgress = NaN;
} else {
payloadProgress = (Number(_arg1.bytesLoaded) / _arg1.bytesTotal);
};
progress();
}
private function completeHandler(_arg1:Event):void{
nextFrame();
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
}
private function patchCompleteHandler(_arg1:Event):void{
patchDone = true;
finish();
}
private function progress():void{
var _local1:Number;
_local1 = 1;
if (!adDone){
_local1 = (Number((getTimer() - adStarted)) / adDuration);
};
if (((((!(payloadDone)) && (!(isNaN(payloadProgress))))) && ((payloadProgress < _local1)))){
_local1 = payloadProgress;
};
if (((((!(patchDone)) && (!(isNaN(patchProgress))))) && ((patchProgress < _local1)))){
_local1 = patchProgress;
};
if (_local1 > 1){
_local1 = 1;
};
if (_local1 > lastProgress){
lastProgress = _local1;
theme.updateProgress(lastProgress);
};
if (((!(adServerControl)) && ((getTimer() > (adStarted + adDuration))))){
trace("giving up... maybe?");
if (!adComplete){
adLoader.close();
};
adDone = true;
finish();
};
}
private function patchIOErrorHandler(_arg1:IOErrorEvent):void{
patchDone = true;
finish();
}
private function adCompleteHandler(_arg1:Event):void{
if (!adServerControl){
adStarted = getTimer();
};
adComplete = true;
progress();
}
}
}//package mochicrypt
Section 9
//Theme (mochicrypt.Theme)
package mochicrypt {
import flash.display.*;
import mochicrypt.*;
import mochicrypt.util.*;
class Theme extends Sprite {
private var barBackground:Shape;
private var _barTopColor:Number;
private var _barBottomColor:Number;
private var progressBar:Sprite;
private var barForeground:Shape;
private var barOutline:Shape;
private static const BAR_BACK_COLOR:int = Config.getInt("barBackColor", 16777161);
private static const BAR_OUTLINE_COLOR:int = Config.getInt("barOutlineColor", 13994812);
private static const BAR_FORE_COLOR:int = Config.getInt("barForeColor", 0xFF8A00);
function Theme(_arg1:DisplayObject, _arg2:Number, _arg3:Number){
progressBar = new Sprite();
barBackground = new Shape();
barForeground = new Shape();
barOutline = new Shape();
super();
var _local4:Bitmap = new Background();
_local4.width = _arg2;
_local4.height = _arg3;
setupProgressBar(_arg2, _arg3);
addChild(_local4);
addChild(_arg1);
addChild(progressBar);
}
public function adLoaded(_arg1:Number, _arg2:Number):void{
}
private function setupProgressBar(_arg1:Number, _arg2:Number):void{
var _local3:Graphics;
var _local4:Number;
var _local5:Number = (_arg1 - 40);
var _local6:Number = 10;
setColors();
_local3 = barBackground.graphics;
_local4 = ((ColorTools.getRedComponent(BAR_BACK_COLOR))>ColorTools.getBlueComponent(BAR_BACK_COLOR)) ? 0x660000 : 51;
DrawingMethods.roundedRect(_local3, true, 0, 0, _local5, _local6, "0", [ColorTools.getTintedColor(BAR_BACK_COLOR, _local4, 0.1), BAR_BACK_COLOR]);
_local3 = barForeground.graphics;
_local4 = ((ColorTools.getRedComponent(BAR_FORE_COLOR))>ColorTools.getBlueComponent(BAR_FORE_COLOR)) ? 0x660000 : 51;
DrawingMethods.roundedRect(_local3, true, 0, 0, _local5, _local6, "0", [ColorTools.getTintedColor(BAR_FORE_COLOR, 0xFFFFFF, 0.4), ColorTools.getTintedColor(BAR_FORE_COLOR, 0xFFFFFF, 0.2), BAR_FORE_COLOR, ColorTools.getTintedColor(BAR_FORE_COLOR, _local4, 0.3)], null, [0, 120, 121, 0xFF]);
DrawingMethods.roundedRect(_local3, false, 0, (10 * 0.4), _local5, 1, "0", [0xFFFFFF], [0.1]);
_local3 = barOutline.graphics;
DrawingMethods.emptyRect(_local3, true, 0, 0, _local5, (_local6 + 1), 1, BAR_OUTLINE_COLOR);
progressBar.addChild(barBackground);
progressBar.addChild(barForeground);
progressBar.addChild(barOutline);
barBackground.x = (barForeground.x = (barOutline.x = 20));
barForeground.scaleX = 0;
progressBar.x = 10;
progressBar.y = (_arg2 - 20);
var _local7:MovieClip = new LockIcon();
_local7.addFrameScript(49, _local7.stop);
progressBar.addChild(_local7);
}
private function setColors():void{
_barTopColor = ColorTools.getTintedColor(BAR_FORE_COLOR, 0xFFFFFF, 20);
_barBottomColor = ColorTools.getTintedColor(BAR_FORE_COLOR, 0, 20);
}
public function updateProgress(_arg1:Number):void{
barForeground.scaleX = _arg1;
}
}
}//package mochicrypt