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.*;
import flash.system.*;
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 lastProgress:Number;// = 0
private var patchDisabled:Boolean;// = false
private var adStarted:int;
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(){
this.lc = new LocalConnection();
this.adLoader = new Loader();
this.patchLoader = new Loader();
this.adStarted = getTimer();
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);
}
private function patchProgressHandler(_arg1:ProgressEvent):void{
if (_arg1.bytesLoaded == _arg1.bytesTotal){
this.patchProgress = NaN;
} else {
this.patchProgress = (Number(_arg1.bytesLoaded) / _arg1.bytesTotal);
};
this.progress();
}
private function adIOErrorHandler(_arg1:IOErrorEvent):void{
this.adDone = true;
this.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 = this.adjustFrameRate;
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;
var btn:Button;
if (((((!(this.payloadDone)) || (!(this.adDone)))) || (!(this.patchDone)))){
return;
};
if (this.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 - 32);
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 & 31))]) & 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 = this.patchLoader.content["patch"](data);
} catch(error:Error) {
trace("patch failed", error);
};
var vsn:String = Capabilities.version;
vsn = vsn.substring((vsn.indexOf(" ") + 1), vsn.indexOf(","));
if (data[3] > parseInt(vsn)){
btn = new Button();
btn.x = ((width - btn.width) / 2);
btn.y = ((height - btn.height) / 2);
addChild(btn);
} else {
try {
if (!isNaN(this.origFrameRate)){
stage.frameRate = this.origFrameRate;
};
} catch(error:Error) {
trace("resetting frameRate failed", error);
};
this.payloadLoader = new Loader();
addChild(this.payloadLoader);
this.payloadLoader.loadBytes(data);
};
this.patchLoader.unload();
this.adLoader.unload();
trace("ad should be gone...");
removeEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
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);
this.adLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, this.adIOErrorHandler);
this.lc.close();
removeChild(this.theme);
this.theme.removeChild(this.adLoader);
this.lc = null;
this.adLoader = null;
this.patchLoader = null;
this.theme = null;
}
private function enterFrameHandler(_arg1:Event):void{
this.progress();
if (((!(this.payloadDone)) && ((currentFrame == 2)))){
this.payloadDone = true;
this.finish();
};
}
private function initHandler(_arg1:Event):void{
var pair:String;
var kv:Array;
var event = _arg1;
try {
this.origFrameRate = stage.frameRate;
} catch(error:Error) {
trace("can't access stage.frameRate in initHandler", error);
};
this.adjustFrameRate(30);
var lcName:String = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
this.lc.client = this.makeLCClient();
this.lc.allowDomain("*", "x.mochiads.com");
this.lc.allowInsecureDomain("*", "x.mochiads.com");
this.lc.connect(lcName);
this.adLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.adIOErrorHandler);
this.adLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.adCompleteHandler);
var lv:URLVariables = new URLVariables();
var options:String = loaderInfo.parameters.mochiad_options;
if (options){
for (pair in options.split("&")) {
kv = pair.split("=");
lv[unescape(kv[0])] = lv[unescape(kv[1])];
};
};
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;
this.adLoader.x = (0.5 * loaderInfo.width);
this.adLoader.y = (0.5 * loaderInfo.height);
try {
this.adLoader.load(req);
} catch(error:Error) {
adDone = true;
};
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;
};
this.theme = new Theme(this.adLoader, loaderInfo.width, loaderInfo.height);
addChild(this.theme);
addEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
this.finish();
}
private function progressHandler(_arg1:ProgressEvent):void{
if (_arg1.bytesLoaded == _arg1.bytesTotal){
this.payloadProgress = NaN;
} else {
this.payloadProgress = (Number(_arg1.bytesLoaded) / _arg1.bytesTotal);
};
this.progress();
}
private function adjustFrameRate(_arg1:Number):void{
var newFrameRate = _arg1;
try {
if (!isNaN(this.origFrameRate)){
stage.frameRate = newFrameRate;
};
} catch(error:Error) {
trace("couldn't adjust stage.frameRate", error);
};
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
}
private function patchCompleteHandler(_arg1:Event):void{
this.patchDone = true;
this.finish();
}
private function progress():void{
var _local1:Number;
_local1 = 1;
if (!this.adDone){
_local1 = (Number((getTimer() - this.adStarted)) / this.adDuration);
};
if (((((!(this.payloadDone)) && (!(isNaN(this.payloadProgress))))) && ((this.payloadProgress < _local1)))){
_local1 = this.payloadProgress;
};
if (((((!(this.patchDone)) && (!(isNaN(this.patchProgress))))) && ((this.patchProgress < _local1)))){
_local1 = this.patchProgress;
};
if (_local1 > 1){
_local1 = 1;
};
if (_local1 > this.lastProgress){
this.lastProgress = _local1;
this.theme.updateProgress(this.lastProgress);
};
if (((!(this.adServerControl)) && ((getTimer() > (this.adStarted + this.adDuration))))){
trace("giving up... maybe?");
if (!this.adComplete){
this.adLoader.close();
};
this.adDone = true;
this.finish();
};
}
private function patchIOErrorHandler(_arg1:IOErrorEvent):void{
this.patchDone = true;
this.finish();
}
private function adCompleteHandler(_arg1:Event):void{
if (!this.adServerControl){
this.adStarted = getTimer();
};
this.adComplete = true;
this.progress();
}
private function completeHandler(_arg1:Event):void{
nextFrame();
}
}
}//package mochicrypt
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
class Button extends SimpleButton {
private function Button(){
var _local1 = "Download the latest\nAdobe Flash Player";
upState = new State(0xFFFFFF, _local1);
downState = new State(0xCCCCCC, _local1);
hitTestState = upState;
overState = upState;
addEventListener(MouseEvent.CLICK, this.buttonClicked);
width = upState.width;
height = upState.height;
}
public function buttonClicked(_arg1:Event):void{
navigateToURL(new URLRequest("http://get.adobe.com/flashplayer/"));
}
}
class State extends Sprite {
private function State(_arg1:uint, _arg2:String){
var _local3:TextFormat = new TextFormat("Verdana");
_local3.align = TextFormatAlign.CENTER;
var _local4:TextField = new TextField();
_local4.text = _arg2;
_local4.multiline = true;
_local4.x = (_local4.y = 2);
_local4.setTextFormat(_local3);
_local4.width = (_local4.textWidth + 4);
_local4.height = (_local4.textHeight + 4);
addChild(_local4);
var _local5:Graphics = graphics;
_local5.beginFill(_arg1);
_local5.lineStyle(1, 0);
_local5.drawRoundRect(0, 0, (_local4.width + 4), (_local4.height + 4), 4);
}
}
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 barForeground:Shape;
private var progressBar:Sprite;
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);
private static const SHOW_LOCK:Boolean = Config.getBool("showLock", true);
function Theme(_arg1:DisplayObject, _arg2:Number, _arg3:Number){
this.progressBar = new Sprite();
this.barBackground = new Shape();
this.barForeground = new Shape();
this.barOutline = new Shape();
super();
var _local4:Bitmap = new Background();
_local4.width = _arg2;
_local4.height = _arg3;
this.setupProgressBar(_arg2, _arg3);
addChild(_local4);
addChild(_arg1);
addChild(this.progressBar);
}
public function adLoaded(_arg1:Number, _arg2:Number):void{
}
private function setupProgressBar(_arg1:Number, _arg2:Number):void{
var _local3:Graphics;
var _local5:Number;
var _local8:MovieClip;
var _local4:Number = 0;
if (SHOW_LOCK){
_local4 = 20;
_local8 = new LockIcon();
_local8.addFrameScript(49, _local8.stop);
this.progressBar.addChild(_local8);
};
var _local6:Number = ((_arg1 - 20) - _local4);
var _local7:Number = 10;
_local3 = this.barBackground.graphics;
_local5 = ((ColorTools.getRedComponent(BAR_BACK_COLOR))>ColorTools.getBlueComponent(BAR_BACK_COLOR)) ? 0x660000 : 51;
DrawingMethods.roundedRect(_local3, true, 0, 0, _local6, _local7, "0", [ColorTools.getTintedColor(BAR_BACK_COLOR, _local5, 0.1), BAR_BACK_COLOR]);
_local3 = this.barForeground.graphics;
_local5 = ((ColorTools.getRedComponent(BAR_FORE_COLOR))>ColorTools.getBlueComponent(BAR_FORE_COLOR)) ? 0x660000 : 51;
DrawingMethods.roundedRect(_local3, true, 0, 0, _local6, _local7, "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, _local5, 0.3)], null, [0, 120, 121, 0xFF]);
DrawingMethods.roundedRect(_local3, false, 0, (10 * 0.4), _local6, 1, "0", [0xFFFFFF], [0.1]);
_local3 = this.barOutline.graphics;
DrawingMethods.emptyRect(_local3, true, 0, 0, _local6, (_local7 + 1), 1, BAR_OUTLINE_COLOR);
this.progressBar.addChild(this.barBackground);
this.progressBar.addChild(this.barForeground);
this.progressBar.addChild(this.barOutline);
this.barBackground.x = (this.barForeground.x = (this.barOutline.x = _local4));
this.barForeground.scaleX = 0;
this.progressBar.x = 10;
this.progressBar.y = (_arg2 - 20);
}
public function updateProgress(_arg1:Number):void{
this.barForeground.scaleX = _arg1;
}
}
}//package mochicrypt