Section 1
//MD5 (com.adobe.crypto.MD5)
package com.adobe.crypto {
import flash.utils.*;
import com.adobe.utils.*;
public class MD5 {
public static var digest:ByteArray;
private static function ff(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (transform(f, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
private static function f(_arg1:int, _arg2:int, _arg3:int):int{
return (((_arg1 & _arg2) | (~(_arg1) & _arg3)));
}
private static function g(_arg1:int, _arg2:int, _arg3:int):int{
return (((_arg1 & _arg3) | (_arg2 & ~(_arg3))));
}
private static function h(_arg1:int, _arg2:int, _arg3:int):int{
return (((_arg1 ^ _arg2) ^ _arg3));
}
private static function i(_arg1:int, _arg2:int, _arg3:int):int{
return ((_arg2 ^ (_arg1 | ~(_arg3))));
}
private static function transform(_arg1:Function, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int, _arg8:int):int{
var _local9:int = (((_arg2 + int(_arg1(_arg3, _arg4, _arg5))) + _arg6) + _arg8);
return ((IntUtil.rol(_local9, _arg7) + _arg3));
}
private static function hh(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (transform(h, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
public static function hash(_arg1:String):String{
var _local2:ByteArray = new ByteArray();
_local2.writeUTFBytes(_arg1);
return (hashBinary(_local2));
}
private static function createBlocks(_arg1:ByteArray):Array{
var _local2:Array = new Array();
var _local3:int = (_arg1.length * 8);
var _local4 = 0xFF;
var _local5:int;
while (_local5 < _local3) {
_local2[int((_local5 >> 5))] = (_local2[int((_local5 >> 5))] | ((_arg1[(_local5 / 8)] & _local4) << (_local5 % 32)));
_local5 = (_local5 + 8);
};
_local2[int((_local3 >> 5))] = (_local2[int((_local3 >> 5))] | (128 << (_local3 % 32)));
_local2[int(((((_local3 + 64) >>> 9) << 4) + 14))] = _local3;
return (_local2);
}
public static function hashBinary(_arg1:ByteArray):String{
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local2 = 1732584193;
var _local3 = -271733879;
var _local4 = -1732584194;
var _local5 = 271733878;
var _local10:Array = createBlocks(_arg1);
var _local11:int = _local10.length;
var _local12:int;
while (_local12 < _local11) {
_local6 = _local2;
_local7 = _local3;
_local8 = _local4;
_local9 = _local5;
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 0))], 7, -680876936);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 1))], 12, -389564586);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 2))], 17, 606105819);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 3))], 22, -1044525330);
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 4))], 7, -176418897);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 5))], 12, 1200080426);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 6))], 17, -1473231341);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 7))], 22, -45705983);
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 8))], 7, 1770035416);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 9))], 12, -1958414417);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 10))], 17, -42063);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 11))], 22, -1990404162);
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 12))], 7, 1804603682);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 13))], 12, -40341101);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 14))], 17, -1502002290);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 15))], 22, 1236535329);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 1))], 5, -165796510);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 6))], 9, -1069501632);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 11))], 14, 643717713);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 0))], 20, -373897302);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 5))], 5, -701558691);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 10))], 9, 38016083);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 15))], 14, -660478335);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 4))], 20, -405537848);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 9))], 5, 568446438);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 14))], 9, -1019803690);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 3))], 14, -187363961);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 8))], 20, 1163531501);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 13))], 5, -1444681467);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 2))], 9, -51403784);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 7))], 14, 1735328473);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 12))], 20, -1926607734);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 5))], 4, -378558);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 8))], 11, -2022574463);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 11))], 16, 1839030562);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 14))], 23, -35309556);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 1))], 4, -1530992060);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 4))], 11, 1272893353);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 7))], 16, -155497632);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 10))], 23, -1094730640);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 13))], 4, 681279174);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 0))], 11, -358537222);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 3))], 16, -722521979);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 6))], 23, 76029189);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 9))], 4, -640364487);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 12))], 11, -421815835);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 15))], 16, 530742520);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 2))], 23, -995338651);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 0))], 6, -198630844);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 7))], 10, 1126891415);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 14))], 15, -1416354905);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 5))], 21, -57434055);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 12))], 6, 1700485571);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 3))], 10, -1894986606);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 10))], 15, -1051523);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 1))], 21, -2054922799);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 8))], 6, 1873313359);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 15))], 10, -30611744);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 6))], 15, -1560198380);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 13))], 21, 1309151649);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 4))], 6, -145523070);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 11))], 10, -1120210379);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 2))], 15, 718787259);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 9))], 21, -343485551);
_local2 = (_local2 + _local6);
_local3 = (_local3 + _local7);
_local4 = (_local4 + _local8);
_local5 = (_local5 + _local9);
_local12 = (_local12 + 16);
};
digest = new ByteArray();
digest.writeInt(_local2);
digest.writeInt(_local3);
digest.writeInt(_local4);
digest.writeInt(_local5);
digest.position = 0;
return ((((IntUtil.toHex(_local2) + IntUtil.toHex(_local3)) + IntUtil.toHex(_local4)) + IntUtil.toHex(_local5)));
}
private static function gg(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (transform(g, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
private static function ii(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (transform(i, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
public static function hashBytes(_arg1:ByteArray):String{
return (hashBinary(_arg1));
}
}
}//package com.adobe.crypto
Section 2
//JSON (com.adobe.serialization.json.JSON)
package com.adobe.serialization.json {
public class JSON {
public static function decode(_arg1:String){
var _local2:JSONDecoder = new JSONDecoder(_arg1);
return (_local2.getValue());
}
public static function encode(_arg1:Object):String{
var _local2:JSONEncoder = new JSONEncoder(_arg1);
return (_local2.getString());
}
}
}//package com.adobe.serialization.json
Section 3
//JSONDecoder (com.adobe.serialization.json.JSONDecoder)
package com.adobe.serialization.json {
public class JSONDecoder {
private var value;
private var tokenizer:JSONTokenizer;
private var token:JSONToken;
public function JSONDecoder(_arg1:String){
tokenizer = new JSONTokenizer(_arg1);
nextToken();
value = parseValue();
}
private function parseObject():Object{
var _local2:String;
var _local1:Object = new Object();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (_local1);
};
while (true) {
if (token.type == JSONTokenType.STRING){
_local2 = String(token.value);
nextToken();
if (token.type == JSONTokenType.COLON){
nextToken();
_local1[_local2] = parseValue();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (_local1);
};
if (token.type == JSONTokenType.COMMA){
nextToken();
} else {
tokenizer.parseError(("Expecting } or , but found " + token.value));
};
} else {
tokenizer.parseError(("Expecting : but found " + token.value));
};
} else {
tokenizer.parseError(("Expecting string but found " + token.value));
};
};
return (null);
}
private function parseValue():Object{
if (token == null){
tokenizer.parseError("Unexpected end of input");
};
switch (token.type){
case JSONTokenType.LEFT_BRACE:
return (parseObject());
case JSONTokenType.LEFT_BRACKET:
return (parseArray());
case JSONTokenType.STRING:
case JSONTokenType.NUMBER:
case JSONTokenType.TRUE:
case JSONTokenType.FALSE:
case JSONTokenType.NULL:
return (token.value);
default:
tokenizer.parseError(("Unexpected " + token.value));
};
return (null);
}
private function nextToken():JSONToken{
return ((token = tokenizer.getNextToken()));
}
public function getValue(){
return (value);
}
private function parseArray():Array{
var _local1:Array = new Array();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (_local1);
};
while (true) {
_local1.push(parseValue());
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (_local1);
};
if (token.type == JSONTokenType.COMMA){
nextToken();
} else {
tokenizer.parseError(("Expecting ] or , but found " + token.value));
};
};
return (null);
}
}
}//package com.adobe.serialization.json
Section 4
//JSONEncoder (com.adobe.serialization.json.JSONEncoder)
package com.adobe.serialization.json {
import flash.utils.*;
public class JSONEncoder {
private var jsonString:String;
public function JSONEncoder(_arg1){
jsonString = convertToString(_arg1);
}
private function escapeString(_arg1:String):String{
var _local3:String;
var _local6:String;
var _local7:String;
var _local2 = "";
var _local4:Number = _arg1.length;
var _local5:int;
while (_local5 < _local4) {
_local3 = _arg1.charAt(_local5);
switch (_local3){
case "\"":
_local2 = (_local2 + "\\\"");
break;
case "\\":
_local2 = (_local2 + "\\\\");
break;
case "\b":
_local2 = (_local2 + "\\b");
break;
case "\f":
_local2 = (_local2 + "\\f");
break;
case "\n":
_local2 = (_local2 + "\\n");
break;
case "\r":
_local2 = (_local2 + "\\r");
break;
case "\t":
_local2 = (_local2 + "\\t");
break;
default:
if (_local3 < " "){
_local6 = _local3.charCodeAt(0).toString(16);
_local7 = ((_local6.length == 2)) ? "00" : "000";
_local2 = (_local2 + (("\\u" + _local7) + _local6));
} else {
_local2 = (_local2 + _local3);
};
};
_local5++;
};
return ((("\"" + _local2) + "\""));
}
private function arrayToString(_arg1:Array):String{
var _local2 = "";
var _local3:int;
while (_local3 < _arg1.length) {
if (_local2.length > 0){
_local2 = (_local2 + ",");
};
_local2 = (_local2 + convertToString(_arg1[_local3]));
_local3++;
};
return ((("[" + _local2) + "]"));
}
public function getString():String{
return (jsonString);
}
private function objectToString(_arg1:Object):String{
var value:Object;
var key:String;
var v:XML;
var o = _arg1;
var s = "";
var classInfo:XML = describeType(o);
if (classInfo.@name.toString() == "Object"){
for (key in o) {
value = o[key];
if ((value is Function)){
} else {
if (s.length > 0){
s = (s + ",");
};
s = (s + ((escapeString(key) + ":") + convertToString(value)));
};
};
} else {
for each (v in classInfo..*.(((name() == "variable")) || ((name() == "accessor")))) {
if (s.length > 0){
s = (s + ",");
};
s = (s + ((escapeString(v.@name.toString()) + ":") + convertToString(o[v.@name])));
};
};
return ((("{" + s) + "}"));
}
private function convertToString(_arg1):String{
if ((_arg1 is String)){
return (escapeString((_arg1 as String)));
};
if ((_arg1 is Number)){
return ((isFinite((_arg1 as Number))) ? _arg1.toString() : "null");
} else {
if ((_arg1 is Boolean)){
return ((_arg1) ? "true" : "false");
} else {
if ((_arg1 is Array)){
return (arrayToString((_arg1 as Array)));
};
if ((((_arg1 is Object)) && (!((_arg1 == null))))){
return (objectToString(_arg1));
};
};
};
return ("null");
}
}
}//package com.adobe.serialization.json
Section 5
//JSONParseError (com.adobe.serialization.json.JSONParseError)
package com.adobe.serialization.json {
public class JSONParseError extends Error {
private var _location:int;
private var _text:String;
public function JSONParseError(_arg1:String="", _arg2:int=0, _arg3:String=""){
super(_arg1);
name = "JSONParseError";
_location = _arg2;
_text = _arg3;
}
public function get location():int{
return (_location);
}
public function get text():String{
return (_text);
}
}
}//package com.adobe.serialization.json
Section 6
//JSONToken (com.adobe.serialization.json.JSONToken)
package com.adobe.serialization.json {
public class JSONToken {
private var _value:Object;
private var _type:int;
public function JSONToken(_arg1:int=-1, _arg2:Object=null){
_type = _arg1;
_value = _arg2;
}
public function get value():Object{
return (_value);
}
public function get type():int{
return (_type);
}
public function set type(_arg1:int):void{
_type = _arg1;
}
public function set value(_arg1:Object):void{
_value = _arg1;
}
}
}//package com.adobe.serialization.json
Section 7
//JSONTokenizer (com.adobe.serialization.json.JSONTokenizer)
package com.adobe.serialization.json {
public class JSONTokenizer {
private var loc:int;
private var ch:String;
private var obj:Object;
private var jsonString:String;
public function JSONTokenizer(_arg1:String){
jsonString = _arg1;
loc = 0;
nextChar();
}
private function skipComments():void{
if (ch == "/"){
nextChar();
switch (ch){
case "/":
do {
nextChar();
} while (((!((ch == "\n"))) && (!((ch == "")))));
nextChar();
break;
case "*":
nextChar();
while (true) {
if (ch == "*"){
nextChar();
if (ch == "/"){
nextChar();
break;
};
} else {
nextChar();
};
if (ch == ""){
parseError("Multi-line comment not closed");
};
};
break;
default:
parseError((("Unexpected " + ch) + " encountered (expecting '/' or '*' )"));
};
};
}
private function isDigit(_arg1:String):Boolean{
return ((((_arg1 >= "0")) && ((_arg1 <= "9"))));
}
private function readString():JSONToken{
var _local3:String;
var _local4:int;
var _local1:JSONToken = new JSONToken();
_local1.type = JSONTokenType.STRING;
var _local2 = "";
nextChar();
while (((!((ch == "\""))) && (!((ch == ""))))) {
if (ch == "\\"){
nextChar();
switch (ch){
case "\"":
_local2 = (_local2 + "\"");
break;
case "/":
_local2 = (_local2 + "/");
break;
case "\\":
_local2 = (_local2 + "\\");
break;
case "b":
_local2 = (_local2 + "\b");
break;
case "f":
_local2 = (_local2 + "\f");
break;
case "n":
_local2 = (_local2 + "\n");
break;
case "r":
_local2 = (_local2 + "\r");
break;
case "t":
_local2 = (_local2 + "\t");
break;
case "u":
_local3 = "";
_local4 = 0;
while (_local4 < 4) {
if (!isHexDigit(nextChar())){
parseError((" Excepted a hex digit, but found: " + ch));
};
_local3 = (_local3 + ch);
_local4++;
};
_local2 = (_local2 + String.fromCharCode(parseInt(_local3, 16)));
break;
default:
_local2 = (_local2 + ("\\" + ch));
};
} else {
_local2 = (_local2 + ch);
};
nextChar();
};
if (ch == ""){
parseError("Unterminated string literal");
};
nextChar();
_local1.value = _local2;
return (_local1);
}
private function nextChar():String{
return ((ch = jsonString.charAt(loc++)));
}
public function getNextToken():JSONToken{
var _local2:String;
var _local3:String;
var _local4:String;
var _local1:JSONToken = new JSONToken();
skipIgnored();
switch (ch){
case "{":
_local1.type = JSONTokenType.LEFT_BRACE;
_local1.value = "{";
nextChar();
break;
case "}":
_local1.type = JSONTokenType.RIGHT_BRACE;
_local1.value = "}";
nextChar();
break;
case "[":
_local1.type = JSONTokenType.LEFT_BRACKET;
_local1.value = "[";
nextChar();
break;
case "]":
_local1.type = JSONTokenType.RIGHT_BRACKET;
_local1.value = "]";
nextChar();
break;
case ",":
_local1.type = JSONTokenType.COMMA;
_local1.value = ",";
nextChar();
break;
case ":":
_local1.type = JSONTokenType.COLON;
_local1.value = ":";
nextChar();
break;
case "t":
_local2 = ((("t" + nextChar()) + nextChar()) + nextChar());
if (_local2 == "true"){
_local1.type = JSONTokenType.TRUE;
_local1.value = true;
nextChar();
} else {
parseError(("Expecting 'true' but found " + _local2));
};
break;
case "f":
_local3 = (((("f" + nextChar()) + nextChar()) + nextChar()) + nextChar());
if (_local3 == "false"){
_local1.type = JSONTokenType.FALSE;
_local1.value = false;
nextChar();
} else {
parseError(("Expecting 'false' but found " + _local3));
};
break;
case "n":
_local4 = ((("n" + nextChar()) + nextChar()) + nextChar());
if (_local4 == "null"){
_local1.type = JSONTokenType.NULL;
_local1.value = null;
nextChar();
} else {
parseError(("Expecting 'null' but found " + _local4));
};
break;
case "\"":
_local1 = readString();
break;
default:
if (((isDigit(ch)) || ((ch == "-")))){
_local1 = readNumber();
} else {
if (ch == ""){
return (null);
};
parseError((("Unexpected " + ch) + " encountered"));
};
};
return (_local1);
}
private function skipWhite():void{
while (isWhiteSpace(ch)) {
nextChar();
};
}
public function parseError(_arg1:String):void{
throw (new JSONParseError(_arg1, loc, jsonString));
}
private function isWhiteSpace(_arg1:String):Boolean{
return ((((((((_arg1 == " ")) || ((_arg1 == "\t")))) || ((_arg1 == "\n")))) || ((_arg1 == "\r"))));
}
private function skipIgnored():void{
var _local1:int;
do {
_local1 = loc;
skipWhite();
skipComments();
} while (_local1 != loc);
}
private function isHexDigit(_arg1:String):Boolean{
var _local2:String = _arg1.toUpperCase();
return (((isDigit(_arg1)) || ((((_local2 >= "A")) && ((_local2 <= "F"))))));
}
private function readNumber():JSONToken{
var _local1:JSONToken = new JSONToken();
_local1.type = JSONTokenType.NUMBER;
var _local2 = "";
if (ch == "-"){
_local2 = (_local2 + "-");
nextChar();
};
if (!isDigit(ch)){
parseError("Expecting a digit");
};
if (ch == "0"){
_local2 = (_local2 + ch);
nextChar();
if (isDigit(ch)){
parseError("A digit cannot immediately follow 0");
};
} else {
while (isDigit(ch)) {
_local2 = (_local2 + ch);
nextChar();
};
};
if (ch == "."){
_local2 = (_local2 + ".");
nextChar();
if (!isDigit(ch)){
parseError("Expecting a digit");
};
while (isDigit(ch)) {
_local2 = (_local2 + ch);
nextChar();
};
};
if ((((ch == "e")) || ((ch == "E")))){
_local2 = (_local2 + "e");
nextChar();
if ((((ch == "+")) || ((ch == "-")))){
_local2 = (_local2 + ch);
nextChar();
};
if (!isDigit(ch)){
parseError("Scientific notation number needs exponent value");
};
while (isDigit(ch)) {
_local2 = (_local2 + ch);
nextChar();
};
};
var _local3:Number = Number(_local2);
if (((isFinite(_local3)) && (!(isNaN(_local3))))){
_local1.value = _local3;
return (_local1);
};
parseError((("Number " + _local3) + " is not valid!"));
return (null);
}
}
}//package com.adobe.serialization.json
Section 8
//JSONTokenType (com.adobe.serialization.json.JSONTokenType)
package com.adobe.serialization.json {
public class JSONTokenType {
public static const NUMBER:int = 11;
public static const FALSE:int = 8;
public static const RIGHT_BRACKET:int = 4;
public static const NULL:int = 9;
public static const TRUE:int = 7;
public static const RIGHT_BRACE:int = 2;
public static const UNKNOWN:int = -1;
public static const COMMA:int = 0;
public static const LEFT_BRACKET:int = 3;
public static const STRING:int = 10;
public static const LEFT_BRACE:int = 1;
public static const COLON:int = 6;
}
}//package com.adobe.serialization.json
Section 9
//IntUtil (com.adobe.utils.IntUtil)
package com.adobe.utils {
public class IntUtil {
private static var hexChars:String = "0123456789abcdef";
public static function toHex(_arg1:int, _arg2:Boolean=false):String{
var _local4:int;
var _local5:int;
var _local3 = "";
if (_arg2){
_local4 = 0;
while (_local4 < 4) {
_local3 = (_local3 + (hexChars.charAt(((_arg1 >> (((3 - _local4) * 8) + 4)) & 15)) + hexChars.charAt(((_arg1 >> ((3 - _local4) * 8)) & 15))));
_local4++;
};
} else {
_local5 = 0;
while (_local5 < 4) {
_local3 = (_local3 + (hexChars.charAt(((_arg1 >> ((_local5 * 8) + 4)) & 15)) + hexChars.charAt(((_arg1 >> (_local5 * 8)) & 15))));
_local5++;
};
};
return (_local3);
}
public static function ror(_arg1:int, _arg2:int):uint{
var _local3:int = (32 - _arg2);
return (((_arg1 << _local3) | (_arg1 >>> (32 - _local3))));
}
public static function rol(_arg1:int, _arg2:int):int{
return (((_arg1 << _arg2) | (_arg1 >>> (32 - _arg2))));
}
}
}//package com.adobe.utils
Section 10
//Library (com.ccapi.Library)
package com.ccapi {
import flash.events.*;
import com.adobe.serialization.json.*;
import flash.utils.*;
import flash.text.*;
import flash.display.*;
import flash.net.*;
import flash.external.*;
public class Library extends MovieClip {
private var _outBox:TextField;
private var _logText:String;// = ""
private var _outBoxExists:Boolean;// = false
private static var _returnUserDataTimer:Timer;
private static var _returnUserDataCallback:Function = null;
private static var _requestDialogCallback:Function = null;
public function Library(){
_outBox = new TextField();
super();
}
public function showLeaderboard(){
return (navTo((Api.instance._vars.baseurl + "leaderboard")));
}
public function showRequestDialog(_arg1:String, _arg2:Function, _arg3=null){
_requestDialogCallback = _arg2;
callJS("showRequestDialog", [_arg1, (_arg3) ? _arg3 : 0]);
}
public function updateUserCredits(_arg1:int, _arg2:Boolean=false){
Api.instance.header.update({credits:_arg1});
if (_arg2){
Api.instance.player.updateCache("credits", _arg1);
};
return (true);
}
public function updateUserLevel(_arg1:int, _arg2:int){
Api.instance.header.update({level:_arg1, points:_arg2});
}
public function getUserData(_arg1:Array, _arg2:Array, _arg3:Function){
var fbids = _arg1;
var fields = _arg2;
var callback = _arg3;
_returnUserDataCallback = callback;
_returnUserDataTimer = new Timer(3000, 1);
_returnUserDataTimer.addEventListener(TimerEvent.TIMER, function (_arg1:TimerEvent){
Api.instance.out("getUserData timed out");
Api.instance.returnUserData("fail");
});
callJS("retrieveUserData", [fbids, fields]);
_returnUserDataTimer.start();
}
public function json_encode(_arg1:Object){
var out:String;
var object = _arg1;
try {
out = JSON.encode(object);
return (out);
} catch(error:Error) {
return (false);
};
}
public function out(_arg1){
var _local3:*;
var _local2:Api = Api.instance;
if (!_outBoxExists){
if (_local2._vars.debug){
stage.addEventListener(KeyboardEvent.KEY_DOWN, showOut);
stage.addEventListener(KeyboardEvent.KEY_UP, hideOut);
};
_outBox.x = 100;
_outBox.y = 100;
_outBox.width = 500;
_outBox.height = 200;
_outBox.border = true;
_outBox.background = true;
_outBoxExists = true;
};
switch (typeof(_arg1)){
case "string":
_outBox.appendText(("\n" + _arg1));
_logText = (_logText + ("\n" + _arg1));
break;
case "object":
_outBox.appendText("\n");
_logText = (_logText + ("\n" + json_encode(_arg1)));
for (_local3 in _arg1) {
_outBox.appendText((((_local3 + " = ") + _arg1[_local3]) + ","));
};
break;
};
_outBox.scrollV = _outBox.maxScrollV;
}
public function processFacebookAPICalls(){
new URLLoaderApi().load((Api.instance._vars.apiurl + "player/processfacebookapicalls"));
return (true);
}
private function showOut(_arg1:KeyboardEvent){
if (_arg1.keyCode === 17){
addChild(_outBox);
};
}
public function showTopUp(_arg1:String=null){
return (navTo(((Api.instance._vars.baseurl + "topup?r=g") + ((_arg1)!=null) ? ("&rh=" + _arg1) : "")));
}
public function cloneObject(_arg1:Object){
var _local2:ByteArray = new ByteArray();
_local2.writeObject(_arg1);
_local2.position = 0;
return (_local2.readObject());
}
public function recordDieLog(){
var _local1:String = json_encode([["dielog", _logText]]);
new URLLoaderApi().load((Api.instance._vars.apiurl + "player/recorddebugdata"), [["data", _local1]], null, true, false, null, true);
}
public function showAppPage(){
return (navTo(Api.instance._vars.apppage));
}
public function showTips(){
return (navTo((Api.instance._vars.baseurl + "tips")));
}
public function recordStats(_arg1:String, _arg2:Object=null){
if (_arg2 !== null){
_arg2 = json_encode(_arg2);
callJS("recordStats", [_arg1, _arg2]);
} else {
callJS("recordStats", [_arg1]);
};
}
public function requestDialogCallback(_arg1){
Api.instance.out(("requestDialogCallback: " + _arg1));
if (_requestDialogCallback === null){
return (false);
};
if ((((_arg1 == 0)) || ((_arg1 == "0")))){
_requestDialogCallback(false);
} else {
_requestDialogCallback(true);
};
_requestDialogCallback = null;
}
public function json_decode(_arg1:String){
var out:Object;
var string = _arg1;
try {
out = JSON.decode(string);
return (out);
} catch(error:Error) {
return ({});
};
}
public function showInvite(){
return (navTo((Api.instance._vars.baseurl + "invite")));
}
public function callJS(_arg1:String, _arg2:Array=null){
Api.instance.out(("callJS: " + _arg1));
if (_arg2 == null){
ExternalInterface.call("callFunc", _arg1);
} else {
ExternalInterface.call("callFunc", _arg1, _arg2);
};
}
public function showStore(_arg1:String=null){
return (navTo((((Api.instance._vars.baseurl + "store") + ((_arg1)!=null) ? ("/" + _arg1) : "") + "?r=g")));
}
private function hideOut(_arg1:KeyboardEvent){
if (_arg1.keyCode === 17){
removeChild(_outBox);
};
}
public function showSendNinjas(){
return (navTo((Api.instance._vars.baseurl + "sendninjas")));
}
public function recordLog(_arg1:Boolean=false){
var short = _arg1;
var timer:Timer = new Timer((short) ? 1500 : 12000, 1);
timer.addEventListener(TimerEvent.TIMER, function (_arg1:TimerEvent){
var _local2:String = json_encode([["recordlog", _logText]]);
new URLLoaderApi().load((Api.instance._vars.apiurl + "player/recorddebugdata"), [["data", _local2]]);
});
timer.start();
}
public function returnUserData(_arg1:String){
var _local2:*;
Api.instance.out("returnUserData");
_returnUserDataTimer.stop();
if (_arg1 != "fail"){
_local2 = json_decode(_arg1);
} else {
_local2 = [];
};
if (_returnUserDataCallback !== null){
_returnUserDataCallback(_local2);
};
_returnUserDataCallback = null;
}
public function checkUserCreditsChange(_arg1:int){
if (Api.instance.player.checkCreditChange(_arg1)){
return (updateUserCredits(_arg1, true));
};
return (false);
}
public function showFreeGifts(){
return (navTo((Api.instance._vars.baseurl + "sendchest")));
}
protected function loadSwf(_arg1, _arg2:Function=null, _arg3:Boolean=true){
var _local4:LoaderApi = new LoaderApi();
return (_local4.loadSwf(_arg1, _arg2, _arg3));
}
public function navTo(_arg1:String){
var _local2:URLRequest = new URLRequest(_arg1);
navigateToURL(_local2, "_top");
return (true);
}
}
}//package com.ccapi
Section 11
//SecNum (com.ccapi.SecNum)
package com.ccapi {
public class SecNum {
private var _o;
public function SecNum(_arg1){
if ((_arg1 is String)){
BadNum();
return;
};
_arg1 = int((_arg1 * 1000));
var _local2:int = (Math.random() * 99999);
var _local3:* = (int(_arg1) ^ _local2);
var _local4:* = ((_arg1 + (_local2 * 2)) ^ _local2);
_o = {s:_local2, n:_local4, x:_local3};
}
public function add(_arg1){
var _local2:int;
var _local3:*;
var _local4:*;
var _local5:*;
if ((_arg1 is String)){
BadNum();
} else {
_arg1 = (_arg1 + this.get());
_arg1 = int((_arg1 * 1000));
_local2 = (Math.random() * 99999);
_local3 = (int(_arg1) ^ _local2);
_local4 = ((_arg1 + (_local2 * 2)) ^ _local2);
_local5 = {s:_local2, n:_local4, x:_local3};
_o = null;
_o = _local5;
return ((_local5.num / 1000));
};
}
public function set(_arg1:Number){
_arg1 = Math.ceil((_arg1 * 1000));
var _local2:int = (Math.random() * 99999);
var _local3:* = (_arg1 ^ _local2);
var _local4:* = ((_arg1 + (_local2 * 2)) ^ _local2);
var _local5:* = {s:_local2, n:_local4, x:_local3};
_o = null;
_o = _local5;
}
public function get(){
var _local1:* = (_o.x ^ _o.s);
var _local2:* = ((_o.n ^ _o.s) - (_o.s * 2));
if (_local1 == _local2){
return ((_local1 / 1000));
};
BadNum();
}
public function BadNum(){
trace("bad number attempt");
}
}
}//package com.ccapi
Section 12
//Api (Api)
package {
import flash.events.*;
import flash.display.*;
import com.ccapi.*;
import flash.external.*;
import flash.system.*;
import flash.ui.*;
public class Api extends Library {
private var _player:PlayerApi;
public var _vars:Object;
private var _score:ScoreApi;
public var api:Api;
private var _sbLoader:LoaderApi;
public var _loadComplete:Boolean;// = false
private var _lNow:int;// = 0
private var _lfFinished:Object;
private var _childInited:Boolean;// = false
private var _header:HeaderApi;
private var _facebook:FacebookApi;
private var _gameLoader:LoaderApi;
private var _heLoader:LoaderApi;
private var _game:GameApi;
public var _debug:Boolean;// = false
private var _loLoader:LoaderApi;
private var _lTotal:int;// = 0
private var _dead:Boolean;// = false
private var _award:AwardApi;
private var _dataLoaded:Boolean;// = false
private var _headerMode:Boolean;// = false
private static var _instance:Api;
public function Api(){
_vars = {dimensions:{header:[760, 50], game:[760, 500], scoreboard:[760, 180]}, positions:{header:[0, 0], game:[0, 50], scoreboard:[0, 550]}};
_lfFinished = {};
super();
addFrameScript(0, frame1, 1, frame2);
_instance = this;
_vars.userid = stage.loaderInfo.parameters.userid;
_vars.gameid = stage.loaderInfo.parameters.gameid;
_vars.baseurl = stage.loaderInfo.parameters.baseurl;
_vars.localurl = stage.loaderInfo.parameters.localurl;
_vars.asseturl = (stage.loaderInfo.parameters.strurl + "flash/");
_vars.assetversion = stage.loaderInfo.parameters.av;
_vars.apiurl = (stage.loaderInfo.parameters.localurl + "api/");
_vars.debug = ((stage.loaderInfo.parameters.debug == "true")) ? true : false;
_vars.motd = stage.loaderInfo.parameters.motd;
_vars.dailycoins = stage.loaderInfo.parameters.dailycoins;
_vars.bookmarked = ((stage.loaderInfo.parameters.bookmarked == 1)) ? true : false;
_vars.day2coins = ((stage.loaderInfo.parameters.day2coins > 0)) ? stage.loaderInfo.parameters.day2coins : 0;
_vars.newday = ((stage.loaderInfo.parameters.newday > 0)) ? true : false;
_vars.fangift = stage.loaderInfo.parameters.fangift;
_vars.emailperm = ((stage.loaderInfo.parameters.emailperm > 0)) ? true : false;
_vars.isfan = ((stage.loaderInfo.parameters.isfan > 0)) ? true : false;
_vars.apppage = stage.loaderInfo.parameters.apppage;
_vars.inviteaccept = stage.loaderInfo.parameters.inviteaccept;
_vars.notifications = stage.loaderInfo.parameters.notifications;
_vars.recordlog = ((stage.loaderInfo.parameters.recordlog > 0)) ? true : false;
_vars.medals = json_decode(stage.loaderInfo.parameters.medals);
_vars.cmedals = json_decode(stage.loaderInfo.parameters.cmedals);
_vars.fbcall = ((stage.loaderInfo.parameters.fbcall > 0)) ? true : false;
_vars.invite10reward = ((stage.loaderInfo.parameters.invite10reward > 0)) ? true : false;
if (stage.loaderInfo.parameters.headermode){
_headerMode = true;
};
var _local1:String = _vars.localurl.replace("http://", "").replace("/", "");
Security.allowDomain(_local1);
Security.allowDomain("dd.live.fb.cs.casualcollective.com");
if (_vars.recordlog){
_vars.debug = true;
};
}
private function load2(){
_loLoader._asset.x = 0;
_loLoader._asset.y = 50;
addChild(_loLoader._asset);
}
public function get header():HeaderApi{
if (_dead){
return (null);
};
if (!_header){
_header = new HeaderApi();
};
return (_header);
}
public function onInit(_arg1:Event){
play();
}
public function init(){
load();
try {
ExternalInterface.addCallback("updateUserCredits", function (_arg1){
updateUserCredits(_arg1, true);
});
ExternalInterface.addCallback("checkEmailPerm", function (_arg1){
player.checkEmailPerm(_arg1);
});
ExternalInterface.addCallback("requestBookmarkClosed", function (){
player.requestBookmarkClosed();
});
ExternalInterface.addCallback("returnUserData", function (_arg1){
Api.instance.returnUserData(_arg1);
});
ExternalInterface.addCallback("returnAppFriendData", function (_arg1){
Api.instance.player.returnAppFriendData(_arg1);
});
ExternalInterface.addCallback("returnGiftableFriendData", function (_arg1){
Api.instance.player.returnGiftableFriendData(_arg1);
});
ExternalInterface.addCallback("returnNonAppFriendData", function (_arg1){
Api.instance.player.returnNonAppFriendData(_arg1);
});
ExternalInterface.addCallback("fbcBuyItemCallback", function (_arg1){
Api.instance.player.fbcBuyItemCallback(_arg1);
});
ExternalInterface.addCallback("requestDialogCallback", function (_arg1){
Api.instance.requestDialogCallback(_arg1);
});
} catch(e:Error) {
};
}
public function get score():ScoreApi{
if (_dead){
return (null);
};
if (!_score){
_score = new ScoreApi();
};
return (_score);
}
public function die(){
out("Killing application...");
recordDieLog();
_dead = true;
_vars = {};
_gameLoader._asset.x = 10000;
_sbLoader._asset.x = 10000;
}
private function loadFinish(_arg1:String){
_lfFinished[_arg1] = true;
if (_arg1 == "game"){
player.recordDebugData("aloadga", _gameLoader._loadTime);
} else {
if (_arg1 == "scoreboard"){
player.recordDebugData("aloadsb", _sbLoader._loadTime);
} else {
if (_arg1 == "header"){
player.recordDebugData("aloadhe", _heLoader._loadTime);
};
};
};
if (((((_lfFinished["game"]) && (_lfFinished["scoreboard"]))) && (_lfFinished["header"]))){
_loadComplete = true;
if (_vars.userid > ((_vars.apiurl.indexOf("stage") > 0)) ? 100 : 410558){
recordStats("do-gameloaded");
};
initChildren();
if (_vars.recordlog){
recordLog();
};
if (_vars.fbcall){
processFacebookAPICalls();
};
};
}
private function initChildren(){
_gameLoader.fireInit();
_gameLoader._asset.x = 0;
_gameLoader._asset.y = 50;
_heLoader._asset.x = 0;
_heLoader._asset.y = 0;
_sbLoader.fireInit();
_sbLoader._asset.x = 0;
_sbLoader._asset.y = 550;
if (_dataLoaded){
hideLoader();
} else {
_childInited = true;
};
}
public function updateHeader(_arg1:Object, _arg2:Object, _arg3:Object, _arg4:Object=null){
_heLoader.pass().update(_arg1, _arg2, _arg3, _arg4);
}
public function updateLoader(_arg1:int, _arg2=null){
if (_headerMode){
return (false);
};
_lNow = (_lNow + _arg1);
if (_arg2 != null){
_lTotal = (_lTotal + _arg2);
};
_loLoader._asset.mcProgress.update(_lNow, _lTotal);
}
public function get facebook():FacebookApi{
if (_dead){
return (null);
};
if (!_facebook){
_facebook = new FacebookApi();
};
return (_facebook);
}
public function updateScores(){
_sbLoader.pass().updateScores();
}
public function get award():AwardApi{
if (_dead){
return (null);
};
if (!_award){
_award = new AwardApi();
};
return (_award);
}
public function get player():PlayerApi{
if (_dead){
return (null);
};
if (!_player){
_player = new PlayerApi();
};
return (_player);
}
function frame1(){
stop();
root.loaderInfo.addEventListener(Event.INIT, onInit);
}
private function load(){
if (_headerMode){
_heLoader = loadSwf((((_vars.asseturl + "header-ext.v") + _vars.assetversion) + ".swf"), function (_arg1){
_heLoader._asset.x = 0;
_heLoader._asset.y = 0;
addChild(_heLoader._asset);
header.update();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
(Api.instance.contextMenu = new ContextMenu()).hideBuiltInItems();
});
} else {
_loLoader = loadSwf((((_vars.asseturl + "loading.v") + _vars.assetversion) + ".swf"), function (_arg1){
load2();
}, false);
};
}
public function dataLoaded(){
if (_childInited){
hideLoader();
} else {
_dataLoaded = true;
};
}
function frame2(){
api = Api.instance;
api.out("Init");
api.init();
}
public function getVar(_arg1:String, _arg2:Function){
var _local3:*;
if (_arg1 == "inviteaccept"){
_local3 = json_decode(_vars.inviteaccept);
} else {
_local3 = _vars[_arg1];
};
_arg2(_arg1, _local3);
}
public function get game():GameApi{
if (_dead){
return (null);
};
if (!_game){
_game = new GameApi();
};
return (_game);
}
private function hideLoader(){
removeChild(_loLoader._asset);
addChild(_gameLoader._asset);
addChild(_heLoader._asset);
header.update();
addChild(_sbLoader._asset);
}
public function loadGame(){
player.getInfo(function (){
});
_heLoader = loadSwf((((((_vars.asseturl + "header") + ((_vars.userid > 796762)) ? "-new" : "-old") + ".v") + _vars.assetversion) + ".swf"), function (_arg1){
loadFinish("header");
});
_sbLoader = loadSwf((((_vars.asseturl + "scoreboard.v") + _vars.assetversion) + ".swf"), function (_arg1){
loadFinish("scoreboard");
});
_gameLoader = loadSwf((((_vars.asseturl + "game.v") + _vars.assetversion) + ".swf"), function (_arg1){
loadFinish("game");
});
}
public static function get instance():Api{
return (_instance);
}
}
}//package
Section 13
//AwardApi (AwardApi)
package {
import com.ccapi.*;
public class AwardApi extends Library {
private var _newAwards:Array;
private var _api:Api;
public function AwardApi(){
_newAwards = [];
super();
_api = Api.instance;
}
public function save(_arg1:Array=null){
_newAwards = [];
if (_arg1){
callJS("notes.winAward", _arg1);
};
}
public function submit(_arg1:String){
if (!_api.game._started){
_api.out("AwardApi.submit - Failed (Game not started!)");
return (false);
};
if (_newAwards.indexOf(_arg1) > 0){
return (false);
};
_newAwards.push(_arg1);
return (true);
}
public function getNew(){
return (_newAwards);
}
public function get(_arg1:Function, _arg2:Boolean=false){
var onComplete = _arg1;
var force = _arg2;
_api.player.getInfo(function (_arg1:Object){
onComplete(_arg1.awards);
});
}
}
}//package
Section 14
//FacebookApi (FacebookApi)
package {
import com.ccapi.*;
public class FacebookApi extends Library {
private var _api:Api;
public function FacebookApi(){
_api = Api.instance;
}
public function getData(){
var _local2:*;
var _local1:* = _api.stage.loaderInfo.parameters;
for (_local2 in _local1) {
if (((!((_local2.substr(0, 3) == "fb_"))) && (!((_local2 == "fbid"))))){
delete _local1[_local2];
};
if (_local2 == "fb_friends"){
delete _local1[_local2];
};
};
return (_local1);
}
public function getId(){
var _local1:* = _api.stage.loaderInfo.parameters.fb_sig_user;
return (_local1);
}
}
}//package
Section 15
//GameApi (GameApi)
package {
import com.ccapi.*;
public class GameApi extends Library {
public var _started:Boolean;// = false
public var _data:Object;
private var _api:Api;
private var _score:Number;
public function GameApi(){
_api = Api.instance;
}
private function doEnd2(_arg1:Object, _arg2:Function=null){
var tauntfriends:Array;
var countAbove:int;
var countBelow:int;
var countTotal:int;
var posNow:String;
var i:*;
var data = _arg1;
var onComplete = _arg2;
_api.score.save(data.score);
_api.award.save(data.newawards);
if (data.sendfeed){
if ((((((data.sendfeed == "beatnames")) || ((data.sendfeed == "mapbeatnames")))) || ((data.sendfeed == "modebeatnames")))){
data.feedName = data.sendfeed;
data.showFeedDialog = function (){
callJS("sendFeed", [data.sendfeed, _score, _data.modeid, _data.modename, _data.mapid, _data.mapname, data.grade, data.beatnames]);
};
} else {
data.feedName = data.sendfeed;
data.showFeedDialog = function (){
callJS("sendFeed", [data.sendfeed, _score, _data.modeid, _data.modename, _data.mapid, _data.mapname, data.grade]);
};
};
} else {
if (data.levelup){
data.feedName = "levelup";
data.showFeedDialog = function (){
callJS("sendFeed", ["levelup", data.level]);
};
};
};
if (((data.modecredits) && ((data.modecredits > 0)))){
data.credits = (data.credits - data.modecredits);
};
_api.player.giveDifficultyBonus(data.modecredits);
_api.header.update(data);
if (data.dashboardadd){
_api.player.dashboardAdd(data.dashboardadd.func, data.dashboardadd.data);
};
if (((((!(data.tauntfriends)) && (data.friendscores))) && ((data.friendscores.length > 0)))){
tauntfriends = data.friendscores;
countAbove = 0;
countBelow = 0;
countTotal = 0;
posNow = "above";
for (i in tauntfriends) {
if (!tauntfriends[i].mine){
if (posNow == "above"){
countAbove = (countAbove + 1);
tauntfriends[i].feedtype = "tauntabove";
} else {
countBelow = (countBelow + 1);
tauntfriends[i].feedtype = "tauntbelow";
};
countTotal = (countTotal + 1);
} else {
posNow = "below";
};
};
if (countTotal > 6){
while ((((countAbove > 3)) && ((countTotal > 6)))) {
tauntfriends.shift();
countAbove = (countAbove - 1);
countTotal = (countTotal - 1);
};
};
data.tauntfriends = tauntfriends.slice(0, 7);
};
if (((!(data.tauntfriends)) || (!((typeof(data.tauntfriends) == "object"))))){
data.tauntfriends = [];
};
if (data.fbcall){
_api.processFacebookAPICalls();
};
if (onComplete !== null){
onComplete(data);
};
}
private function doEnd(_arg1:Object, _arg2:Function=null){
var data = _arg1;
var onComplete = _arg2;
_api.out("GameApi.doEnd");
if (typeof(data) !== "object"){
_api.out("GameApi.doEnd - Error (Data not Object)");
return (false);
};
if (data.error != 0){
_api.out((("GameApi.doEnd - Error (" + data.error) + ")"));
return (false);
};
_api.out(data);
_started = false;
_api.player.setInfo(data, function (_arg1){
doEnd2(_arg1, onComplete);
});
}
public function start(_arg1:Object, _arg2:Function=null){
if (_started){
_api.out("GameApi.start - Failed (Game already started!)");
return (false);
};
_api.out("GameApi.start - Started");
_started = true;
_data = _arg1;
if (_arg2 !== null){
_arg2();
};
return (true);
}
public function end(_arg1:Function=null, _arg2:Object=null){
var onComplete = _arg1;
var args = _arg2;
_api.out("GameApi.end");
if (!_started){
_api.out("GameApi.end - Failed (Game not started!)");
return (false);
};
var score:Number = _api.score.getNew();
_score = score;
var awards:Array = _api.award.getNew();
var awardstr:String = json_encode(awards);
var difficulty:Number = _api.score.getDifficulty();
var win:Number = _api.score.getWin();
var grade:String = _api.score.getGrade();
var gradeup:int = _api.score.getGradeUp();
var data:String = json_encode(_data);
var ratio:Number = _api.score.getRatio();
var timeplayed:* = 0;
if (args !== null){
if (args.timeplayed > 0){
timeplayed = args.timeplayed;
};
};
if ((((((score < 1)) && ((difficulty == 0)))) && ((win == 0)))){
_started = false;
return (false);
};
if (_api._vars.recordlog){
_api.recordLog(true);
};
new URLLoaderApi().load((_api["_vars"].apiurl + "game/end"), [["score", score], ["awards", awardstr], ["av", _api._vars.assetversion], ["data", data], ["difficulty", difficulty], ["win", win], ["grade", grade], ["gradeup", gradeup], ["ratio", ratio], ["timeplayed", timeplayed]], function (_arg1:Object){
doEnd(_arg1, onComplete);
}, true, true, "agameend");
return (true);
}
}
}//package
Section 16
//HeaderApi (HeaderApi)
package {
import com.ccapi.*;
public class HeaderApi extends Library {
private var _data:Object;// = null
private var _api:Api;
private var _levels:Array;
public function HeaderApi(){
_levels = [5, 32, 162, 224, 290, 362, 439, 522, 611, 707, 810, 921, 1040, 1168, 1306, 1454, 1613, 1784, 1968, 2165, 2378, 2606, 2851, 3115, 3399, 3704, 4032, 4384, 4763, 5170, 5608, 6078, 6584, 7128, 7713, 8341, 9017, 9743, 10524, 11363, 12265, 13235, 14278, 15398, 16603, 17898, 19291, 20788, 22397, 24126, 25986, 27985, 30134, 32444, 34927, 37597, 40466, 43551, 46868, 50433, 54283, 58441, 62932, 67782, 73021, 78678, 84788, 91386, 98513, 106209, 114521, 123499, 133194, 143665, 154974, 167188, 180378, 194624, 210009, 226626, 244571, 263953, 284884, 307491, 331905, 358273, 386751, 417507, 450723, 486596, 525339, 567182, 612372, 661177, 713887, 770814, 832294, 898693, 970404];
super();
_api = Api.instance;
}
private function getData(){
_api.player.getInfo(function (_arg1){
sendUpdate(_arg1);
});
}
private function sendUpdate(_arg1:Object){
var _local2:Object;
_arg1.level = int(_arg1.level);
_arg1.points = int(_arg1.points);
if (_data != null){
_local2 = {};
_local2.level = (_data.level < _arg1.level);
if (_data.credits < _arg1.credits){
_local2.coins = "increase";
} else {
if (_data.credits > _arg1.credits){
_local2.coins = "decrease";
} else {
_local2.coins = "same";
};
};
} else {
_local2 = null;
};
_data = _arg1;
var _local3:* = _api.facebook.getId();
var _local4:* = _api._vars.userid;
var _local5:int;
if ((((_local4 > 796762)) && ((_arg1.friendcount > 10)))){
_local5 = ((10 * 20) + 50);
} else {
_local5 = ((_arg1.friendcount * 20) + 50);
};
var _local6:Object = {cooldown:_arg1.dailygiftcd, friendcount:_arg1.friendcount, coins:_local5};
var _local7:Object = {level:_arg1.level, points:_arg1.points, curlevel:getPointsForLevel(_arg1.level), nextlevel:getPointsForLevel((_arg1.level + 1))};
var _local8:Object = {coins:_arg1.credits};
_api.updateHeader(_local6, _local7, _local8, _local2);
}
private function getPointsForLevel(_arg1:int){
if (_arg1 == 0){
return (0);
};
return (_levels[(_arg1 - 1)]);
}
public function update(_arg1:Object=null){
var _local3:*;
if (_arg1 == null){
return (getData());
};
var _local2:Object = {};
for (_local3 in _data) {
if (_arg1.hasOwnProperty(_local3)){
_local2[_local3] = _arg1[_local3];
} else {
_local2[_local3] = _data[_local3];
};
};
sendUpdate(_local2);
}
}
}//package
Section 17
//LoaderApi (LoaderApi)
package {
import flash.events.*;
import flash.utils.*;
import flash.text.*;
import flash.display.*;
import flash.net.*;
public class LoaderApi {
private var _loading:TextField;
public var _endTime:int;// = 0
private var _sentTotal:int;
private var _showLoader:Boolean;
public var _startTime:int;// = 0
private var _onComplete:Function;
private var _bytesLoaded:int;// = 0
private var _api:Object;
private var _assetLoader:Loader;
private var _file:String;
private var _url:String;
public var _asset:MovieClip;
public var _loadTime:int;// = 0
public function LoaderApi(){
_assetLoader = new Loader();
_loading = new TextField();
super();
_api = Api.instance;
}
private function loadError(_arg1:IOErrorEvent){
_api.out(("Loader.loadError - " + _file));
}
private function showLoading(){
_loading.text = "LOADING";
_loading.width = 300;
_loading.height = 200;
_loading.x = 200;
_loading.y = 100;
_api.addChild(_loading);
}
public function pass(){
return (_asset);
}
private function loadInit(_arg1:Event){
_api.out(("Loader.loadInit - " + _file));
}
private function hideLoading(){
_api.removeChild(_loading);
}
public function fireInit(){
_api.out(("Loader.fireInit - " + _file));
_asset.init();
}
private function loadProgress(_arg1:ProgressEvent){
if (!_showLoader){
return (false);
};
var _local2:* = (_arg1.bytesLoaded - _bytesLoaded);
_bytesLoaded = _arg1.bytesLoaded;
if (_sentTotal == _arg1.bytesTotal){
_api.updateLoader(_local2);
} else {
_api.updateLoader(_local2, _arg1.bytesTotal);
_sentTotal = _arg1.bytesTotal;
};
}
public function loadSwf(_arg1:String, _arg2:Function=null, _arg3:Boolean=true){
_url = _arg1;
_file = _url.substr((_arg1.lastIndexOf("/") + 1));
_showLoader = _arg3;
_api.out(("Loader.loadSwf - " + _file));
if (_arg2 !== null){
_onComplete = _arg2;
};
_assetLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
_assetLoader.contentLoaderInfo.addEventListener(Event.INIT, loadInit);
_assetLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
_assetLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
var _local4:URLRequest = new URLRequest(_arg1);
_startTime = (getTimer() / 1000);
_assetLoader.load(_local4);
return (this);
}
private function loadComplete(_arg1:Event){
var e = _arg1;
_api.out(("Loader.loadComplete - " + _file));
_asset = (_assetLoader.content as MovieClip);
_api.out(_asset.setApi);
_endTime = (getTimer() / 1000);
_loadTime = (_endTime - _startTime);
try {
_asset.setApi(_api);
} catch(e:Error) {
_api.out(((("FAIL: Loader.setApi - " + _file) + " - ") + e.toString()));
};
if ((((_onComplete is Function)) && (!((_onComplete == null))))){
_onComplete(_asset);
};
}
}
}//package
Section 18
//PlayerApi (PlayerApi)
package {
import flash.events.*;
import flash.utils.*;
import com.ccapi.*;
public class PlayerApi extends Library {
private var _running:Boolean;// = false
private var _data:Object;
private var _fbcBuyItemCallback:Function;
private var _modescores:Object;// = null
private var _saveData:Object;
private var _getModeScoreOC:Array;
private var _repOC:Function;
public var _sdTimer:Timer;
private var _firstLoad:Boolean;// = true
private var _recordDebugDataTimer:Timer;// = null
private var _getModeScoreWorking:Boolean;// = false
private var _cbOC:Function;
private var _onComplete:Array;
private var _api:Api;
private var _rbOC:Function;
private var _difficultyBonus:SecNum;
private var _recordDebugDataData:Array;
private var _lastGetModeScoreTime:int;// = 0
private static var _returnGiftableFriendDataTimer:Timer;
private static var _returnGiftableFriendDataCallback:Function = null;
private static var _returnAppFriendDataTimer:Timer;
private static var _returnNonAppFriendDataCallback:Function = null;
private static var _returnNonAppFriendDataTimer:Timer;
private static var _returnAppFriendDataCallback:Function = null;
public function PlayerApi(){
_onComplete = [];
_difficultyBonus = new SecNum(0);
_getModeScoreOC = [];
_recordDebugDataData = [];
super();
_api = Api.instance;
}
public function checkEmailPerm(_arg1){
var _local2:Boolean = ((_arg1 > 0)) ? true : false;
if (_repOC !== null){
_repOC(_local2);
};
}
public function showFeedDialog(_arg1:Object){
var _local2:*;
var _local3 = "";
if (_arg1.feedtype == "buyitem"){
callJS("sendFeed", [_arg1.feedtype, _arg1.buytype, _arg1.itemname, _arg1.level]);
} else {
if (_arg1.myscore){
_local2 = (_arg1.score - _arg1.myscore);
_local3 = ((_arg1.myscore + ".") + _arg1.score);
} else {
_local2 = (_arg1.score - _data.score);
_local3 = ((_data.score + ".") + _arg1.score);
};
if (_arg1.mapname){
callJS("sendFeed", [_arg1.feedtype, _local3, null, null, null, _arg1.mapname, null, null, _arg1.fbid, _local2]);
} else {
callJS("sendFeed", [_arg1.feedtype, _local3, null, _arg1.modename, null, null, null, null, _arg1.fbid, _local2]);
};
};
}
public function getGiftableFriendData(_arg1:Array, _arg2:Function, _arg3:int=5){
var fields = _arg1;
var callback = _arg2;
var limit = _arg3;
_returnGiftableFriendDataCallback = callback;
_returnGiftableFriendDataTimer = new Timer(10000, 1);
_returnGiftableFriendDataTimer.addEventListener(TimerEvent.TIMER, function (_arg1:TimerEvent){
_api.out("getGiftableFriendData timed out");
returnGiftableFriendData("fail");
});
callJS("retrieveGiftableFriendData", [fields, limit]);
_returnGiftableFriendDataTimer.start();
}
public function earnItem(_arg1:String){
new URLLoaderApi().load((_api["_vars"].apiurl + "player/earnitem"), [["itemhandle", _arg1]]);
}
public function claimDailyGift(_arg1:Function){
var onComplete = _arg1;
new URLLoaderApi().load((_api["_vars"].apiurl + "player/claimdailygift"), null, function (_arg1:Object){
if (_arg1.error != 0){
_api.out(("claimDailyGift Error: " + _arg1.error));
onComplete(_arg1.error, _data.credits, 0);
} else {
updateCache("credits", _arg1.credits);
updateUserCredits(_arg1.credits);
onComplete(_arg1.creditcount, _arg1.credits, _arg1.friendcount);
};
});
}
public function claimFanGift(){
new URLLoaderApi().load((_api["_vars"].apiurl + "player/claimfangift"), null, function (_arg1){
updateUserCredits(_arg1.credits, true);
});
return (_api._vars.fangift);
}
public function doneTutorial(){
return (true);
}
public function buyAndUseItem(_arg1:String, _arg2:Function=null){
return (buyItem(_arg1, _arg2, true));
}
public function logProgress(_arg1:int){
new URLLoaderApi().load((_api["_vars"].apiurl + "player/logprogress"), [["progress", _arg1]]);
}
public function useNinjas(_arg1:int, _arg2:Boolean=false){
new URLLoaderApi().load((_api["_vars"].apiurl + "player/useninjas"), [["id", _arg1], ["success", ((_arg2 === true)) ? 1 : 0]]);
}
public function fbcBuyItem(_arg1, _arg2:Function){
_fbcBuyItemCallback = _arg2;
callJS("fbc_buyItem", [_arg1, null, 1]);
}
public function getModeScores(_arg1:Object, _arg2:Function){
var timestamp:*;
var args = _arg1;
var onComplete = _arg2;
var now:Date = new Date();
timestamp = int((now.getTime() / 1000));
_getModeScoreOC.push({args:args, callback:onComplete});
if (_getModeScoreWorking){
return (true);
};
_getModeScoreWorking = true;
if ((((_lastGetModeScoreTime === 0)) || (((_lastGetModeScoreTime + 30) < timestamp)))){
new URLLoaderApi().load((_api["_vars"].apiurl + "player/getfullmodescores"), null, function (_arg1){
_modescores = _arg1;
doGetModeScores();
_lastGetModeScoreTime = timestamp;
});
} else {
doGetModeScores();
};
}
public function batchUseItem(_arg1:Array, _arg2:Function){
var i:*;
var itemhandle = _arg1;
var onComplete = _arg2;
var itemlist = "";
for (i in itemhandle) {
itemlist = (itemlist + ("," + itemhandle[i]));
};
itemlist = itemlist.substr(1);
new URLLoaderApi().load((_api["_vars"].apiurl + "player/batchuseitem"), [["itemhandle", itemlist]], function (_arg1:Object){
onComplete(_arg1);
});
return (true);
}
public function getNonAppFriendData(_arg1:Array, _arg2:Function, _arg3:int=5){
var fields = _arg1;
var callback = _arg2;
var limit = _arg3;
_returnNonAppFriendDataCallback = callback;
_returnNonAppFriendDataTimer = new Timer(10000, 1);
_returnNonAppFriendDataTimer.addEventListener(TimerEvent.TIMER, function (_arg1:TimerEvent){
_api.out("getNonAppFriendData timed out");
returnNonAppFriendData("fail");
});
callJS("retrieveNonAppFriendData", [fields, limit]);
_returnNonAppFriendDataTimer.start();
}
public function returnAppFriendData(_arg1:String){
var _local2:*;
_api.out("returnAppFriendData");
_returnAppFriendDataTimer.stop();
if (_arg1 != "fail"){
_local2 = json_decode(_arg1);
} else {
_local2 = [];
};
if (_returnAppFriendDataCallback !== null){
_returnAppFriendDataCallback(_local2);
};
_returnAppFriendDataCallback = null;
}
public function getInfo(_arg1:Function, _arg2:Boolean=false){
var onComplete = _arg1;
var force = _arg2;
if (_running){
_onComplete.push(onComplete);
return (true);
};
if (((!((_data === null))) && (!(force)))){
onComplete(_data);
} else {
_running = true;
_api.out("Player.getInfo (nocache)");
new URLLoaderApi().load((_api["_vars"].apiurl + "player/getinfo"), null, function (_arg1:Object){
_api.out(("GETINFO: " + _arg1));
cacheInfo(_arg1, onComplete);
});
};
return (true);
}
public function recordDebugData(_arg1:String, _arg2){
var key = _arg1;
var value = _arg2;
try {
key = key.substr(0, 10);
if (value !== null){
value = value.substr(0, 2000);
};
} catch(e:Error) {
};
if (key === null){
return (false);
};
_recordDebugDataData.push([key, value]);
if (_recordDebugDataTimer == null){
_recordDebugDataTimer = new Timer(10000, 1);
_recordDebugDataTimer.addEventListener(TimerEvent.TIMER, function (_arg1:TimerEvent){
doRecordDebugData();
});
_recordDebugDataTimer.start();
};
return (true);
}
public function setInfo(_arg1:Object, _arg2:Function=null){
var _local4:*;
var _local3:Object = {};
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
cacheInfo(_local3, _arg2);
}
public function checkCreditChange(_arg1:int){
if (_data == null){
return (false);
};
if (_data["credits"] == _arg1){
return (false);
};
return (true);
}
public function requestBookmarkClosed(){
if (_rbOC !== null){
checkBookmark(_rbOC);
};
}
public function buyItem(_arg1:String, _arg2:Function=null, _arg3:Boolean=false){
var itemhandle = _arg1;
var onComplete = _arg2;
var useItem = _arg3;
new URLLoaderApi().load((_api["_vars"].apiurl + "player/buyitem"), [["itemhandle", itemhandle], ["useitem", ((useItem === true)) ? 1 : 0]], function (_arg1:Object){
var data = _arg1;
if (data.error != 0){
if (onComplete !== null){
onComplete(data);
};
} else {
updateCache("credits", data.credits);
if (((((!(useItem)) && ((data.itemhandle.substr(0, 1) == "i")))) && (!((data.itemhandle.substr(0, 2) == "i7"))))){
data.feedName = "buyitem";
if (data.itemhandle.replace("i", "") >= 100){
data.showFeedDialog = function (){
showFeedDialog({feedtype:"buyitem", buytype:"Tower", itemname:data.itemname, level:1});
};
} else {
data.showFeedDialog = function (){
showFeedDialog({feedtype:"buyitem", buytype:"Booster", itemname:data.itemname, level:1});
};
};
};
if (onComplete !== null){
onComplete(data);
};
updateUserCredits(data.credits);
};
});
return (true);
}
public function useItem(_arg1:String, _arg2:Function){
var itemhandle = _arg1;
var onComplete = _arg2;
new URLLoaderApi().load((_api["_vars"].apiurl + "player/useitem"), [["itemhandle", itemhandle]], function (_arg1:Object){
onComplete(_arg1);
});
return (true);
}
public function clearCache(){
_data = null;
}
public function updateCache(_arg1:String, _arg2){
_data[_arg1] = _arg2;
}
private function doRecordDebugData(){
var jdata:String;
if (_recordDebugDataData.length < 1){
_recordDebugDataTimer = null;
return (false);
};
if (_api._loadComplete){
jdata = json_encode(_recordDebugDataData);
_recordDebugDataData = [];
new URLLoaderApi().load((_api["_vars"].apiurl + "player/recorddebugdata"), [["data", jdata]], function (_arg1){
var data = _arg1;
_recordDebugDataTimer = new Timer(10000, 1);
_recordDebugDataTimer.addEventListener(TimerEvent.TIMER, function (_arg1:TimerEvent){
doRecordDebugData();
});
_recordDebugDataTimer.start();
});
} else {
_recordDebugDataTimer = new Timer(5000, 1);
_recordDebugDataTimer.addEventListener(TimerEvent.TIMER, function (_arg1:TimerEvent){
doRecordDebugData();
});
_recordDebugDataTimer.start();
};
}
public function getAppFriendData(_arg1:Array, _arg2:Function, _arg3:int=5){
var fields = _arg1;
var callback = _arg2;
var limit = _arg3;
_returnAppFriendDataCallback = callback;
_returnAppFriendDataTimer = new Timer(10000, 1);
_returnAppFriendDataTimer.addEventListener(TimerEvent.TIMER, function (_arg1:TimerEvent){
_api.out("getAppFriendData timed out");
returnAppFriendData("fail");
});
callJS("retrieveAppFriendData", [fields, limit]);
_returnAppFriendDataTimer.start();
}
public function saveData(_arg1:Object, _arg2:Boolean=false){
var data = _arg1;
var journal = _arg2;
if (_sdTimer != null){
_saveData = data;
} else {
_saveData = data;
_sdTimer = new Timer(1500, 1);
_sdTimer.addEventListener(TimerEvent.TIMER, function (_arg1:TimerEvent){
doSaveData(journal);
});
_sdTimer.start();
};
}
private function completeCache(_arg1:Function=null){
var _local3:*;
_api.out(json_encode(_data.friendscores));
var _local2:Object = cloneObject(_data);
if (_arg1 !== null){
_arg1(_local2);
};
if (_onComplete.length > 0){
for (_local3 in _onComplete) {
var _local6 = _onComplete;
_local6[_local3](_local2);
};
_onComplete = [];
};
_running = false;
return (true);
}
public function upgradeItem(_arg1:String, _arg2:Function=null){
var itemhandle = _arg1;
var onComplete = _arg2;
new URLLoaderApi().load((_api["_vars"].apiurl + "player/upgradeitem"), [["itemhandle", itemhandle]], function (_arg1:Object){
var data = _arg1;
if (data.error != 0){
if (onComplete !== null){
onComplete(data);
};
} else {
updateCache("credits", data.credits);
if (data.itemhandle.substr(0, 1) == "i"){
data.feedName = "buyitem";
data.showFeedDialog = function (){
showFeedDialog({feedtype:"buyitem", buytype:"Tower", itemname:data.itemname, level:data.level});
};
};
if (onComplete !== null){
onComplete(data);
};
updateUserCredits(data.credits);
};
});
return (true);
}
private function cacheInfo(_arg1:Object, _arg2:Function=null){
var getData:Array;
var i:*;
var data = _arg1;
var onComplete = _arg2;
if (typeof(data) !== "object"){
_api.out("ERROR: PlayerApi.cacheInfo - data is not object");
_running = false;
return (false);
};
if (_firstLoad){
_firstLoad = false;
_api.dataLoaded();
};
_data = data;
_data.playerdata = json_decode(_data.playerdata);
if (typeof(_data.items) != "object"){
_data.items = [];
};
if (data.friendscores){
getData = [];
for (i in _data.friendscores) {
if (_data.friendscores[i].getdata){
getData.push(_data.friendscores[i].fbid);
};
};
if (getData.length){
if (onComplete !== null){
_onComplete.push(onComplete);
};
getUserData(getData, ["profile_url", "pic", "pic_square", "first_name", "last_name"], function (_arg1){
populateFriendScores(_arg1);
});
return (true);
};
};
completeCache(onComplete);
}
public function giveDifficultyBonus(_arg1:Number=0){
var coins = _arg1;
if (coins > 0){
_difficultyBonus.set(coins);
return (true);
};
coins = _difficultyBonus.get();
getInfo(function (_arg1){
_api.header.update(_arg1);
});
_difficultyBonus.set(0);
return (coins);
}
private function doGetModeScores(){
var i:*;
for (i in _getModeScoreOC) {
try {
if (_modescores[((_getModeScoreOC[i].args.modeid + ".") + _getModeScoreOC[i].args.mapid)] !== null){
_getModeScoreOC[i].callback(_modescores[((_getModeScoreOC[i].args.modeid + ".") + _getModeScoreOC[i].args.mapid)]);
} else {
_getModeScoreOC[i].callback({});
};
} catch(e:Error) {
_getModeScoreOC[i].callback({});
};
};
_getModeScoreWorking = false;
_getModeScoreOC = [];
}
public function getScore(){
return (_data.score);
}
public function requestEmailPerm(_arg1:Function=null){
_repOC = _arg1;
callJS("requestEmailPerms", [true]);
}
public function checkBookmark(_arg1:Function){
var onComplete = _arg1;
new URLLoaderApi().load((_api["_vars"].apiurl + "player/checkbookmark"), null, function (_arg1){
var _local2:Boolean = ((_arg1.added > 0)) ? true : false;
onComplete(_local2);
});
}
public function returnGiftableFriendData(_arg1:String){
var _local2:*;
_api.out("returnGiftableFriendData");
_returnGiftableFriendDataTimer.stop();
if (_arg1 != "fail"){
_local2 = json_decode(_arg1);
} else {
_local2 = [];
};
if (_returnGiftableFriendDataCallback !== null){
_returnGiftableFriendDataCallback(_local2);
};
_returnGiftableFriendDataCallback = null;
}
public function populateFriendScores(_arg1:Array){
var _local2:*;
var _local3:*;
var _local4:*;
_api.out(("populateFriendScores: " + _arg1.length));
if (_arg1.length < 1){
for (_local3 in _data.friendscores) {
if (_data.friendscores[_local3].getdata){
_data.friendscores.splice(_local3, 1);
};
};
return (completeCache());
};
for (_local2 in _arg1) {
for (_local4 in _data.friendscores) {
if (_arg1[_local2].uid == _data.friendscores[_local4].fbid){
_data.friendscores[_local4].profile_url = _arg1[_local2].profile_url;
_data.friendscores[_local4].pic = _arg1[_local2].pic;
_data.friendscores[_local4].pic_square = _arg1[_local2].pic_square;
_data.friendscores[_local4].first_name = _arg1[_local2].first_name;
_data.friendscores[_local4].last_name = _arg1[_local2].last_name;
};
};
};
completeCache();
}
public function getSplit(){
var _local1:* = _api.facebook.getId();
if ((_local1 & 1)){
return (1);
};
return (0);
}
public function requestBookmark(_arg1:Function=null){
_rbOC = _arg1;
callJS("requestBookmark", [true]);
}
public function dashboardAdd(_arg1:String, _arg2:String, _arg3=null){
if (_arg3 === null){
_arg3 = _api.facebook.getId();
};
callJS("dashboardAdd", [_arg1, _arg2, _arg3]);
}
public function doSaveData(_arg1:Boolean=false){
_sdTimer.stop();
_sdTimer = null;
var _local2:* = json_encode(_saveData);
new URLLoaderApi().load((_api["_vars"].apiurl + "player/savedata"), [["playerdata", _local2], ["journal", (_arg1) ? "1" : "0"]]);
}
public function returnNonAppFriendData(_arg1:String){
var _local2:*;
_api.out("returnNonAppFriendData");
_returnNonAppFriendDataTimer.stop();
if (_arg1 != "fail"){
_local2 = json_decode(_arg1);
} else {
_local2 = [];
};
if (_returnNonAppFriendDataCallback !== null){
_returnNonAppFriendDataCallback(_local2);
};
_returnNonAppFriendDataCallback = null;
}
public function claimInviteReward(_arg1:Array){
var ids = _arg1;
var jids:String = json_encode(ids);
new URLLoaderApi().load((_api["_vars"].apiurl + "player/claiminvitereward"), [["ids", jids]], function (_arg1){
updateUserCredits(_arg1.credits, true);
});
return (true);
}
public function fbcBuyItemCallback(_arg1){
_api.out("fbcBuyItemCallback");
var _local2:* = json_decode(_arg1);
if (_local2.status == "settled"){
_fbcBuyItemCallback(true);
} else {
_fbcBuyItemCallback(false);
};
}
}
}//package
Section 19
//ScoreApi (ScoreApi)
package {
import flash.display.*;
import com.ccapi.*;
public class ScoreApi extends MovieClip {
private var _score:SecNum;
private var _grade:String;// = ""
private var _difficulty:SecNum;
private var _ratio:Number;// = 0
private var _win:SecNum;
private var _gradeUp:int;// = 0
private var _pointcalc;
private var _api:Api;
public function ScoreApi(){
_score = new SecNum(0);
_win = new SecNum(0);
_difficulty = new SecNum(0);
_pointcalc = [30, 30, 50, 70, 90, 110];
super();
_api = Api.instance;
}
public function save(_arg1:Number){
_score.set(0);
_api.updateScores();
}
public function update(){
_api.updateScores();
}
private function doGet(_arg1:Object, _arg2:Function){
_arg2(_arg1.score);
}
public function getRatio(){
return (_ratio);
}
public function get(_arg1:Function){
var onComplete = _arg1;
_api.player.getInfo(function (_arg1:Object){
doGet(_arg1, onComplete);
});
}
private function awardMedals(_arg1:Number, _arg2:Number){
if ((((_arg1 > 0)) && ((_arg2 <= _arg1)))){
return (false);
};
var _local3:* = getMedalForScore(_arg1);
var _local4:* = getMedalForScore(_arg2);
if (_local3 == _local4){
return (false);
};
return (_local4);
}
public function getGradeUp(){
return (_gradeUp);
}
public function getGrade(){
return (_grade);
}
public function set(_arg1:Object){
var _local8:*;
_api.out("ScoreApi.set");
if (!_api.game._started){
_api.out("ScoreApi.set - Failed (Game not started!)");
return ({error:"Game not started"});
};
if (_arg1.score > _score.get()){
_score.set(_arg1.score);
};
if (_arg1.won === true){
_win.set(1);
} else {
_win.set(0);
};
_difficulty.set(_arg1.diff);
_grade = _arg1.grade;
_gradeUp = _arg1.gradeup;
_ratio = _arg1.ratio;
var _local2:int = Math.ceil((_ratio * _pointcalc[(((_arg1.diff > 0)) ? _arg1.diff : 1 - 1)]));
var _local3:Number = _arg1.score;
if (_local3 > 20000){
_local3 = 20000;
};
var _local4:int;
_local4 = Math.ceil((Math.ceil((_local3 / 1000)) * 7.5));
if (_local4 < 1){
_local4 = 0;
};
if (_local4 > 150){
_local4 = 150;
};
var _local5:int = _api.player.getScore();
var _local6:* = awardMedals(_local5, _score.get());
var _local7:Object = {score:_score.get(), points:_local2, credits:_local4};
if (_local6 != false){
_local7["medal"] = _local6;
_api._vars.cmedals[_local6] = (_api._vars.cmedals[_local6] + 1);
if (_local5 > 0){
_local8 = getMedalForScore(_local5);
if (_local8 != false){
_api._vars.cmedals[_local8] = (_api._vars.cmedals[_local8] - 1);
};
};
};
_api.out(_local7);
return (_local7);
}
private function getMedalForScore(_arg1:int){
if (_arg1 < 1){
return (false);
};
var _local2:* = _api._vars.medals;
if (_arg1 >= _local2["gold"]){
return ("gold");
};
if (_arg1 >= _local2["silver"]){
return ("silver");
};
if (_arg1 >= _local2["bronze"]){
return ("bronze");
};
if (_arg1 >= _local2["tinfoil"]){
return ("tinfoil");
};
return (false);
}
public function getDifficulty(){
return (_difficulty.get());
}
public function getAll(_arg1:Function, _arg2:String="friends"){
var onComplete = _arg1;
var type = _arg2;
_api.player.getInfo(function (_arg1){
var _local2:* = ((type == "friends")) ? _arg1.friendscores : _arg1.topscores;
onComplete(_local2);
});
}
public function getNew(){
return (_score.get());
}
public function getWin(){
return (_win.get());
}
}
}//package
Section 20
//URLLoaderApi (URLLoaderApi)
package {
import flash.events.*;
import flash.utils.*;
import com.ccapi.*;
import com.adobe.crypto.*;
import flash.net.*;
public class URLLoaderApi extends Library {
private var _dieMode:Boolean;// = false
private var _datastr:String;// = ""
public var _endTime:int;// = 0
public var _startTime:int;// = 0
private var _status:int;
private var _api:Api;
private var _recordTime:Boolean;// = false
private var _onComplete:Function;
private var _req:URLLoader;
public var _procTime:int;// = 0
private var _url:String;
private var _onlyTime:String;// = null
public function URLLoaderApi(){
_api = Api.instance;
}
private function loadError(_arg1:IOErrorEvent){
_endTime = (getTimer() / 1000);
_procTime = (_endTime - _startTime);
if (_onlyTime != null){
_api.player.recordDebugData((_onlyTime + "e"), _procTime);
} else {
if (_status == 0){
_api.player.recordDebugData("aurlloader", ((((((("time: " + _procTime) + " - url: ") + _url) + " - status: ") + _status) + " - data: ") + _datastr));
} else {
_api.player.recordDebugData("aurlloader", ((((("time: " + _procTime) + " - url: ") + _url) + " - status: ") + _status));
};
};
_api.out(((("IOERROR (Status " + _status) + ") - ") + _url));
}
private function getSalt(){
return ("5h6273t87wer8g7hes7rgh375ht73");
}
private function getHash(_arg1:String, _arg2:int){
return (MD5.hash(((getSalt() + _arg1) + getNum(_arg2))));
}
private function fireComplete(_arg1:Event){
if (_dieMode){
return (false);
};
if (_onComplete === null){
return (true);
};
var _local2:String = _req.data;
var _local3:Array = _local2.split(",\"h\":");
_local2 = (_local3[0] + "}");
var _local4:String = ("{\"h\":" + _local3[1]);
var _local5:String = _local2;
var _local6:* = json_decode(_local2);
var _local7:* = json_decode(_local4);
var _local8:String = MD5.hash(((getSalt() + _local5) + getNum(_local7.hn)));
if (_local8 !== _local7.h){
_api.out((("FATAL ERROR: Invalid data returned, exiting... (" + _req.data) + ")"));
_api.die();
};
_api.out(_local6);
_onComplete(_local6);
_endTime = (getTimer() / 1000);
_procTime = (_endTime - _startTime);
if (_recordTime === true){
if (_onlyTime != null){
_api.player.recordDebugData(_onlyTime, _procTime);
} else {
_api.player.recordDebugData("aurlload", ((("time: " + _procTime) + " - url: ") + _url));
};
};
}
public function load(_arg1:String, _arg2:Array=null, _arg3:Function=null, _arg4:Boolean=true, _arg5:Boolean=false, _arg6:String=null, _arg7:Boolean=false){
var _local13:Object;
var _local14:String;
var _local15:*;
var _local16:int;
var _local17:Array;
_api.out((("URLLoaderApi.load(" + _arg1) + ")"));
_startTime = (getTimer() / 1000);
_recordTime = _arg5;
_onlyTime = _arg6;
_dieMode = _arg7;
_onComplete = _arg3;
if (_arg4){
_local13 = _api.facebook.getData();
_local14 = "";
for (_local15 in _local13) {
_local14 = (_local14 + ((("&" + _local15) + "=") + _local13[_local15]));
};
_local14 = _local14.substr(1);
_arg1 = ((_arg1 + "?") + _local14);
};
_url = _arg1;
var _local8:URLRequest = new URLRequest(_arg1);
var _local9 = "";
var _local10:URLVariables = new URLVariables();
if (((!((_arg2 == null))) && ((_arg2.length > 0)))){
_local16 = 0;
while (_local16 < _arg2.length) {
_local17 = _arg2[_local16];
_local10[_local17[0]] = _local17[1];
_datastr = (_datastr + ((("&" + _local17[0]) + "=") + _local17[1]));
_local9 = (_local9 + _local17[1]);
_local16++;
};
_datastr = _datastr.substr(1);
};
var _local11:int = int((Math.random() * 9999999));
_local10.hn = _local11;
var _local12:String = getHash(_local9, _local11);
_local10.h = _local12;
_local8.data = _local10;
_local8.method = URLRequestMethod.POST;
_req = new URLLoader(_local8);
_req.addEventListener(Event.COMPLETE, fireComplete);
_req.addEventListener(IOErrorEvent.IO_ERROR, loadError);
_req.addEventListener(HTTPStatusEvent.HTTP_STATUS, setStatus);
}
private function getNum(_arg1:int){
return ((_arg1 * (_arg1 % 11)));
}
private function setStatus(_arg1:HTTPStatusEvent){
_status = _arg1.status;
}
}
}//package