STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
229502
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2594 · P5188

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/45015423?noj=FRM45015423-18DC" width="1" height="1"></div>

60 Seconds.swf

This is the info page for
Flash #87578

(Click the ID number above for more basic data on this flash file.)


ActionScript [AS3]
Section 1
//MD5 (com.adobe.crypto.MD5) package com.adobe.crypto { import com.adobe.utils.*; public class MD5 { 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 createBlocks(_arg1:String):Array{ var _local2:Array = new Array(); var _local3:int = (_arg1.length * 8); var _local4 = 0xFF; var _local5:int; while (_local5 < _local3) { _local2[(_local5 >> 5)] = (_local2[(_local5 >> 5)] | ((_arg1.charCodeAt((_local5 / 8)) & _local4) << (_local5 % 32))); _local5 = (_local5 + 8); }; _local2[(_local3 >> 5)] = (_local2[(_local3 >> 5)] | (128 << (_local3 % 32))); _local2[((((_local3 + 64) >>> 9) << 4) + 14)] = _local3; return (_local2); } 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)); } 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 _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[(_local12 + 0)], 7, -680876936); _local5 = ff(_local5, _local2, _local3, _local4, _local10[(_local12 + 1)], 12, -389564586); _local4 = ff(_local4, _local5, _local2, _local3, _local10[(_local12 + 2)], 17, 606105819); _local3 = ff(_local3, _local4, _local5, _local2, _local10[(_local12 + 3)], 22, -1044525330); _local2 = ff(_local2, _local3, _local4, _local5, _local10[(_local12 + 4)], 7, -176418897); _local5 = ff(_local5, _local2, _local3, _local4, _local10[(_local12 + 5)], 12, 1200080426); _local4 = ff(_local4, _local5, _local2, _local3, _local10[(_local12 + 6)], 17, -1473231341); _local3 = ff(_local3, _local4, _local5, _local2, _local10[(_local12 + 7)], 22, -45705983); _local2 = ff(_local2, _local3, _local4, _local5, _local10[(_local12 + 8)], 7, 1770035416); _local5 = ff(_local5, _local2, _local3, _local4, _local10[(_local12 + 9)], 12, -1958414417); _local4 = ff(_local4, _local5, _local2, _local3, _local10[(_local12 + 10)], 17, -42063); _local3 = ff(_local3, _local4, _local5, _local2, _local10[(_local12 + 11)], 22, -1990404162); _local2 = ff(_local2, _local3, _local4, _local5, _local10[(_local12 + 12)], 7, 1804603682); _local5 = ff(_local5, _local2, _local3, _local4, _local10[(_local12 + 13)], 12, -40341101); _local4 = ff(_local4, _local5, _local2, _local3, _local10[(_local12 + 14)], 17, -1502002290); _local3 = ff(_local3, _local4, _local5, _local2, _local10[(_local12 + 15)], 22, 1236535329); _local2 = gg(_local2, _local3, _local4, _local5, _local10[(_local12 + 1)], 5, -165796510); _local5 = gg(_local5, _local2, _local3, _local4, _local10[(_local12 + 6)], 9, -1069501632); _local4 = gg(_local4, _local5, _local2, _local3, _local10[(_local12 + 11)], 14, 643717713); _local3 = gg(_local3, _local4, _local5, _local2, _local10[(_local12 + 0)], 20, -373897302); _local2 = gg(_local2, _local3, _local4, _local5, _local10[(_local12 + 5)], 5, -701558691); _local5 = gg(_local5, _local2, _local3, _local4, _local10[(_local12 + 10)], 9, 38016083); _local4 = gg(_local4, _local5, _local2, _local3, _local10[(_local12 + 15)], 14, -660478335); _local3 = gg(_local3, _local4, _local5, _local2, _local10[(_local12 + 4)], 20, -405537848); _local2 = gg(_local2, _local3, _local4, _local5, _local10[(_local12 + 9)], 5, 568446438); _local5 = gg(_local5, _local2, _local3, _local4, _local10[(_local12 + 14)], 9, -1019803690); _local4 = gg(_local4, _local5, _local2, _local3, _local10[(_local12 + 3)], 14, -187363961); _local3 = gg(_local3, _local4, _local5, _local2, _local10[(_local12 + 8)], 20, 1163531501); _local2 = gg(_local2, _local3, _local4, _local5, _local10[(_local12 + 13)], 5, -1444681467); _local5 = gg(_local5, _local2, _local3, _local4, _local10[(_local12 + 2)], 9, -51403784); _local4 = gg(_local4, _local5, _local2, _local3, _local10[(_local12 + 7)], 14, 1735328473); _local3 = gg(_local3, _local4, _local5, _local2, _local10[(_local12 + 12)], 20, -1926607734); _local2 = hh(_local2, _local3, _local4, _local5, _local10[(_local12 + 5)], 4, -378558); _local5 = hh(_local5, _local2, _local3, _local4, _local10[(_local12 + 8)], 11, -2022574463); _local4 = hh(_local4, _local5, _local2, _local3, _local10[(_local12 + 11)], 16, 1839030562); _local3 = hh(_local3, _local4, _local5, _local2, _local10[(_local12 + 14)], 23, -35309556); _local2 = hh(_local2, _local3, _local4, _local5, _local10[(_local12 + 1)], 4, -1530992060); _local5 = hh(_local5, _local2, _local3, _local4, _local10[(_local12 + 4)], 11, 1272893353); _local4 = hh(_local4, _local5, _local2, _local3, _local10[(_local12 + 7)], 16, -155497632); _local3 = hh(_local3, _local4, _local5, _local2, _local10[(_local12 + 10)], 23, -1094730640); _local2 = hh(_local2, _local3, _local4, _local5, _local10[(_local12 + 13)], 4, 681279174); _local5 = hh(_local5, _local2, _local3, _local4, _local10[(_local12 + 0)], 11, -358537222); _local4 = hh(_local4, _local5, _local2, _local3, _local10[(_local12 + 3)], 16, -722521979); _local3 = hh(_local3, _local4, _local5, _local2, _local10[(_local12 + 6)], 23, 76029189); _local2 = hh(_local2, _local3, _local4, _local5, _local10[(_local12 + 9)], 4, -640364487); _local5 = hh(_local5, _local2, _local3, _local4, _local10[(_local12 + 12)], 11, -421815835); _local4 = hh(_local4, _local5, _local2, _local3, _local10[(_local12 + 15)], 16, 530742520); _local3 = hh(_local3, _local4, _local5, _local2, _local10[(_local12 + 2)], 23, -995338651); _local2 = ii(_local2, _local3, _local4, _local5, _local10[(_local12 + 0)], 6, -198630844); _local5 = ii(_local5, _local2, _local3, _local4, _local10[(_local12 + 7)], 10, 1126891415); _local4 = ii(_local4, _local5, _local2, _local3, _local10[(_local12 + 14)], 15, -1416354905); _local3 = ii(_local3, _local4, _local5, _local2, _local10[(_local12 + 5)], 21, -57434055); _local2 = ii(_local2, _local3, _local4, _local5, _local10[(_local12 + 12)], 6, 1700485571); _local5 = ii(_local5, _local2, _local3, _local4, _local10[(_local12 + 3)], 10, -1894986606); _local4 = ii(_local4, _local5, _local2, _local3, _local10[(_local12 + 10)], 15, -1051523); _local3 = ii(_local3, _local4, _local5, _local2, _local10[(_local12 + 1)], 21, -2054922799); _local2 = ii(_local2, _local3, _local4, _local5, _local10[(_local12 + 8)], 6, 1873313359); _local5 = ii(_local5, _local2, _local3, _local4, _local10[(_local12 + 15)], 10, -30611744); _local4 = ii(_local4, _local5, _local2, _local3, _local10[(_local12 + 6)], 15, -1560198380); _local3 = ii(_local3, _local4, _local5, _local2, _local10[(_local12 + 13)], 21, 1309151649); _local2 = ii(_local2, _local3, _local4, _local5, _local10[(_local12 + 4)], 6, -145523070); _local5 = ii(_local5, _local2, _local3, _local4, _local10[(_local12 + 11)], 10, -1120210379); _local4 = ii(_local4, _local5, _local2, _local3, _local10[(_local12 + 2)], 15, 718787259); _local3 = ii(_local3, _local4, _local5, _local2, _local10[(_local12 + 9)], 21, -343485551); _local2 = (_local2 + _local6); _local3 = (_local3 + _local7); _local4 = (_local4 + _local8); _local5 = (_local5 + _local9); _local12 = (_local12 + 16); }; 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)); } } }//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{ 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); _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")))); } private function skipIgnored():void{ skipWhite(); skipComments(); skipWhite(); } 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
//IHash (com.hurlant.crypto.hash.IHash) package com.hurlant.crypto.hash { import flash.utils.*; public interface IHash { function toString():String; function getHashSize():uint; function getInputSize():uint; function hash(_arg1:ByteArray):ByteArray; } }//package com.hurlant.crypto.hash
Section 11
//SHA1 (com.hurlant.crypto.hash.SHA1) package com.hurlant.crypto.hash { public class SHA1 extends SHABase implements IHash { public static const HASH_SIZE:int = 20; override public function toString():String{ return ("sha1"); } override protected function core(_arg1:Array, _arg2:uint):Array{ var _local10:uint; var _local11:uint; var _local12:uint; var _local13:uint; var _local14:uint; var _local15:uint; var _local16:uint; _arg1[(_arg2 >> 5)] = (_arg1[(_arg2 >> 5)] | (128 << (24 - (_arg2 % 32)))); _arg1[((((_arg2 + 64) >> 9) << 4) + 15)] = _arg2; var _local3:Array = []; var _local4:uint = 1732584193; var _local5:uint = 4023233417; var _local6:uint = 2562383102; var _local7:uint = 271733878; var _local8:uint = 3285377520; var _local9:uint; while (_local9 < _arg1.length) { _local10 = _local4; _local11 = _local5; _local12 = _local6; _local13 = _local7; _local14 = _local8; _local15 = 0; while (_local15 < 80) { if (_local15 < 16){ _local3[_local15] = ((_arg1[(_local9 + _local15)]) || (0)); } else { _local3[_local15] = rol((((_local3[(_local15 - 3)] ^ _local3[(_local15 - 8)]) ^ _local3[(_local15 - 14)]) ^ _local3[(_local15 - 16)]), 1); }; _local16 = ((((rol(_local4, 5) + ft(_local15, _local5, _local6, _local7)) + _local8) + _local3[_local15]) + kt(_local15)); _local8 = _local7; _local7 = _local6; _local6 = rol(_local5, 30); _local5 = _local4; _local4 = _local16; _local15++; }; _local4 = (_local4 + _local10); _local5 = (_local5 + _local11); _local6 = (_local6 + _local12); _local7 = (_local7 + _local13); _local8 = (_local8 + _local14); _local9 = (_local9 + 16); }; return ([_local4, _local5, _local6, _local7, _local8]); } private function kt(_arg1:uint):uint{ return (((_arg1)<20) ? 1518500249 : ((_arg1)<40) ? 1859775393 : ((_arg1)<60) ? 2400959708 : 3395469782); } override public function getHashSize():uint{ return (HASH_SIZE); } private function ft(_arg1:uint, _arg2:uint, _arg3:uint, _arg4:uint):uint{ if (_arg1 < 20){ return (((_arg2 & _arg3) | (~(_arg2) & _arg4))); }; if (_arg1 < 40){ return (((_arg2 ^ _arg3) ^ _arg4)); }; if (_arg1 < 60){ return ((((_arg2 & _arg3) | (_arg2 & _arg4)) | (_arg3 & _arg4))); }; return (((_arg2 ^ _arg3) ^ _arg4)); } private function rol(_arg1:uint, _arg2:uint):uint{ return (((_arg1 << _arg2) | (_arg1 >>> (32 - _arg2)))); } } }//package com.hurlant.crypto.hash
Section 12
//SHABase (com.hurlant.crypto.hash.SHABase) package com.hurlant.crypto.hash { import flash.utils.*; public class SHABase implements IHash { public function toString():String{ return ("sha"); } public function getInputSize():uint{ return (64); } public function getHashSize():uint{ return (0); } public function hash(_arg1:ByteArray):ByteArray{ var _local2:uint = _arg1.length; var _local3:String = _arg1.endian; _arg1.endian = Endian.BIG_ENDIAN; var _local4:uint = (_local2 * 8); while ((_arg1.length % 4) != 0) { _arg1[_arg1.length] = 0; }; _arg1.position = 0; var _local5:Array = []; var _local6:uint; while (_local6 < _arg1.length) { _local5.push(_arg1.readUnsignedInt()); _local6 = (_local6 + 4); }; var _local7:Array = core(_local5, _local4); var _local8:ByteArray = new ByteArray(); var _local9:uint = (getHashSize() / 4); _local6 = 0; while (_local6 < _local9) { _local8.writeUnsignedInt(_local7[_local6]); _local6++; }; _arg1.length = _local2; _arg1.endian = _local3; return (_local8); } protected function core(_arg1:Array, _arg2:uint):Array{ return (null); } } }//package com.hurlant.crypto.hash
Section 13
//ARC4 (com.hurlant.crypto.prng.ARC4) package com.hurlant.crypto.prng { import flash.utils.*; import com.hurlant.util.*; import com.hurlant.crypto.symmetric.*; public class ARC4 implements IPRNG, IStreamCipher { private const psize:uint = 0x0100; private var S:ByteArray; private var i:int;// = 0 private var j:int;// = 0 public function ARC4(_arg1:ByteArray=null){ S = new ByteArray(); if (_arg1){ init(_arg1); }; } public function decrypt(_arg1:ByteArray):void{ encrypt(_arg1); } public function init(_arg1:ByteArray):void{ var _local2:int; var _local3:int; var _local4:int; _local2 = 0; while (_local2 < 0x0100) { S[_local2] = _local2; _local2++; }; _local3 = 0; _local2 = 0; while (_local2 < 0x0100) { _local3 = (((_local3 + S[_local2]) + _arg1[(_local2 % _arg1.length)]) & 0xFF); _local4 = S[_local2]; S[_local2] = S[_local3]; S[_local3] = _local4; _local2++; }; this.i = 0; this.j = 0; } public function next():uint{ var _local1:int; i = ((i + 1) & 0xFF); j = ((j + S[i]) & 0xFF); _local1 = S[i]; S[i] = S[j]; S[j] = _local1; return (S[((_local1 + S[i]) & 0xFF)]); } public function encrypt(_arg1:ByteArray):void{ var _local2:uint; while (_local2 < _arg1.length) { var _temp1 = _local2; _local2 = (_local2 + 1); var _local3 = _temp1; _arg1[_local3] = (_arg1[_local3] ^ next()); }; } public function dispose():void{ var _local1:uint; if (S != null){ _local1 = 0; while (_local1 < S.length) { S[_local1] = (Math.random() * 0x0100); _local1++; }; S.length = 0; S = null; }; this.i = 0; this.j = 0; Memory.gc(); } public function getBlockSize():uint{ return (1); } public function getPoolSize():uint{ return (psize); } public function toString():String{ return ("rc4"); } } }//package com.hurlant.crypto.prng
Section 14
//IPRNG (com.hurlant.crypto.prng.IPRNG) package com.hurlant.crypto.prng { import flash.utils.*; public interface IPRNG { function init(_arg1:ByteArray):void; function next():uint; function getPoolSize():uint; function toString():String; function dispose():void; } }//package com.hurlant.crypto.prng
Section 15
//Random (com.hurlant.crypto.prng.Random) package com.hurlant.crypto.prng { import flash.utils.*; import flash.system.*; import flash.text.*; import com.hurlant.util.*; public class Random { private var ready:Boolean;// = false private var pool:ByteArray; private var seeded:Boolean;// = false private var psize:int; private var state:IPRNG; private var pptr:int; public function Random(_arg1:Class=null){ var _local2:uint; super(); if (_arg1 == null){ _arg1 = ARC4; }; state = (new (_arg1) as IPRNG); psize = state.getPoolSize(); pool = new ByteArray(); pptr = 0; while (pptr < psize) { _local2 = (65536 * Math.random()); var _local3 = pptr++; pool[_local3] = (_local2 >>> 8); var _local4 = pptr++; pool[_local4] = (_local2 & 0xFF); }; pptr = 0; seed(); } public function autoSeed():void{ var _local3:Font; var _local1:ByteArray = new ByteArray(); _local1.writeUnsignedInt(System.totalMemory); _local1.writeUTF(Capabilities.serverString); _local1.writeUnsignedInt(getTimer()); _local1.writeUnsignedInt(new Date().getTime()); var _local2:Array = Font.enumerateFonts(true); for each (_local3 in _local2) { _local1.writeUTF(_local3.fontName); _local1.writeUTF(_local3.fontStyle); _local1.writeUTF(_local3.fontType); }; _local1.position = 0; while (_local1.bytesAvailable >= 4) { seed(_local1.readUnsignedInt()); }; } public function seed(_arg1:int=0):void{ if (_arg1 == 0){ _arg1 = new Date().getTime(); }; var _local2 = pptr++; pool[_local2] = (pool[_local2] ^ (_arg1 & 0xFF)); var _local3 = pptr++; pool[_local3] = (pool[_local3] ^ ((_arg1 >> 8) & 0xFF)); var _local4 = pptr++; pool[_local4] = (pool[_local4] ^ ((_arg1 >> 16) & 0xFF)); var _local5 = pptr++; pool[_local5] = (pool[_local5] ^ ((_arg1 >> 24) & 0xFF)); pptr = (pptr % psize); seeded = true; } public function toString():String{ return (("random-" + state.toString())); } public function dispose():void{ var _local1:uint; while (_local1 < pool.length) { pool[_local1] = (Math.random() * 0x0100); _local1++; }; pool.length = 0; pool = null; state.dispose(); state = null; psize = 0; pptr = 0; Memory.gc(); } public function nextBytes(_arg1:ByteArray, _arg2:int):void{ while (_arg2--) { _arg1.writeByte(nextByte()); }; } public function nextByte():int{ if (!ready){ if (!seeded){ autoSeed(); }; state.init(pool); pool.length = 0; pptr = 0; ready = true; }; return (state.next()); } } }//package com.hurlant.crypto.prng
Section 16
//RSAKey (com.hurlant.crypto.rsa.RSAKey) package com.hurlant.crypto.rsa { import flash.utils.*; import com.hurlant.math.*; import com.hurlant.crypto.prng.*; import com.hurlant.util.*; public class RSAKey { public var dmp1:BigInteger; protected var canDecrypt:Boolean; public var d:BigInteger; public var e:int; public var dmq1:BigInteger; public var n:BigInteger; public var p:BigInteger; public var q:BigInteger; protected var canEncrypt:Boolean; public var coeff:BigInteger; public function RSAKey(_arg1:BigInteger, _arg2:int, _arg3:BigInteger=null, _arg4:BigInteger=null, _arg5:BigInteger=null, _arg6:BigInteger=null, _arg7:BigInteger=null, _arg8:BigInteger=null){ this.n = _arg1; this.e = _arg2; this.d = _arg3; this.p = _arg4; this.q = _arg5; this.dmp1 = _arg6; this.dmq1 = _arg7; this.coeff = _arg8; canEncrypt = ((!((n == null))) && (!((e == 0)))); canDecrypt = ((canEncrypt) && (!((d == null)))); } public function verify(_arg1:ByteArray, _arg2:ByteArray, _arg3:uint, _arg4:Function=null):void{ _decrypt(doPublic, _arg1, _arg2, _arg3, _arg4, 1); } protected function doPrivate2(_arg1:BigInteger):BigInteger{ if ((((p == null)) && ((q == null)))){ return (_arg1.modPow(d, n)); }; var _local2:BigInteger = _arg1.mod(p).modPow(dmp1, p); var _local3:BigInteger = _arg1.mod(q).modPow(dmq1, q); while (_local2.compareTo(_local3) < 0) { _local2 = _local2.add(p); }; var _local4:BigInteger = _local2.subtract(_local3).multiply(coeff).mod(p).multiply(q).add(_local3); return (_local4); } public function dump():String{ var _local1 = ((((("N=" + n.toString(16)) + "\n") + "E=") + e.toString(16)) + "\n"); if (canDecrypt){ _local1 = (_local1 + (("D=" + d.toString(16)) + "\n")); if (((!((p == null))) && (!((q == null))))){ _local1 = (_local1 + (("P=" + p.toString(16)) + "\n")); _local1 = (_local1 + (("Q=" + q.toString(16)) + "\n")); _local1 = (_local1 + (("DMP1=" + dmp1.toString(16)) + "\n")); _local1 = (_local1 + (("DMQ1=" + dmq1.toString(16)) + "\n")); _local1 = (_local1 + (("IQMP=" + coeff.toString(16)) + "\n")); }; }; return (_local1); } public function decrypt(_arg1:ByteArray, _arg2:ByteArray, _arg3:uint, _arg4:Function=null):void{ _decrypt(doPrivate2, _arg1, _arg2, _arg3, _arg4, 2); } private function _decrypt(_arg1:Function, _arg2:ByteArray, _arg3:ByteArray, _arg4:uint, _arg5:Function, _arg6:int):void{ var _local9:BigInteger; var _local10:BigInteger; var _local11:ByteArray; if (_arg5 == null){ _arg5 = pkcs1unpad; }; if (_arg2.position >= _arg2.length){ _arg2.position = 0; }; var _local7:uint = getBlockSize(); var _local8:int = (_arg2.position + _arg4); while (_arg2.position < _local8) { _local9 = new BigInteger(_arg2, _arg4); _local10 = _arg1(_local9); _local11 = _arg5(_local10, _local7); _arg3.writeBytes(_local11); }; } protected function doPublic(_arg1:BigInteger):BigInteger{ return (_arg1.modPowInt(e, n)); } public function dispose():void{ e = 0; n.dispose(); n = null; Memory.gc(); } private function _encrypt(_arg1:Function, _arg2:ByteArray, _arg3:ByteArray, _arg4:uint, _arg5:Function, _arg6:int):void{ var _local9:BigInteger; var _local10:BigInteger; if (_arg5 == null){ _arg5 = pkcs1pad; }; if (_arg2.position >= _arg2.length){ _arg2.position = 0; }; var _local7:uint = getBlockSize(); var _local8:int = (_arg2.position + _arg4); while (_arg2.position < _local8) { _local9 = new BigInteger(_arg5(_arg2, _local8, _local7, _arg6), _local7); _local10 = _arg1(_local9); _local10.toArray(_arg3); }; } private function rawpad(_arg1:ByteArray, _arg2:int, _arg3:uint):ByteArray{ return (_arg1); } public function encrypt(_arg1:ByteArray, _arg2:ByteArray, _arg3:uint, _arg4:Function=null):void{ _encrypt(doPublic, _arg1, _arg2, _arg3, _arg4, 2); } private function pkcs1pad(_arg1:ByteArray, _arg2:int, _arg3:uint, _arg4:uint=2):ByteArray{ var _local9:int; var _local5:ByteArray = new ByteArray(); var _local6:uint = _arg1.position; _arg2 = Math.min(_arg2, _arg1.length, ((_local6 + _arg3) - 11)); _arg1.position = _arg2; var _local7:int = (_arg2 - 1); while ((((_local7 >= _local6)) && ((_arg3 > 11)))) { --_arg3; var _local10 = _arg3; var _temp1 = _local7; _local7 = (_local7 - 1); _local5[_local10] = _arg1[_temp1]; }; --_arg3; _local10 = _arg3; _local5[_local10] = 0; var _local8:Random = new Random(); while (_arg3 > 2) { _local9 = 0; while (_local9 == 0) { _local9 = ((_arg4)==2) ? _local8.nextByte() : 0xFF; }; --_arg3; var _local11 = _arg3; _local5[_local11] = _local9; }; --_arg3; _local11 = _arg3; _local5[_local11] = _arg4; --_arg3; var _local12 = _arg3; _local5[_local12] = 0; return (_local5); } private function pkcs1unpad(_arg1:BigInteger, _arg2:uint, _arg3:uint=2):ByteArray{ var _local4:ByteArray = _arg1.toByteArray(); var _local5:ByteArray = new ByteArray(); var _local6:int; while ((((_local6 < _local4.length)) && ((_local4[_local6] == 0)))) { _local6++; }; if (((!(((_local4.length - _local6) == (_arg2 - 1)))) || ((_local4[_local6] > 2)))){ trace(((("PKCS#1 unpad: i=" + _local6) + ", expected b[i]==[0,1,2], got b[i]=") + _local4[_local6].toString(16))); return (null); }; _local6++; while (_local4[_local6] != 0) { ++_local6; if (_local6 >= _local4.length){ trace((((("PKCS#1 unpad: i=" + _local6) + ", b[i-1]!=0 (=") + _local4[(_local6 - 1)].toString(16)) + ")")); return (null); }; }; while (++_local6 < _local4.length) { _local5.writeByte(_local4[_local6]); }; _local5.position = 0; return (_local5); } public function getBlockSize():uint{ return (((n.bitLength() + 7) / 8)); } public function toString():String{ return ("rsa"); } public function sign(_arg1:ByteArray, _arg2:ByteArray, _arg3:uint, _arg4:Function=null):void{ _encrypt(doPrivate2, _arg1, _arg2, _arg3, _arg4, 1); } protected function doPrivate(_arg1:BigInteger):BigInteger{ if ((((p == null)) || ((q == null)))){ return (_arg1.modPow(d, n)); }; var _local2:BigInteger = _arg1.mod(p).modPow(dmp1, p); var _local3:BigInteger = _arg1.mod(q).modPow(dmq1, q); while (_local2.compareTo(_local3) < 0) { _local2 = _local2.add(p); }; return (_local2.subtract(_local3).multiply(coeff).mod(p).multiply(q).add(_local3)); } protected static function bigRandom(_arg1:int, _arg2:Random):BigInteger{ if (_arg1 < 2){ return (BigInteger.nbv(1)); }; var _local3:ByteArray = new ByteArray(); _arg2.nextBytes(_local3, (_arg1 >> 3)); _local3.position = 0; var _local4:BigInteger = new BigInteger(_local3); _local4.primify(_arg1, 1); return (_local4); } public static function parsePublicKey(_arg1:String, _arg2:String):RSAKey{ return (new RSAKey(new BigInteger(_arg1, 16), parseInt(_arg2, 16))); } public static function generate(_arg1:uint, _arg2:String):RSAKey{ var _local7:BigInteger; var _local8:BigInteger; var _local9:BigInteger; var _local10:BigInteger; var _local3:Random = new Random(); var _local4:uint = (_arg1 >> 1); var _local5:RSAKey = new RSAKey(null, 0, null); _local5.e = parseInt(_arg2, 16); var _local6:BigInteger = new BigInteger(_arg2, 16); while (true) { while (true) { _local5.p = bigRandom((_arg1 - _local4), _local3); if ((((_local5.p.subtract(BigInteger.ONE).gcd(_local6).compareTo(BigInteger.ONE) == 0)) && (_local5.p.isProbablePrime(10)))){ break; }; }; while (true) { _local5.q = bigRandom(_local4, _local3); if ((((_local5.q.subtract(BigInteger.ONE).gcd(_local6).compareTo(BigInteger.ONE) == 0)) && (_local5.q.isProbablePrime(10)))){ break; }; }; if (_local5.p.compareTo(_local5.q) <= 0){ _local10 = _local5.p; _local5.p = _local5.q; _local5.q = _local10; }; _local7 = _local5.p.subtract(BigInteger.ONE); _local8 = _local5.q.subtract(BigInteger.ONE); _local9 = _local7.multiply(_local8); if (_local9.gcd(_local6).compareTo(BigInteger.ONE) == 0){ _local5.n = _local5.p.multiply(_local5.q); _local5.d = _local6.modInverse(_local9); _local5.dmp1 = _local5.d.mod(_local7); _local5.dmq1 = _local5.d.mod(_local8); _local5.coeff = _local5.q.modInverse(_local5.p); break; }; }; return (_local5); } public static function parsePrivateKey(_arg1:String, _arg2:String, _arg3:String, _arg4:String=null, _arg5:String=null, _arg6:String=null, _arg7:String=null, _arg8:String=null):RSAKey{ if (_arg4 == null){ return (new RSAKey(new BigInteger(_arg1, 16), parseInt(_arg2, 16), new BigInteger(_arg3, 16))); }; return (new RSAKey(new BigInteger(_arg1, 16), parseInt(_arg2, 16), new BigInteger(_arg3, 16), new BigInteger(_arg4, 16), new BigInteger(_arg5, 16), new BigInteger(_arg6, 16), new BigInteger(_arg7), new BigInteger(_arg8))); } } }//package com.hurlant.crypto.rsa
Section 17
//ICipher (com.hurlant.crypto.symmetric.ICipher) package com.hurlant.crypto.symmetric { import flash.utils.*; public interface ICipher { function encrypt(_arg1:ByteArray):void; function getBlockSize():uint; function toString():String; function decrypt(_arg1:ByteArray):void; function dispose():void; } }//package com.hurlant.crypto.symmetric
Section 18
//IStreamCipher (com.hurlant.crypto.symmetric.IStreamCipher) package com.hurlant.crypto.symmetric { public interface IStreamCipher extends ICipher { } }//package com.hurlant.crypto.symmetric
Section 19
//BarrettReduction (com.hurlant.math.BarrettReduction) package com.hurlant.math { import com.hurlant.math.*; class BarrettReduction implements IReduction { private var r2:BigInteger; private var q3:BigInteger; private var mu:BigInteger; private var m:BigInteger; function BarrettReduction(_arg1:BigInteger){ r2 = new BigInteger(); q3 = new BigInteger(); BigInteger.ONE.dlShiftTo((2 * _arg1.t), r2); mu = r2.divide(_arg1); this.m = _arg1; } public function revert(_arg1:BigInteger):BigInteger{ return (_arg1); } public function sqrTo(_arg1:BigInteger, _arg2:BigInteger):void{ _arg1.squareTo(_arg2); reduce(_arg2); } public function convert(_arg1:BigInteger):BigInteger{ var _local2:BigInteger; if ((((_arg1.s < 0)) || ((_arg1.t > (2 * m.t))))){ return (_arg1.mod(m)); }; if (_arg1.compareTo(m) < 0){ return (_arg1); }; _local2 = new BigInteger(); _arg1.copyTo(_local2); reduce(_local2); return (_local2); } public function reduce(_arg1:BigInteger):void{ var _local2:BigInteger = (_arg1 as BigInteger); _local2.drShiftTo((m.t - 1), r2); if (_local2.t > (m.t + 1)){ _local2.t = (m.t + 1); _local2.clamp(); }; mu.multiplyUpperTo(r2, (m.t + 1), q3); m.multiplyLowerTo(q3, (m.t + 1), r2); while (_local2.compareTo(r2) < 0) { _local2.dAddOffset(1, (m.t + 1)); }; _local2.subTo(r2, _local2); while (_local2.compareTo(m) >= 0) { _local2.subTo(m, _local2); }; } public function mulTo(_arg1:BigInteger, _arg2:BigInteger, _arg3:BigInteger):void{ _arg1.multiplyTo(_arg2, _arg3); reduce(_arg3); } } }//package com.hurlant.math
Section 20
//bi_internal (com.hurlant.math.bi_internal) package com.hurlant.math { public namespace bi_internal = "http://crypto.hurlant.com/BigInteger"; }//package com.hurlant.math
Section 21
//BigInteger (com.hurlant.math.BigInteger) package com.hurlant.math { import flash.utils.*; import com.hurlant.crypto.prng.*; import com.hurlant.util.*; public class BigInteger { bi_internal var a:Array; bi_internal var s:int; public var t:int; public static const ONE:BigInteger = nbv(1); public static const ZERO:BigInteger = nbv(0); public static const DM:int = (DV - 1); public static const F1:int = 22; public static const F2:int = 8; public static const lplim:int = ((1 << 26) / lowprimes[(lowprimes.length - 1)]); public static const lowprimes:Array = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 0x0101, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509]; public static const FV:Number = Math.pow(2, BI_FP); public static const BI_FP:int = 52; public static const DV:int = (1 << DB); public static const DB:int = 30; public function BigInteger(_arg1=null, _arg2:int=0){ var _local3:ByteArray; var _local4:int; super(); a = new Array(); if ((_arg1 is String)){ _arg1 = Hex.toArray(_arg1); _arg2 = 0; }; if ((_arg1 is ByteArray)){ _local3 = (_arg1 as ByteArray); _local4 = ((_arg2) || ((_local3.length - _local3.position))); fromArray(_local3, _local4); }; } public function clearBit(_arg1:int):BigInteger{ return (changeBit(_arg1, op_andnot)); } private function op_or(_arg1:int, _arg2:int):int{ return ((_arg1 | _arg2)); } public function negate():BigInteger{ var _local1:BigInteger = nbi(); ZERO.subTo(this, _local1); return (_local1); } public function andNot(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); bitwiseTo(_arg1, op_andnot, _local2); return (_local2); } public function modPow(_arg1:BigInteger, _arg2:BigInteger):BigInteger{ var _local4:int; var _local6:IReduction; var _local12:int; var _local15:BigInteger; var _local16:BigInteger; var _local3:int = _arg1.bitLength(); var _local5:BigInteger = nbv(1); if (_local3 <= 0){ return (_local5); }; if (_local3 < 18){ _local4 = 1; } else { if (_local3 < 48){ _local4 = 3; } else { if (_local3 < 144){ _local4 = 4; } else { if (_local3 < 0x0300){ _local4 = 5; } else { _local4 = 6; }; }; }; }; if (_local3 < 8){ _local6 = new ClassicReduction(_arg2); } else { if (_arg2.isEven()){ _local6 = new BarrettReduction(_arg2); } else { _local6 = new MontgomeryReduction(_arg2); }; }; var _local7:Array = []; var _local8 = 3; var _local9:int = (_local4 - 1); var _local10:int = ((1 << _local4) - 1); _local7[1] = _local6.convert(this); if (_local4 > 1){ _local16 = new BigInteger(); _local6.sqrTo(_local7[1], _local16); while (_local8 <= _local10) { _local7[_local8] = new BigInteger(); _local6.mulTo(_local16, _local7[(_local8 - 2)], _local7[_local8]); _local8 = (_local8 + 2); }; }; var _local11:int = (_arg1.t - 1); var _local13:Boolean; var _local14:BigInteger = new BigInteger(); _local3 = (nbits(_arg1.a[_local11]) - 1); while (_local11 >= 0) { if (_local3 >= _local9){ _local12 = ((_arg1.a[_local11] >> (_local3 - _local9)) & _local10); } else { _local12 = ((_arg1.a[_local11] & ((1 << (_local3 + 1)) - 1)) << (_local9 - _local3)); if (_local11 > 0){ _local12 = (_local12 | (_arg1.a[(_local11 - 1)] >> ((DB + _local3) - _local9))); }; }; _local8 = _local4; while ((_local12 & 1) == 0) { _local12 = (_local12 >> 1); _local8--; }; _local3 = (_local3 - _local8); if (_local3 < 0){ _local3 = (_local3 + DB); _local11--; }; if (_local13){ _local7[_local12].copyTo(_local5); _local13 = false; } else { while (_local8 > 1) { _local6.sqrTo(_local5, _local14); _local6.sqrTo(_local14, _local5); _local8 = (_local8 - 2); }; if (_local8 > 0){ _local6.sqrTo(_local5, _local14); } else { _local15 = _local5; _local5 = _local14; _local14 = _local15; }; _local6.mulTo(_local14, _local7[_local12], _local5); }; while ((((_local11 >= 0)) && (((_arg1.a[_local11] & (1 << _local3)) == 0)))) { _local6.sqrTo(_local5, _local14); _local15 = _local5; _local5 = _local14; _local14 = _local15; --_local3; if (_local3 < 0){ _local3 = (DB - 1); _local11--; }; }; }; return (_local6.revert(_local5)); } public function isProbablePrime(_arg1:int):Boolean{ var _local2:int; var _local4:int; var _local5:int; var _local3:BigInteger = abs(); if ((((_local3.t == 1)) && ((_local3.a[0] <= lowprimes[(lowprimes.length - 1)])))){ _local2 = 0; while (_local2 < lowprimes.length) { if (_local3[0] == lowprimes[_local2]){ return (true); }; _local2++; }; return (false); }; if (_local3.isEven()){ return (false); }; _local2 = 1; while (_local2 < lowprimes.length) { _local4 = lowprimes[_local2]; _local5 = (_local2 + 1); while ((((_local5 < lowprimes.length)) && ((_local4 < lplim)))) { var _temp1 = _local5; _local5 = (_local5 + 1); _local4 = (_local4 * lowprimes[_temp1]); }; _local4 = _local3.modInt(_local4); while (_local2 < _local5) { var _temp2 = _local4; var _temp3 = _local2; _local2 = (_local2 + 1); if ((_temp2 % lowprimes[_temp3]) == 0){ return (false); }; }; }; return (_local3.millerRabin(_arg1)); } public function divide(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); divRemTo(_arg1, _local2, null); return (_local2); } public function mod(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = nbi(); abs().divRemTo(_arg1, null, _local2); if ((((s < 0)) && ((_local2.compareTo(ZERO) > 0)))){ _arg1.subTo(_local2, _local2); }; return (_local2); } protected function addTo(_arg1:BigInteger, _arg2:BigInteger):void{ var _local3:int; var _local4:int; var _local5:int = Math.min(_arg1.t, t); while (_local3 < _local5) { _local4 = (_local4 + (this.a[_local3] + _arg1.a[_local3])); var _temp1 = _local3; _local3 = (_local3 + 1); var _local6 = _temp1; _arg2.a[_local6] = (_local4 & DM); _local4 = (_local4 >> DB); }; if (_arg1.t < t){ _local4 = (_local4 + _arg1.s); while (_local3 < t) { _local4 = (_local4 + this.a[_local3]); var _temp2 = _local3; _local3 = (_local3 + 1); _local6 = _temp2; _arg2.a[_local6] = (_local4 & DM); _local4 = (_local4 >> DB); }; _local4 = (_local4 + s); } else { _local4 = (_local4 + s); while (_local3 < _arg1.t) { _local4 = (_local4 + _arg1.a[_local3]); var _temp3 = _local3; _local3 = (_local3 + 1); _local6 = _temp3; _arg2.a[_local6] = (_local4 & DM); _local4 = (_local4 >> DB); }; _local4 = (_local4 + _arg1.s); }; _arg2.s = ((_local4)<0) ? -1 : 0; if (_local4 > 0){ var _temp4 = _local3; _local3 = (_local3 + 1); _local6 = _temp4; _arg2.a[_local6] = _local4; } else { if (_local4 < -1){ var _temp5 = _local3; _local3 = (_local3 + 1); _local6 = _temp5; _arg2.a[_local6] = (DV + _local4); }; }; _arg2.t = _local3; _arg2.clamp(); } protected function bitwiseTo(_arg1:BigInteger, _arg2:Function, _arg3:BigInteger):void{ var _local4:int; var _local5:int; var _local6:int = Math.min(_arg1.t, t); _local4 = 0; while (_local4 < _local6) { _arg3.a[_local4] = _arg2(this.a[_local4], _arg1.a[_local4]); _local4++; }; if (_arg1.t < t){ _local5 = (_arg1.s & DM); _local4 = _local6; while (_local4 < t) { _arg3.a[_local4] = _arg2(this.a[_local4], _local5); _local4++; }; _arg3.t = t; } else { _local5 = (s & DM); _local4 = _local6; while (_local4 < _arg1.t) { _arg3.a[_local4] = _arg2(_local5, _arg1.a[_local4]); _local4++; }; _arg3.t = _arg1.t; }; _arg3.s = _arg2(s, _arg1.s); _arg3.clamp(); } protected function modInt(_arg1:int):int{ var _local4:int; if (_arg1 <= 0){ return (0); }; var _local2:int = (DV % _arg1); var _local3:int = ((s)<0) ? (_arg1 - 1) : 0; if (t > 0){ if (_local2 == 0){ _local3 = (a[0] % _arg1); } else { _local4 = (t - 1); while (_local4 >= 0) { _local3 = (((_local2 * _local3) + a[_local4]) % _arg1); _local4--; }; }; }; return (_local3); } protected function chunkSize(_arg1:Number):int{ return (Math.floor(((Math.LN2 * DB) / Math.log(_arg1)))); } public function gcd(_arg1:BigInteger):BigInteger{ var _local6:BigInteger; var _local2:BigInteger = ((s)<0) ? negate() : clone(); var _local3:BigInteger = ((_arg1.s)<0) ? _arg1.negate() : _arg1.clone(); if (_local2.compareTo(_local3) < 0){ _local6 = _local2; _local2 = _local3; _local3 = _local6; }; var _local4:int = _local2.getLowestSetBit(); var _local5:int = _local3.getLowestSetBit(); if (_local5 < 0){ return (_local2); }; if (_local4 < _local5){ _local5 = _local4; }; if (_local5 > 0){ _local2.rShiftTo(_local5, _local2); _local3.rShiftTo(_local5, _local3); }; while (_local2.sigNum() > 0) { _local4 = _local2.getLowestSetBit(); if (_local4 > 0){ _local2.rShiftTo(_local4, _local2); }; _local4 = _local3.getLowestSetBit(); if (_local4 > 0){ _local3.rShiftTo(_local4, _local3); }; if (_local2.compareTo(_local3) >= 0){ _local2.subTo(_local3, _local2); _local2.rShiftTo(1, _local2); } else { _local3.subTo(_local2, _local3); _local3.rShiftTo(1, _local3); }; }; if (_local5 > 0){ _local3.lShiftTo(_local5, _local3); }; return (_local3); } bi_internal function dAddOffset(_arg1:int, _arg2:int):void{ while (t <= _arg2) { var _local3 = t++; a[_local3] = 0; }; a[_arg2] = (a[_arg2] + _arg1); while (a[_arg2] >= DV) { a[_arg2] = (a[_arg2] - DV); ++_arg2; if (_arg2 >= t){ _local3 = t++; a[_local3] = 0; }; _local3 = a; var _local4 = _arg2; var _local5 = (_local3[_local4] + 1); _local3[_local4] = _local5; }; } bi_internal function lShiftTo(_arg1:int, _arg2:BigInteger):void{ var _local8:int; var _local3:int = (_arg1 % DB); var _local4:int = (DB - _local3); var _local5:int = ((1 << _local4) - 1); var _local6:int = (_arg1 / DB); var _local7 = ((s << _local3) & DM); _local8 = (t - 1); while (_local8 >= 0) { _arg2.a[((_local8 + _local6) + 1)] = ((a[_local8] >> _local4) | _local7); _local7 = ((a[_local8] & _local5) << _local3); _local8--; }; _local8 = (_local6 - 1); while (_local8 >= 0) { _arg2.a[_local8] = 0; _local8--; }; _arg2.a[_local6] = _local7; _arg2.t = ((t + _local6) + 1); _arg2.s = s; _arg2.clamp(); } public function getLowestSetBit():int{ var _local1:int; while (_local1 < t) { if (a[_local1] != 0){ return (((_local1 * DB) + lbit(a[_local1]))); }; _local1++; }; if (s < 0){ return ((t * DB)); }; return (-1); } public function subtract(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); subTo(_arg1, _local2); return (_local2); } public function primify(_arg1:int, _arg2:int):void{ if (!testBit((_arg1 - 1))){ bitwiseTo(BigInteger.ONE.shiftLeft((_arg1 - 1)), op_or, this); }; if (isEven()){ dAddOffset(1, 0); }; while (!(isProbablePrime(_arg2))) { dAddOffset(2, 0); while (bitLength() > _arg1) { subTo(BigInteger.ONE.shiftLeft((_arg1 - 1)), this); }; }; } bi_internal function multiplyLowerTo(_arg1:BigInteger, _arg2:int, _arg3:BigInteger):void{ var _local5:int; var _local4:int = Math.min((t + _arg1.t), _arg2); _arg3.s = 0; _arg3.t = _local4; while (_local4 > 0) { --_local4; var _local6 = _local4; _arg3.a[_local6] = 0; }; _local5 = (_arg3.t - t); while (_local4 < _local5) { _arg3.a[(_local4 + t)] = am(0, _arg1.a[_local4], _arg3, _local4, 0, t); _local4++; }; _local5 = Math.min(_arg1.t, _arg2); while (_local4 < _local5) { am(0, _arg1.a[_local4], _arg3, _local4, 0, (_arg2 - _local4)); _local4++; }; _arg3.clamp(); } public function modPowInt(_arg1:int, _arg2:BigInteger):BigInteger{ var _local3:IReduction; if ((((_arg1 < 0x0100)) || (_arg2.isEven()))){ _local3 = new ClassicReduction(_arg2); } else { _local3 = new MontgomeryReduction(_arg2); }; return (exp(_arg1, _local3)); } bi_internal function intAt(_arg1:String, _arg2:int):int{ return (parseInt(_arg1.charAt(_arg2), 36)); } public function testBit(_arg1:int):Boolean{ var _local2:int = Math.floor((_arg1 / DB)); if (_local2 >= t){ return (!((s == 0))); }; return (!(((a[_local2] & (1 << (_arg1 % DB))) == 0))); } bi_internal function exp(_arg1:int, _arg2:IReduction):BigInteger{ var _local7:BigInteger; if ((((_arg1 > 4294967295)) || ((_arg1 < 1)))){ return (ONE); }; var _local3:BigInteger = nbi(); var _local4:BigInteger = nbi(); var _local5:BigInteger = _arg2.convert(this); var _local6:int = (nbits(_arg1) - 1); _local5.copyTo(_local3); while (--_local6 >= 0) { _arg2.sqrTo(_local3, _local4); if ((_arg1 & (1 << _local6)) > 0){ _arg2.mulTo(_local4, _local5, _local3); } else { _local7 = _local3; _local3 = _local4; _local4 = _local7; }; }; return (_arg2.revert(_local3)); } public function toArray(_arg1:ByteArray):uint{ var _local2 = 8; var _local3:int = ((1 << 8) - 1); var _local4:int; var _local5:int = t; var _local6:int = (DB - ((_local5 * DB) % _local2)); var _local7:Boolean; var _local8:int; var _temp1 = _local5; _local5 = (_local5 - 1); if (_temp1 > 0){ if ((((_local6 < DB)) && (((a[_local5] >> _local6) > 0)))){ _local7 = true; _arg1.writeByte(_local4); _local8++; }; while (_local5 >= 0) { if (_local6 < _local2){ _local4 = ((a[_local5] & ((1 << _local6) - 1)) << (_local2 - _local6)); var _temp2 = _local4; _local5 = (_local5 - 1); _local6 = (_local6 + (DB - _local2)); _local4 = (_temp2 | (a[_local5] >> _local6)); } else { _local6 = (_local6 - _local2); _local4 = ((a[_local5] >> _local6) & _local3); if (_local6 <= 0){ _local6 = (_local6 + DB); _local5--; }; }; if (_local4 > 0){ _local7 = true; }; if (_local7){ _arg1.writeByte(_local4); _local8++; }; }; }; return (_local8); } public function dispose():void{ var _local1:Random = new Random(); var _local2:uint; while (_local2 < a.length) { a[_local2] = _local1.nextByte(); delete a[_local2]; _local2++; }; a = null; t = 0; s = 0; Memory.gc(); } private function lbit(_arg1:int):int{ if (_arg1 == 0){ return (-1); }; var _local2:int; if ((_arg1 & 0xFFFF) == 0){ _arg1 = (_arg1 >> 16); _local2 = (_local2 + 16); }; if ((_arg1 & 0xFF) == 0){ _arg1 = (_arg1 >> 8); _local2 = (_local2 + 8); }; if ((_arg1 & 15) == 0){ _arg1 = (_arg1 >> 4); _local2 = (_local2 + 4); }; if ((_arg1 & 3) == 0){ _arg1 = (_arg1 >> 2); _local2 = (_local2 + 2); }; if ((_arg1 & 1) == 0){ _local2++; }; return (_local2); } bi_internal function divRemTo(_arg1:BigInteger, _arg2:BigInteger=null, _arg3:BigInteger=null):void{ var qd:int; var m = _arg1; var q = _arg2; var r = _arg3; var pm:BigInteger = m.abs(); if (pm.t <= 0){ return; }; var pt:BigInteger = abs(); if (pt.t < pm.t){ if (q != null){ q.fromInt(0); }; if (r != null){ copyTo(r); }; return; }; if (r == null){ r = nbi(); }; var y:BigInteger = nbi(); var ts:int = s; var ms:int = m.s; var nsh:int = (DB - nbits(pm.a[(pm.t - 1)])); if (nsh > 0){ pm.lShiftTo(nsh, y); pt.lShiftTo(nsh, r); } else { pm.copyTo(y); pt.copyTo(r); }; var ys:int = y.t; var y0:int = y.a[(ys - 1)]; if (y0 == 0){ return; }; var yt:Number = ((y0 * (1 << F1)) + ((ys)>1) ? (y.a[(ys - 2)] >> F2) : 0); var d1:Number = (FV / yt); var d2:Number = ((1 << F1) / yt); var e:Number = (1 << F2); var i:int = r.t; var j:int = (i - ys); var t:BigInteger = ((q)==null) ? nbi() : q; y.dlShiftTo(j, t); if (r.compareTo(t) >= 0){ var _local5 = r.t++; r.a[_local5] = 1; r.subTo(t, r); }; ONE.dlShiftTo(ys, t); t.subTo(y, y); while (y.t < ys) { y.(y.t++); //not popped }; while ((j = (j - 1)), (j - 1) >= 0) { i = (i - 1); qd = ((r.a[(i - 1)])==y0) ? DM : ((Number(r.a[i]) * d1) + ((Number(r.a[(i - 1)]) + e) * d2)); if ((r.a[i] = (r.a[i] + y.am(0, qd, r, j, 0, ys))) < qd){ y.dlShiftTo(j, t); r.subTo(t, r); while ((qd = (qd - 1)), r.a[i] < (qd - 1)) { r.subTo(t, r); }; }; }; if (q != null){ r.drShiftTo(ys, q); if (ts != ms){ ZERO.subTo(q, q); }; }; r.t = ys; r.clamp(); if (nsh > 0){ r.rShiftTo(nsh, r); }; if (ts < 0){ ZERO.subTo(r, r); }; } public function remainder(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); divRemTo(_arg1, null, _local2); return (_local2); } bi_internal function multiplyUpperTo(_arg1:BigInteger, _arg2:int, _arg3:BigInteger):void{ _arg2--; var _local4:int = (_arg3.t = ((t + _arg1.t) - _arg2)); _arg3.s = 0; while (--_local4 >= 0) { _arg3.a[_local4] = 0; }; _local4 = Math.max((_arg2 - t), 0); while (_local4 < _arg1.t) { _arg3.a[((t + _local4) - _arg2)] = am((_arg2 - _local4), _arg1.a[_local4], _arg3, 0, 0, ((t + _local4) - _arg2)); _local4++; }; _arg3.clamp(); _arg3.drShiftTo(1, _arg3); } public function divideAndRemainder(_arg1:BigInteger):Array{ var _local2:BigInteger = new BigInteger(); var _local3:BigInteger = new BigInteger(); divRemTo(_arg1, _local2, _local3); return ([_local2, _local3]); } public function valueOf():Number{ var _local1:Number = 1; var _local2:Number = 0; var _local3:uint; while (_local3 < t) { _local2 = (_local2 + (a[_local3] * _local1)); _local1 = (_local1 * DV); _local3++; }; return (_local2); } public function shiftLeft(_arg1:int):BigInteger{ var _local2:BigInteger = new BigInteger(); if (_arg1 < 0){ rShiftTo(-(_arg1), _local2); } else { lShiftTo(_arg1, _local2); }; return (_local2); } public function multiply(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); multiplyTo(_arg1, _local2); return (_local2); } bi_internal function am(_arg1:int, _arg2:int, _arg3:BigInteger, _arg4:int, _arg5:int, _arg6:int):int{ var _local9:int; var _local10:int; var _local11:int; var _local7 = (_arg2 & 32767); var _local8 = (_arg2 >> 15); while (--_arg6 >= 0) { _local9 = (a[_arg1] & 32767); var _temp1 = _arg1; _arg1 = (_arg1 + 1); _local10 = (a[_temp1] >> 15); _local11 = ((_local8 * _local9) + (_local10 * _local7)); _local9 = ((((_local7 * _local9) + ((_local11 & 32767) << 15)) + _arg3.a[_arg4]) + (_arg5 & 1073741823)); _arg5 = ((((_local9 >>> 30) + (_local11 >>> 15)) + (_local8 * _local10)) + (_arg5 >>> 30)); var _temp2 = _arg4; _arg4 = (_arg4 + 1); var _local12 = _temp2; _arg3.a[_local12] = (_local9 & 1073741823); }; return (_arg5); } bi_internal function drShiftTo(_arg1:int, _arg2:BigInteger):void{ var _local3:int; _local3 = _arg1; while (_local3 < t) { _arg2.a[(_local3 - _arg1)] = a[_local3]; _local3++; }; _arg2.t = Math.max((t - _arg1), 0); _arg2.s = s; } public function add(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); addTo(_arg1, _local2); return (_local2); } protected function nbi(){ return (new BigInteger()); } protected function millerRabin(_arg1:int):Boolean{ var _local7:BigInteger; var _local8:int; var _local2:BigInteger = subtract(BigInteger.ONE); var _local3:int = _local2.getLowestSetBit(); if (_local3 <= 0){ return (false); }; var _local4:BigInteger = _local2.shiftRight(_local3); _arg1 = ((_arg1 + 1) >> 1); if (_arg1 > lowprimes.length){ _arg1 = lowprimes.length; }; var _local5:BigInteger = new BigInteger(); var _local6:int; while (_local6 < _arg1) { _local5.fromInt(lowprimes[_local6]); _local7 = _local5.modPow(_local4, this); if (((!((_local7.compareTo(BigInteger.ONE) == 0))) && (!((_local7.compareTo(_local2) == 0))))){ _local8 = 1; while ((((_local8++ < _local3)) && (!((_local7.compareTo(_local2) == 0))))) { _local7 = _local7.modPowInt(2, this); if (_local7.compareTo(BigInteger.ONE) == 0){ return (false); }; }; if (_local7.compareTo(_local2) != 0){ return (false); }; }; _local6++; }; return (true); } bi_internal function dMultiply(_arg1:int):void{ a[t] = am(0, (_arg1 - 1), this, 0, 0, t); t++; clamp(); } private function op_andnot(_arg1:int, _arg2:int):int{ return ((_arg1 & ~(_arg2))); } bi_internal function clamp():void{ var _local1 = (s & DM); while ((((t > 0)) && ((a[(t - 1)] == _local1)))) { t--; }; } bi_internal function invDigit():int{ if (t < 1){ return (0); }; var _local1:int = a[0]; if ((_local1 & 1) == 0){ return (0); }; var _local2 = (_local1 & 3); _local2 = ((_local2 * (2 - ((_local1 & 15) * _local2))) & 15); _local2 = ((_local2 * (2 - ((_local1 & 0xFF) * _local2))) & 0xFF); _local2 = ((_local2 * (2 - (((_local1 & 0xFFFF) * _local2) & 0xFFFF))) & 0xFFFF); _local2 = ((_local2 * (2 - ((_local1 * _local2) % DV))) % DV); return (((_local2)>0) ? (DV - _local2) : -(_local2)); } protected function changeBit(_arg1:int, _arg2:Function):BigInteger{ var _local3:BigInteger = BigInteger.ONE.shiftLeft(_arg1); bitwiseTo(_local3, _arg2, _local3); return (_local3); } public function equals(_arg1:BigInteger):Boolean{ return ((compareTo(_arg1) == 0)); } public function compareTo(_arg1:BigInteger):int{ var _local2:int = (s - _arg1.s); if (_local2 != 0){ return (_local2); }; var _local3:int = t; _local2 = (_local3 - _arg1.t); if (_local2 != 0){ return (_local2); }; while (--_local3 >= 0) { _local2 = (a[_local3] - _arg1.a[_local3]); if (_local2 != 0){ return (_local2); }; }; return (0); } public function shiftRight(_arg1:int):BigInteger{ var _local2:BigInteger = new BigInteger(); if (_arg1 < 0){ lShiftTo(-(_arg1), _local2); } else { rShiftTo(_arg1, _local2); }; return (_local2); } bi_internal function multiplyTo(_arg1:BigInteger, _arg2:BigInteger):void{ var _local3:BigInteger = abs(); var _local4:BigInteger = _arg1.abs(); var _local5:int = _local3.t; _arg2.t = (_local5 + _local4.t); while (--_local5 >= 0) { _arg2.a[_local5] = 0; }; _local5 = 0; while (_local5 < _local4.t) { _arg2.a[(_local5 + _local3.t)] = _local3.am(0, _local4.a[_local5], _arg2, _local5, 0, _local3.t); _local5++; }; _arg2.s = 0; _arg2.clamp(); if (s != _arg1.s){ ZERO.subTo(_arg2, _arg2); }; } public function bitCount():int{ var _local1:int; var _local2 = (s & DM); var _local3:int; while (_local3 < t) { _local1 = (_local1 + cbit((a[_local3] ^ _local2))); _local3++; }; return (_local1); } protected function toRadix(_arg1:uint=10):String{ if ((((((sigNum() == 0)) || ((_arg1 < 2)))) || ((_arg1 > 32)))){ return ("0"); }; var _local2:int = chunkSize(_arg1); var _local3:Number = Math.pow(_arg1, _local2); var _local4:BigInteger = nbv(_local3); var _local5:BigInteger = nbi(); var _local6:BigInteger = nbi(); var _local7 = ""; divRemTo(_local4, _local5, _local6); while (_local5.sigNum() > 0) { _local7 = ((_local3 + _local6.intValue()).toString(_arg1).substr(1) + _local7); _local5.divRemTo(_local4, _local5, _local6); }; return ((_local6.intValue().toString(_arg1) + _local7)); } private function cbit(_arg1:int):int{ var _local2:uint; while (_arg1 != 0) { _arg1 = (_arg1 & (_arg1 - 1)); _local2++; }; return (_local2); } bi_internal function rShiftTo(_arg1:int, _arg2:BigInteger):void{ var _local7:int; _arg2.s = s; var _local3:int = (_arg1 / DB); if (_local3 >= t){ _arg2.t = 0; return; }; var _local4:int = (_arg1 % DB); var _local5:int = (DB - _local4); var _local6:int = ((1 << _local4) - 1); _arg2.a[0] = (a[_local3] >> _local4); _local7 = (_local3 + 1); while (_local7 < t) { _arg2.a[((_local7 - _local3) - 1)] = (_arg2.a[((_local7 - _local3) - 1)] | ((a[_local7] & _local6) << _local5)); _arg2.a[(_local7 - _local3)] = (a[_local7] >> _local4); _local7++; }; if (_local4 > 0){ _arg2.a[((t - _local3) - 1)] = (_arg2.a[((t - _local3) - 1)] | ((s & _local6) << _local5)); }; _arg2.t = (t - _local3); _arg2.clamp(); } public function modInverse(_arg1:BigInteger):BigInteger{ var _local2:Boolean = _arg1.isEven(); if (((((isEven()) && (_local2))) || ((_arg1.sigNum() == 0)))){ return (BigInteger.ZERO); }; var _local3:BigInteger = _arg1.clone(); var _local4:BigInteger = clone(); var _local5:BigInteger = nbv(1); var _local6:BigInteger = nbv(0); var _local7:BigInteger = nbv(0); var _local8:BigInteger = nbv(1); while (_local3.sigNum() != 0) { while (_local3.isEven()) { _local3.rShiftTo(1, _local3); if (_local2){ if (((!(_local5.isEven())) || (!(_local6.isEven())))){ _local5.addTo(this, _local5); _local6.subTo(_arg1, _local6); }; _local5.rShiftTo(1, _local5); } else { if (!_local6.isEven()){ _local6.subTo(_arg1, _local6); }; }; _local6.rShiftTo(1, _local6); }; while (_local4.isEven()) { _local4.rShiftTo(1, _local4); if (_local2){ if (((!(_local7.isEven())) || (!(_local8.isEven())))){ _local7.addTo(this, _local7); _local8.subTo(_arg1, _local8); }; _local7.rShiftTo(1, _local7); } else { if (!_local8.isEven()){ _local8.subTo(_arg1, _local8); }; }; _local8.rShiftTo(1, _local8); }; if (_local3.compareTo(_local4) >= 0){ _local3.subTo(_local4, _local3); if (_local2){ _local5.subTo(_local7, _local5); }; _local6.subTo(_local8, _local6); } else { _local4.subTo(_local3, _local4); if (_local2){ _local7.subTo(_local5, _local7); }; _local8.subTo(_local6, _local8); }; }; if (_local4.compareTo(BigInteger.ONE) != 0){ return (BigInteger.ZERO); }; if (_local8.compareTo(_arg1) >= 0){ return (_local8.subtract(_arg1)); }; if (_local8.sigNum() < 0){ _local8.addTo(_arg1, _local8); } else { return (_local8); }; if (_local8.sigNum() < 0){ return (_local8.add(_arg1)); }; return (_local8); } bi_internal function fromArray(_arg1:ByteArray, _arg2:int):void{ var _local7:int; var _local3:int = _arg1.position; var _local4:int = (_local3 + _arg2); var _local5:int; var _local6 = 8; t = 0; s = 0; while (--_local4 >= _local3) { _local7 = ((_local4 < _arg1.length)) ? _arg1[_local4] : 0; if (_local5 == 0){ var _local8 = t++; a[_local8] = _local7; } else { if ((_local5 + _local6) > DB){ a[(t - 1)] = (a[(t - 1)] | ((_local7 & ((1 << (DB - _local5)) - 1)) << _local5)); _local8 = t++; a[_local8] = (_local7 >> (DB - _local5)); } else { a[(t - 1)] = (a[(t - 1)] | (_local7 << _local5)); }; }; _local5 = (_local5 + _local6); if (_local5 >= DB){ _local5 = (_local5 - DB); }; }; clamp(); _arg1.position = Math.min((_local3 + _arg2), _arg1.length); } bi_internal function copyTo(_arg1:BigInteger):void{ var _local2:int = (t - 1); while (_local2 >= 0) { _arg1.a[_local2] = a[_local2]; _local2--; }; _arg1.t = t; _arg1.s = s; } public function intValue():int{ if (s < 0){ if (t == 1){ return ((a[0] - DV)); }; if (t == 0){ return (-1); }; } else { if (t == 1){ return (a[0]); }; if (t == 0){ return (0); }; }; return ((((a[1] & ((1 << (32 - DB)) - 1)) << DB) | a[0])); } public function min(_arg1:BigInteger):BigInteger{ return (((compareTo(_arg1))<0) ? this : _arg1); } public function bitLength():int{ if (t <= 0){ return (0); }; return (((DB * (t - 1)) + nbits((a[(t - 1)] ^ (s & DM))))); } public function shortValue():int{ return (((t)==0) ? s : ((a[0] << 16) >> 16)); } public function and(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); bitwiseTo(_arg1, op_and, _local2); return (_local2); } public function byteValue():int{ return (((t)==0) ? s : ((a[0] << 24) >> 24)); } public function not():BigInteger{ var _local1:BigInteger = new BigInteger(); var _local2:int; while (_local2 < t) { _local1[_local2] = (DM & ~(a[_local2])); _local2++; }; _local1.t = t; _local1.s = ~(s); return (_local1); } bi_internal function subTo(_arg1:BigInteger, _arg2:BigInteger):void{ var _local3:int; var _local4:int; var _local5:int = Math.min(_arg1.t, t); while (_local3 < _local5) { _local4 = (_local4 + (a[_local3] - _arg1.a[_local3])); var _temp1 = _local3; _local3 = (_local3 + 1); var _local6 = _temp1; _arg2.a[_local6] = (_local4 & DM); _local4 = (_local4 >> DB); }; if (_arg1.t < t){ _local4 = (_local4 - _arg1.s); while (_local3 < t) { _local4 = (_local4 + a[_local3]); var _temp2 = _local3; _local3 = (_local3 + 1); _local6 = _temp2; _arg2.a[_local6] = (_local4 & DM); _local4 = (_local4 >> DB); }; _local4 = (_local4 + s); } else { _local4 = (_local4 + s); while (_local3 < _arg1.t) { _local4 = (_local4 - _arg1.a[_local3]); var _temp3 = _local3; _local3 = (_local3 + 1); _local6 = _temp3; _arg2.a[_local6] = (_local4 & DM); _local4 = (_local4 >> DB); }; _local4 = (_local4 - _arg1.s); }; _arg2.s = ((_local4)<0) ? -1 : 0; if (_local4 < -1){ var _temp4 = _local3; _local3 = (_local3 + 1); _local6 = _temp4; _arg2.a[_local6] = (DV + _local4); } else { if (_local4 > 0){ var _temp5 = _local3; _local3 = (_local3 + 1); _local6 = _temp5; _arg2.a[_local6] = _local4; }; }; _arg2.t = _local3; _arg2.clamp(); } public function clone():BigInteger{ var _local1:BigInteger = new BigInteger(); this.copyTo(_local1); return (_local1); } public function pow(_arg1:int):BigInteger{ return (exp(_arg1, new NullReduction())); } public function flipBit(_arg1:int):BigInteger{ return (changeBit(_arg1, op_xor)); } public function xor(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); bitwiseTo(_arg1, op_xor, _local2); return (_local2); } public function or(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); bitwiseTo(_arg1, op_or, _local2); return (_local2); } public function max(_arg1:BigInteger):BigInteger{ return (((compareTo(_arg1))>0) ? this : _arg1); } bi_internal function fromInt(_arg1:int):void{ t = 1; s = ((_arg1)<0) ? -1 : 0; if (_arg1 > 0){ a[0] = _arg1; } else { if (_arg1 < -1){ a[0] = (_arg1 + DV); } else { t = 0; }; }; } bi_internal function isEven():Boolean{ return ((((t)>0) ? (a[0] & 1) : s == 0)); } public function toString(_arg1:Number=16):String{ var _local2:int; if (s < 0){ return (("-" + negate().toString(_arg1))); }; switch (_arg1){ case 2: _local2 = 1; break; case 4: _local2 = 2; break; case 8: _local2 = 3; break; case 16: _local2 = 4; break; case 32: _local2 = 5; break; }; var _local3:int = ((1 << _local2) - 1); var _local4:int; var _local5:Boolean; var _local6 = ""; var _local7:int = t; var _local8:int = (DB - ((_local7 * DB) % _local2)); var _temp1 = _local7; _local7 = (_local7 - 1); if (_temp1 > 0){ if ((((_local8 < DB)) && (((a[_local7] >> _local8) > 0)))){ _local5 = true; _local6 = _local4.toString(36); }; while (_local7 >= 0) { if (_local8 < _local2){ _local4 = ((a[_local7] & ((1 << _local8) - 1)) << (_local2 - _local8)); var _temp2 = _local4; _local7 = (_local7 - 1); _local8 = (_local8 + (DB - _local2)); _local4 = (_temp2 | (a[_local7] >> _local8)); } else { _local8 = (_local8 - _local2); _local4 = ((a[_local7] >> _local8) & _local3); if (_local8 <= 0){ _local8 = (_local8 + DB); _local7--; }; }; if (_local4 > 0){ _local5 = true; }; if (_local5){ _local6 = (_local6 + _local4.toString(36)); }; }; }; return ((_local5) ? _local6 : "0"); } public function setBit(_arg1:int):BigInteger{ return (changeBit(_arg1, op_or)); } public function abs():BigInteger{ return (((s)<0) ? negate() : this); } bi_internal function nbits(_arg1:int):int{ var _local3:int; var _local2 = 1; _local3 = (_arg1 >>> 16); if (_local3 != 0){ _arg1 = _local3; _local2 = (_local2 + 16); }; _local3 = (_arg1 >> 8); if (_local3 != 0){ _arg1 = _local3; _local2 = (_local2 + 8); }; _local3 = (_arg1 >> 4); if (_local3 != 0){ _arg1 = _local3; _local2 = (_local2 + 4); }; _local3 = (_arg1 >> 2); if (_local3 != 0){ _arg1 = _local3; _local2 = (_local2 + 2); }; _local3 = (_arg1 >> 1); if (_local3 != 0){ _arg1 = _local3; _local2 = (_local2 + 1); }; return (_local2); } public function sigNum():int{ if (s < 0){ return (-1); }; if ((((t <= 0)) || ((((t == 1)) && ((a[0] <= 0)))))){ return (0); }; return (1); } public function toByteArray():ByteArray{ var _local4:int; var _local1:int = t; var _local2:ByteArray = new ByteArray(); _local2[0] = s; var _local3:int = (DB - ((_local1 * DB) % 8)); var _local5:int; var _temp1 = _local1; _local1 = (_local1 - 1); if (_temp1 > 0){ if ((((_local3 < DB)) && (!(((a[_local1] >> _local3) == ((s & DM) >> _local3)))))){ var _temp2 = _local5; _local5 = (_local5 + 1); var _local6 = _temp2; _local2[_local6] = (_local4 | (s << (DB - _local3))); }; while (_local1 >= 0) { if (_local3 < 8){ _local4 = ((a[_local1] & ((1 << _local3) - 1)) << (8 - _local3)); var _temp3 = _local4; _local1 = (_local1 - 1); _local3 = (_local3 + (DB - 8)); _local4 = (_temp3 | (a[_local1] >> _local3)); } else { _local3 = (_local3 - 8); _local4 = ((a[_local1] >> _local3) & 0xFF); if (_local3 <= 0){ _local3 = (_local3 + DB); _local1--; }; }; if ((_local4 & 128) != 0){ _local4 = (_local4 | -256); }; if ((((_local5 == 0)) && (!(((s & 128) == (_local4 & 128)))))){ _local5++; }; if ((((_local5 > 0)) || (!((_local4 == s))))){ var _temp4 = _local5; _local5 = (_local5 + 1); _local6 = _temp4; _local2[_local6] = _local4; }; }; }; return (_local2); } bi_internal function squareTo(_arg1:BigInteger):void{ var _local4:int; var _local2:BigInteger = abs(); var _local3:int = (_arg1.t = (2 * _local2.t)); while (--_local3 >= 0) { _arg1.a[_local3] = 0; }; _local3 = 0; while (_local3 < (_local2.t - 1)) { _local4 = _local2.am(_local3, _local2.a[_local3], _arg1, (2 * _local3), 0, 1); if ((_arg1.a[(_local3 + _local2.t)] = (_arg1.a[(_local3 + _local2.t)] + _local2.am((_local3 + 1), (2 * _local2.a[_local3]), _arg1, ((2 * _local3) + 1), _local4, ((_local2.t - _local3) - 1)))) >= DV){ _arg1.a[(_local3 + _local2.t)] = (_arg1.a[(_local3 + _local2.t)] - DV); _arg1.a[((_local3 + _local2.t) + 1)] = 1; }; _local3++; }; if (_arg1.t > 0){ _arg1.a[(_arg1.t - 1)] = (_arg1.a[(_arg1.t - 1)] + _local2.am(_local3, _local2.a[_local3], _arg1, (2 * _local3), 0, 1)); }; _arg1.s = 0; _arg1.clamp(); } private function op_and(_arg1:int, _arg2:int):int{ return ((_arg1 & _arg2)); } protected function fromRadix(_arg1:String, _arg2:int=10):void{ var _local9:int; fromInt(0); var _local3:int = chunkSize(_arg2); var _local4:Number = Math.pow(_arg2, _local3); var _local5:Boolean; var _local6:int; var _local7:int; var _local8:int; while (_local8 < _arg1.length) { _local9 = intAt(_arg1, _local8); if (_local9 < 0){ if ((((_arg1.charAt(_local8) == "-")) && ((sigNum() == 0)))){ _local5 = true; }; } else { _local7 = ((_arg2 * _local7) + _local9); ++_local6; if (_local6 >= _local3){ dMultiply(_local4); dAddOffset(_local7, 0); _local6 = 0; _local7 = 0; }; }; _local8++; }; if (_local6 > 0){ dMultiply(Math.pow(_arg2, _local6)); dAddOffset(_local7, 0); }; if (_local5){ BigInteger.ZERO.subTo(this, this); }; } bi_internal function dlShiftTo(_arg1:int, _arg2:BigInteger):void{ var _local3:int; _local3 = (t - 1); while (_local3 >= 0) { _arg2.a[(_local3 + _arg1)] = a[_local3]; _local3--; }; _local3 = (_arg1 - 1); while (_local3 >= 0) { _arg2.a[_local3] = 0; _local3--; }; _arg2.t = (t + _arg1); _arg2.s = s; } private function op_xor(_arg1:int, _arg2:int):int{ return ((_arg1 ^ _arg2)); } public static function nbv(_arg1:int):BigInteger{ var _local2:BigInteger = new (BigInteger); _local2.fromInt(_arg1); return (_local2); } } }//package com.hurlant.math
Section 22
//ClassicReduction (com.hurlant.math.ClassicReduction) package com.hurlant.math { import com.hurlant.math.*; class ClassicReduction implements IReduction { private var m:BigInteger; function ClassicReduction(_arg1:BigInteger){ this.m = _arg1; } public function revert(_arg1:BigInteger):BigInteger{ return (_arg1); } public function reduce(_arg1:BigInteger):void{ _arg1.divRemTo(m, null, _arg1); } public function mulTo(_arg1:BigInteger, _arg2:BigInteger, _arg3:BigInteger):void{ _arg1.multiplyTo(_arg2, _arg3); reduce(_arg3); } public function sqrTo(_arg1:BigInteger, _arg2:BigInteger):void{ _arg1.squareTo(_arg2); reduce(_arg2); } public function convert(_arg1:BigInteger):BigInteger{ if ((((_arg1.s < 0)) || ((_arg1.compareTo(m) >= 0)))){ return (_arg1.mod(m)); }; return (_arg1); } } }//package com.hurlant.math
Section 23
//IReduction (com.hurlant.math.IReduction) package com.hurlant.math { import com.hurlant.math.*; interface IReduction { function revert(_arg1:BigInteger):BigInteger; function reduce(_arg1:BigInteger):void; function convert(_arg1:BigInteger):BigInteger; function mulTo(_arg1:BigInteger, _arg2:BigInteger, _arg3:BigInteger):void; function sqrTo(_arg1:BigInteger, _arg2:BigInteger):void; } }//package com.hurlant.math
Section 24
//MontgomeryReduction (com.hurlant.math.MontgomeryReduction) package com.hurlant.math { import com.hurlant.math.*; class MontgomeryReduction implements IReduction { private var mp:int; private var mph:int; private var mpl:int; private var mt2:int; private var m:BigInteger; private var um:int; function MontgomeryReduction(_arg1:BigInteger){ this.m = _arg1; mp = _arg1.invDigit(); mpl = (mp & 32767); mph = (mp >> 15); um = ((1 << (BigInteger.DB - 15)) - 1); mt2 = (2 * _arg1.t); } public function convert(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); _arg1.abs().dlShiftTo(m.t, _local2); _local2.divRemTo(m, null, _local2); if ((((_arg1.s < 0)) && ((_local2.compareTo(BigInteger.ZERO) > 0)))){ m.subTo(_local2, _local2); }; return (_local2); } public function revert(_arg1:BigInteger):BigInteger{ var _local2:BigInteger = new BigInteger(); _arg1.copyTo(_local2); reduce(_local2); return (_local2); } public function sqrTo(_arg1:BigInteger, _arg2:BigInteger):void{ _arg1.squareTo(_arg2); reduce(_arg2); } public function reduce(_arg1:BigInteger):void{ var _local3:int; var _local4:int; while (_arg1.t <= mt2) { var _local5 = _arg1.t++; _arg1.a[_local5] = 0; }; var _local2:int; while (_local2 < m.t) { _local3 = (_arg1.a[_local2] & 32767); _local4 = (((_local3 * mpl) + ((((_local3 * mph) + ((_arg1.a[_local2] >> 15) * mpl)) & um) << 15)) & BigInteger.DM); _local3 = (_local2 + m.t); _arg1.a[_local3] = (_arg1.a[_local3] + m.am(0, _local4, _arg1, _local2, 0, m.t)); while (_arg1.a[_local3] >= BigInteger.DV) { _arg1.a[_local3] = (_arg1.a[_local3] - BigInteger.DV); _local5 = _arg1.a; ++_local3; var _local6 = _local3; var _local7 = (_local5[_local6] + 1); _local5[_local6] = _local7; }; _local2++; }; _arg1.clamp(); _arg1.drShiftTo(m.t, _arg1); if (_arg1.compareTo(m) >= 0){ _arg1.subTo(m, _arg1); }; } public function mulTo(_arg1:BigInteger, _arg2:BigInteger, _arg3:BigInteger):void{ _arg1.multiplyTo(_arg2, _arg3); reduce(_arg3); } } }//package com.hurlant.math
Section 25
//NullReduction (com.hurlant.math.NullReduction) package com.hurlant.math { public class NullReduction implements IReduction { public function convert(_arg1:BigInteger):BigInteger{ return (_arg1); } public function sqrTo(_arg1:BigInteger, _arg2:BigInteger):void{ _arg1.squareTo(_arg2); } public function mulTo(_arg1:BigInteger, _arg2:BigInteger, _arg3:BigInteger):void{ _arg1.multiplyTo(_arg2, _arg3); } public function revert(_arg1:BigInteger):BigInteger{ return (_arg1); } public function reduce(_arg1:BigInteger):void{ } } }//package com.hurlant.math
Section 26
//Base64 (com.hurlant.util.Base64) package com.hurlant.util { import flash.utils.*; public class Base64 { public static const version:String = "1.0.0"; private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; public function Base64(){ throw (new Error("Base64 class is static container only")); } public static function encode(_arg1:String):String{ var _local2:ByteArray = new ByteArray(); _local2.writeUTFBytes(_arg1); return (encodeByteArray(_local2)); } public static function encodeByteArray(_arg1:ByteArray):String{ var _local3:Array; var _local5:uint; var _local6:uint; var _local7:uint; var _local2 = ""; var _local4:Array = new Array(4); _arg1.position = 0; while (_arg1.bytesAvailable > 0) { _local3 = new Array(); _local5 = 0; while ((((_local5 < 3)) && ((_arg1.bytesAvailable > 0)))) { _local3[_local5] = _arg1.readUnsignedByte(); _local5++; }; _local4[0] = ((_local3[0] & 252) >> 2); _local4[1] = (((_local3[0] & 3) << 4) | (_local3[1] >> 4)); _local4[2] = (((_local3[1] & 15) << 2) | (_local3[2] >> 6)); _local4[3] = (_local3[2] & 63); _local6 = _local3.length; while (_local6 < 3) { _local4[(_local6 + 1)] = 64; _local6++; }; _local7 = 0; while (_local7 < _local4.length) { _local2 = (_local2 + BASE64_CHARS.charAt(_local4[_local7])); _local7++; }; }; return (_local2); } public static function decode(_arg1:String):String{ var _local2:ByteArray = decodeToByteArray(_arg1); return (_local2.readUTFBytes(_local2.length)); } public static function decodeToByteArray(_arg1:String):ByteArray{ var _local6:uint; var _local7:uint; var _local2:ByteArray = new ByteArray(); var _local3:Array = new Array(4); var _local4:Array = new Array(3); var _local5:uint; while (_local5 < _arg1.length) { _local6 = 0; while ((((_local6 < 4)) && (((_local5 + _local6) < _arg1.length)))) { _local3[_local6] = BASE64_CHARS.indexOf(_arg1.charAt((_local5 + _local6))); _local6++; }; _local4[0] = ((_local3[0] << 2) + ((_local3[1] & 48) >> 4)); _local4[1] = (((_local3[1] & 15) << 4) + ((_local3[2] & 60) >> 2)); _local4[2] = (((_local3[2] & 3) << 6) + _local3[3]); _local7 = 0; while (_local7 < _local4.length) { if (_local3[(_local7 + 1)] == 64){ break; }; _local2.writeByte(_local4[_local7]); _local7++; }; _local5 = (_local5 + 4); }; _local2.position = 0; return (_local2); } } }//package com.hurlant.util
Section 27
//Hex (com.hurlant.util.Hex) package com.hurlant.util { import flash.utils.*; public class Hex { public static function fromString(_arg1:String, _arg2:Boolean=false):String{ var _local3:ByteArray = new ByteArray(); _local3.writeUTFBytes(_arg1); return (fromArray(_local3, _arg2)); } public static function toString(_arg1:String):String{ var _local2:ByteArray = toArray(_arg1); return (_local2.readUTFBytes(_local2.length)); } public static function toArray(_arg1:String):ByteArray{ _arg1 = _arg1.replace(/\s|:/gm, ""); var _local2:ByteArray = new ByteArray(); if ((_arg1.length & (1 == 1))){ _arg1 = ("0" + _arg1); }; var _local3:uint; while (_local3 < _arg1.length) { _local2[(_local3 / 2)] = parseInt(_arg1.substr(_local3, 2), 16); _local3 = (_local3 + 2); }; return (_local2); } public static function fromArray(_arg1:ByteArray, _arg2:Boolean=false):String{ var _local3 = ""; var _local4:uint; while (_local4 < _arg1.length) { _local3 = (_local3 + ("0" + _arg1[_local4].toString(16)).substr(-2, 2)); if (_arg2){ if (_local4 < (_arg1.length - 1)){ _local3 = (_local3 + ":"); }; }; _local4++; }; return (_local3); } } }//package com.hurlant.util
Section 28
//Memory (com.hurlant.util.Memory) package com.hurlant.util { import flash.net.*; import flash.system.*; public class Memory { public static function gc():void{ try { new LocalConnection().connect("foo"); new LocalConnection().connect("foo"); } catch(e) { }; } public static function get used():uint{ return (System.totalMemory); } } }//package com.hurlant.util
Section 29
//JabberChatRoom (com.kongregate.as3.chat.JabberChatRoom) package com.kongregate.as3.chat { import com.kongregate.as3.common.events.*; import org.jivesoftware.xiff.core.*; import org.jivesoftware.xiff.events.*; import com.kongregate.as3.common.util.*; import org.jivesoftware.xiff.conference.*; import com.adobe.serialization.json.*; public class JabberChatRoom { private var mType:String; private var mName:String; private var mHistoryNum:int; private var mRoom:Room; private var mOccupants:Object; private var mHistoryMode:String; private var mConnection:JabberConnection;// = null private var mXmppName:String; public static const TYPE_CHAT:String = "chat"; public static const TYPE_GAME:String = "game"; public function JabberChatRoom(_arg1:JabberConnection, _arg2:String, _arg3:String, _arg4:String, _arg5:int=60, _arg6:String="seconds"){ mOccupants = {}; super(); mConnection = _arg1; mType = _arg2; mHistoryNum = _arg5; mHistoryMode = _arg6; mXmppName = _arg3; mName = _arg4; createRoomObject(); } private function dispatchEvent(_arg1:String, _arg2:Object=null):void{ var _local3:JabberEvent = new JabberEvent(_arg1, _arg2); mConnection.dispatchEvent(_local3); } public function get type():String{ return (mType); } private function onUserChanged(_arg1:RoomEvent):void{ var _local5:Boolean; var _local6:Object; if (Log.isDebug()){ Log.spam((("User " + _arg1.nickname) + " status changed")); }; var _local2:User = new User(_arg1.nickname, null, null); var _local3:String = _arg1.data.status; var _local4:Object = getValidOccupant(_arg1.nickname); if (_local4){ _local5 = true; if (((!((_local3 == null))) && ((_local3.length > 0)))){ _local2.parseCompressedVariables(_local3); _local5 = _local2.validateUserVariables(true); } else { _local2.variables = _local4.variables; }; if (_local5){ _local2.variables.role = _arg1.data.role; _local2.variables.presence = _arg1.data.show; _local4.variables = _local2.variables; _local6 = {room:toObject(), user:_local2}; dispatchEvent(JabberEvent.USER_CHANGED, _local6); } else { Log.error(("Unable to validate update user variables for " + _arg1.nickname)); }; } else { Log.error(("User changed event for invalid occupant: " + _arg1.nickname)); }; } public function get name():String{ return (mName); } private function onUserDeparture(_arg1:RoomEvent):void{ var _local3:User; var _local4:Object; if (Log.isDebug()){ Log.spam(((("User " + _arg1.nickname) + " left ") + toString())); }; var _local2:Object = getValidOccupant(_arg1.nickname); if (_local2){ delete mOccupants[_arg1.nickname]; _local3 = new User(_arg1.nickname, null, null); _local4 = {room:toObject(), user:_local3}; dispatchEvent(JabberEvent.USER_DEPARTURE, _local4); } else { Log.error("Invalid user leaving room, ignoring"); }; } private function onLeaveRoom(_arg1:RoomEvent):void{ Log.info(("Left room " + toString())); dispatchEvent(JabberEvent.LEAVE_ROOM, {room:toObject()}); } function get room():Room{ return (mRoom); } private function createRoomObject():void{ destroy(); mRoom = new Room(mConnection.connection); mRoom.addEventListener(RoomEvent.ROOM_JOIN, onJoinRoom); mRoom.addEventListener(RoomEvent.ROOM_LEAVE, onLeaveRoom); mRoom.addEventListener(RoomEvent.USER_JOIN, onUserJoin); mRoom.addEventListener(RoomEvent.USER_CHANGED, onUserChanged); mRoom.addEventListener(RoomEvent.USER_DEPARTURE, onUserDeparture); mRoom.addEventListener(RoomEvent.GROUP_MESSAGE, onGroupMessage); mRoom.addEventListener(RoomEvent.SUBJECT_CHANGE, onSubjectChange); mRoom.nickname = mConnection.user.username; mRoom.roomJID = new JID(((mXmppName + "@") + mConnection.conferenceServer)); } public function sendMessage(_arg1:String):void{ if (Log.isDebug()){ Log.debug(("Sending message: " + _arg1)); }; mRoom.sendMessage(_arg1); } public function get xmppName():String{ return (mXmppName); } public function toObject():Object{ return ({xmpp_name:xmppName, id:xmppName, name:name, type:type}); } private function onUserJoin(_arg1:RoomEvent):void{ var _local4:Object; if (Log.isDebug()){ Log.spam(((("User " + _arg1.nickname) + " joined ") + toString())); }; var _local2:User = new User(_arg1.nickname, null, null); _local2.parseCompressedVariables(_arg1.data.status); var _local3:Boolean = _local2.validateUserVariables(true); if (_local3){ _local2.variables.role = _arg1.data.role; _local2.variables.presence = _arg1.data.show; _local4 = {room:toObject(), user:_local2}; dispatchEvent(JabberEvent.USER_JOIN, _local4); } else { Log.error(("Unable to validate join user variables for " + _arg1.nickname)); }; mOccupants[_arg1.nickname] = {valid:_local3, variables:_local2.variables}; } private function onJoinRoom(_arg1:RoomEvent):void{ Log.info(("Joined room " + toString())); dispatchEvent(JabberEvent.JOIN_ROOM, {room:toObject()}); } public function toString():String{ return ((((mRoom.roomJID.toString() + " (") + xmppName) + ")")); } public function join():void{ createRoomObject(); Log.info(("Joining room " + toString())); mRoom.join(false, mConnection.user.compressedVariables, mHistoryMode, mHistoryNum); } private function getValidOccupant(_arg1:String):Object{ var _local2:Object = mOccupants[_arg1]; if (((_local2) && (_local2.valid))){ return (_local2); }; return (null); } private function onGroupMessage(_arg1:RoomEvent):void{ var _local5:Object; var _local2:User = new User(_arg1.data.from.resource); var _local3:Boolean = _arg1.data.time; var _local4:Boolean = ((!(_local2.isGuest())) && (((getValidOccupant(_local2.username)) || (_local3)))); if (_local4){ _local5 = {room:toObject(), user:_local2, message:_arg1.data.body, history:_local3}; dispatchEvent(JabberEvent.ROOM_MESSAGE, _local5); } else { if (Log.isDebug()){ Log.spam(("Room message from invalid user ignored: " + _local2.username)); }; }; } private function onSubjectChange(_arg1:RoomEvent):void{ var subject:String; var data:Object; var numGuests:int; var e = _arg1; try { subject = e.subject; Log.debug(("Room subject changed: " + subject)); data = JSON.decode(subject); numGuests = data.g; if (!isNaN(numGuests)){ data = {room:toObject(), guests:numGuests}; dispatchEvent(JabberEvent.GUEST_COUNT, data); }; } catch(e:Error) { Log.error(("Error during subject change: " + e.toString())); }; } public function leave():void{ Log.info(("Leaving room " + toString())); mRoom.removeEventListener(RoomEvent.ROOM_JOIN, onJoinRoom); mRoom.removeEventListener(RoomEvent.USER_JOIN, onUserJoin); mRoom.removeEventListener(RoomEvent.USER_CHANGED, onUserChanged); mRoom.removeEventListener(RoomEvent.USER_DEPARTURE, onUserDeparture); mRoom.removeEventListener(RoomEvent.GROUP_MESSAGE, onGroupMessage); mRoom.removeEventListener(RoomEvent.SUBJECT_CHANGE, onSubjectChange); mRoom.leave(); } public function destroy():void{ if (mRoom != null){ mRoom.removeEventListener(RoomEvent.ROOM_JOIN, onJoinRoom); mRoom.removeEventListener(RoomEvent.ROOM_LEAVE, onLeaveRoom); mRoom.removeEventListener(RoomEvent.USER_JOIN, onUserJoin); mRoom.removeEventListener(RoomEvent.USER_CHANGED, onUserChanged); mRoom.removeEventListener(RoomEvent.USER_DEPARTURE, onUserDeparture); mRoom.removeEventListener(RoomEvent.GROUP_MESSAGE, onGroupMessage); mRoom.removeEventListener(RoomEvent.SUBJECT_CHANGE, onSubjectChange); mRoom.leave(); }; mOccupants = {}; } public function set status(_arg1:String):void{ mRoom.status = _arg1; } } }//package com.kongregate.as3.chat
Section 30
//JabberConnection (com.kongregate.as3.chat.JabberConnection) package com.kongregate.as3.chat { import com.kongregate.as3.service.*; import com.kongregate.as3.common.events.*; import org.jivesoftware.xiff.data.*; import org.jivesoftware.xiff.core.*; import flash.events.*; import com.kongregate.as3.common.comm.*; import org.jivesoftware.xiff.events.*; import com.kongregate.as3.common.util.*; import flash.utils.*; import flash.system.*; public class JabberConnection extends BufferedEventDispatcher { private var mConnecting:Boolean;// = false private var mPresence:String; private var mRooms:Object; private var mLastPacketReceived:int; private var mEverConnectedWithSocket:Boolean;// = false private var mGameApiService:GameAPIService; private var mSocketConnectionAttemptCount:uint;// = 0 private var mConnection:XMPPConnection; private var mLastError:String;// = "" private var mLastPacketSent:int; private var mCompressionEnabled:Boolean; private var mUser:User; private var mLoginFailed:Boolean;// = true private var mLastSetPresence:int; private var mSessionConflict:Boolean;// = false private var gStaticInit:Boolean; private var mBanned:Boolean;// = false private var mConnectionMonitorTimer:Timer; private var mOptions:Object; private var mRateLimiter:RateLimiter; private static const CONNECTION_TIMEOUT:int = 180000; private static const CONNECTION_MONITOR_INTERVAL:int = 60000; private static const SET_PRESENCE_INTERVAL:int = 3000; private static const SOCKET_ATTEMPTS_BEFORE_BOSH:int = 1; private static var OUTGOING_RATE_LIMITER_RULES:Array = [{duration:1000, capacity:2}, {duration:60000, capacity:20}]; public static var MAX_OUTGOING_MESSAGE_LENGTH:int = 250; public function JabberConnection(_arg1:Object){ mRooms = {}; mOptions = {}; mLastPacketReceived = getTimer(); mLastPacketSent = getTimer(); gStaticInit = staticInit(); mConnectionMonitorTimer = new Timer(CONNECTION_MONITOR_INTERVAL); mRateLimiter = new RateLimiter(OUTGOING_RATE_LIMITER_RULES); mLastSetPresence = getTimer(); super(); mOptions = _arg1; initializeSocketConnection(); mConnectionMonitorTimer.addEventListener(TimerEvent.TIMER, onConnectionMonitorTimer); Log.info(((("JabberConnection initialized, BOSH enabled=" + boshEnabled) + ", compression enabled=") + compressionEnabled)); } public function get isBosh():Boolean{ return ((mConnection is XMPPBOSHConnection)); } private function get compressionEnabled():Boolean{ return ((((mOptions.enable_compression == true)) || ((mOptions.enable_compression == "true")))); } public function sendRoomMessage(_arg1:String, _arg2:String):void{ setPresence(Presence.SHOW_CHAT); _arg2 = validateMessage(_arg2); if (null == _arg2){ return; }; var _local3:JabberChatRoom = getRoom(_arg1); if (_local3 != null){ _local3.sendMessage(_arg2); } else { Log.warn(("Message sent to non-existant room type: " + _arg1)); }; } private function get xiffConnectionType():String{ return ((isBosh) ? "terminatedStandard" : "terminatedFlash"); } public function get loginFailed():Boolean{ return (mLoginFailed); } private function initializeConnection():void{ if (((!(boshEnabled)) || ((mSocketConnectionAttemptCount < SOCKET_ATTEMPTS_BEFORE_BOSH)))){ initializeSocketConnection(); mSocketConnectionAttemptCount++; } else { mSocketConnectionAttemptCount = 0; initializeBOSHConnection(); }; } public function get sessionConflict():Boolean{ return (mSessionConflict); } private function validateMessage(_arg1:String):String{ if (user.isGuest()){ return (null); }; var _local2:Object = mRateLimiter.ruleViolated(); if (_local2){ dispatchEvent(new JabberEvent(JabberEvent.MESSAGE_ERROR, {errorType:JabberEvent.ERROR_MSG_RATE_LIMIT, ruleViolated:_local2})); return (null); }; if (_arg1.length > MAX_OUTGOING_MESSAGE_LENGTH){ dispatchEvent(new JabberEvent(JabberEvent.MESSAGE_ERROR, {errorType:JabberEvent.ERROR_MSG_TOO_LONG})); _arg1 = StringTruncate.truncateOn(_arg1, MAX_OUTGOING_MESSAGE_LENGTH, " ", "…"); }; return (BadLanguageFilter.filter(_arg1)); } public function get lastError():String{ return (mLastError); } public function sendKongregateMessage(_arg1:Message):void{ var _local2:IQ = new IQ(null, IQ.GET_TYPE, XMPPStanza.generateID("sgm_"), null, null); var _local3:KongregateIQExtension = new KongregateIQExtension(_local2.getNode()); _local3.opcode = _arg1.getOpcode(); _local3.params = _arg1.getParams(); _local2.addExtension(_local3); mConnection.send(_local2); } public function disconnect():void{ Log.info("Disconnecting from Jabber server"); mConnection.disconnect(); } public function set user(_arg1:User):void{ mUser = _arg1; mConnection.username = _arg1.username; mConnection.password = _arg1.password; } public function get banned():Boolean{ return (mBanned); } public function get conferenceServer():String{ return (("conference." + mConnection.server)); } private function onIncomingMessage(_arg1:MessageEvent):void{ var _local3:String; var _local4:String; var _local5:int; if (_arg1.data.type != Message.NORMAL_TYPE){ return; }; var _local2:Message = Message.fromBase64(_arg1.data.body); if (_local2 != null){ _local3 = _arg1.data.from.node.toLowerCase(); _local4 = _local2.getParam(Opcode.PARAM_FROM).toLowerCase(); _local5 = _local2.getParam(Opcode.PARAM_GAME_ID); if (((!((_local4 == _local3))) || (!((_local5 == mGameApiService.gameId))))){ Log.warn((_local3 + " sent us a peer message that failed validation")); return; }; if (_local2.getOpcode() != null){ dispatchEvent(new PeerMessageEvent(_local2)); }; }; } private function onConnection(_arg1:ConnectionSuccessEvent):void{ mConnecting = false; if (isSocket){ mEverConnectedWithSocket = true; mSocketConnectionAttemptCount = 0; }; Log.info((((((("Connected to server (" + connectionType) + ")[") + mConnection.serverAddress) + "/") + mConnection.server) + "]")); var _local2:JabberEvent = new JabberEvent(JabberEvent.CONNECT, {success:true}); dispatchEvent(_local2); } public function joinRoom(_arg1:String, _arg2:String=null, _arg3:String=null):void{ Log.info(((("Join room request[" + _arg1) + "] xmppName=") + _arg2)); var _local4:Boolean = (((_arg2 == null)) || ((_arg2.length == 0))); if ((((_arg1 == JabberChatRoom.TYPE_GAME)) && (_local4))){ Log.info("Game room join request received with no roomID, requesting one from server"); requestJoinGameRoom(); return; }; if (_local4){ Log.error((("Tried to join room (type: " + _arg1) + ") with blank xmpp name")); return; }; leaveRoom(_arg1); var _local5 = "seconds"; var _local6 = 60; var _local7:JabberChatRoom = new JabberChatRoom(this, _arg1, _arg2, _arg3, _local6, _local5); mRooms[_arg1] = _local7; _local7.join(); } public function switchUser(_arg1:User):void{ Log.debug((((("Switching user from " + user.username) + " to ") + _arg1.username) + ".")); disconnect(); user = _arg1; connect(); } public function set gameApi(_arg1:GameAPIService):void{ mGameApiService = _arg1; } private function initializeConnectionEventHandlers():void{ mConnection.addEventListener(ConnectionSuccessEvent.CONNECT_SUCCESS, onConnection); mConnection.addEventListener(XIFFErrorEvent.XIFF_ERROR, onXiffError); mConnection.addEventListener(DisconnectionEvent.DISCONNECT, onDisconnection); mConnection.addEventListener(LoginEvent.LOGIN, onLogin); mConnection.addEventListener(KongregateIQExtension.NS, onKongregateIQ); mConnection.addEventListener(IncomingDataEvent.INCOMING_DATA, onIncomingData); mConnection.addEventListener(OutgoingDataEvent.OUTGOING_DATA, onOutgoingData); mConnection.addEventListener(MessageEvent.MESSAGE, onIncomingMessage); this.addEventListener(MessageEvent.RECEIVED_KONG_IQ, onServerMessage); } private function get boshEnabled():Boolean{ return ((((((mOptions.enable_bosh == true)) || ((mOptions.enable_bosh == "true")))) && (!(mEverConnectedWithSocket)))); } public function leaveRoom(_arg1:String):void{ var _local2:JabberChatRoom = getRoom(_arg1); if (_local2 != null){ _local2.leave(); mRooms[_arg1] = null; }; } private function onOutgoingData(_arg1:OutgoingDataEvent):void{ mLastPacketSent = getTimer(); } private function onServerMessage(_arg1:MessageEvent):void{ var _local2:Message; var _local3:String; var _local4:String; var _local5:Object; var _local6:JabberEvent; var _local7:JabberEvent; var _local8:JabberChatRoom; _local2 = _arg1.msg; if (!_local2){ return; }; switch (_local2.getOpcode()){ case Opcode.OP_SILENCED: dispatchEvent(new JabberEvent(JabberEvent.SILENCED, _local2.getParams())); break; case Opcode.OP_PARTICIPATE: dispatchEvent(new JabberEvent(JabberEvent.PARTICIPATE, _local2.getParams())); break; case Opcode.OP_PRIVATE_MESSAGE: if (_local2.getParam(Opcode.PARAM_SUCCESS)){ _local6 = new JabberEvent(JabberEvent.PRIVATE_MESSAGE, {success:true, from:_local2.getParam(Opcode.PARAM_FROM), message:_local2.getParam(Opcode.PARAM_DATA)}); dispatchEvent(_local6); } else { _local7 = new JabberEvent(JabberEvent.PRIVATE_MESSAGE, {success:false, to:_local2.getParam(Opcode.PARAM_TO), from:_local2.getParam(Opcode.PARAM_FROM), message:_local2.getParam(Opcode.PARAM_DATA)}); dispatchEvent(_local7); }; break; case Opcode.OP_REQUEST_GAME_ROOM: _local3 = _local2.getParam(Opcode.PARAM_ROOM_NAME); _local4 = _local2.getParam(Opcode.PARAM_ROOM_NATURAL_NAME); Log.info(((("Game room response received: " + _local3) + ", name=") + _local4)); joinRoom(JabberChatRoom.TYPE_GAME, _local3, _local4); break; case Opcode.OP_STATUS_UPDATE: _local5 = _local2.getParams(); user.mergeVariables(_local5); for each (_local8 in mRooms) { _local8.status = user.getCompressedVariables(); }; break; case Opcode.OP_ADMIN_MESSAGE: dispatchEvent(new JabberEvent(JabberEvent.ADMIN_MESSAGE, _local2.getParams())); break; default: dispatchEvent(new MessageEvent(MessageEvent.RECEIVED_KONG_ADMIN_IQ, _local2)); break; }; } public function get connectionType():String{ return ((isBosh) ? "BOSH" : (compressionEnabled) ? "cmp.socket" : "socket"); } private function removeConnectionEventHandlers():void{ if (mConnection){ mConnection.removeEventListener(ConnectionSuccessEvent.CONNECT_SUCCESS, onConnection); mConnection.removeEventListener(XIFFErrorEvent.XIFF_ERROR, onXiffError); mConnection.removeEventListener(DisconnectionEvent.DISCONNECT, onDisconnection); mConnection.removeEventListener(LoginEvent.LOGIN, onLogin); mConnection.removeEventListener(IncomingDataEvent.INCOMING_DATA, onIncomingData); mConnection.removeEventListener(OutgoingDataEvent.OUTGOING_DATA, onOutgoingData); mConnection.removeEventListener(MessageEvent.MESSAGE, onIncomingMessage); }; this.removeEventListener(MessageEvent.RECEIVED_KONG_IQ, onServerMessage); } private function onKongregateIQ(_arg1:IQEvent):void{ var _local3:KongregateIQExtension; var _local4:Message; var _local5:MessageEvent; var _local2:String = _arg1.iq.from.node.toLowerCase(); if ((((_local2 == "admin")) || ((_local2.indexOf("kong_") == 0)))){ _local3 = (_arg1.data as KongregateIQExtension); _local4 = Message.fromOpcode(_local3.opcode); _local4.setParams(_local3.params); Log.debug(((("Kongregate Packet[" + _local2) + "] ") + _local4.toString())); _local5 = new MessageEvent(MessageEvent.RECEIVED_KONG_IQ, _local4); dispatchEvent(_local5); }; } public function get user():User{ return (mUser); } public function get isSocket():Boolean{ return (!(isBosh)); } private function onDisconnection(_arg1:DisconnectionEvent):void{ var _local2:String; var _local3:JabberEvent; var _local4:JabberChatRoom; mConnecting = false; for (_local2 in mRooms) { _local4 = mRooms[_local2]; _local4.leave(); }; Log.info("Disconnected from server"); _local3 = new JabberEvent(JabberEvent.DISCONNECT, {conflict:sessionConflict, login_failed:loginFailed, banned:banned}); dispatchEvent(_local3); } private function postInitializeConnection():void{ if (user){ mConnection.username = user.username; mConnection.password = user.password; }; initializeConnectionEventHandlers(); } private function onConnectionMonitorTimer(_arg1:TimerEvent):void{ var now:int; var msg:Message; var e = _arg1; try { if (mConnection.isActive()){ now = getTimer(); if ((now - mLastPacketReceived) >= CONNECTION_TIMEOUT){ Log.info("Time of last packet received is outside threshold, closing connection"); mConnection.disconnect(); } else { if (((!(isBosh)) && (((now - mLastPacketSent) >= CONNECTION_MONITOR_INTERVAL)))){ if ((now - mLastPacketReceived) >= CONNECTION_MONITOR_INTERVAL){ msg = Message.fromOpcode(Opcode.OP_PING); msg.addParam(Opcode.PARAM_TIME, now); sendKongregateMessage(msg); } else { mConnection.sendKeepAlive(); }; }; }; } else { if (shouldReconnect){ Log.info("Auto-reconnecting"); connect(); }; }; } catch(e:Error) { Log.info(((("Error in connection monitor (" + e.toString()) + ", shouldReconnect=") + shouldReconnect)); if (shouldReconnect){ Log.info("Auto-reconnecting"); disconnect(); connect(); }; }; } public function get connection():XMPPConnection{ return (mConnection); } public function sendKongregateMessageToPlayer(_arg1:Message, _arg2:String):void{ var _local3:String = _arg1.toBase64(); var _local4:JID = new JID(((_arg2.toLowerCase() + "@") + mConnection.server)); var _local5:Message = new Message(_local4, null, _local3, null, Message.NORMAL_TYPE, null); mConnection.send(_local5); } private function initializeSocketConnection():void{ removeConnectionEventHandlers(); mConnection = (compressionEnabled) ? new XMPPSocketConnection(true) : new XMPPConnection(); mConnection.server = mOptions.host; mConnection.serverAddress = mOptions.ip; if (mOptions.port){ mConnection.port = mOptions.port; } else { mConnection.port = 5222; }; mConnectionMonitorTimer.addEventListener(TimerEvent.TIMER, onConnectionMonitorTimer); var _local1:String = ((("xmlsocket://" + mConnection.serverAddress) + ":") + mConnection.port); Log.info(("Loading cross-domain policy from " + _local1)); Security.loadPolicyFile(_local1); postInitializeConnection(); } public function get shouldReconnect():Boolean{ return (((((((((!(connection.isActive())) && (!(mConnecting)))) && (!(sessionConflict)))) && (!(banned)))) && (!(loginFailed)))); } private function requestJoinGameRoom():void{ var _local1:Message = Message.fromOpcode(Opcode.OP_REQUEST_GAME_ROOM); _local1.addParam(Opcode.PARAM_GAME_ID, mGameApiService.gameId); _local1.addParam(Opcode.PARAM_GAME_NAME, mGameApiService.gameTitle); _local1.addParam(Opcode.PARAM_PERMALINK, mGameApiService.gamePermalink); sendKongregateMessage(_local1); } public function getRoom(_arg1:String):JabberChatRoom{ return (mRooms[_arg1]); } public function connect():void{ if (((!(mConnecting)) && (!(mConnection.isActive())))){ initializeConnection(); Log.info((("Initializing connection (" + connectionType) + ")")); mConnectionMonitorTimer.start(); mConnecting = true; mSessionConflict = false; mLoginFailed = false; mConnection.connect(xiffConnectionType); dispatchEvent(new JabberEvent(JabberEvent.CONNECTION_ATTEMPT, {})); }; } private function onLogin(_arg1:LoginEvent):void{ var _local3:String; var _local4:Object; var _local5:JabberEvent; var _local6:JabberChatRoom; Log.info(("Logged in successfully as " + mConnection.username)); mPresence = Presence.SHOW_CHAT; var _local2:Presence = new Presence(null, null, null, mPresence, null, 5); mConnection.send(_local2); for (_local3 in mRooms) { _local6 = mRooms[_local3]; _local6.join(); }; _local4 = {username:mConnection.username, success:true, bosh:isBosh}; _local5 = new JabberEvent(JabberEvent.LOGIN, _local4); dispatchEvent(_local5); } private function onIncomingData(_arg1:IncomingDataEvent):void{ mLastPacketReceived = getTimer(); } private function initializeBOSHConnection():void{ removeConnectionEventHandlers(); var _local1:XMPPBOSHConnection = new XMPPBOSHConnection(); _local1.server = mOptions.host; _local1.serverAddress = mOptions.bosh_host; _local1.port = mOptions.bosh_port; _local1.secure = false; _local1.useSasl = false; mConnection = _local1; postInitializeConnection(); } public function sendPrivateMessage(_arg1:String, _arg2:String):void{ _arg2 = validateMessage(_arg2); if (null == _arg2){ return; }; var _local3:Message = Message.fromOpcode(Opcode.OP_PRIVATE_MESSAGE); _local3.addParam(Opcode.PARAM_FROM, mConnection.username); _local3.addParam(Opcode.PARAM_TO, _arg1); _local3.addParam(Opcode.PARAM_DATA, _arg2); sendKongregateMessage(_local3); } private function onXiffError(_arg1:XIFFErrorEvent):void{ var _local3:JabberEvent; var _local2:String = ((((("XMPP error (" + _arg1.errorCode) + "/") + _arg1.errorType) + "): ") + _arg1.errorCondition); mLastError = _local2; Log.warn(_local2); if (mConnecting){ mConnecting = false; if (!mConnection.isActive()){ if (((boshEnabled) && (isSocket))){ Log.info((("Socket connection failed (Attempt #" + mSocketConnectionAttemptCount) + ")")); if (mSocketConnectionAttemptCount >= SOCKET_ATTEMPTS_BEFORE_BOSH){ Log.info("Socket failed too many times, switching to BOSH"); connect(); }; return; }; Log.error("Error during connection, broadcasting failed connection event"); _local3 = new JabberEvent(JabberEvent.CONNECT, {success:false}); dispatchEvent(_local3); }; } else { if (!mConnection.isLoggedIn()){ Log.error((("Error during authentication (" + mConnection.username) + "), disconnecting with login_failed")); mLoginFailed = true; disconnect(); } else { if (_arg1.errorMessage == "conflict"){ Log.info("Session conflict detected"); mSessionConflict = true; } else { if ((((_arg1.errorCode == 502)) && ((_arg1.errorMessage == "policy-violation")))){ Log.info("Disconnection from ban detected."); mBanned = true; }; }; }; }; } public function destroy():void{ if ((this is BufferedEventDispatcher)){ var _local1 = this; _local1["shutdown"](); }; removeEventHandlers(); disconnect(); } public function setPresence(_arg1:String):void{ var _local2:int = getTimer(); if ((_local2 - mLastSetPresence) < SET_PRESENCE_INTERVAL){ return; }; if (mPresence == _arg1){ return; }; mPresence = _arg1; mLastSetPresence = _local2; Log.info(("Changing user presence to " + mPresence)); var _local3:Message = Message.fromOpcode(Opcode.OP_SET_PRESENCE); _local3.addParam(Opcode.PARAM_FROM, mConnection.username); _local3.addParam(Opcode.PARAM_PRESENCE, _arg1); sendKongregateMessage(_local3); } private function removeEventHandlers():void{ var _local1:String; removeConnectionEventHandlers(); if (mConnectionMonitorTimer){ mConnectionMonitorTimer.removeEventListener(TimerEvent.TIMER, onConnectionMonitorTimer); mConnectionMonitorTimer.stop(); }; if (mGameApiService){ gameApi = null; }; for (_local1 in mRooms) { if (mRooms[_local1]){ mRooms[_local1].destroy(); }; }; } private static function staticInit():Boolean{ KongregateIQExtension.enable(); return (true); } } }//package com.kongregate.as3.chat
Section 31
//KongregateIQExtension (com.kongregate.as3.chat.KongregateIQExtension) package com.kongregate.as3.chat { import flash.xml.*; import org.jivesoftware.xiff.data.*; import com.kongregate.as3.common.util.*; import com.adobe.serialization.json.*; public class KongregateIQExtension extends Extension implements IExtension, ISerializable { private var mMessage:XMLNode; private var mOpcode:String; private var mParams:Object; public static var ELEMENT:String = "query"; public static var NS:String = "kongregate:iq:msg"; public function KongregateIQExtension(_arg1:XMLNode=null){ super(_arg1); mParams = null; mOpcode = null; mMessage = null; } public function serialize(_arg1:XMLNode):Boolean{ mMessage = replaceTextNode(getNode(), mMessage, "msg", Base64.encode(JSON.encode(mParams))); mMessage.attributes["opcode"] = mOpcode; if (!exists(getNode().parentNode)){ _arg1.appendChild(getNode().cloneNode(true)); }; return (true); } public function getNS():String{ return (KongregateIQExtension.NS); } public function set params(_arg1:Object):void{ mParams = _arg1; } public function get params():Object{ return (mParams); } public function getElementName():String{ return (KongregateIQExtension.ELEMENT); } public function get opcode():String{ return (mOpcode); } public function set opcode(_arg1:String):void{ mOpcode = _arg1; } public function deserialize(_arg1:XMLNode):Boolean{ var children:Array; var i:int; var newlines:RegExp; var base64:String; var node = _arg1; setNode(node); children = node.childNodes; i = 0; while (i < children.length) { switch (children[i].nodeName){ case "msg": mOpcode = children[i].attributes.opcode; newlines = /\n/g; base64 = children[i].firstChild.nodeValue.replace(newlines, ""); try { mParams = JSON.decode(Base64.decode(base64)); } catch(e:Error) { mParams = {}; Log.error(((("Error deserializing kongregate IQ: (" + e.toString()) + ")") + base64)); }; break; }; i = (i + 1); }; return (true); } public static function enable():void{ ExtensionClassRegistry.register(KongregateIQExtension); } } }//package com.kongregate.as3.chat
Section 32
//SpamService (com.kongregate.as3.chat.SpamService) package com.kongregate.as3.chat { import com.kongregate.as3.common.events.*; import flash.events.*; import com.kongregate.as3.common.util.*; import flash.utils.*; public class SpamService { private var mLastToggledAt:Array; private var mNumTogglers:int; private var mPort:String; private var mUserList:Array; private var mToggleTimer:Timer; private var mConnections:Object; private var mIp:String; private var mHost:String; private var mRoomInfo:Array; public function SpamService(_arg1:Object){ mConnections = {}; mIp = _arg1.ip; mHost = _arg1.host; mPort = _arg1.port; } private function onLogin(_arg1:JabberEvent):void{ var _local2:String = _arg1.data.username; var _local3:JabberConnection = mConnections[_local2]; if (_local3 == null){ return; }; _local3.joinRoom(mRoomInfo[0], mRoomInfo[1], mRoomInfo[2]); } public function spamToggles(_arg1:Object):void{ var _local2:int = (_arg1.interval) ? _arg1.interval : 500; mNumTogglers = (_arg1.numToggle) ? _arg1.numToggle : 5; mLastToggledAt = []; if (mToggleTimer){ mToggleTimer.stop(); mToggleTimer.removeEventListener(TimerEvent.TIMER, onToggleTimer); mToggleTimer = null; }; Log.warn("starting timer"); mToggleTimer = new Timer(_local2); mToggleTimer.addEventListener(TimerEvent.TIMER, onToggleTimer, false, 0, true); mToggleTimer.start(); } private function toggleRandomUser():void{ var _local1:int = Math.floor((Math.random() * mUserList.length)); if (((mLastToggledAt[_local1]) && (((getTimer() - mLastToggledAt[_local1]) < 2000)))){ return; }; var _local2:JabberConnection = mConnections[mUserList[_local1]]; if (_local2.getRoom("chat")){ Log.warn((("user " + mUserList[_local1]) + " leaving the room")); _local2.leaveRoom("chat"); } else { Log.warn((("user " + mUserList[_local1]) + " joining the room")); _local2.joinRoom(mRoomInfo[0], mRoomInfo[1], mRoomInfo[2]); }; mLastToggledAt[_local1] = getTimer(); } public function spamRoomJoins(_arg1:Object):void{ var _local2:Array; var _local3:Timer; var _local4:JabberConnection; var _local5:Array; mUserList = []; for each (_local2 in _arg1.users) { mUserList.push(_local2[0]); _local4 = new JabberConnection({ip:mIp, host:mHost, port:mPort}); _local4.addEventListener(JabberEvent.LOGIN, onLogin); _local5 = [_local2[2].user_vars_sig, _local2[2].user_vars]; _local4.user = new User(_local2[0], _local2[1], _local5); mConnections[_local2[0]] = _local4; }; Log.warn("starting spam connect timer!"); _local3 = new Timer(250, mUserList.length); _local3.addEventListener(TimerEvent.TIMER, onConnectTimer); _local3.start(); } public function setRoomInfo(_arg1:String, _arg2:String, _arg3:String):void{ mRoomInfo = [_arg1, _arg2, _arg3]; } private function onToggleTimer(_arg1:TimerEvent):void{ var _local2:int; Log.warn("on toggle timer"); while (_local2 < mNumTogglers) { toggleRandomUser(); _local2++; }; } private function onConnectTimer(_arg1:TimerEvent):void{ var _local2:int = (_arg1.target.currentCount - 1); Log.warn(("currentCount - " + _local2)); mConnections[mUserList[_local2]].connect(); } } }//package com.kongregate.as3.chat
Section 33
//User (com.kongregate.as3.chat.User) package com.kongregate.as3.chat { import com.kongregate.as3.common.util.*; import flash.utils.*; import com.adobe.serialization.json.*; import com.kongregate.as3.security.*; public class User { private var mUsername:String; private var mPassword:String; private var mVariables:Object; private var mSignedVariables:Array; public static const VALID_KEYS:Array = ["username", "type", "level", "chat_avatar_url", "game_title", "game_url"]; private static const GUEST_PREFIX:String = "guest"; public static const KEY_MAP:Object = {username:0, type:1, level:2, chat_avatar_url:3, game_title:4, game_url:5}; public function User(_arg1:String, _arg2:String=null, _arg3:Array=null){ mUsername = _arg1; mPassword = (("{'k':'" + _arg2) + "'}"); if (((!(isGuest())) && (!((_arg3 == null))))){ mSignedVariables = _arg3; parseSignedVariables(_arg3); } else { mVariables = {}; }; } public function getCompressedVariables():String{ return (this.compressedVariables); } public function get signedVariables():Array{ return (mSignedVariables); } function get compressedVariables():String{ var _local1:ByteArray = new ByteArray(); _local1.writeObject(mSignedVariables); _local1.compress(); return (Base64.encodeByteArray(_local1)); } public function isGuest():Boolean{ return ((0 == username.toLowerCase().indexOf(GUEST_PREFIX))); } private function processRemoteVariables():void{ var _local5:Array; var _local6:String; var _local7:String; var _local1:RegExp = /^http:/; var _local2:RegExp = /^\/games/; var _local3:String = variables.game_url; var _local4:String = variables.chat_avatar_url; if (((!(_local3.match(_local1))) && (!(_local3.match(_local2))))){ _local3 = ("/games" + _local3); }; if (((!(_local4.match(_local1))) && (_local4.match(/:/)))){ _local5 = _local4.split(":"); if (((!(_local5)) || ((_local5.length < 2)))){ throw (new Error(("Invalid short-form avatar url: " + _local4))); }; _local6 = _local5[0]; _local7 = _local5[1]; _local4 = (((("http://" + _local6) + ".") + Configuration.getConfigValue("base_domain")) + _local7); }; variables.chat_avatar_url = encodeURI(_local4); variables.game_url = encodeURI(_local3); } private function parseSignedVariables(_arg1:Array):void{ var keyName:String; var sig:*; var json:String; var unsignedVars:Object; var variables:Array; var userType:String; var signedVariables = _arg1; mVariables = {}; if (isGuest()){ return; }; try { if ((signedVariables[0] is String)){ signedVariables[0] = Base64.decodeToByteArray(signedVariables[0]); }; if (signedVariables.length > 2){ unsignedVars = signedVariables[2]; for (keyName in unsignedVars) { if (!mVariables[keyName]){ mVariables[keyName] = unsignedVars[keyName]; }; }; }; sig = signedVariables[0]; json = signedVariables[1]; if (EncryptionUtils.verifyRSASignature(json, sig)){ variables = JSON.decode(json); if (variables[KEY_MAP.username] == username){ for (keyName in KEY_MAP) { mVariables[keyName] = variables[KEY_MAP[keyName]]; }; userType = (variables[KEY_MAP.type]) ? variables[KEY_MAP.type] : ""; mVariables.developer = (userType.indexOf("d") >= 0); mVariables.admin = (userType.indexOf("a") >= 0); mVariables.moderator = (userType.indexOf("m") >= 0); mVariables.curator = (userType.indexOf("c") >= 0); return; }; Log.error(((("parseSignedVariables: expected username " + username) + ", but got ") + variables[username])); }; } catch(e:Error) { Log.error(("parseSignedVariables: " + e.toString())); }; Log.error(("Failed to parse signed user vars: " + JSON.encode(signedVariables))); mVariables = {}; } public function parseCompressedVariables(_arg1:String):void{ var byteArray:ByteArray; var signedVariables:Array; var compressedVars = _arg1; mVariables = new Object(); if (compressedVars != null){ try { byteArray = Base64.decodeToByteArray(compressedVars); byteArray.uncompress(); signedVariables = byteArray.readObject(); parseSignedVariables(signedVariables); } catch(e:Error) { Log.error(((("Error while decompressing variables: " + compressedVars) + ", ") + e.toString())); mVariables = {}; }; }; } public function set variables(_arg1:Object):void{ mVariables = _arg1; } public function get username():String{ return (mUsername); } public function get variables():Object{ return (mVariables); } function get password():String{ return (mPassword); } public function validateUserVariables(_arg1:Boolean=true):Boolean{ var chatAvatarUrl:String; var gameUrl:String; var tagExp:RegExp; var quoteOrSpaceExp:RegExp; var remote = _arg1; if (isGuest()){ return (true); }; if (username != variables.username){ return (false); }; if (((!((variables.level is Number))) || ((variables.level <= 0)))){ return (false); }; try { chatAvatarUrl = variables.chat_avatar_url; gameUrl = variables.game_url; tagExp = /\<.+?\>/; if (((((chatAvatarUrl.match(tagExp)) || (gameUrl.match(tagExp)))) || (variables.game_title.match(tagExp)))){ return (false); }; quoteOrSpaceExp = /['" ]+/; if (((chatAvatarUrl.match(quoteOrSpaceExp)) || (gameUrl.match(quoteOrSpaceExp)))){ return (false); }; if (remote){ processRemoteVariables(); }; return (true); } catch(e:Error) { Log.error(("Error while validating user variables: " + e.toString())); }; return (false); } public function mergeVariables(_arg1:Object):void{ var _local2:String; if (mSignedVariables.length <= 2){ mSignedVariables.push({}); }; for (_local2 in _arg1) { if (VALID_KEYS.indexOf(_local2) < 0){ mSignedVariables[2][_local2] = _arg1[_local2]; }; }; parseSignedVariables(mSignedVariables); } public static function isValidUsername(_arg1:String):Boolean{ return ((_arg1.search(/^[^_]\w*$/) >= 0)); } } }//package com.kongregate.as3.chat
Section 34
//ExternalMessageDispatcher (com.kongregate.as3.common.comm.external.ExternalMessageDispatcher) package com.kongregate.as3.common.comm.external { import com.kongregate.as3.common.comm.*; import com.kongregate.as3.common.util.*; import flash.external.*; public class ExternalMessageDispatcher implements IMessageHandler { private var mListeners:Array; private static var mInstance:ExternalMessageDispatcher; public function ExternalMessageDispatcher(){ mListeners = new Array(); super(); } public function addListener(_arg1:Function):void{ mListeners.push(_arg1); } public function handleExternalMessage(_arg1:Object):void{ var _local2:String = _arg1.type; var _local3:Object = _arg1.data; var _local4:Message = Message.fromOpcode(_local2); _local4.setParams(_local3); broadcastMessage(_local4); } public function addCallbacks():void{ try { ExternalInterface.addCallback("dispatchEvent", handleExternalMessage); } catch(e:Error) { Log.info(("Error while trying to add callback: " + e.toString())); }; } private function broadcastMessage(_arg1:Message):void{ Log.debug(("External message received: " + _arg1.toString())); var _local2:Number = 0; while (_local2 < mListeners.length) { var _local3 = mListeners; _local3[_local2](_arg1); _local2++; }; } public function handleMessage(_arg1:Message):void{ var _local2:Message; if (_arg1.getOpcode() == Opcode.OP_EXTERNAL_MESSAGE){ _local2 = Message.fromOpcode(_arg1.getParam(Opcode.PARAM_OPCODE)); _local2.setParams(_arg1.getParam(Opcode.PARAM_DATA)); broadcastMessage(_local2); }; } public static function getInstance():ExternalMessageDispatcher{ if (!mInstance){ mInstance = new (ExternalMessageDispatcher); }; return (mInstance); } } }//package com.kongregate.as3.common.comm.external
Section 35
//MessageConnection (com.kongregate.as3.common.comm.local.MessageConnection) package com.kongregate.as3.common.comm.local { import com.kongregate.as3.common.events.*; import flash.events.*; import com.kongregate.as3.common.comm.*; import com.kongregate.as3.common.util.*; import flash.utils.*; import flash.net.*; import flash.external.*; public class MessageConnection extends EventDispatcher { private var mChannelName:String;// = "" private var mErrorReported:Boolean;// = false private var mConnectionAttempts:Number;// = 0 private var mPendingPackets:Array; private var mIsClient:Boolean;// = false private var mConnected:Boolean;// = false private var mReceivedMessageParts:Object; private var mSending:Boolean;// = false private var mSendChannel:String;// = "" private var mSequenceNumber:uint;// = 0 private var mReportSent:Boolean;// = false private var mBroken:Boolean;// = false private var mAttemptingConnection:Boolean;// = false private var mConnectionTimer:Timer; private var mPacketDeliveryTimer:Timer; private var mConnectionTestTimer:Timer; private var mReceiveChannel:String;// = "" private var mClientCapabilities:uint;// = 0 private var mLocalConnection:LocalConnection; private static const SERVICE_CHAT:String = "Chat"; private static const CONNECT_RETRY_COUNT:Number = 0; private static const FULL_RECEIVE_FUNCTION:String = "handleMessage"; private static const SERVICE_GAME:String = "Game"; private static const LC_BYTE_LIMIT:uint = 39000; private static const CHANNEL_PREFIX:String = "_"; public static const MY_CAPABILITIES:uint = 1; private static const CONNECT_RETRY_INTERVAL:Number = 3500; private static const PARTIAL_RECEIVE_FUNCTION:String = "handleMessagePart"; public static const SERVICE_NAME:String = "KongregateService"; public static const PARTIAL_MESSAGES:uint = 1; private static const SERVICE_STRING:String = "Service"; public static const CLIENT_NAME:String = "KongregateClient"; public function MessageConnection(_arg1:Boolean, _arg2:String, _arg3:Boolean=true){ mConnectionTestTimer = new Timer(5000, 0); mPacketDeliveryTimer = new Timer(100, 0); mReceivedMessageParts = {}; mPendingPackets = []; super(); createLocalConnection(); mIsClient = _arg1; mChannelName = _arg2; mSendChannel = (((CHANNEL_PREFIX + (isClient()) ? SERVICE_NAME : CLIENT_NAME) + "_") + mChannelName); mConnectionTimer = new Timer(CONNECT_RETRY_INTERVAL, CONNECT_RETRY_COUNT); mConnectionTimer.addEventListener(TimerEvent.TIMER, retryConnection); mConnectionTestTimer.addEventListener(TimerEvent.TIMER, testConnection); mPacketDeliveryTimer.addEventListener(TimerEvent.TIMER, packetDeliverer); if (_arg3){ startListening(); }; } public function isConnected():Boolean{ return (mConnected); } private function onSecurityError(_arg1:SecurityErrorEvent):void{ Log.error(("MessageConnection SecurityError: " + _arg1.toString())); } private function sendMessagePart(_arg1:uint, _arg2:uint, _arg3:ByteArray):Boolean{ var messageNumber = _arg1; var totalBytes = _arg2; var part = _arg3; try { Log.debug(((((("sending message part # - " + messageNumber) + ", totalBytes ") + totalBytes) + ", cursize ") + part.length)); sendPacket([messageNumber, totalBytes, part]); return (true); } catch(e:Error) { Log.error(("MessageConnection error: " + e.toString())); Log.error(e); }; return (false); } private function getSendNickname():String{ return (((mSendChannel.indexOf(SERVICE_STRING) >= 0)) ? SERVICE_CHAT : SERVICE_GAME); } private function createLocalConnection(_arg1:Boolean=false):void{ var domain:String; var prefix:String; var theDomain:String; var listen = _arg1; if (mLocalConnection){ try { mLocalConnection.close(); } catch(e:Error) { }; mLocalConnection.removeEventListener(StatusEvent.STATUS, onStatus); mLocalConnection.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError); mLocalConnection.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); mLocalConnection = null; }; mLocalConnection = new LocalConnection(); mLocalConnection.client = this; mLocalConnection.addEventListener(StatusEvent.STATUS, onStatus); mLocalConnection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError); mLocalConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); for each (domain in Utils.ALLOWED_DOMAINS) { mLocalConnection.allowDomain(domain); mLocalConnection.allowInsecureDomain(domain); for each (prefix in Utils.ALLOWED_PREFIXES) { theDomain = ((prefix + ".") + domain); mLocalConnection.allowDomain(theDomain); mLocalConnection.allowInsecureDomain(theDomain); }; }; mLocalConnection.allowDomain(mLocalConnection.domain); mLocalConnection.allowInsecureDomain(mLocalConnection.domain); if (listen){ startListening(); }; } private function testConnection(_arg1:TimerEvent):void{ var _local2:Message = Message.fromOpcode(Opcode.OP_PING); if (((isConnected()) && (!(mSending)))){ if (mBroken){ sendPacket([_local2.getOpcode(), _local2.getParams()], false); } else { sendMessage(_local2); }; }; } public function isServer():Boolean{ return (!(isClient())); } public function isClient():Boolean{ return (mIsClient); } private function refreshConnection():void{ if (isConnected()){ try { mLocalConnection.close(); } catch(e:Error) { Log.error((("Close failed: " + e.toString()) + " -> Opening another connection.")); if (((!(isClient())) && (!(mErrorReported)))){ try { mErrorReported = true; Log.info("Creating event for failed LocalConnection"); ExternalInterface.call("holodeck.recordAnalyticsEvent", "Game", "LocalConnectionError"); } catch(e:Error) { }; }; }; try { mLocalConnection.connect(mReceiveChannel); } catch(e:Error) { Log.error("Couldn't create LocalConnection, connection already exists"); }; }; } private function retryConnection(_arg1:TimerEvent=null):void{ if (((mAttemptingConnection) && (!(mConnected)))){ mConnectionAttempts++; sendConnectionRequest(); }; } private function onAsyncError(_arg1:AsyncErrorEvent):void{ Log.error(("MessageConnection AsyncError: " + _arg1.error.toString())); Log.error(_arg1.error); } private function sendConnectionRequest():void{ Log.debug((("Attempting connection (Retry #" + mConnectionAttempts) + ")")); var _local1:Message = Message.fromOpcode(Opcode.OP_CONNECT); _local1.addParam(Opcode.PARAM_CHANNEL, mReceiveChannel); _local1.addParam(Opcode.PARAM_CAPABILITIES, MY_CAPABILITIES); sendMessage(_local1); } private function onStatus(_arg1:StatusEvent):void{ mSending = false; switch (_arg1.level){ case "error": if (((isConnected()) && (!(mBroken)))){ mBroken = true; Log.warn("LocalConnection is broken, will attempt to reconnect"); }; break; case "status": if (mBroken){ mBroken = false; Log.info("Connection restored"); } else { if (((isConnected()) && ((mPendingPackets.length > 0)))){ mPendingPackets.shift(); }; }; break; }; } private function getReceiveNickname():String{ return (((mReceiveChannel.indexOf(SERVICE_STRING) >= 0)) ? SERVICE_CHAT : SERVICE_GAME); } public function handleMessage(_arg1:Object):void{ var _local2:MessageEvent; var _local3:Boolean; var _local5:String; var _local4:Message = new Message(); _local4.setOpcode(_arg1.opcode); _local4.setParams(_arg1.params); if (Log.isDebug()){ _local5 = dumpMessage(_local4); if (((_local5) && ((_local5.length > 0)))){ Log.debug(((((("[" + getSendNickname()) + "->") + getReceiveNickname()) + "]: ") + _local5)); } else { if (_local4.getOpcode() != Opcode.OP_PING){ Log.debug(((((("[" + getSendNickname()) + "->") + getReceiveNickname()) + "]: ") + _local4.getOpcode())); }; }; }; switch (_local4.getOpcode()){ case Opcode.OP_CONNECT: handleConnect(_local4); break; case Opcode.OP_CONNECTED: Log.info((("MessageConnection established for " + getReceiveNickname()) + "!")); mAttemptingConnection = false; mConnectionTimer.stop(); if (!mConnected){ mConnected = true; _local2 = new MessageEvent(MessageEvent.CONNECT); _local3 = this.dispatchEvent(_local2); mConnectionTestTimer.start(); mPacketDeliveryTimer.start(); }; break; default: _local2 = new MessageEvent(MessageEvent.MESSAGE, _local4); _local3 = this.dispatchEvent(_local2); }; } private function listen(_arg1:String):void{ var channelName = _arg1; Log.info("Listening for connection..."); mReceiveChannel = (CHANNEL_PREFIX + channelName); try { mLocalConnection.connect(mReceiveChannel); Log.debug((("Channel: " + channelName) + ", success=true")); } catch(error:ArgumentError) { Log.error((("Can't connect on channel: " + mReceiveChannel) + ". The connection name is already being used")); Log.error(error); }; } private function sendPacket(_arg1:Array, _arg2:Boolean=true):void{ if (((isConnected()) && (_arg2))){ mPendingPackets.push(_arg1); return; }; if (_arg1.length == 2){ mLocalConnection.send(mSendChannel, FULL_RECEIVE_FUNCTION, {opcode:_arg1[0], params:_arg1[1]}); } else { mLocalConnection.send(mSendChannel, PARTIAL_RECEIVE_FUNCTION, _arg1[0], _arg1[1], _arg1[2]); }; } public function handleConnect(_arg1:Message):void{ var _local2:Message; var _local3:MessageEvent; var _local4:Boolean; Log.info((((getReceiveNickname() + " received connect from ") + getSendNickname()) + "...")); Log.debug(((("isConnected=" + mConnected) + ", attemptingConnection=") + mAttemptingConnection)); if (!mConnected){ mConnected = true; mClientCapabilities = _arg1.getParam(Opcode.PARAM_CAPABILITIES); _local2 = Message.fromOpcode(Opcode.OP_CONNECTED); sendMessage(_local2); _local3 = new MessageEvent(MessageEvent.CONNECT); _local4 = this.dispatchEvent(_local3); mConnectionTestTimer.start(); mPacketDeliveryTimer.start(); }; } public function handleMessagePart(_arg1:uint, _arg2:uint, _arg3:Object):void{ var byteHolder:ByteArray; var object:Object; var messageNumber = _arg1; var totalBytes = _arg2; var part = _arg3; var bytePart:ByteArray = (part as ByteArray); if (!mReceivedMessageParts[messageNumber]){ mReceivedMessageParts[messageNumber] = new ByteArray(); mReceivedMessageParts[messageNumber].length = totalBytes; mReceivedMessageParts[messageNumber].position = 0; }; try { byteHolder = mReceivedMessageParts[messageNumber]; byteHolder.writeBytes(bytePart); Log.debug(((((((("handling message part # - " + messageNumber) + ", totalBytes: ") + totalBytes) + ", partsize: ") + part.length) + ", current: ") + byteHolder.position)); } catch(e:Error) { Log.debug(((((((("failed on part # - " + messageNumber) + ", totalBytes ") + totalBytes) + ", cursize ") + part.length) + ", current: ") + byteHolder.position)); }; if (0 == byteHolder.bytesAvailable){ byteHolder.position = 0; object = byteHolder.readObject(); delete mReceivedMessageParts[messageNumber]; handleMessage(object); }; } public function doConnect():void{ if (((mAttemptingConnection) || (isConnected()))){ return; }; Log.debug("MessageConnection.doConnect()"); mAttemptingConnection = true; mConnectionAttempts = 0; sendConnectionRequest(); if (mConnectionTimer.running){ mConnectionTimer.reset(); }; mConnectionTimer.start(); } public function sendMessage(_arg1:Message):Boolean{ var debugString:String; var byteOffset:uint; var part:ByteArray; var msg = _arg1; if (Log.isDebug()){ debugString = dumpMessage(msg); if (((debugString) && ((debugString.length > 0)))){ Log.debug(((((("[" + getReceiveNickname()) + "->") + getSendNickname()) + "]: ") + debugString)); }; }; var bytes:ByteArray = new ByteArray(); bytes.writeObject({opcode:msg.getOpcode(), params:msg.getParams()}); var bytesLength:uint = bytes.length; if (((usePartialMessages) && ((bytesLength >= LC_BYTE_LIMIT)))){ mSequenceNumber++; byteOffset = 0; while (byteOffset < bytesLength) { part = new ByteArray(); if ((bytesLength - byteOffset) > LC_BYTE_LIMIT){ part.length = LC_BYTE_LIMIT; } else { part.length = (bytesLength - byteOffset); }; part.writeBytes(bytes, byteOffset, part.length); if (!sendMessagePart(mSequenceNumber, bytesLength, part)){ return (false); }; byteOffset = (byteOffset + part.length); }; return (true); } else { try { refreshConnection(); sendPacket([msg.getOpcode(), msg.getParams()]); return (true); } catch(e:Error) { Log.error(("MessageConnection error: " + e.toString())); Log.error(e); }; }; return (false); } private function packetDeliverer(_arg1:TimerEvent):void{ var _local2:Array; if ((((((mPendingPackets.length > 0)) && (!(mSending)))) && (!(mBroken)))){ mSending = true; _local2 = mPendingPackets[0]; sendPacket(_local2, false); }; } private function dumpMessage(_arg1:Message):String{ var fwdMsg:Message; var url:String; var msg = _arg1; var opcode:String = msg.getOpcode(); try { if (msg.getOpcode() == Opcode.OP_FORWARD){ fwdMsg = Message.fromObject(msg.getParam(Opcode.PARAM_DATA)); return (((("<FWD:" + msg.getParam(Opcode.PARAM_USER)) + "> ") + dumpMessage(fwdMsg))); } else { if ((((((((opcode == Opcode.OP_PING)) || ((opcode == Opcode.OP_LOG)))) || ((opcode == Opcode.OP_META_INVALIDATE)))) || ((opcode == Opcode.OP_CHAT_CANVAS_ELEMENT)))){ return (undefined); } else { if (opcode == Opcode.OP_HTTP_REQUEST){ url = msg.getParam(Opcode.PARAM_URL); if (!url){ return ((("<HTTP_RESPONSE, success=" + msg.getParam(Opcode.PARAM_SUCCESS)) + ">")); } else { return ((("<HTTP: " + url) + ">")); }; } else { if (Log.isDebug()){ return (msg.toString()); }; }; }; }; } catch(e:Error) { }; return (opcode); } public function close():void{ mLocalConnection.close(); } public function startListening():void{ listen((((isClient()) ? CLIENT_NAME : SERVICE_NAME + "_") + mChannelName)); } private function get usePartialMessages():Boolean{ return (((isClient()) || ((mClientCapabilities & PARTIAL_MESSAGES)))); } } }//package com.kongregate.as3.common.comm.local
Section 36
//IMessageHandler (com.kongregate.as3.common.comm.IMessageHandler) package com.kongregate.as3.common.comm { public interface IMessageHandler { function handleMessage(_arg1:Message):void; } }//package com.kongregate.as3.common.comm
Section 37
//Message (com.kongregate.as3.common.comm.Message) package com.kongregate.as3.common.comm { import com.kongregate.as3.common.util.*; import com.kongregate.as3.common.error.*; public class Message { private var mParams:Object; private var mOpcode:String; public function Message(){ mOpcode = ""; mParams = new Object(); } public function getOpcode():String{ return (mOpcode); } public function setParams(_arg1:Object):void{ mParams = _arg1; } public function toBase64():String{ return (Base64.encode(JSON.encode({mOpcode:mOpcode, mParams:mParams}))); } public function isSuccessful():Boolean{ return (getParam(Opcode.PARAM_SUCCESS)); } public function addParam(_arg1:String, _arg2):void{ mParams[_arg1] = _arg2; } public function getMessageID():Number{ return (getParam(Opcode.PARAM_MESSAGE_ID)); } public function setOpcode(_arg1:String):void{ mOpcode = _arg1; } public function getError():int{ var _local1:int = getParam(Opcode.PARAM_ERROR); return ((_local1) ? ErrorCode.NONE : _local1); } public function getRequestID():Number{ return (getParam(Opcode.PARAM_REQUEST_ID)); } public function getParam(_arg1:String){ return (mParams[_arg1]); } public function toString():String{ return (((getOpcode() + ": ") + JSON.encode(getParams()))); } public function getParams():Object{ return (mParams); } public static function fromObject(_arg1:Object):Message{ var _local2:Message = Message.fromOpcode(_arg1.mOpcode); _local2.setParams(_arg1.mParams); return (_local2); } public static function fromBase64(_arg1:String):Message{ return (fromString(Base64.decode(_arg1))); } public static function fromString(_arg1:String):Message{ var jsonObject:Object; var msg:Message; var key:String; var text = _arg1; try { jsonObject = JSON.decode(text); msg = Message.fromOpcode(jsonObject.mOpcode); for (key in jsonObject.mParams) { msg.addParam(key, jsonObject.mParams[key]); }; return (msg); } catch(e:Error) { }; return (null); } public static function fromOpcode(_arg1:String):Message{ var _local2:Message = new (Message); _local2.setOpcode(_arg1); return (_local2); } } }//package com.kongregate.as3.common.comm
Section 38
//Opcode (com.kongregate.as3.common.comm.Opcode) package com.kongregate.as3.common.comm { public class Opcode { public static const PARAM_REQUEST_ID:String = "req.id"; public static const PARAM_WAIT:String = "wait"; public static const OP_CONNECTED:String = "connected"; public static const PARAM_RESULTS:String = "results"; public static const PARAM_MESSAGE:String = "message"; public static const PARAM_SUCCESS:String = "success"; public static const PARAM_GAME_TYPE:String = "game_type"; public static const PARAM_ROOM_NAME:String = "room.name"; public static const PARAM_STATE:String = "state"; public static const PARAM_SAVE_GAME:String = "game"; public static const OP_SCORE_SUBMIT:String = "score.submit"; public static const PARAM_SCORE:String = "score"; public static const PARAM_STATS:String = "stats"; public static const PARAM_RESULT:String = "result"; public static const OP_SAVE_SHARED_CONTENT:String = "save_shared_content"; public static const OP_GAME_LOAD:String = "gm.load"; public static const PARAM_SORT:String = "sort_order"; public static const OP_AVATAR_FINISHED:String = "avatar.finished"; public static const PARAM_DATA:String = "data"; public static const PARAM_USER_ID:String = "user_id"; public static const PARAM_SCORE_POSTED:String = "posted"; public static const OP_STATS_PLAYER:String = "stat.player"; public static const OP_GAME_RESTART:String = "game_restart"; public static const OP_FORWARD:String = "fwd"; public static const PARAM_CAPABILITIES:String = "caps"; public static const PARAM_STAT_NAME:String = "stat"; public static const OP_META_JOIN:String = "meta.join"; public static const PARAM_FROM_PLAYER:String = "from.pl"; public static const PARAM_RESEND:String = "resend"; public static const PARAM_REASON:String = "reason"; public static const OP_GAME_SETTING_ON:String = "game_setting_on"; public static const OP_PARTICIPATE:String = "participate"; public static const OP_REQUEST_GAME_ROOM:String = "room.rq"; public static const PARAM_SCORE_MODE:String = "mode"; public static const PARAM_USER:String = "user"; public static const PARAM_CLIENT_VERSION:String = "client.ver"; public static const OP_META_PLAYNOW:String = "meta.playnow"; public static const OP_GAME_PAUSE:String = "game_pause"; public static const PARAM_SCORE_POSITION:String = "pos"; public static const PARAM_STAT_MAX:String = "max"; public static const OP_CONNECT:String = "connect"; public static const OP_SCORE_MODE:String = "score.mode"; public static const PARAM_SAVE_GAMES:String = "games"; public static const OP_GAME_CONTINUE:String = "game_cont"; public static const OP_GAME_LOAD_ALL:String = "gm.load.all"; public static const PARAM_DECKS:String = "decks"; public static const PARAM_PATHS:String = "paths"; public static const PARAM_URL:String = "url"; public static const OP_SILENCED:String = "silenced"; public static const PARAM_FROM:String = "from"; public static const PARAM_SESSION_LOOKUP_KEY:String = "slk"; public static const PARAM_ADMIN_MESSAGE:String = "admin_message"; public static const PARAM_GAME_END:String = "game_end"; public static const PARAM_LABEL:String = "label"; public static const PARAM_PRESENCE:String = "presence"; public static const OP_ALERT_REQUEST:String = "alert.rq"; public static const PARAM_SLOT:String = "slot"; public static const OP_GAME_SETTING_OFF:String = "game_setting_off"; public static const OP_GOODBYE:String = "goodbye"; public static const PARAM_PLAYER_NO:String = "player_no"; public static const PARAM_SESSION_ID:String = "sessionid"; public static const PARAM_JAVASCRIPT:String = "javascript"; public static const OP_STATS_REGISTER:String = "stat.reg"; public static const PARAM_ROOM_NATURAL_NAME:String = "room.natural"; public static const PARAM_SCORE_LOW:String = "lowscore"; public static const OP_PRIVATE_MESSAGE:String = "chat.pm"; public static const PARAM_ID:String = "id"; public static const OP_GAME_MENU:String = "game_menu"; public static const PARAM_GAME_ID:String = "game_id"; public static const PARAM_PHASE_NO:String = "phase_no"; public static const PARAM_ALERT_NAME:String = "alert.name"; public static const PARAM_TASKS_COMPLETED:String = "stats.tc"; public static const OP_GAME_SAVE:String = "gm.save"; public static const PARAM_SAVE_LIST:String = "list"; public static const OP_GAME_START:String = "game_start"; public static const OP_HELLO:String = "hello"; public static const OP_META_EVENT:String = "meta.event"; public static const PARAM_GAME_START:String = "game_start"; public static const OP_META_STATE:String = "meta.state"; public static const PARAM_CONFIRMATION:String = "conf"; public static const PARAM_STATS_PROGRESSED:String = "stats.prgs"; public static const PARAM_OPPONENT:String = "opponent"; public static const OP_CHAT:String = "chat"; public static const OP_ADMIN_MESSAGE:String = "admin_message"; public static const OP_BROWSE_SHARED_CONTENT:String = "browse_shared_content"; public static const PARAM_MESSAGES:String = "msgs"; public static const OP_PING:String = "ping"; public static const PARAM_DESCRIPTION:String = "desc"; public static const OP_META_CREATE:String = "meta.create"; public static const PARAM_NAME:String = "name"; public static const OP_GAME_UNPAUSE:String = "game_unpause"; public static const PARAM_IMAGE:String = "image"; public static const PARAM_CHANNEL:String = "chnl"; public static const OP_GAME_DELETE:String = "gm.del"; public static const PARAM_LIST:String = "list"; public static const PARAM_GAME_AUTH_TOKEN:String = "auth_token"; public static const OP_GAME_SET_MODE:String = "game_set_mode"; public static const PARAM_DURATION:String = "duration"; public static const OP_HTTP_REQUEST:String = "http"; public static const PARAM_STAT_SORT:String = "sort"; public static const OP_PING_LOCAL:String = "ping.local"; public static const PARAM_SCORE_LIST:String = "list"; public static const OP_ALERT:String = "alert"; public static const PARAM_TIME:String = "time"; public static const PARAM_OPCODE:String = "opcode"; public static const PARAM_GAME_BREAK:String = "game_break"; public static const OP_GAME_MUTE:String = "game_mute"; public static const OP_SCORE_LIST:String = "score.list"; public static const OP_META_QUIT:String = "meta.quit"; public static const PARAM_CONFLICTS:String = "conflicts"; public static const OP_GAME_BREAK:String = "game_break"; public static const PARAM_GAME_NAME:String = "game_name"; public static const OP_STATS_SUBMIT:String = "stat.submit"; public static const OP_META_INVALIDATE:String = "meta.inval"; public static const OP_STATS_LIST:String = "stat.list"; public static const OP_META_JOINED:String = "meta.joined"; public static const PARAM_MESSAGE_ID:String = "msg.id"; public static const OP_GAME_END:String = "game_end"; public static const PARAM_STATS_CURRENT_HIGH_SCORE:String = "stats.current_high"; public static const PARAM_KEY:String = "key"; public static const OP_META_WAITING:String = "meta.waiting"; public static const PARAM_ERROR:String = "error"; public static const PARAM_INVALIDATED:String = "invalidated"; public static const PARAM_FILENAME:String = "filename"; public static const OP_LOAD_SHARED_CONTENT:String = "load_shared_content"; public static const PARAM_PERMALINK:String = "permalink"; public static const OP_SHARED_CONTENT_SAVE_COMPLETE:String = "shared_content_save_complete"; public static const OP_GAME_LIST_SAVES:String = "gm.list"; public static const PARAM_TO:String = "to"; public static const PARAM_STAT_START:String = "start"; public static const PARAM_CHOICE:String = "choice"; public static const OP_META_LIST:String = "meta.list"; public static const OP_DISCONNECT:String = "disconnect"; public static const OP_USER_INFO:String = "user.info"; public static const OP_GAME_UNMUTE:String = "game_unmute"; public static const OP_META_INFO:String = "meta.info"; public static const PARAM_TYPE:String = "type"; public static const OP_STATUS_UPDATE:String = "status_update"; public static const OP_DISCONNECTED:String = "disconnected"; public static const OP_AVATAR_SUBMIT:String = "avatar.submit"; public static const OP_KICK:String = "kick"; public static const OP_SET_PRESENCE:String = "set_presence"; public static const PARAM_CONTENT_TYPE:String = "content_type"; public static const PARAM_GAME_VERSION:String = "gm.ver"; public static var PARAM_PURCHASE_METHOD:String = "purchase_method"; public static var OP_EXTERNAL_MESSAGE:String = "ext.msg"; public static var OP_PURCHASE_KREDS:String = "mtx.kred_purchase"; public static var OP_CHAT_CLEAR_DIALOG:String = "chat.dlg.clear"; public static var OP_ITEM_INSTANCES:String = "mtx.item_instances"; public static var OP_CHAT_DISPLAY:String = "chat.disp"; public static var PARAM_ITEM_TAGS:String = "item_tags"; public static var OP_USE_ITEM_INSTANCE:String = "mtx.use_item_instance"; public static var OP_CHAT_MSG:String = "chat.msg"; public static var OP_CHAT_TAB:String = "chat.tab"; public static var OP_USER_PROFILE:String = "user.profile"; public static var OP_CHAT_DISPLAY_SIGN_IN:String = "chat.sign"; public static var PARAM_LOG_MESSAGE:String = "msg"; public static var OP_ITEM_CHECKOUT:String = "mtx.checkout"; public static var PARAM_ITEM_IDENTIFIERS:String = "item_ids"; public static var PARAM_LOG_LEVEL:String = "level"; public static var PARAM_ITEMS:String = "items"; public static var OP_CHAT_CANVAS_ELEMENT:String = "chat.elm"; public static var OP_ITEM_LIST:String = "mtx.item_list"; public static var PARAM_CANVAS_SIZE:String = "chat.canvas.size"; public static var OP_LOG:String = "log.msg"; } }//package com.kongregate.as3.common.comm
Section 39
//ErrorCode (com.kongregate.as3.common.error.ErrorCode) package com.kongregate.as3.common.error { public class ErrorCode { public static const SAVE_TOO_LARGE:int = 3; public static const NOT_AUTHORIZED:int = 1; public static const NONE:int = 0; public static const NOT_INITIALIZED:int = 4; public static const SERVER_ERROR:int = 2; } }//package com.kongregate.as3.common.error
Section 40
//BufferedEventDispatcher (com.kongregate.as3.common.events.BufferedEventDispatcher) package com.kongregate.as3.common.events { import flash.events.*; import flash.utils.*; public class BufferedEventDispatcher extends EventDispatcher { private var mEventQueue:Array; private var mDispatchInterval:int; private var mBatchSize:int; private var mDispatchTimer:Timer; public function BufferedEventDispatcher(_arg1:int=50, _arg2:int=4){ mDispatchInterval = _arg1; mBatchSize = _arg2; mEventQueue = new Array(); mDispatchTimer = new Timer(_arg1); mDispatchTimer.addEventListener(TimerEvent.TIMER, onDispatchTimer, false, 0, true); mDispatchTimer.start(); } override public function dispatchEvent(_arg1:Event):Boolean{ mEventQueue.unshift(_arg1); return (true); } public function shutdown():void{ mEventQueue = new Array(); mDispatchTimer.removeEventListener(TimerEvent.TIMER, onDispatchTimer); mDispatchTimer.stop(); } private function onDispatchTimer(_arg1:TimerEvent):void{ var _local4:Event; var _local2:int = Math.min(mEventQueue.length, mBatchSize); var _local3:int; while (_local3 < _local2) { _local4 = mEventQueue.pop(); if (_local4){ super.dispatchEvent(_local4); }; _local3++; }; } } }//package com.kongregate.as3.common.events
Section 41
//ChatAPIEvent (com.kongregate.as3.common.events.ChatAPIEvent) package com.kongregate.as3.common.events { public class ChatAPIEvent extends KongregateEvent { public static const CLEAR_CHAT:String = "custom_tab_clear_messages"; public static const SHOW_TAB:String = "custom_tab_show"; public static const DISPLAY_MESSAGE:String = "custom_tab_message"; public static const CLOSE_TAB:String = "custom_tab_close"; public function ChatAPIEvent(_arg1:String, _arg2:Object){ super(_arg1, _arg2); } } }//package com.kongregate.as3.common.events
Section 42
//ClientMessageEvent (com.kongregate.as3.common.events.ClientMessageEvent) package com.kongregate.as3.common.events { import com.kongregate.as3.common.comm.*; public class ClientMessageEvent extends MessageEvent { public static const CLIENT_MESSAGE:String = "client_message"; public function ClientMessageEvent(_arg1:Message){ super(CLIENT_MESSAGE, _arg1); } } }//package com.kongregate.as3.common.events
Section 43
//GameAPIEvent (com.kongregate.as3.common.events.GameAPIEvent) package com.kongregate.as3.common.events { public class GameAPIEvent extends KongregateEvent { public static const SAVE_SHARED_CONTENT:String = "save_shared_content"; public static const STATISTIC_UPDATED:String = "statistic_updated"; public static const API_INITIALIZED:String = "api_initialized"; public static const SHARED_CONTENT_SAVE_COMPLETE:String = "shared_content_save_complete"; public static const NEW_HIGH_SCORE:String = "new_high_score"; public static const PROCESSING_SAVE_SHARED_CONTENT:String = "processing_save_shared_content"; public static const LOAD_SHARED_CONTENT:String = "load_shared_content"; public static const IMAGE_AVATAR_SUBMIT:String = "image_avatar_submit"; public static const BROWSE_SHARED_CONTENT:String = "browse_shared_content"; public static const IMAGE_AVATAR_COMPLETE:String = "image_avatar_complete"; public function GameAPIEvent(_arg1:String, _arg2:Object=null){ super(_arg1, _arg2); } } }//package com.kongregate.as3.common.events
Section 44
//JabberEvent (com.kongregate.as3.common.events.JabberEvent) package com.kongregate.as3.common.events { public class JabberEvent extends KongregateEvent { public static const LEAVE_ROOM:String = "leave_room"; public static const LOGIN:String = "login"; public static const CONNECT:String = "connect"; public static const PRIVATE_MESSAGE:String = "private_message"; public static const CONNECTION_ATTEMPT:String = "connection_attempt"; public static const JOIN_ROOM:String = "join_room"; public static const ERROR_MSG_RATE_LIMIT:String = "error_msg_rate_limit"; public static const ADMIN_MESSAGE:String = "admin_message"; public static const ROOM_MESSAGE:String = "room_message"; public static const DISCONNECT:String = "disconnect"; public static const USER_JOIN:String = "user_join"; public static const MESSAGE_ERROR:String = "message_error"; public static const SILENCED:String = "silenced"; public static const USER_CHANGED:String = "user_changed"; public static const GUEST_COUNT:String = "guest_count"; public static const ERROR_MSG_TOO_LONG:String = "error_msg_too_long"; public static const USER_DEPARTURE:String = "user_departure"; public static const PARTICIPATE:String = "participate"; public function JabberEvent(_arg1:String, _arg2:Object=null){ super(_arg1, _arg2); } } }//package com.kongregate.as3.common.events
Section 45
//KongregateEvent (com.kongregate.as3.common.events.KongregateEvent) package com.kongregate.as3.common.events { import flash.events.*; public class KongregateEvent extends Event { protected var mData:Object; public function KongregateEvent(_arg1:String, _arg2:Object=null){ super(_arg1); mData = _arg2; } public function toObject():Object{ var _local1:Object = {type:type, data:mData}; return (_local1); } public function get data():Object{ return (mData); } public function get success():Boolean{ if (mData["success"] != null){ return (mData["success"]); }; return (true); } } }//package com.kongregate.as3.common.events
Section 46
//LogEvent (com.kongregate.as3.common.events.LogEvent) package com.kongregate.as3.common.events { import flash.events.*; public class LogEvent extends Event { private var _text; public static const WARN:String = "Warn"; public static const ERROR:String = "Error"; public static const SPAM:String = "Spam"; public static const INFO:String = "Info"; public static const DEBUG:String = "Debug"; public static const TYPE_ALL:String = "All"; public function LogEvent(_arg1:String, _arg2){ super(_arg1); _text = _arg2; } public function get text(){ return (_text); } } }//package com.kongregate.as3.common.events
Section 47
//MessageEvent (com.kongregate.as3.common.events.MessageEvent) package com.kongregate.as3.common.events { import flash.events.*; import com.kongregate.as3.common.comm.*; public class MessageEvent extends Event { private var mMessage:Message; public static const MESSAGE:String = "msg_message"; public static const ERROR:String = "msg_error"; public static const CONNECT:String = "msg_connect"; public static const RECEIVED_KONG_IQ:String = "received_kong_iq"; public static const RECEIVED_KONG_ADMIN_IQ:String = "received_kong_admin_iq"; public static const CLOSE:String = "msg_close"; public function MessageEvent(_arg1:String, _arg2:Message=null){ super(_arg1); mMessage = _arg2; } public function get msg():Message{ return (mMessage); } } }//package com.kongregate.as3.common.events
Section 48
//PeerMessageEvent (com.kongregate.as3.common.events.PeerMessageEvent) package com.kongregate.as3.common.events { import com.kongregate.as3.common.comm.*; public class PeerMessageEvent extends MessageEvent { public static const PEER_MESSAGE:String = "peer_message"; public function PeerMessageEvent(_arg1:Message){ super(PEER_MESSAGE, _arg1); } } }//package com.kongregate.as3.common.events
Section 49
//ServerMessageEvent (com.kongregate.as3.common.events.ServerMessageEvent) package com.kongregate.as3.common.events { import com.kongregate.as3.common.comm.*; public class ServerMessageEvent extends MessageEvent { public static const SERVER_MESSAGE:String = "server_message"; public function ServerMessageEvent(_arg1:Message){ super(SERVER_MESSAGE, _arg1); } } }//package com.kongregate.as3.common.events
Section 50
//ItemUtils (com.kongregate.as3.common.items.ItemUtils) package com.kongregate.as3.common.items { import com.adobe.serialization.json.*; public class ItemUtils { public static function buildCartJSON(_arg1:Array):String{ var _local4:*; var _local5:String; var _local6:Object; var _local2:Array = []; var _local3:int; while (_local3 < _arg1.length) { _local4 = _arg1[_local3]; if ((_local4 is String)){ _local2.push({identifier:_local4}); } else { if ((_local4 is Object)){ _local5 = _local4["identifier"]; if (((_local5) && ((_local5.length > 0)))){ _local6 = _local4["data"]; _local2.push({identifier:_local5, data:_local6}); }; } else { if ((((_local4 is Array)) && ((_local4.length == 2)))){ _local2.push({identifier:_local4[0], data:_local4[1]}); }; }; }; _local3++; }; return (JSON.encode(_local2)); } } }//package com.kongregate.as3.common.items
Section 51
//Statistic (com.kongregate.as3.common.stats.Statistic) package com.kongregate.as3.common.stats { import com.kongregate.as3.chat.*; import com.kongregate.as3.service.*; import com.kongregate.as3.common.util.*; import flash.utils.*; public class Statistic { private var mCurrentValue:Number; private var mName:String; private var mSentAt:int; private var mType:String; private var mTaskProgresses:Array; private var mStatisticService:StatisticService; private var mDisplayInTable:Boolean; private var mLastSentValue:Number; private var mAccumulatedValue:Number; private var mUpdatedAt:int; private var mId:int; private var mSavedValue:Number; public static const MEDIUM_PRIORITY_MIN_WAIT_INTERVAL:int = 30000; public static const MEDIUM:String = "medium"; public static const HIGH_PRIORITY_MIN_WAIT_INTERVAL:int = 15000; public static const HIGH:String = "high"; public static const TYPE_MIN:String = "Min"; public static const TYPE_REPLACE:String = "Replace"; public static const LOW_PRIORITY_MIN_WAIT_INTERVAL:int = 120000; public static const LOW:String = "low"; public static const HIGH_SCORE:String = "HighScore"; public static const TYPE_ADD:String = "Add"; public static const TYPE_MAX:String = "Max"; public function Statistic(_arg1:int=0, _arg2:String=null, _arg3:String=null, _arg4:Boolean=false, _arg5:Array=null){ mId = _arg1; mName = _arg2; mType = _arg3; mDisplayInTable = _arg4; if (_arg5){ mTaskProgresses = _arg5; } else { mTaskProgresses = []; }; mSentAt = 0; mAccumulatedValue = 0; } public function get taskProgresses():Array{ if (mTaskProgresses == null){ return ([]); }; return (mTaskProgresses); } public function set lastSentValue(_arg1:Number):void{ if (TYPE_ADD == mType){ return; }; mLastSentValue = _arg1; } public function set taskProgresses(_arg1:Array):void{ mTaskProgresses = _arg1; } public function get name():String{ return (mName); } public function set statisticService(_arg1:StatisticService):void{ mStatisticService = _arg1; } public function betterThanLastSentValue(_arg1:Number):Boolean{ return (Statistic.betterThanForType(mLastSentValue, _arg1, mType)); } public function get displayInTable():Boolean{ return (mDisplayInTable); } public function markAsSent():void{ mSentAt = getTimer(); mLastSentValue = currentValue; if (TYPE_ADD == mType){ mCurrentValue = 0; }; } public function get id():int{ return (mId); } public function setId(_arg1:int):void{ mId = _arg1; } public function set accumulatedValue(_arg1:Number):void{ mAccumulatedValue = _arg1; } public function readyToSend():Boolean{ if (!dirty()){ return (false); }; return ((((0 == sentAt)) || (((getTimer() - sentAt) >= minWaitInterval())))); } public function get savedValue():Number{ return (mSavedValue); } public function get priority():String{ if (taskProgresses.length > 0){ return (HIGH); }; if (displayInTable){ return (MEDIUM); }; return (LOW); } public function get type():String{ return (mType); } public function betterThanSavedValue(_arg1:Number):Boolean{ return (Statistic.betterThanForType(mSavedValue, _arg1, mType)); } public function get lastSentValue():Number{ return (mLastSentValue); } public function betterThanCurrentValue(_arg1:Number):Boolean{ return (Statistic.betterThanForType(currentValue, _arg1, mType)); } public function get user():User{ if (!mStatisticService){ return (null); }; return (mStatisticService.user); } private function minWaitInterval():int{ switch (priority){ case LOW: return (LOW_PRIORITY_MIN_WAIT_INTERVAL); case MEDIUM: return (MEDIUM_PRIORITY_MIN_WAIT_INTERVAL); case HIGH: return (HIGH_PRIORITY_MIN_WAIT_INTERVAL); }; return (300000); } public function get accumulatedValue():Number{ if (TYPE_ADD == type){ return (mAccumulatedValue); }; return (value); } public function dirty():Boolean{ var _local1:int; if (isNaN(currentValue)){ return (false); }; if (TYPE_ADD == mType){ return (!((currentValue == 0))); }; _local1 = 0; while (_local1 < taskProgresses.length) { if (betterThanForType(taskProgresses[_local1].currentProgress, currentValue, mType)){ return (true); }; _local1++; }; return (((betterThanSavedValue(currentValue)) && (betterThanLastSentValue(currentValue)))); } public function set savedValue(_arg1:Number):void{ mSavedValue = _arg1; } public function sendImmediately():Boolean{ if (!dirty()){ return (false); }; if (taskProgresses.length <= 0){ return (false); }; var _local1:int; while (_local1 < taskProgresses.length) { if (taskProgresses[_local1].isCompleted()){ Log.debug({taskCompleted:taskProgresses[_local1], value:value}); return (true); }; _local1++; }; return (false); } public function attemptTaskProgressUpdate(_arg1:Number):void{ var _local3:TaskProgress; var _local2:int; while (_local2 < taskProgresses.length) { _local3 = taskProgresses[_local2]; _local3.attemptUpdate(_arg1); _local2++; }; } public function get sentAt():int{ return (mSentAt); } private function set currentValue(_arg1:Number):void{ mUpdatedAt = getTimer(); mCurrentValue = _arg1; } public function get value():Number{ return (currentValue); } public function attemptUpdate(_arg1:Number):Boolean{ if (TYPE_ADD == mType){ if (isNaN(mCurrentValue)){ mCurrentValue = 0; }; if (((!(user)) || (user.isGuest()))){ mAccumulatedValue = (mAccumulatedValue + _arg1); }; mCurrentValue = (mCurrentValue + _arg1); return (!((0 == _arg1))); }; if (!betterThanCurrentValue(_arg1)){ return (false); }; mCurrentValue = _arg1; return (true); } private function get currentValue():Number{ return (mCurrentValue); } public static function fromObject(_arg1:Object):Statistic{ var _local3:TaskProgress; var _local4:int; var _local2:Statistic = new Statistic(_arg1.id, _arg1.name, _arg1.stat_type, _arg1.display_in_table); if ((_arg1.accomplishment_tasks is Array)){ _local4 = 0; while (_local4 < _arg1.accomplishment_tasks.length) { _local3 = TaskProgress.fromStatisticAndObject(_local2, _arg1.accomplishment_tasks[_local4]); _local2.taskProgresses.push(_local3); _local4++; }; }; return (_local2); } public static function betterThanForType(_arg1:Number, _arg2:Number, _arg3:String):Boolean{ if (TYPE_ADD == _arg3){ throw (new Error("Cannot call betterThanCurrentValue() for add stats")); }; if (isNaN(_arg1)){ return (true); }; if (TYPE_MIN == _arg3){ return ((_arg2 < _arg1)); }; if (TYPE_MAX == _arg3){ return ((_arg2 > _arg1)); }; return (!((_arg2 == _arg1))); } } }//package com.kongregate.as3.common.stats
Section 52
//TaskProgress (com.kongregate.as3.common.stats.TaskProgress) package com.kongregate.as3.common.stats { public class TaskProgress { private var mStatistic:Statistic; private var mId:int; private var mQuota:Number; private var mName:String; private var mCurrentProgress:Number; public function TaskProgress(_arg1:Statistic, _arg2:int=0, _arg3:String=null, _arg4:Number=0){ mStatistic = _arg1; mId = _arg2; mName = _arg3; mQuota = _arg4; } public function getStatistic():Statistic{ return (mStatistic); } public function setCurrentProgress(_arg1:Number):void{ if (isNaN(_arg1)){ return; }; if (Statistic.TYPE_MIN == mStatistic.type){ if (_arg1 >= mCurrentProgress){ return; }; } else { if (_arg1 <= mCurrentProgress){ return; }; }; mCurrentProgress = _arg1; } public function get currentProgress():Number{ return (mCurrentProgress); } public function isCompleted():Boolean{ if (isNaN(mCurrentProgress)){ return (false); }; if (Statistic.TYPE_MIN == mStatistic.type){ return ((mCurrentProgress <= mQuota)); }; return ((mCurrentProgress >= mQuota)); } public function attemptUpdate(_arg1:Number):Boolean{ if (Statistic.TYPE_ADD == mStatistic.type){ if (isNaN(mCurrentProgress)){ mCurrentProgress = 0; }; mCurrentProgress = (mCurrentProgress + _arg1); return (!((0 == _arg1))); }; if (!Statistic.betterThanForType(mCurrentProgress, _arg1, mStatistic.type)){ return (false); }; mCurrentProgress = _arg1; return (true); } public function get name():String{ return (mName); } public function get id():Number{ return (mId); } public function get quota():Number{ return (mQuota); } public static function fromStatisticAndObject(_arg1:Statistic, _arg2:Object):TaskProgress{ return (new TaskProgress(_arg1, _arg2.id, _arg2.name, _arg2.quota)); } } }//package com.kongregate.as3.common.stats
Section 53
//BadLanguageFilter (com.kongregate.as3.common.util.BadLanguageFilter) package com.kongregate.as3.common.util { public class BadLanguageFilter { private static const BAD_PHRASES:Array = ["fuck", "cunt", "cocksuck", "nigger", "faggot"]; private static const BAD_WORDS:Array = ["fag"]; private static var gBadRegExp:RegExp; public static function filter(_arg1:String):String{ var _local4:Number; if (!gBadRegExp){ initialize(); }; var _local2 = ""; var _local3:int; while (_local3 < _arg1.length) { _local4 = _arg1.charCodeAt(_local3); if ((((((((_local4 < 32)) && (!((_local4 == 9))))) && (!((_local4 == 10))))) && (!((_local4 == 13))))){ } else { _local2 = (_local2 + _arg1.charAt(_local3)); }; _local3++; }; return (_local2.replace(gBadRegExp, "****")); } public static function initialize():void{ var _local1:int; var _local3:String; var _local4:String; var _local2:Array = []; _local1 = 0; while (_local1 < BAD_PHRASES.length) { _local4 = BAD_PHRASES[_local1]; _local3 = _local4.replace(/\w(?=\w)/g, "$&[\\s;]*"); _local2.push((("(" + _local3) + ")")); _local1++; }; _local1 = 0; while (_local1 < BAD_WORDS.length) { _local4 = BAD_WORDS[_local1]; _local3 = _local4.replace(/\w(?=\w)/g, "$&[\\s;]*"); _local3 = (("\\b(" + _local3) + ")\\b"); _local2.push(_local3); _local1++; }; gBadRegExp = new RegExp(_local2.join("|"), "gi"); } } }//package com.kongregate.as3.common.util
Section 54
//Base64 (com.kongregate.as3.common.util.Base64) package com.kongregate.as3.common.util { import flash.utils.*; public class Base64 { public static const version:String = "1.0.0"; private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; public function Base64(){ throw (new Error("Base64 class is static container only")); } public static function encode(_arg1:String):String{ var _local2:ByteArray = new ByteArray(); _local2.writeUTFBytes(_arg1); return (encodeByteArray(_local2)); } public static function encodeByteArray(_arg1:ByteArray):String{ var _local3:Array; var _local5:uint; var _local6:uint; var _local7:uint; var _local2 = ""; var _local4:Array = new Array(4); _arg1.position = 0; while (_arg1.bytesAvailable > 0) { _local3 = new Array(); _local5 = 0; while ((((_local5 < 3)) && ((_arg1.bytesAvailable > 0)))) { _local3[_local5] = _arg1.readUnsignedByte(); _local5++; }; _local4[0] = ((_local3[0] & 252) >> 2); _local4[1] = (((_local3[0] & 3) << 4) | (_local3[1] >> 4)); _local4[2] = (((_local3[1] & 15) << 2) | (_local3[2] >> 6)); _local4[3] = (_local3[2] & 63); _local6 = _local3.length; while (_local6 < 3) { _local4[(_local6 + 1)] = 64; _local6++; }; _local7 = 0; while (_local7 < _local4.length) { _local2 = (_local2 + BASE64_CHARS.charAt(_local4[_local7])); _local7++; }; }; return (_local2); } public static function decode(_arg1:String):String{ var _local2:ByteArray = decodeToByteArray(_arg1); return (_local2.readUTFBytes(_local2.length)); } public static function decodeToByteArray(_arg1:String):ByteArray{ var _local6:uint; var _local7:uint; var _local2:ByteArray = new ByteArray(); var _local3:Array = new Array(4); var _local4:Array = new Array(3); var _local5:uint; while (_local5 < _arg1.length) { _local6 = 0; while ((((_local6 < 4)) && (((_local5 + _local6) < _arg1.length)))) { _local3[_local6] = BASE64_CHARS.indexOf(_arg1.charAt((_local5 + _local6))); _local6++; }; _local4[0] = ((_local3[0] << 2) + ((_local3[1] & 48) >> 4)); _local4[1] = (((_local3[1] & 15) << 4) + ((_local3[2] & 60) >> 2)); _local4[2] = (((_local3[2] & 3) << 6) + _local3[3]); _local7 = 0; while (_local7 < _local4.length) { if (_local3[(_local7 + 1)] == 64){ break; }; _local2.writeByte(_local4[_local7]); _local7++; }; _local5 = (_local5 + 4); }; _local2.position = 0; return (_local2); } } }//package com.kongregate.as3.common.util
Section 55
//Configuration (com.kongregate.as3.common.util.Configuration) package com.kongregate.as3.common.util { import flash.display.*; public class Configuration { private static var gConfig:Object = null; public static function initialize(_arg1:DisplayObject, _arg2:Object=null):void{ var parent = _arg1; var config = _arg2; if (config != null){ gConfig = config; } else { try { gConfig = parent.loaderInfo.parameters; if (getConfigValue("debug_level")){ Log.setLogLevel(int(getConfigValue("debug_level"))); } else { Log.setLogLevel(1); }; Log.debug({Flashvars:gConfig}); } catch(e:Error) { gConfig = null; Log.error(("Couldn't get configuration object: " + e.toString())); }; }; } public static function getConfigValue(_arg1:String):String{ return (gConfig[_arg1]); } public static function getConfig():Object{ return (gConfig); } } }//package com.kongregate.as3.common.util
Section 56
//JSON (com.kongregate.as3.common.util.JSON) package com.kongregate.as3.common.util { public class JSON { public static function encode(_arg1):String{ var _local2:String; var _local3:Number; var _local4:Number; var _local6:*; var _local7:String; var _local8:Number; var _local5 = ""; switch (typeof(_arg1)){ case "object": if (_arg1){ if ((_arg1 is Array)){ _local4 = _arg1.length; _local3 = 0; while (_local3 < _local4) { _local6 = encode(_arg1[_local3]); if (_local5){ _local5 = (_local5 + ","); }; _local5 = (_local5 + _local6); _local3++; }; return ((("[" + _local5) + "]")); } else { if (typeof(_arg1.toString) != "undefined"){ for (_local7 in _arg1) { _local6 = _arg1[_local7]; if (((!((typeof(_local6) == "undefined"))) && (!((typeof(_local6) == "function"))))){ _local6 = encode(_local6); if (_local5){ _local5 = (_local5 + ","); }; _local5 = (_local5 + ((encode(_local7) + ":") + _local6)); }; }; return ((("{" + _local5) + "}")); }; }; }; return ("null"); case "number": return ((isFinite(_arg1)) ? String(_arg1) : "null"); case "string": _local4 = _arg1.length; _local5 = "\""; _local3 = 0; while (_local3 < _local4) { _local2 = _arg1.charAt(_local3); if (_local2 >= " "){ if ((((_local2 == "\\")) || ((_local2 == "\"")))){ _local5 = (_local5 + "\\"); }; _local5 = (_local5 + _local2); } else { switch (_local2){ case "\b": _local5 = (_local5 + "\\b"); break; case "\f": _local5 = (_local5 + "\\f"); break; case "\n": _local5 = (_local5 + "\\n"); break; case "\r": _local5 = (_local5 + "\\r"); break; case "\t": _local5 = (_local5 + "\\t"); break; default: _local8 = _local2.charCodeAt(); _local5 = (_local5 + (("\\u00" + Math.floor((_local8 / 16)).toString(16)) + (_local8 % 16).toString(16))); }; }; _local3 = (_local3 + 1); }; return ((_local5 + "\"")); case "boolean": return (String(_arg1)); default: return ("null"); }; } public static function decode(_arg1:String){ var at:Number; var ch:String; var _isDigit:Function; var _isHexDigit:Function; var _white:Function; var _string:Function; var _next:Function; var _array:Function; var _object:Function; var _number:Function; var _word:Function; var _value:Function; var _error:Function; var source = _arg1; source = new String(source); at = 0; ch = " "; _isDigit = function (_arg1:String){ return (((("0" <= _arg1)) && ((_arg1 <= "9")))); }; _isHexDigit = function (_arg1:String){ return (((((_isDigit(_arg1)) || (((("A" <= _arg1)) && ((_arg1 <= "F")))))) || (((("a" <= _arg1)) && ((_arg1 <= "f")))))); }; _error = function (_arg1:String):void{ throw (new Error(_arg1, (at - 1))); }; _next = function (){ ch = source.charAt(at); at = (at + 1); return (ch); }; _white = function ():void{ while (ch) { if (ch <= " "){ _next(); } else { if (ch == "/"){ switch (_next()){ case "/": do { } while (((((_next()) && (!((ch == "\n"))))) && (!((ch == "\r"))))); break; case "*": _next(); while (true) { if (ch){ if (ch == "*"){ if (_next() == "/"){ _next(); break; }; } else { _next(); }; } else { _error("Unterminated Comment"); }; }; break; default: _error("Syntax Error"); }; } else { break; }; }; }; }; _string = function (){ var _local3:*; var _local4:*; var _local1:* = ""; var _local2:* = ""; var _local5:Boolean; if (ch == "\""){ while (_next()) { if (ch == "\""){ _next(); return (_local2); }; if (ch == "\\"){ switch (_next()){ 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": _local4 = 0; _local1 = 0; while (_local1 < 4) { _local3 = parseInt(_next(), 16); if (!isFinite(_local3)){ _local5 = true; break; }; _local4 = ((_local4 * 16) + _local3); _local1 = (_local1 + 1); }; if (_local5){ _local5 = false; break; }; _local2 = (_local2 + String.fromCharCode(_local4)); break; default: _local2 = (_local2 + ch); }; } else { _local2 = (_local2 + ch); }; }; }; _error("Bad String"); return (null); }; _array = function (){ var _local1:Array = []; if (ch == "["){ _next(); _white(); if (ch == "]"){ _next(); return (_local1); }; while (ch) { _local1.push(_value()); _white(); if (ch == "]"){ _next(); return (_local1); }; if (ch != ","){ break; }; _next(); _white(); }; }; _error("Bad Array"); return (null); }; _object = function (){ var _local1:* = {}; var _local2:* = {}; if (ch == "{"){ _next(); _white(); if (ch == "}"){ _next(); return (_local2); }; while (ch) { _local1 = _string(); _white(); if (ch != ":"){ break; }; _next(); _local2[_local1] = _value(); _white(); if (ch == "}"){ _next(); return (_local2); }; if (ch != ","){ break; }; _next(); _white(); }; }; _error("Bad Object"); }; _number = function (){ var _local2:*; var _local1:* = ""; var _local3 = ""; var _local4 = ""; if (ch == "-"){ _local1 = "-"; _local4 = _local1; _next(); }; if (ch == "0"){ _next(); if ((((ch == "x")) || ((ch == "X")))){ _next(); while (_isHexDigit(ch)) { _local3 = (_local3 + ch); _next(); }; if (_local3 == ""){ _error("mal formed Hexadecimal"); } else { return (Number(((_local4 + "0x") + _local3))); }; } else { _local1 = (_local1 + "0"); }; }; while (_isDigit(ch)) { _local1 = (_local1 + ch); _next(); }; if (ch == "."){ _local1 = (_local1 + "."); while (((((_next()) && ((ch >= "0")))) && ((ch <= "9")))) { _local1 = (_local1 + ch); }; }; _local2 = (1 * _local1); if (!isFinite(_local2)){ _error("Bad Number"); } else { return (_local2); }; return (NaN); }; _word = function (){ switch (ch){ case "t": if ((((((_next() == "r")) && ((_next() == "u")))) && ((_next() == "e")))){ _next(); return (true); }; break; case "f": if ((((((((_next() == "a")) && ((_next() == "l")))) && ((_next() == "s")))) && ((_next() == "e")))){ _next(); return (false); }; break; case "n": if ((((((_next() == "u")) && ((_next() == "l")))) && ((_next() == "l")))){ _next(); return (null); }; break; }; _error("Syntax Error"); return (null); }; _value = function (){ _white(); switch (ch){ case "{": return (_object()); case "[": return (_array()); case "\"": return (_string()); case "-": return (_number()); default: return (((((ch >= "0")) && ((ch <= "9")))) ? _number() : _word()); }; }; return (_value()); } } }//package com.kongregate.as3.common.util
Section 57
//Log (com.kongregate.as3.common.util.Log) package com.kongregate.as3.common.util { import com.kongregate.as3.common.events.*; import flash.events.*; import flash.system.*; import flash.external.*; public class Log extends EventDispatcher { private var mLogName:String;// = "" private var mInitialized:Boolean;// = false private var mLogLevel:Number;// = 3 private var mLogEntries:Array; public static const MAX_LOG_ENTRIES:Number = 250; private static var gInstance:Log; public static var LEVELS_MAP:Object = {Error:1, Warn:2, Info:3, Debug:4, Spam:5}; public static var LEVELS:Array = ["Error", "Warn", "Info", "Debug", "Spam"]; private function getName():String{ return (mLogName); } public function getOSInfo():String{ return (((((((("OS: " + Capabilities.os) + ", ") + Capabilities.screenResolutionX) + "x") + Capabilities.screenResolutionY) + ", current version: ") + Capabilities.version)); } private function isDebug():Boolean{ return ((mLogLevel >= 4)); } private function setName(_arg1:String):void{ mLogName = _arg1; } public function addLogEntry(_arg1:String, _arg2):void{ if ((_arg2 is String)){ if (mLogEntries.length > MAX_LOG_ENTRIES){ mLogEntries.splice(0, 1); }; mLogEntries.push({type:_arg1, time:getTimestamp(), text:sanitize(_arg2)}); }; } private function init():void{ if (!mInitialized){ mInitialized = true; this.addEventListener(LogEvent.DEBUG, onDebugMessage); this.addEventListener(LogEvent.INFO, onInfoMessage); this.addEventListener(LogEvent.WARN, onWarnMessage); this.addEventListener(LogEvent.ERROR, onErrorMessage); this.addEventListener(LogEvent.SPAM, onSpamMessage); mLogEntries = new Array(); Log.info("kongregate log initialized."); Log.info(getOSInfo()); }; } private function onWarnMessage(_arg1:LogEvent):void{ logToFirebug("warn", _arg1.text); } private function log(_arg1:int, _arg2):void{ var _local3:String; if (_arg1 < LEVELS_MAP.Spam){ addLogEntry(_local3, _arg2); }; if (mLogLevel >= _arg1){ _local3 = getLevelString(_arg1); dispatch(_local3, _arg2); }; } private function onDebugMessage(_arg1:LogEvent):void{ logToFirebug("debug", _arg1.text); } private function onErrorMessage(_arg1:LogEvent):void{ var _local2:* = _arg1.text; if ((_local2 is Error)){ _local2 = ((_local2.message + "\n") + _local2.getStackTrace()); logToFirebug("warn", _local2); } else { _local2 = _arg1.text; logToFirebug("warn", _local2); }; } private function onSpamMessage(_arg1:LogEvent):void{ logToFirebug("debug", _arg1.text); } private function getTimestamp():String{ var _local1:Date = new Date(); return (_local1.toString().split("GMT")[0]); } private function onInfoMessage(_arg1:LogEvent):void{ logToFirebug("info", _arg1.text); } public function setLogLevel(_arg1:Number):void{ mLogLevel = _arg1; } private function getErrorReport():Array{ return (mLogEntries); } private function sanitize(_arg1:String):String{ return (_arg1.split("<").join("&lt;")); } private function logToFirebug(_arg1:String, _arg2):void{ var type = _arg1; var text = _arg2; var oldMarshalExceptions:Boolean = ExternalInterface.marshallExceptions; ExternalInterface.marshallExceptions = true; try { ExternalInterface.call(("console." + type), text); } catch(e:Error) { } finally { ExternalInterface.marshallExceptions = oldMarshalExceptions; }; } private function dispatch(_arg1:String, _arg2):Boolean{ if (((!((mLogName == null))) && ((mLogName.length > 0)))){ if ((_arg2 is String)){ _arg2 = ((("[" + mLogName) + "] ") + _arg2); }; }; var _local3:Boolean = dispatchEvent(new LogEvent(_arg1, _arg2)); return (_local3); } private function getLevelString(_arg1:int):String{ return (LEVELS[(_arg1 - 1)]); } public static function getName():String{ return (getInstance().getName()); } public static function hasEventListener(_arg1:String):Boolean{ return (getInstance().hasEventListener(_arg1)); } public static function warn(_arg1):void{ getInstance().log(2, _arg1); } public static function error(_arg1):void{ getInstance().log(1, _arg1); } public static function isDebug():Boolean{ return (getInstance().isDebug()); } public static function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{ getInstance().removeEventListener(_arg1, _arg2, _arg3); } public static function getInstance():Log{ if (gInstance == null){ gInstance = new (Log); gInstance.init(); }; return (gInstance); } public static function spam(_arg1):void{ getInstance().log(5, _arg1); } public static function debug(_arg1):void{ getInstance().log(4, _arg1); } public static function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{ getInstance().addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5); } public static function init():void{ getInstance().init(); } public static function setName(_arg1:String):void{ getInstance().setName(_arg1); } public static function getErrorReport():Array{ return (getInstance().getErrorReport()); } public static function setLogLevel(_arg1:Number):void{ getInstance().setLogLevel(_arg1); } public static function info(_arg1):void{ getInstance().log(3, _arg1); } } }//package com.kongregate.as3.common.util
Section 58
//RateLimiter (com.kongregate.as3.common.util.RateLimiter) package com.kongregate.as3.common.util { import flash.utils.*; public class RateLimiter { private var mLongestDuration:Number; private var mRules:Array; private var mTimestamps:Array; public function RateLimiter(_arg1:Array){ var rateLimitRules = _arg1; super(); mTimestamps = []; mRules = rateLimitRules; mLongestDuration = 0; mRules.forEach(function (_arg1:Object, _arg2, _arg3):void{ if (_arg1.duration > mLongestDuration){ mLongestDuration = _arg1.duration; }; }); } public function ruleViolated():Object{ var now:int; var occurenceCounts:Object; var latest:int; now = getTimer(); cull((now - mLongestDuration)); var cutoffTimes:Array = []; cutoffTimes = mRules.map(function (_arg1:Object, _arg2, _arg3):int{ return ((now - _arg1.duration)); }); occurenceCounts = {}; cutoffTimes.sort(); var i:int = (cutoffTimes.length - 1); while (i >= 0) { latest = cutoffTimes[i]; occurenceCounts[(now - latest)] = mTimestamps.filter(function (_arg1:int, _arg2, _arg3):Boolean{ return ((_arg1 >= latest)); }).length; i = (i - 1); }; if (Log.isDebug()){ Log.spam({rateLimiterOccurenceCounts:occurenceCounts}); }; var rulesViolated:Array = mRules.filter(function (_arg1:Object, _arg2, _arg3):Boolean{ return ((occurenceCounts[_arg1.duration] > _arg1.capacity)); }); if (0 == rulesViolated.length){ mTimestamps.push(now); }; return (rulesViolated[0]); } private function cull(_arg1:int):void{ var cutoffTime = _arg1; mTimestamps = mTimestamps.filter(function (_arg1:int, _arg2, _arg3):Boolean{ return ((_arg1 >= cutoffTime)); }); } } }//package com.kongregate.as3.common.util
Section 59
//StringTruncate (com.kongregate.as3.common.util.StringTruncate) package com.kongregate.as3.common.util { public class StringTruncate { public static function truncateOn(_arg1:String, _arg2:int, _arg3:String, _arg4:String=""):String{ var _local6:int; if (_arg1.length < _arg2){ return (_arg1); }; _arg2 = (_arg2 - _arg4.length); var _local5:String = _arg1.substr(0, _arg2); if (_arg1.substr(_arg2, _arg3.length) != _arg3){ _local6 = _local5.lastIndexOf(_arg3); _local5 = _local5.substr(0, (_arg2 - (_arg2 - _local6))); }; _local5 = (_local5 + _arg4); return (_local5); } } }//package com.kongregate.as3.common.util
Section 60
//Utils (com.kongregate.as3.common.util.Utils) package com.kongregate.as3.common.util { import flash.events.*; import flash.utils.*; import flash.net.*; import flash.system.*; public class Utils { public static const ALLOWED_PREFIXES:Array = ["a", "www", "chat", "internal"]; public static const ALLOWED_DOMAINS:Array = ["kongregate.com", "kongregatestage.com", "kongregatetrunk.com", "kongshred.com", "kongregatedev.com"]; public static function getTimeStamp():String{ return (((Math.floor((Math.random() * 10000000)).toString() + "_") + getTimer())); } public static function doHttpRequest(_arg1:String, _arg2:String, _arg3:Object, _arg4:Function, _arg5:Number):void{ var method = _arg1; var url = _arg2; var dataObj = _arg3; var resultCallback = _arg4; var timeout = _arg5; var request:URLRequest = new URLRequest(url); request.method = method; dataObj.ts = getTimeStamp(); request.data = createURLVariables(dataObj); var loader:URLLoader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.TEXT; var internalCallback:Function = function (_arg1:Event):void{ if (resultCallback != null){ resultCallback(processHttpResponse(_arg1)); }; }; loader.addEventListener(Event.COMPLETE, internalCallback); loader.addEventListener(IOErrorEvent.IO_ERROR, internalCallback); try { loader.load(request); } catch(error:Error) { internalCallback(null); }; } public static function submitAlert(_arg1:String, _arg2:String, _arg3:String, _arg4:String, _arg5:Number, _arg6:Number, _arg7:Function=null):void{ var _local8:Object = Log.getErrorReport(); var _local9:URLVariables = new URLVariables("name=Franklin"); if (_arg1){ _local9.body = _arg1; }; if (_arg5){ _local9.game_id = _arg5; }; _local9.automatic = ((((_arg6 == 1)) || ((_arg6 == true)))) ? 1 : 0; _local9.report_name = _arg4; _local9.username = _arg3; _local9.version = _local8.version; _local9[_arg2] = JSON.encode(_local8.log); sendHttpRequest("/alerts", _local9, _arg7, 0); } private static function processHttpResponse(_arg1:Event):Object{ var response:Object; var e = _arg1; if ((((e == null)) || (!((e.type == Event.COMPLETE))))){ return ({success:false, response:null, parsed_response:null}); }; var target:URLLoader = (e.target as URLLoader); var data:String = (target.data as String); try { response = JSON.decode(data); return ({success:true, response:data, parsed_response:response}); } catch(e:Error) { }; return ({success:true, response:data, parsed_response:null}); } public static function allowDomains():void{ var _local1:String; var _local2:String; for each (_local1 in ALLOWED_DOMAINS) { Security.allowDomain(_local1); for each (_local2 in ALLOWED_PREFIXES) { Security.allowDomain(((_local2 + ".") + _local1)); }; }; } public static function crudUpdate(_arg1:String, _arg2:Object, _arg3:Function=undefined, _arg4:Number=0):void{ _arg2._method = "put"; sendHttpRequest(_arg1, _arg2, _arg3, _arg4); } public static function httpPost(_arg1:String, _arg2:Object, _arg3:Function, _arg4:Number):void{ doHttpRequest(URLRequestMethod.POST, _arg1, _arg2, _arg3, _arg4); } private static function createURLVariables(_arg1:Object):URLVariables{ var _local3:String; var _local2:URLVariables = new URLVariables(); for (_local3 in _arg1) { _local2[_local3] = _arg1[_local3]; }; return (_local2); } public static function sendImageToServer(_arg1:ByteArray, _arg2:String, _arg3:Function):void{ var image = _arg1; var server = _arg2; var callback = _arg3; var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream"); var request:URLRequest = new URLRequest((server + "/image_importer")); request.requestHeaders.push(header); request.method = URLRequestMethod.POST; request.data = image; var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, function (_arg1:Event):void{ callback(_arg1.target.data); }); loader.load(request); } public static function submitGameAlert(_arg1:String, _arg2:int, _arg3:String):void{ Utils.submitAlert("Automatically generated game alert", "game_log", _arg1, _arg3, _arg2, 1); } public static function httpGet(_arg1:String, _arg2:Object, _arg3:Function, _arg4:Number):void{ doHttpRequest(URLRequestMethod.GET, _arg1, _arg2, _arg3, _arg4); } public static function getFlashMajorVersion():Number{ var _local2:Array; var _local3:Number; var _local1:String = Capabilities.version; if (((!(_local1)) || ((_local1.length == 0)))){ return (5); }; _local2 = _local1.split(","); _local3 = _local2[0].indexOf(" "); return (Number(_local2[0].substr(_local3))); } public static function crudCreate(_arg1:String, _arg2:Object, _arg3:Function, _arg4:Number=0):void{ _arg2._method = "post"; sendHttpRequest(_arg1, _arg2, _arg3, _arg4); } public static function crudDestroy(_arg1:String, _arg2:Function, _arg3:Number=0):void{ sendHttpRequest(_arg1, {_method:"delete"}, _arg2, _arg3); } public static function bind(_arg1:Function, _arg2:Object){ var functionToApply = _arg1; var object = _arg2; var temporaryFunction:Function = function ():Function{ return (function (){ functionToApply.apply(object, arguments); }); }; return (temporaryFunction.apply(undefined)); } private static function populateURLVariablesWithObject(_arg1, _arg2, _arg3:String=null):void{ var _local4:*; var _local5:String; var _local6:String; if ("function" == typeof(_arg2)){ return; }; if ("object" != typeof(_arg2)){ _arg1[_arg3] = _arg2; }; for (_local6 in _arg2) { _local4 = _arg2[_local6]; if ((((undefined == _local4)) || (("function" == typeof(_local4))))){ } else { if (!_arg3){ _local5 = _local6; } else { _local5 = (((_arg3 + "[") + _local6) + "]"); }; populateURLVariablesWithObject(_arg1, _local4, _local5); }; }; } public static function sendHttpRequest(_arg1:String, _arg2:Object, _arg3:Function, _arg4:Number):void{ var url = _arg1; var dataObj = _arg2; var resultCallback = _arg3; var timeout = _arg4; dataObj.ts = getTimeStamp(); var request:URLRequest = new URLRequest(url); request.method = URLRequestMethod.POST; var variables:URLVariables = new URLVariables(); populateURLVariablesWithObject(variables, dataObj); request.data = variables; var loader:URLLoader = new URLLoader(); if ("function" == typeof(resultCallback)){ loader.addEventListener(Event.COMPLETE, resultCallback); }; if (timeout > 0){ loader.addEventListener(IOErrorEvent.IO_ERROR, resultCallback); }; try { loader.load(request); } catch(error:Error) { }; } } }//package com.kongregate.as3.common.util
Section 61
//EncryptionUtils (com.kongregate.as3.security.EncryptionUtils) package com.kongregate.as3.security { import flash.utils.*; import com.hurlant.crypto.rsa.*; import com.meychi.ascrypt3.*; import com.hurlant.crypto.hash.*; import com.hurlant.util.*; public class EncryptionUtils { private static var gSHA1:SHA1 = new SHA1(); public static function verifyRSASignature(_arg1:String, _arg2):Boolean{ var publicModulo:String; var key:RSAKey; var generatedSig:String; var dest:ByteArray; var text = _arg1; var sig = _arg2; if ((sig is String)){ sig = Base64.decodeToByteArray(sig); }; var keyBits:int = (sig.length * 8); var keyBytes:int = Math.min(20, ((keyBits / 8) - 11)); var publicExponent = "010001"; switch (keyBits){ case 0x0800: publicModulo = "99C611C9D836B25447585E452D2EE182B6000D17AFDB635BACAA9ACB771F7DA590C92BCDE0D2F9ED25C8E460385C2A0452D6CE7E9D555A4997B96E4133924D97DE70C9BFAEEFE36CFC19F40B43A21CAE542DEF5FBE1B1E135587B69B13621605FC39A1A12F8CE6535624B25D72CC5A8FA422548D3CBC6641DDBB10EC180EA35708268C6667A83820746BFD350ECBC992E4290618D0143141A447BBB04722F37663CE24FE8E2995E28F7C18AB63EFD0F75065C630D4C8133FCD8B497372D0A81412279AF2D17460C50923A4F149BD81C92ECBACE7A4ACC7634FAB0A8621BFB72982AD75E4E034CD3496D9D1D136E3C2073B82714E02B62E022B506430E034B163"; break; case 0x0400: publicModulo = "BE52250928CCE10B71B7A2A57B38C9350C64B32C7B9B898398C1A2ECE4909C9D60212F839D6AAC30E9BF34F8D1BF82262453EC2EB6021F839FF255BDB28D7B36CD8F194C1923B4DB85B8F23C9522C71D99515127D3E4001266730EA3EEF4B3D5D8D7CAA78ADB0F4D78A44B58E8B1045A859976052685B79B38A05FABAF182DAF"; break; case 0x0200: publicModulo = "AD1B37CBC2D0D25A0F0DBD43EE8DFA9A4E62D6D373EC2139A59145E646DF9D29D5501CD5296D4CE49BF70C15F3E9D319756EB0483AD8C52166E119B728A2265F"; break; case 384: publicModulo = "E1DA91108A58294F4E8DE463ABADE3D3137C73C58F2B631B1C7A1AEE0F16F7D2F22EE3E644C933FF1E14DC00663BCD5F"; break; case 0x0100: publicModulo = "D90F37EB8EE783E1EBF7DB3F8DF443C077C1CF457CBAB127A30D393DCFD0EC1D"; break; case 192: publicModulo = "B8948BED5C4B6EC845DC9E16D3DBA6DB1D8BDB67EDEC3F67"; break; case 128: publicModulo = "C7FDADF9564247416D811A6ECDA1BCDD"; break; default: return (false); }; try { key = RSAKey.parsePublicKey(publicModulo, publicExponent); generatedSig = Hex.fromArray(gSHA1.hash(Hex.toArray(Hex.fromString(text)))).substr(0, (keyBytes * 2)); dest = new ByteArray(); key.verify(sig, dest, sig.length); return ((Hex.fromArray(dest).toLowerCase() == generatedSig.toLowerCase())); } catch(e:Error) { }; return (false); } public static function aesEncrypt(_arg1:String, _arg2:String):String{ var _local3:Rijndael = new Rijndael(0x0100, 128); return (_local3.encrypt(_arg2, generateKey(_arg1), "ECB")); } private static function trimBack(_arg1:String):String{ if (_arg1.charCodeAt((_arg1.length - 1)) < 32){ _arg1 = trimBack(_arg1.substring(0, (_arg1.length - 1))); }; return (_arg1); } public static function generateKey(_arg1:String):String{ return (MD5.calculate(_arg1)); } public static function aesDecrypt(_arg1:String, _arg2:String):String{ var _local3:Rijndael = new Rijndael(0x0100, 128); var _local4:String = _local3.decrypt(_arg2, generateKey(_arg1), "ECB").split(String.fromCharCode(0))[0]; _local4 = trimBack(_local4); return (_local4); } } }//package com.kongregate.as3.security
Section 62
//ChatService (com.kongregate.as3.service.ChatService) package com.kongregate.as3.service { import com.kongregate.as3.common.events.*; import flash.events.*; import com.kongregate.as3.common.comm.*; import com.kongregate.as3.common.util.*; import flash.external.*; public class ChatService extends EventDispatcher { private var mGameApiService:GameAPIService; private var mQueuedMessages:Array; private var mCustomTabShowing:Boolean;// = false public static var CUSTOM_TAB:String = "custom"; public static var DEFAULT_TAB:String = "Default"; public function ChatService(_arg1:GameAPIService){ mQueuedMessages = []; super(); mGameApiService = _arg1; mGameApiService.addEventListener(ClientMessageEvent.CLIENT_MESSAGE, onClientMessage); } private function onClientMessage(_arg1:ClientMessageEvent):void{ if (!mGameApiService.chatApiEnabled){ return; }; var _local2:Message = _arg1.msg; switch (_local2.getOpcode()){ case Opcode.OP_CHAT_DISPLAY: handleChatMessage(_local2); break; case Opcode.OP_CHAT_TAB: handleTabMessage(_local2); break; case Opcode.OP_CHAT_CANVAS_ELEMENT: forwardToCanvasSwf(_local2); break; case Opcode.OP_CHAT_CLEAR_DIALOG: clearChat(); break; }; } private function clearChat():void{ dispatchEvent(new ChatAPIEvent(ChatAPIEvent.CLEAR_CHAT, {})); } private function handleChatMessage(_arg1:Message):void{ var _local2:String = _arg1.getParam(Opcode.PARAM_USER); var _local3:String = _arg1.getParam(Opcode.PARAM_DATA); if ((((((((_local2 == null)) || ((_local2.length == 0)))) || ((_local3 == null)))) || ((_local3.length == 0)))){ return; }; if (_local2.indexOf("@") == 0){ _local2 = _local2.substr(1, (_local2.length - 1)); }; var _local4:Object = {user:{username:_local2}, message:BadLanguageFilter.filter(_local3)}; var _local5:ChatAPIEvent = new ChatAPIEvent(ChatAPIEvent.DISPLAY_MESSAGE, _local4); dispatchEvent(_local5); } private function forwardToCanvasSwf(_arg1:Message):void{ mQueuedMessages.push({type:_arg1.getOpcode(), data:_arg1.getParam(Opcode.PARAM_DATA)}); if (mCustomTabShowing){ flushMessageQueue(); }; } private function flushMessageQueue():void{ var i:int; while (i < mQueuedMessages.length) { try { ExternalInterface.call("konduitToCanvas", mQueuedMessages[i]); } catch(e:Error) { Log.error(("Error during external interface call: " + e.toString())); }; i = (i + 1); }; mQueuedMessages = []; } private function displaySignInLightbox():void{ var url:String; try { url = ("/accounts/new/behind_login.js?game_id=" + mGameApiService.gameId); ExternalInterface.call("displayLightbox", url); } catch(e:Error) { Log.error(("Error displaying lightbox: " + e.toString())); }; } private function handleTabMessage(_arg1:Message):void{ var _local2:ChatAPIEvent; mQueuedMessages = []; var _local3:String = _arg1.getParam(Opcode.PARAM_NAME); if (DEFAULT_TAB == _local3){ closeTab(); return; }; var _local4:Number = _arg1.getParam(Opcode.PARAM_CANVAS_SIZE); if (((!(isFinite(_local4))) || ((_local4 < 0)))){ _local4 = 0.5; }; _local4 = (Math.min(_local4, 1) / 2); clearChat(); var _local5:Object = {name:_local3, description:_arg1.getParam(Opcode.PARAM_DESCRIPTION), size:_local4}; _local2 = new ChatAPIEvent(ChatAPIEvent.SHOW_TAB, _local5); dispatchEvent(_local2); } public function onCustomTabShown(_arg1:Object):void{ if (!mGameApiService.chatApiEnabled){ return; }; Log.info("Custom tab visible!"); mCustomTabShowing = true; flushMessageQueue(); var _local2:Message = Message.fromOpcode(Opcode.OP_CHAT_TAB); _local2.addParam(Opcode.PARAM_CANVAS_SIZE, {width:_arg1.width, height:_arg1.height}); mGameApiService.sendClientMessage(_local2); } private function closeTab():void{ Log.info("Closing tab!"); mCustomTabShowing = false; mQueuedMessages = []; clearChat(); dispatchEvent(new ChatAPIEvent(ChatAPIEvent.CLOSE_TAB, {})); } public function onUserMessage(_arg1:Object):void{ if (!mGameApiService.chatApiEnabled){ return; }; var _local2:Message = Message.fromOpcode(Opcode.OP_CHAT_MSG); _local2.addParam(Opcode.PARAM_USER, _arg1.user.username); _local2.addParam(Opcode.PARAM_DATA, _arg1.message); mGameApiService.sendClientMessage(_local2); } } }//package com.kongregate.as3.service
Section 63
//GameAPIService (com.kongregate.as3.service.GameAPIService) package com.kongregate.as3.service { import com.kongregate.as3.chat.*; import com.kongregate.as3.common.events.*; import flash.events.*; import com.kongregate.as3.common.comm.*; import com.kongregate.as3.common.util.*; import com.kongregate.as3.common.comm.local.*; import com.kongregate.as3.common.comm.external.*; import com.kongregate.as3.common.stats.*; import flash.external.*; public class GameAPIService extends EventDispatcher { private var mGameId:int; private var mSessionLookupKeyPermission:Boolean; private var mMicrotransactionService:MicrotransactionService; private var mChatService:ChatService; private var mChannelId:String; private var mHighScoreService:HighScoreService; private var mUserId:Number; private var mExternalMessageDispatcher:ExternalMessageDispatcher; private var mGameTitle:String; private var mChatApiPermission:Boolean; private var mJabberConnection:JabberConnection; private var mApiHost:String; private var mMicrotransactionApiPermission:Boolean; private var mGamePermalink:String; private var mStatisticService:StatisticService; private var mSharedContentApiPermission:Boolean; private var mGameUrl:String; private var mGameAuthToken:String; private var mLocalConnection:MessageConnection; public function GameAPIService(_arg1:JabberConnection, _arg2:Object){ mChannelId = _arg2.channel_id; mGameId = parseInt(_arg2.game_id); mGamePermalink = _arg2.game_permalink; mGameTitle = _arg2.game_title; mGameUrl = _arg2.game_url; mGameAuthToken = _arg2.game_auth_token; mUserId = parseInt(_arg2.user_id); mSessionLookupKeyPermission = (_arg2.permission_slk == "true"); mMicrotransactionApiPermission = (_arg2.permission_mtx_api == "true"); mChatApiPermission = (_arg2.permission_chat_api == "true"); mSharedContentApiPermission = (_arg2.permission_sc_api == "true"); mApiHost = _arg2.api_host; mJabberConnection = _arg1; mLocalConnection = new MessageConnection(false, mChannelId, false); mStatisticService = new StatisticService(this); mHighScoreService = new HighScoreService({api:this, stats:mStatisticService}); mMicrotransactionService = new MicrotransactionService(this); mChatService = new ChatService(this); mExternalMessageDispatcher = ExternalMessageDispatcher.getInstance(); mExternalMessageDispatcher.addListener(onExternalMessage); initializeEventHandlers(); mLocalConnection.startListening(); } private function onLocalConnect(_arg1:MessageEvent):void{ var _local2:Message = Message.fromOpcode(Opcode.OP_HELLO); _local2.addParam(Opcode.PARAM_SUCCESS, true); sendClientMessage(_local2); sendUserInfo(); var _local3:GameAPIEvent = new GameAPIEvent(GameAPIEvent.API_INITIALIZED, {success:true}); dispatchEvent(_local3); } public function get gameTitle():String{ return (mGameTitle); } public function get microtransactionApiEnabled():Boolean{ return (mMicrotransactionApiPermission); } public function sendClientMessage(_arg1:Message):void{ if (mLocalConnection.isConnected()){ mLocalConnection.sendMessage(_arg1); }; } public function loadSharedContent(_arg1:Object):void{ var _local2:Message = Message.fromOpcode(Opcode.OP_LOAD_SHARED_CONTENT); _local2.addParam(Opcode.PARAM_DATA, _arg1.content); _local2.addParam(Opcode.PARAM_CONTENT_TYPE, _arg1.contentType); _local2.addParam(Opcode.PARAM_NAME, _arg1.name); _local2.addParam(Opcode.PARAM_PERMALINK, _arg1.permalink); _local2.addParam(Opcode.PARAM_ID, _arg1.id); _local2.addParam(Opcode.PARAM_LABEL, _arg1.label); sendClientMessage(_local2); } public function isLoggedIn():Boolean{ return (jabberConnection.connection.isLoggedIn()); } private function onLocalMessage(_arg1:MessageEvent):void{ var msg:Message; var event:GameAPIEvent; var params:Object; var fwd:Message; var toUsername:String; var logName:String; var text:String; var level:String; var e = _arg1; msg = e.msg; switch (msg.getOpcode()){ case Opcode.OP_FORWARD: fwd = Message.fromOpcode(msg.getParam(Opcode.PARAM_DATA).mOpcode); toUsername = msg.getParam(Opcode.PARAM_USER); fwd.setParams(msg.getParam(Opcode.PARAM_DATA).mParams); fwd.addParam(Opcode.PARAM_FROM, username); fwd.addParam(Opcode.PARAM_GAME_ID, gameId); sendToPlayer(fwd, toUsername); break; case Opcode.OP_CHAT_DISPLAY_SIGN_IN: displaySignInLightbox(); break; case Opcode.OP_SAVE_SHARED_CONTENT: if (!this.sharedContentApiEnabled){ params = {contentType:msg.getParam(Opcode.PARAM_CONTENT_TYPE)}; event = new GameAPIEvent(GameAPIEvent.SAVE_SHARED_CONTENT, params); dispatchEvent(event); sharedContentSaveComplete({success:false}); break; }; Utils.sendImageToServer(msg.getParam(Opcode.PARAM_IMAGE), mApiHost, function (_arg1:String):void{ params = {contentType:msg.getParam(Opcode.PARAM_CONTENT_TYPE), content:msg.getParam(Opcode.PARAM_DATA), filename:_arg1, label:msg.getParam(Opcode.PARAM_LABEL)}; event = new GameAPIEvent(GameAPIEvent.SAVE_SHARED_CONTENT, params); dispatchEvent(event); }); dispatchEvent(new GameAPIEvent(GameAPIEvent.PROCESSING_SAVE_SHARED_CONTENT)); break; case Opcode.OP_BROWSE_SHARED_CONTENT: if (!this.sharedContentApiEnabled){ break; }; params = {content_type:msg.getParam(Opcode.PARAM_CONTENT_TYPE), sort_order:msg.getParam(Opcode.PARAM_SORT), label:msg.getParam(Opcode.PARAM_LABEL)}; event = new GameAPIEvent(GameAPIEvent.BROWSE_SHARED_CONTENT, params); dispatchEvent(event); break; case Opcode.OP_AVATAR_SUBMIT: Utils.sendImageToServer(msg.getParam(Opcode.PARAM_IMAGE), mApiHost, function (_arg1:String):void{ params = {filename:_arg1}; event = new GameAPIEvent(GameAPIEvent.IMAGE_AVATAR_SUBMIT, params); dispatchEvent(event); }); break; case Opcode.OP_LOG: logName = Log.getName(); try { Log.setName("Game"); text = msg.getParam(Opcode.PARAM_LOG_MESSAGE); level = msg.getParam(Opcode.PARAM_LOG_LEVEL); var _local3 = Log; _local3[level.toLowerCase()](text); } finally { Log.setName(logName); }; break; }; dispatchEvent(new ClientMessageEvent(msg)); } public function get gameUrl():String{ return (mGameUrl); } public function switchUser(_arg1:User, _arg2:String, _arg3:Number):void{ mJabberConnection.switchUser(_arg1); mGameAuthToken = _arg2; mUserId = _arg3; sendUserInfo(); } public function get jabberConnection():JabberConnection{ return (mJabberConnection); } public function sendServerMessage(_arg1:Message):void{ _arg1.addParam(Opcode.PARAM_GAME_ID, gameId); jabberConnection.sendKongregateMessage(_arg1); } public function get gamePermalink():String{ return (mGamePermalink); } public function get localConnection():MessageConnection{ return (mLocalConnection); } public function get gameId():int{ return (mGameId); } public function onServerMessage(_arg1:MessageEvent):void{ var _local2:Message = _arg1.msg; dispatchEvent(new ServerMessageEvent(_local2)); } private function displaySignInLightbox():void{ try { ExternalInterface.call("displaySignInLightbox"); } catch(e:Error) { Log.error(("Error displaying sign-in lightbox: " + e.toString())); }; } public function get chatApiEnabled():Boolean{ return (mChatApiPermission); } private function sendUserInfo():void{ if (user == null){ return; }; var _local1:Message = Message.fromOpcode(Opcode.OP_USER_INFO); _local1.addParam(Opcode.PARAM_USER, user.username); _local1.addParam(Opcode.PARAM_USER_ID, mUserId); _local1.addParam(Opcode.PARAM_GAME_AUTH_TOKEN, mGameAuthToken); sendClientMessage(_local1); } public function get chatApiService():ChatService{ return (mChatService); } public function addStatistics(_arg1:Array):void{ var _local2:Object; for each (_local2 in _arg1) { Log.info({addingStat:_local2}); mStatisticService.addStatistic(Statistic.fromObject(_local2)); }; mStatisticService.initialize(); } public function get sharedContentApiEnabled():Boolean{ return (mSharedContentApiPermission); } public function sharedContentSaveComplete(_arg1:Object):void{ var _local2:Message = Message.fromOpcode(Opcode.OP_SHARED_CONTENT_SAVE_COMPLETE); _local2.addParam(Opcode.PARAM_DATA, _arg1.content); _local2.addParam(Opcode.PARAM_SUCCESS, _arg1.success); _local2.addParam(Opcode.PARAM_NAME, _arg1.name); _local2.addParam(Opcode.PARAM_PERMALINK, _arg1.permalink); _local2.addParam(Opcode.PARAM_ID, _arg1.id); _local2.addParam(Opcode.PARAM_LABEL, _arg1.label); sendClientMessage(_local2); } public function get username():String{ return (user.username); } public function imageAvatarSubmissionComplete(_arg1:Boolean):void{ var _local2:Message = Message.fromOpcode(Opcode.OP_AVATAR_FINISHED); _local2.addParam(Opcode.PARAM_SUCCESS, _arg1); sendClientMessage(_local2); } public function get user():User{ return (jabberConnection.user); } private function onExternalMessage(_arg1:Message):void{ var _local2:Message = Message.fromOpcode(Opcode.OP_EXTERNAL_MESSAGE); _local2.addParam(Opcode.PARAM_OPCODE, _arg1.getOpcode()); _local2.addParam(Opcode.PARAM_DATA, _arg1.getParams()); sendClientMessage(_local2); } public function get gameAuthToken():String{ return (mGameAuthToken); } public function onServerAdminMessage(_arg1:MessageEvent):void{ var _local2:Message = _arg1.msg; sendClientMessage(_local2); } public function onPeerMessage(_arg1:MessageEvent):void{ sendClientMessage(_arg1.msg); } public function onStatisticEvent(_arg1:GameAPIEvent):void{ var _local2:GameAPIEvent = new GameAPIEvent(_arg1.type, _arg1.data); dispatchEvent(_local2); } private function sendToPlayer(_arg1:Message, _arg2:String):void{ _arg1.addParam(Opcode.PARAM_FROM, username); mJabberConnection.sendKongregateMessageToPlayer(_arg1, _arg2); } public function get clientHasSessionLookupKeyPermission():Boolean{ return (mSessionLookupKeyPermission); } private function initializeEventHandlers():void{ mLocalConnection.addEventListener(MessageEvent.CONNECT, onLocalConnect); mLocalConnection.addEventListener(MessageEvent.MESSAGE, onLocalMessage); mJabberConnection.addEventListener(MessageEvent.RECEIVED_KONG_IQ, onServerMessage); mJabberConnection.addEventListener(MessageEvent.RECEIVED_KONG_ADMIN_IQ, onServerAdminMessage); mJabberConnection.addEventListener(PeerMessageEvent.PEER_MESSAGE, onPeerMessage); mStatisticService.addEventListener(GameAPIEvent.STATISTIC_UPDATED, onStatisticEvent); mStatisticService.addEventListener(GameAPIEvent.NEW_HIGH_SCORE, onStatisticEvent); } public function setAccomplishmentProgress(_arg1:Array):void{ mStatisticService.setAccomplishmentProgress(_arg1); mStatisticService.initialize(); } public function destroy():void{ removeEventHandlers(); mLocalConnection.close(); mMicrotransactionService.destroy(); } public function get channelId():String{ return (mChannelId); } private function removeEventHandlers():void{ mLocalConnection.removeEventListener(MessageEvent.CONNECT, onLocalConnect); mLocalConnection.removeEventListener(MessageEvent.MESSAGE, onLocalMessage); mJabberConnection.removeEventListener(MessageEvent.RECEIVED_KONG_IQ, onServerMessage); mJabberConnection.removeEventListener(MessageEvent.RECEIVED_KONG_ADMIN_IQ, onServerAdminMessage); mJabberConnection.removeEventListener(PeerMessageEvent.PEER_MESSAGE, onPeerMessage); mStatisticService.removeEventListener(GameAPIEvent.STATISTIC_UPDATED, onStatisticEvent); mStatisticService.removeEventListener(GameAPIEvent.NEW_HIGH_SCORE, onStatisticEvent); } } }//package com.kongregate.as3.service
Section 64
//HighScoreService (com.kongregate.as3.service.HighScoreService) package com.kongregate.as3.service { import com.kongregate.as3.common.events.*; import com.kongregate.as3.common.comm.*; import com.kongregate.as3.common.util.*; import com.kongregate.as3.common.stats.*; public class HighScoreService { private var mStatisticService:StatisticService; private var mGameAPIService:GameAPIService; public function HighScoreService(_arg1:Object){ mGameAPIService = _arg1.api; mStatisticService = _arg1.stats; mGameAPIService.addEventListener(ClientMessageEvent.CLIENT_MESSAGE, onClientMessage); } private function getHighScoreList(_arg1:String):void{ var statistic:Statistic; var statName = _arg1; statistic = mStatisticService.findStatisticByName(statName); if (!statistic){ Log.error((("Attempted to find statistic " + statName) + ", but statistic was not found.")); return; }; var finished:Function = function (_arg1:Object):void{ Log.info((((("High score list received for " + statName) + "(") + statistic.id) + ")")); var _local2:Boolean = ((_arg1.success) && (_arg1.parsed_response)); var _local3:Message = Message.fromOpcode(Opcode.OP_SCORE_LIST); _local3.addParam(Opcode.PARAM_SUCCESS, _local2); _local3.addParam(Opcode.PARAM_STAT_NAME, statName); _local3.addParam(Opcode.PARAM_SCORE_LIST, _arg1.parsed_response); mGameAPIService.sendClientMessage(_local3); }; Log.info((((("Requesting high score list for statistic " + statName) + "(") + statistic.id) + ")")); Utils.httpGet("/high_scores.json", {statistic_id:statistic.id}, finished, 0); } private function onClientMessage(_arg1:ClientMessageEvent):void{ var _local2:Message = _arg1.msg; switch (_local2.getOpcode()){ case Opcode.OP_SCORE_LIST: getHighScoreList(_local2.getParam(Opcode.PARAM_STAT_NAME)); break; }; } } }//package com.kongregate.as3.service
Section 65
//MicrotransactionService (com.kongregate.as3.service.MicrotransactionService) package com.kongregate.as3.service { import com.kongregate.as3.common.events.*; import com.kongregate.as3.common.comm.*; import com.kongregate.as3.common.util.*; import com.kongregate.as3.common.items.*; import com.adobe.crypto.*; import flash.external.*; public class MicrotransactionService { private var mGameApiService:GameAPIService; public function MicrotransactionService(_arg1:GameAPIService){ mGameApiService = _arg1; initializeEventListeners(); } private function handleKredPurchaseRequest(_arg1:Message):void{ var msg = _arg1; var method:String = msg.getParam(Opcode.PARAM_PURCHASE_METHOD); try { if (((method) && ((method.length > 0)))){ ExternalInterface.call("active_user.activateKredPurchase", method); } else { ExternalInterface.call("active_user.activateKredPurchase", method); }; } catch(e:Error) { Log.error(("Error displaying lightbox: " + e.toString())); }; } public function destroy():void{ removeEventListeners(); } private function generateUserItemSignature(_arg1:Array, _arg2:String):String{ var _local7:Object; var _local8:int; var _local9:String; var _local3 = "PC45.14,Hloi"; var _local4:String = (_local3 + _arg2.toLowerCase()); var _local5:Array = ["identifier", "id", "data", "remaining_uses"]; var _local6:int; while (_local6 < _arg1.length) { _local7 = _arg1[_local6]; _local8 = 0; while (_local8 < _local5.length) { _local9 = _local5[_local8]; _local4 = (_local4 + (_local7[_local9]) ? _local7[_local9] : "null"); _local8++; }; _local6++; }; return (MD5.hash(_local4)); } private function hasTag(_arg1:Object, _arg2:String):Boolean{ var _local3:int; while (_local3 < _arg1.tags.length) { if (_arg1.tags[_local3] == _arg2){ return (true); }; _local3++; }; return (false); } private function handleUseItemInstanceRequest(_arg1:Message):void{ var itemInstanceId:Number; var msg = _arg1; var username:String = mGameApiService.username; itemInstanceId = msg.getParam(Opcode.PARAM_ID); var finished:Function = function (_arg1:Object):void{ Log.info(("Item instance use result for item instance id:" + itemInstanceId)); var _local2:Object = _arg1.parsed_response; var _local3:Boolean = ((((_arg1.success) && (_local2))) && (_local2.success)); var _local4:Message = Message.fromOpcode(Opcode.OP_USE_ITEM_INSTANCE); _local4.addParam(Opcode.PARAM_SUCCESS, _local3); _local4.addParam(Opcode.PARAM_REQUEST_ID, msg.getParam(Opcode.PARAM_REQUEST_ID)); _local4.addParam(Opcode.PARAM_ID, itemInstanceId); mGameApiService.sendClientMessage(_local4); }; Log.info(((("Requesting item instance use for " + username) + ", item ID: ") + itemInstanceId)); var params:Object = {api_key:mGameApiService.gameId, username:username, game_auth_token:mGameApiService.gameAuthToken, id:itemInstanceId}; Utils.httpPost("/api/use_item.json", params, finished, 0); } private function removeEventListeners():void{ mGameApiService.removeEventListener(ClientMessageEvent.CLIENT_MESSAGE, onClientMessage); } private function handleItemInstancesRequest(_arg1:Message):void{ var username:String; var msg = _arg1; username = msg.getParam(Opcode.PARAM_USER); var finished:Function = function (_arg1:Object):void{ var _local4:String; Log.info(("Item instance list received for " + username)); var _local2:Boolean = ((((_arg1.success) && (_arg1.parsed_response))) && (_arg1.parsed_response.success)); if (_local2){ _local4 = generateUserItemSignature(_arg1.parsed_response.items, username); _local2 = (_local4.toLowerCase() == _arg1.parsed_response.signature.toLowerCase()); }; var _local3:Message = Message.fromOpcode(Opcode.OP_ITEM_INSTANCES); _local3.addParam(Opcode.PARAM_SUCCESS, _local2); _local3.addParam(Opcode.PARAM_USER, username); _local3.addParam(Opcode.PARAM_REQUEST_ID, msg.getParam(Opcode.PARAM_REQUEST_ID)); if (_local2){ _local3.addParam(Opcode.PARAM_DATA, _arg1.parsed_response.items); }; mGameApiService.sendClientMessage(_local3); }; var params:Object = {api_key:mGameApiService.gameId, username:username}; Log.info(("Requesting item instance list from server for user " + username)); Utils.httpGet("/api/user_items.json", params, finished, 0); } private function handleItemCheckoutRequest(_arg1:Message):void{ var msg = _arg1; var items:Array = msg.getParam(Opcode.PARAM_ITEMS); var cartJSON:String = ItemUtils.buildCartJSON(items); var url:String = ((mGameApiService.gameUrl + "/checkouts/new?cart=") + escape(cartJSON)); try { ExternalInterface.call("holodeck.recordAnalyticsEvent", "Lightbox", "Kred"); ExternalInterface.call("displayItemCheckoutLightbox", url); } catch(e:Error) { Log.error(("Error displaying lightbox: " + e.toString())); }; } private function getTags(_arg1:Message):Array{ var _local2:Array = _arg1.getParam(Opcode.PARAM_ITEM_TAGS); if ((((_local2 == null)) || ((_local2.length == 0)))){ return (null); }; var _local3:Array = []; var _local4:int; while (_local4 < _local2.length) { if (((((_local2[_local4]) && ((_local2[_local4] is String)))) && ((_local2[_local4].length > 0)))){ _local3.push(_local2[_local4]); }; _local4++; }; return (((_local3.length > 0)) ? _local3 : null); } private function getItemsWithTags(_arg1:Array, _arg2:Array):Array{ var _local5:Boolean; var _local6:int; if ((((_arg2 == null)) || ((_arg2.length == 0)))){ return (_arg1); }; var _local3:Array = new Array(); var _local4:int; while (_local4 < _arg1.length) { _local5 = true; _local6 = 0; while (_local6 < _arg2.length) { if (!hasTag(_arg1[_local4], _arg2[_local6])){ _local5 = false; break; }; _local6++; }; if (_local5){ _local3.push(_arg1[_local4]); }; _local4++; }; return (_local3); } private function initializeEventListeners():void{ mGameApiService.addEventListener(ClientMessageEvent.CLIENT_MESSAGE, onClientMessage); } private function handleItemListRequest(_arg1:Message):void{ var tags:Array; var msg = _arg1; tags = getTags(msg); var params:Object = {api_key:mGameApiService.gameId}; var finished:Function = function (_arg1:Object):void{ var _local4:Array; var _local2:Message = Message.fromOpcode(Opcode.OP_ITEM_LIST); var _local3:Boolean = ((((_arg1.success) && (_arg1.parsed_response))) && (_arg1.parsed_response.success)); _local2.addParam(Opcode.PARAM_SUCCESS, _local3); _local2.addParam(Opcode.PARAM_REQUEST_ID, msg.getParam(Opcode.PARAM_REQUEST_ID)); if (_local3){ _local4 = getItemsWithTags(_arg1.parsed_response.items, tags); _local2.addParam(Opcode.PARAM_DATA, _local4); }; mGameApiService.sendClientMessage(_local2); }; Log.info("Requesting item list from server"); Utils.httpGet("/api/items.json", params, finished, 0); } private function onClientMessage(_arg1:ClientMessageEvent):void{ if (!mGameApiService.microtransactionApiEnabled){ return; }; var _local2:Message = _arg1.msg; var _local3:String = _local2.getOpcode(); switch (_local3){ case Opcode.OP_ITEM_LIST: handleItemListRequest(_local2); break; case Opcode.OP_ITEM_INSTANCES: handleItemInstancesRequest(_local2); break; case Opcode.OP_ITEM_CHECKOUT: handleItemCheckoutRequest(_local2); break; case Opcode.OP_USE_ITEM_INSTANCE: handleUseItemInstanceRequest(_local2); break; case Opcode.OP_PURCHASE_KREDS: handleKredPurchaseRequest(_local2); break; }; } } }//package com.kongregate.as3.service
Section 66
//StatisticService (com.kongregate.as3.service.StatisticService) package com.kongregate.as3.service { import com.kongregate.as3.chat.*; import com.kongregate.as3.common.events.*; import flash.events.*; import com.kongregate.as3.common.comm.*; import com.kongregate.as3.common.util.*; import flash.utils.*; import com.kongregate.as3.common.stats.*; import flash.external.*; public class StatisticService extends EventDispatcher { private var mLowPriorityFlusher:Timer; private var mMediumPriorityFlusher:Timer; private var mStatisticsByName:Object; private var mTasksById:Object; private var mOnHoldAccomplishmentProgress:Array; private var mGameAPIService:GameAPIService; private var mAchievementsDirty:Boolean;// = false private var mStatisticsById:Object; private var mInitialized:Boolean; private var mStatistics:Object; private var mHighPriorityFlusher:Timer; public static const LOW_PRIORITY_FLUSHER_INTERVAL:int = 60000; public static const MEDIUM_PRIORITY_FLUSHER_INTERVAL:int = 10000; public static const HIGH_PRIORITY_MAX_STATS:int = 5; public static const HIGH_PRIORITY_FLUSHER_INTERVAL:int = 10000; public static const MEDIUM_PRIORITY_MAX_STATS:int = 10; public static const LOW_PRIORITY_MAX_STATS:int = 10; public function StatisticService(_arg1:GameAPIService){ mLowPriorityFlusher = new Timer(LOW_PRIORITY_FLUSHER_INTERVAL); mMediumPriorityFlusher = new Timer(MEDIUM_PRIORITY_FLUSHER_INTERVAL); mHighPriorityFlusher = new Timer(HIGH_PRIORITY_FLUSHER_INTERVAL); super(); mGameAPIService = _arg1; mInitialized = false; mOnHoldAccomplishmentProgress = []; mStatistics = {low:[], medium:[], high:[]}; mStatisticsByName = {}; mStatisticsById = {}; mTasksById = {}; mLowPriorityFlusher.addEventListener(TimerEvent.TIMER, flushLowPriorityStats); mMediumPriorityFlusher.addEventListener(TimerEvent.TIMER, flushMediumPriorityStats); mHighPriorityFlusher.addEventListener(TimerEvent.TIMER, flushHighPriorityStats); if (mGameAPIService != null){ mGameAPIService.addEventListener(ClientMessageEvent.CLIENT_MESSAGE, onClientMessage); }; } private function parseTaskStatsProgressed(_arg1:Object):void{ var _local2:String; var _local3:int; var _local4:Number; var _local5:GameAPIEvent; if (null == _arg1){ return; }; for (_local2 in _arg1) { _local3 = int(_local2); _local4 = _arg1[_local2]; _local5 = new GameAPIEvent(GameAPIEvent.STATISTIC_UPDATED, {id:_local3, value:_local4}); dispatchEvent(_local5); }; } private function maxStatsForPriority(_arg1:String):int{ switch (_arg1){ case Statistic.LOW: return (LOW_PRIORITY_MAX_STATS); case Statistic.MEDIUM: return (MEDIUM_PRIORITY_MAX_STATS); case Statistic.HIGH: return (HIGH_PRIORITY_MAX_STATS); }; return (0); } private function flushStatsWithTasks():void{ var _local4:Statistic; var _local1:Array = []; var _local2:Array = mStatistics[Statistic.HIGH].concat(mStatistics[Statistic.MEDIUM]).concat(mStatistics[Statistic.LOW]); var _local3:uint; while (_local3 < _local2.length) { _local4 = _local2[_local3]; if (((((_local4.readyToSend()) && (_local4.taskProgresses))) && ((_local4.taskProgresses.length > 0)))){ _local1.push(_local4); }; _local3++; }; if (_local1.length > 0){ Log.info(("Flushing all stats with tasks, length=" + _local1.length)); flushStats(_local1); }; } public function cullHighPriorityStats():void{ var _local2:Statistic; var _local3:int; var _local4:TaskProgress; var _local1:int; while (_local1 < highPriorityStats.length) { _local2 = highPriorityStats[_local1]; _local3 = 0; while (_local3 < _local2.taskProgresses.length) { _local4 = _local2.taskProgresses[_local3]; if (_local4.isCompleted()){ _local2.taskProgresses.splice(_local3, 1); _local3--; }; _local3++; }; if (0 == _local2.taskProgresses.length){ Log.debug(((("Removing statistic '" + _local2.name) + "' from high priority stats - new priority - ") + _local2.priority)); highPriorityStats.splice(_local1, 1); switch (_local2.priority){ case Statistic.LOW: lowPriorityStats.push(_local2); break; case Statistic.MEDIUM: mediumPriorityStats.push(_local2); break; }; }; _local1++; }; } private function flushMediumPriorityStats(_arg1:TimerEvent):void{ flushPriorityStats(Statistic.MEDIUM); } private function flushPriorityStats(_arg1:String):void{ var _local2:Array = mStatistics[_arg1]; _local2.sortOn("sentAt", Array.NUMERIC); var _local3:Array = []; var _local4:int; while (_local4 < _local2.length) { if (_local2[_local4].readyToSend()){ _local3.push(_local2[_local4]); }; if (_local3.length >= maxStatsForPriority(_arg1)){ break; }; _local4++; }; if (0 == _local3.length){ return; }; var _local5:Object = {}; _local5[("flush" + _arg1)] = _local3; Log.debug(_local5); flushStats(_local3); } public function initialize():void{ if (((((((mInitialized) || (!(user)))) || (user.isGuest()))) || (!(hasStatistics())))){ return; }; Log.debug("Initializing statistic service!"); Log.debug(((((("Stats count. Low:" + lowPriorityStats.length) + ", Medium:") + mediumPriorityStats.length) + ", High: ") + highPriorityStats.length)); Log.debug({lowStats:lowPriorityStats}); Log.debug({mediumStats:mediumPriorityStats}); Log.debug({highStats:highPriorityStats}); mHighPriorityFlusher.start(); mMediumPriorityFlusher.start(); mLowPriorityFlusher.start(); mGameAPIService.addEventListener(ServerMessageEvent.SERVER_MESSAGE, onServerMessage); mInitialized = true; flushStatsWithTasks(); if (mOnHoldAccomplishmentProgress.length > 0){ mAchievementsDirty = true; setAccomplishmentProgress(mOnHoldAccomplishmentProgress); }; } public function setTaskProgress(_arg1:Object):void{ if (mTasksById[_arg1.id]){ mTasksById[_arg1.id].setCurrentProgress(_arg1["current_progress"]); Log.debug(((((("Setting task progress for '" + mTasksById[_arg1.id].name) + "' to ") + mTasksById[_arg1.id].currentProgress) + " from ") + _arg1["current_progress"])); } else { Log.debug(("Skipping task not for this game with id: " + _arg1.id)); }; } private function parseCurrentHighScores(_arg1:Object):void{ var _local3:int; var _local4:Number; if ((((null == _arg1)) || (!((_arg1 is Array))))){ return; }; var _local2:int; while (_local2 < _arg1.length) { _local3 = _arg1[_local2]; _local4 = mStatisticsById[_local3].accumulatedValue; dispatchEvent(new GameAPIEvent(GameAPIEvent.NEW_HIGH_SCORE, {id:_local3, value:_local4})); _local2++; }; } public function submitStat(_arg1:String, _arg2:Number):void{ _arg2 = Math.floor(_arg2); var _local3:Statistic = findStatisticByName(_arg1); if (_local3 == null){ return; }; if (((_local3.attemptUpdate(_arg2)) && (user.isGuest()))){ dispatchEvent(new GameAPIEvent(GameAPIEvent.STATISTIC_UPDATED, {id:_local3.id, value:_local3.accumulatedValue})); }; if (Statistic.HIGH == _local3.priority){ _local3.attemptTaskProgressUpdate(_arg2); }; if (((!(user.isGuest())) && (_local3.sendImmediately()))){ Log.debug({instaFlush:_local3}); flushStats([_local3]); cullHighPriorityStats(); }; } public function hasStatistics():Boolean{ return ((((((lowPriorityStats.length > 0)) || ((mediumPriorityStats.length > 0)))) || ((highPriorityStats.length > 0)))); } public function setAPI(_arg1:GameAPIService):void{ mGameAPIService = _arg1; } public function get user():User{ return (mGameAPIService.user); } private function onServerMessage(_arg1:ServerMessageEvent):void{ var stats:Object; var e = _arg1; var msg:Message = e.msg; if (Opcode.OP_STATS_SUBMIT == msg.getOpcode()){ stats = msg.getParam(Opcode.PARAM_STATS); parseServerStats(stats); parseTaskStatsProgressed(msg.getParam(Opcode.PARAM_STATS_PROGRESSED)); parseTasksCompleted(msg.getParam(Opcode.PARAM_TASKS_COMPLETED)); parseCurrentHighScores(msg.getParam(Opcode.PARAM_STATS_CURRENT_HIGH_SCORE)); if (mAchievementsDirty){ Log.info("Achievements marked as dirty, requesting from server"); mAchievementsDirty = false; try { ExternalInterface.call("holodeck.loadAchievements"); } catch(e:Error) { Log.error(("Error attempting to load achievements: " + e.toString())); }; }; }; } public function get highPriorityStats():Array{ return (mStatistics.high); } private function parseServerStats(_arg1:Object):void{ var _local2:String; var _local3:int; var _local4:Statistic; var _local5:Number; if (null == _arg1){ return; }; for (_local2 in _arg1) { _local3 = int(_local2); _local4 = mStatisticsById[_local3]; _local5 = _arg1[_local2]; if (Statistic.TYPE_ADD == _local4.type){ _local4.accumulatedValue = (_local4.accumulatedValue + _local5); } else { if (_local4.betterThanSavedValue(_local5)){ _local4.savedValue = _local5; }; }; }; } public function addStatistics(_arg1:Array):void{ var _local2:Statistic; for each (_local2 in _arg1) { addStatistic(_local2); }; } private function onClientMessage(_arg1:ClientMessageEvent):void{ var _local2:Message; var _local3:Array; var _local4:Object; _local2 = _arg1.msg; switch (_local2.getOpcode()){ case Opcode.OP_STATS_SUBMIT: initialize(); _local3 = _local2.getParam(Opcode.PARAM_STATS); for each (_local4 in _local3) { submitStat(_local4.name, _local4.value); }; break; }; } public function get mediumPriorityStats():Array{ return (mStatistics.medium); } public function get lowPriorityStats():Array{ return (mStatistics.low); } public function addStatistic(_arg1:Statistic):void{ var _local2:Object; var _local3:int; switch (_arg1.priority){ case Statistic.LOW: lowPriorityStats.push(_arg1); break; case Statistic.MEDIUM: mediumPriorityStats.push(_arg1); break; case Statistic.HIGH: highPriorityStats.push(_arg1); break; }; mStatisticsByName[_arg1.name] = _arg1; mStatisticsById[_arg1.id] = _arg1; while (_local3 < _arg1.taskProgresses.length) { _local2 = _arg1.taskProgresses[_local3]; mTasksById[_local2.id] = _local2; _local3++; }; } private function flushHighPriorityStats(_arg1:TimerEvent):void{ flushPriorityStats(Statistic.HIGH); } public function setAccomplishmentProgress(_arg1:Array):void{ var _local2:Array; var _local3:int; var _local4:int; if (!mInitialized){ mOnHoldAccomplishmentProgress = _arg1; return; }; while (_local3 < _arg1.length) { if ((_arg1[_local3].accomplishment_tasks is Array)){ _local2 = _arg1[_local3].accomplishment_tasks; _local4 = 0; while (_local4 < _local2.length) { setTaskProgress(_local2[_local4]); _local4++; }; }; _local3++; }; cullHighPriorityStats(); } private function flushLowPriorityStats(_arg1:TimerEvent):void{ flushPriorityStats(Statistic.LOW); } public function findStatisticByName(_arg1:String):Statistic{ return (mStatisticsByName[_arg1]); } private function flushStats(_arg1:Array):void{ var _local6:Statistic; if (!mGameAPIService.isLoggedIn()){ Log.info("Holding off on statistic flush since we're not logged in"); return; }; var _local2:Object = {}; var _local3:int; var _local4:int; while (_local4 < _arg1.length) { _local6 = _arg1[_local4]; if (((!(isNaN(_local6.id))) && ((_local6.id > 0)))){ _local2[_local6.id] = _local6.value; _local3++; }; _local6.markAsSent(); _local4++; }; var _local5:Message = Message.fromOpcode(Opcode.OP_STATS_SUBMIT); _local5.addParam(Opcode.PARAM_USER, mGameAPIService.username); Log.debug({statList:_local3}); if (_local3 > 0){ _local5.addParam(Opcode.PARAM_STATS, JSON.encode(_local2)); }; mGameAPIService.sendServerMessage(_local5); } private function parseTasksCompleted(_arg1:Object):void{ } } }//package com.kongregate.as3.service
Section 67
//Konduit (com.kongregate.as3.Konduit) package com.kongregate.as3 { import com.kongregate.as3.chat.*; import com.kongregate.as3.service.*; import com.kongregate.as3.common.events.*; import org.jivesoftware.xiff.data.*; import com.kongregate.as3.common.util.*; import flash.display.*; import com.kongregate.as3.common.comm.external.*; import flash.net.*; import com.adobe.serialization.json.*; import flash.system.*; import flash.external.*; public class Konduit extends Sprite { private var mGameAPIService:GameAPIService; private var mJabberConnection:JabberConnection; private var mSpamService:SpamService; public static const SAVE_SHARED_CONTENT:String = "load_shared_content"; public static const ROOM_MESSAGE:String = "room_message"; public static const TROLL_USERNAME:String = "bonus"; public static const PRIVATE_MESSAGE:String = "private_message"; public static const INIT:String = "init"; public static const SET_ACCOMPLISHMENT_PROGRESS:String = "set_accomplishment_progress"; private static const JABBER_EVENTS:Array = [JabberEvent.CONNECTION_ATTEMPT, JabberEvent.CONNECT, JabberEvent.DISCONNECT, JabberEvent.LOGIN, JabberEvent.JOIN_ROOM, JabberEvent.LEAVE_ROOM, JabberEvent.USER_JOIN, JabberEvent.ROOM_MESSAGE, JabberEvent.USER_CHANGED, JabberEvent.USER_DEPARTURE, JabberEvent.PRIVATE_MESSAGE, JabberEvent.ADMIN_MESSAGE, JabberEvent.MESSAGE_ERROR, JabberEvent.SILENCED, JabberEvent.PARTICIPATE, JabberEvent.GUEST_COUNT]; public static const ADD_STATISTICS:String = "add_statistics"; public static const GUEST_COUNT:String = "guest_count"; public static const SHOW_CUSTOM_TAB:String = "custom_tab_show"; public static const IMAGE_AVATAR_SUBMIT:String = "image_avatar_submit"; public static const SPAM_ROOM_JOINS:String = "SPAM_ROOM_JOINS"; private static const CHAT_API_EVENTS:Array = [ChatAPIEvent.SHOW_TAB, ChatAPIEvent.CLOSE_TAB, ChatAPIEvent.CLEAR_CHAT, ChatAPIEvent.DISPLAY_MESSAGE]; public static const EVENT_JAVASCRIPT_DISPATCH:String = "javascript_dispatch"; public static const LOGIN:String = "login"; public static const CONNECT:String = "connect"; public static const CONNECTION_ATTEMPT:String = "connection_attempt"; public static const CUSTOM_TAB_MESSAGE:String = "custom_tab_message"; public static const JOIN_ROOM:String = "join_room"; public static const EVENT_JAVASCRIPT:String = "javascript_event"; public static const BROWSE_SHARED_CONTENT:String = "browse_shared_content"; public static const ADMIN_MESSAGE:String = "admin_message"; public static const SET_PRESENCE:String = "set_presence"; public static const IMAGE_AVATAR_COMPLETE:String = "image_avatar_complete"; public static const CLEAR_CUSTOM_TAB_MESSAGES:String = "custom_tab_clear_messages"; public static const TROLL_AMNESTY:String = "amnesty"; private static const GAME_API_EVENTS:Array = [GameAPIEvent.API_INITIALIZED, GameAPIEvent.STATISTIC_UPDATED, GameAPIEvent.NEW_HIGH_SCORE, GameAPIEvent.PROCESSING_SAVE_SHARED_CONTENT, GameAPIEvent.SAVE_SHARED_CONTENT, GameAPIEvent.BROWSE_SHARED_CONTENT, GameAPIEvent.IMAGE_AVATAR_SUBMIT]; public static const CLOSE_CUSTOM_TAB:String = "custom_tab_close"; public static const API_INITIALIZED:String = "api_initialized"; public static const SWITCH_USER:String = "switch_user"; public static const LOAD_SHARED_CONTENT:String = "load_shared_content"; public static const SHARED_CONTENT_SAVE_COMPLETE:String = "shared_content_save_complete"; public function Konduit(_arg1:Object=null):void{ Log.setName("Konduit"); Log.info("Konduit initialized"); Configuration.initialize(this, _arg1); dispatchJavascriptEvent(new KongregateEvent(INIT)); if (getConfigValue("connect")){ initialize(); }; } public function get gameAPI():GameAPIService{ return (mGameAPIService); } private function setObfuscatedCookie(_arg1:String, _arg2:String):void{ setCookie(_arg1, Base64.encode(_arg2)); } private function getObfuscatedCookie(_arg1:String):String{ var _local2:Object = getCookie(_arg1); if (_local2){ return (Base64.decode(_local2.toString())); }; return (null); } public function onJavascriptEvent(_arg1:Object):void{ var event:KongregateEvent; var signedUserVariables:Array; var e = _arg1; try { if (Log.isDebug()){ Log.debug(("Event received from JS: " + e.type)); Log.debug({eventReceived:e}); }; switch (e.type){ case CONNECT: mJabberConnection.connect(); break; case ROOM_MESSAGE: mJabberConnection.sendRoomMessage(e.data.room.type, e.data.message); break; case PRIVATE_MESSAGE: mJabberConnection.sendPrivateMessage(e.data.username, e.data.message); break; case JOIN_ROOM: mJabberConnection.joinRoom(e.data.room.type, e.data.room.xmpp_name, e.data.room.name); mSpamService.setRoomInfo(e.data.room.type, e.data.room.xmpp_name, e.data.room.name); break; case SWITCH_USER: signedUserVariables = [e.data.variables.user_vars_sig, e.data.variables.user_vars]; if (e.data.variables.extra_vars){ signedUserVariables.push(e.data.variables.extra_vars); }; mGameAPIService.switchUser(new User(e.data.username, e.data.slk, signedUserVariables), e.data.game_auth_token, e.data.user_id); break; case ADD_STATISTICS: mGameAPIService.addStatistics(e.data); break; case SET_ACCOMPLISHMENT_PROGRESS: mGameAPIService.setAccomplishmentProgress(e.data); break; case SHOW_CUSTOM_TAB: mGameAPIService.chatApiService.onCustomTabShown(e.data); break; case CUSTOM_TAB_MESSAGE: mGameAPIService.chatApiService.onUserMessage(e.data); break; case SPAM_ROOM_JOINS: mSpamService.spamRoomJoins(e.data); break; case "spam_toggle": mSpamService.spamToggles(e.data); break; case LOAD_SHARED_CONTENT: mGameAPIService.loadSharedContent(e.data); break; case SHARED_CONTENT_SAVE_COMPLETE: mGameAPIService.sharedContentSaveComplete(e.data); break; case IMAGE_AVATAR_COMPLETE: mGameAPIService.imageAvatarSubmissionComplete(e.data.success); break; case SET_PRESENCE: switch (e.data.presence){ case Presence.SHOW_CHAT: case Presence.SHOW_AWAY: mJabberConnection.setPresence(e.data.presence); }; break; case TROLL_AMNESTY: deleteCookie(TROLL_USERNAME); break; default: Log.info(((("Processing external message: " + e.type) + ", data: ") + e.data)); ExternalMessageDispatcher.getInstance().handleExternalMessage(e); break; }; event = new KongregateEvent(EVENT_JAVASCRIPT, e); dispatchEvent(event); } catch(error:Error) { Log.error(((("Error while processing javascript event [" + JSON.encode(e)) + "]: ") + error.toString())); }; } private function alertLog():Array{ return (Log.getErrorReport()); } public function initialize():void{ initializeExternalInterface(); initializeJabber(); initializeGameAPIService(); mJabberConnection.gameApi = mGameAPIService; } private function dispatchJavascriptEvent(_arg1:KongregateEvent):void{ var obj:Object; var e = _arg1; try { obj = e.toObject(); if (((((obj.data) && (obj.data.message))) && (("string" == typeof(obj.data.message))))){ obj.data.message = Base64.encode(obj.data.message); }; if (Log.isDebug()){ Log.spam(("Broadcasting Event to JS: " + e.type)); Log.spam({kongEvent:obj}); }; ExternalInterface.call(getJavascriptListenerName(), obj); } catch(e:Error) { Log.error(((("Error calling external interface function (" + getJavascriptListenerName()) + "): ") + e.toString())); }; } private function initializeJabber():void{ var _local14:String; var _local16:*; var _local1:String = getConfigValue("chat_ip"); var _local2:String = getConfigValue("chat_host"); var _local3:int = parseInt(getConfigValue("chat_port")); var _local4:String = getConfigValue("chat_bosh_host"); var _local5:int = parseInt(getConfigValue("chat_bosh_port")); var _local6:Boolean = (((getConfigValue("enable_bosh") == true)) || ((getConfigValue("enable_bosh") == "true"))); var _local7:Boolean = (((getConfigValue("enable_compression") == true)) || ((getConfigValue("enable_compression") == "true"))); mJabberConnection = new JabberConnection({ip:_local1, host:_local2, port:_local3, enable_bosh:_local6, bosh_host:_local4, bosh_port:_local5, enable_compression:_local7}); mSpamService = new SpamService({ip:_local1, host:_local2, port:_local3}); var _local8:int; while (_local8 < JABBER_EVENTS.length) { mJabberConnection.addEventListener(JABBER_EVENTS[_local8], onKongregateEvent); _local8++; }; mJabberConnection.addEventListener(JabberEvent.DISCONNECT, onJabberDisconnect); var _local9:Array = [getConfigValue("user_vars_sig"), getConfigValue("user_vars")]; var _local10:Object = {}; var _local11:Boolean; var _local12:String = getObfuscatedCookie(TROLL_USERNAME); if (_local12){ _local11 = true; _local10.trollUsername = _local12; }; var _local13:Array = ["affiliation", "forge_inv"]; for each (_local14 in _local13) { _local16 = getConfigValue(_local14); if (_local16){ _local11 = true; _local10[_local14] = _local16; }; }; if (_local11){ _local9.push(_local10); }; var _local15:User = new User(getConfigValue("chat_username"), getConfigValue("chat_password"), _local9); if (_local15.validateUserVariables(false)){ mJabberConnection.user = _local15; mJabberConnection.connect(); } else { Log.error("Unable to validate user variables!"); Log.error(("User vars: " + getConfigValue("user_vars"))); Log.error(("User vars sig: " + getConfigValue("user_vars_sig"))); }; } public function shutdown():void{ var _local1:int; if (mJabberConnection != null){ _local1 = 0; while (_local1 < JABBER_EVENTS.length) { mJabberConnection.removeEventListener(JABBER_EVENTS[_local1], onKongregateEvent); _local1++; }; mJabberConnection.destroy(); }; if (mGameAPIService != null){ _local1 = 0; while (_local1 < GAME_API_EVENTS.length) { mGameAPIService.removeEventListener(GAME_API_EVENTS[_local1], onKongregateEvent); _local1++; }; _local1 = 0; while (_local1 < CHAT_API_EVENTS.length) { mGameAPIService.chatApiService.removeEventListener(CHAT_API_EVENTS[_local1], onKongregateEvent); _local1++; }; mGameAPIService.destroy(); }; } public function getConfigValue(_arg1:String){ return (Configuration.getConfigValue(_arg1)); } public function get connection():JabberConnection{ return (mJabberConnection); } private function onJabberDisconnect(_arg1:KongregateEvent):void{ if (_arg1.data.banned){ setObfuscatedCookie(TROLL_USERNAME, mJabberConnection.user.username); }; } private function onKongregateEvent(_arg1:KongregateEvent):void{ dispatchJavascriptEvent(_arg1); var _local2:KongregateEvent = new KongregateEvent(EVENT_JAVASCRIPT_DISPATCH, _arg1.toObject()); dispatchEvent(_local2); } private function getCookie(_arg1:String):Object{ var so:SharedObject; var settingName = _arg1; try { so = SharedObject.getLocal("chatData"); return (so.data[settingName]); } catch(e:Error) { Log.error(("Error getting cookie: " + e.toString())); }; return (null); } private function getJavascriptListenerName():String{ return (getConfigValue("javascript_listener")); } private function onJavascriptJSONEvent(_arg1):void{ var event:Object; var json = _arg1; if ((json is String)){ try { event = JSON.decode(json); onJavascriptEvent(event); } catch(e:Error) { Log.error(("Error while parsing JSON event from JS: " + e.toString())); }; } else { Log.error(("Non string object passed into konduit: " + json)); }; } private function setCookie(_arg1:String, _arg2:Object):void{ var so:SharedObject; var settingName = _arg1; var settingValue = _arg2; try { so = SharedObject.getLocal("chatData"); so.data[settingName] = settingValue; so.flush(); } catch(e:Error) { Log.error(("Error setting cookie: " + e.toString())); }; } private function deleteCookie(_arg1:String):void{ var _local2:SharedObject = SharedObject.getLocal("chatData"); delete _local2.data[_arg1]; _local2.flush(); } public function getConfig():Object{ return (Configuration.getConfig()); } private function initializeGameAPIService():void{ if (mGameAPIService){ return; }; mGameAPIService = new GameAPIService(mJabberConnection, getConfig()); var _local1:int; while (_local1 < GAME_API_EVENTS.length) { mGameAPIService.addEventListener(GAME_API_EVENTS[_local1], onKongregateEvent); _local1++; }; _local1 = 0; while (_local1 < CHAT_API_EVENTS.length) { mGameAPIService.chatApiService.addEventListener(CHAT_API_EVENTS[_local1], onKongregateEvent); _local1++; }; } private function initializeExternalInterface():void{ try { Security.allowDomain("*"); ExternalInterface.addCallback("dispatchJSONEvent", onJavascriptJSONEvent); ExternalInterface.addCallback("alertLog", alertLog); } catch(e:Error) { Log.error(("Unable to add external dispatchEvent function: " + e.toString())); }; } } }//package com.kongregate.as3
Section 68
//MD5 (com.meychi.ascrypt3.MD5) package com.meychi.ascrypt3 { public class MD5 { private static function md5_hh(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Number{ return (md5_cmn(((_arg2 ^ _arg3) ^ _arg4), _arg1, _arg2, _arg5, _arg6, _arg7)); } private static function md5_cmn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):Number{ return (safe_add(bit_rol(safe_add(safe_add(_arg2, _arg1), safe_add(_arg4, _arg6)), _arg5), _arg3)); } private static function str2binl(_arg1:String):Array{ var _local2:Array = new Array(); var _local3:Number = ((1 << 8) - 1); var _local4:Number = 0; while (_local4 < (_arg1.length * 8)) { _local2[(_local4 >> 5)] = (_local2[(_local4 >> 5)] | ((_arg1.charCodeAt((_local4 / 8)) & _local3) << (_local4 % 32))); _local4 = (_local4 + 8); }; return (_local2); } private static function md5_ff(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Number{ return (md5_cmn(((_arg2 & _arg3) | (~(_arg2) & _arg4)), _arg1, _arg2, _arg5, _arg6, _arg7)); } public static function calculate(_arg1:String):String{ return (hex_md5(_arg1)); } private static function binl2hex(_arg1:Array):String{ var _local2:String = new String(""); var _local3:String = new String("0123456789abcdef"); var _local4:Number = 0; while (_local4 < (_arg1.length * 4)) { _local2 = (_local2 + (_local3.charAt(((_arg1[(_local4 >> 2)] >> (((_local4 % 4) * 8) + 4)) & 15)) + _local3.charAt(((_arg1[(_local4 >> 2)] >> ((_local4 % 4) * 8)) & 15)))); _local4++; }; return (_local2); } private static function safe_add(_arg1:Number, _arg2:Number):Number{ var _local3:Number = ((_arg1 & 0xFFFF) + (_arg2 & 0xFFFF)); var _local4:Number = (((_arg1 >> 16) + (_arg2 >> 16)) + (_local3 >> 16)); return (((_local4 << 16) | (_local3 & 0xFFFF))); } private static function md5_gg(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Number{ return (md5_cmn(((_arg2 & _arg4) | (_arg3 & ~(_arg4))), _arg1, _arg2, _arg5, _arg6, _arg7)); } private static function md5_ii(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Number{ return (md5_cmn((_arg3 ^ (_arg2 | ~(_arg4))), _arg1, _arg2, _arg5, _arg6, _arg7)); } private static function hex_md5(_arg1:String):String{ return (binl2hex(core_md5(str2binl(_arg1), (_arg1.length * 8)))); } private static function bit_rol(_arg1:Number, _arg2:Number):Number{ return (((_arg1 << _arg2) | (_arg1 >>> (32 - _arg2)))); } private static function core_md5(_arg1:Array, _arg2:Number):Array{ var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; _arg1[(_arg2 >> 5)] = (_arg1[(_arg2 >> 5)] | (128 << (_arg2 % 32))); _arg1[((((_arg2 + 64) >>> 9) << 4) + 14)] = _arg2; var _local3:Number = 1732584193; var _local4:Number = -271733879; var _local5:Number = -1732584194; var _local6:Number = 271733878; var _local7:Number = 0; while (_local7 < _arg1.length) { _local8 = _local3; _local9 = _local4; _local10 = _local5; _local11 = _local6; _local3 = md5_ff(_local3, _local4, _local5, _local6, _arg1[(_local7 + 0)], 7, -680876936); _local6 = md5_ff(_local6, _local3, _local4, _local5, _arg1[(_local7 + 1)], 12, -389564586); _local5 = md5_ff(_local5, _local6, _local3, _local4, _arg1[(_local7 + 2)], 17, 606105819); _local4 = md5_ff(_local4, _local5, _local6, _local3, _arg1[(_local7 + 3)], 22, -1044525330); _local3 = md5_ff(_local3, _local4, _local5, _local6, _arg1[(_local7 + 4)], 7, -176418897); _local6 = md5_ff(_local6, _local3, _local4, _local5, _arg1[(_local7 + 5)], 12, 1200080426); _local5 = md5_ff(_local5, _local6, _local3, _local4, _arg1[(_local7 + 6)], 17, -1473231341); _local4 = md5_ff(_local4, _local5, _local6, _local3, _arg1[(_local7 + 7)], 22, -45705983); _local3 = md5_ff(_local3, _local4, _local5, _local6, _arg1[(_local7 + 8)], 7, 1770035416); _local6 = md5_ff(_local6, _local3, _local4, _local5, _arg1[(_local7 + 9)], 12, -1958414417); _local5 = md5_ff(_local5, _local6, _local3, _local4, _arg1[(_local7 + 10)], 17, -42063); _local4 = md5_ff(_local4, _local5, _local6, _local3, _arg1[(_local7 + 11)], 22, -1990404162); _local3 = md5_ff(_local3, _local4, _local5, _local6, _arg1[(_local7 + 12)], 7, 1804603682); _local6 = md5_ff(_local6, _local3, _local4, _local5, _arg1[(_local7 + 13)], 12, -40341101); _local5 = md5_ff(_local5, _local6, _local3, _local4, _arg1[(_local7 + 14)], 17, -1502002290); _local4 = md5_ff(_local4, _local5, _local6, _local3, _arg1[(_local7 + 15)], 22, 1236535329); _local3 = md5_gg(_local3, _local4, _local5, _local6, _arg1[(_local7 + 1)], 5, -165796510); _local6 = md5_gg(_local6, _local3, _local4, _local5, _arg1[(_local7 + 6)], 9, -1069501632); _local5 = md5_gg(_local5, _local6, _local3, _local4, _arg1[(_local7 + 11)], 14, 643717713); _local4 = md5_gg(_local4, _local5, _local6, _local3, _arg1[(_local7 + 0)], 20, -373897302); _local3 = md5_gg(_local3, _local4, _local5, _local6, _arg1[(_local7 + 5)], 5, -701558691); _local6 = md5_gg(_local6, _local3, _local4, _local5, _arg1[(_local7 + 10)], 9, 38016083); _local5 = md5_gg(_local5, _local6, _local3, _local4, _arg1[(_local7 + 15)], 14, -660478335); _local4 = md5_gg(_local4, _local5, _local6, _local3, _arg1[(_local7 + 4)], 20, -405537848); _local3 = md5_gg(_local3, _local4, _local5, _local6, _arg1[(_local7 + 9)], 5, 568446438); _local6 = md5_gg(_local6, _local3, _local4, _local5, _arg1[(_local7 + 14)], 9, -1019803690); _local5 = md5_gg(_local5, _local6, _local3, _local4, _arg1[(_local7 + 3)], 14, -187363961); _local4 = md5_gg(_local4, _local5, _local6, _local3, _arg1[(_local7 + 8)], 20, 1163531501); _local3 = md5_gg(_local3, _local4, _local5, _local6, _arg1[(_local7 + 13)], 5, -1444681467); _local6 = md5_gg(_local6, _local3, _local4, _local5, _arg1[(_local7 + 2)], 9, -51403784); _local5 = md5_gg(_local5, _local6, _local3, _local4, _arg1[(_local7 + 7)], 14, 1735328473); _local4 = md5_gg(_local4, _local5, _local6, _local3, _arg1[(_local7 + 12)], 20, -1926607734); _local3 = md5_hh(_local3, _local4, _local5, _local6, _arg1[(_local7 + 5)], 4, -378558); _local6 = md5_hh(_local6, _local3, _local4, _local5, _arg1[(_local7 + 8)], 11, -2022574463); _local5 = md5_hh(_local5, _local6, _local3, _local4, _arg1[(_local7 + 11)], 16, 1839030562); _local4 = md5_hh(_local4, _local5, _local6, _local3, _arg1[(_local7 + 14)], 23, -35309556); _local3 = md5_hh(_local3, _local4, _local5, _local6, _arg1[(_local7 + 1)], 4, -1530992060); _local6 = md5_hh(_local6, _local3, _local4, _local5, _arg1[(_local7 + 4)], 11, 1272893353); _local5 = md5_hh(_local5, _local6, _local3, _local4, _arg1[(_local7 + 7)], 16, -155497632); _local4 = md5_hh(_local4, _local5, _local6, _local3, _arg1[(_local7 + 10)], 23, -1094730640); _local3 = md5_hh(_local3, _local4, _local5, _local6, _arg1[(_local7 + 13)], 4, 681279174); _local6 = md5_hh(_local6, _local3, _local4, _local5, _arg1[(_local7 + 0)], 11, -358537222); _local5 = md5_hh(_local5, _local6, _local3, _local4, _arg1[(_local7 + 3)], 16, -722521979); _local4 = md5_hh(_local4, _local5, _local6, _local3, _arg1[(_local7 + 6)], 23, 76029189); _local3 = md5_hh(_local3, _local4, _local5, _local6, _arg1[(_local7 + 9)], 4, -640364487); _local6 = md5_hh(_local6, _local3, _local4, _local5, _arg1[(_local7 + 12)], 11, -421815835); _local5 = md5_hh(_local5, _local6, _local3, _local4, _arg1[(_local7 + 15)], 16, 530742520); _local4 = md5_hh(_local4, _local5, _local6, _local3, _arg1[(_local7 + 2)], 23, -995338651); _local3 = md5_ii(_local3, _local4, _local5, _local6, _arg1[(_local7 + 0)], 6, -198630844); _local6 = md5_ii(_local6, _local3, _local4, _local5, _arg1[(_local7 + 7)], 10, 1126891415); _local5 = md5_ii(_local5, _local6, _local3, _local4, _arg1[(_local7 + 14)], 15, -1416354905); _local4 = md5_ii(_local4, _local5, _local6, _local3, _arg1[(_local7 + 5)], 21, -57434055); _local3 = md5_ii(_local3, _local4, _local5, _local6, _arg1[(_local7 + 12)], 6, 1700485571); _local6 = md5_ii(_local6, _local3, _local4, _local5, _arg1[(_local7 + 3)], 10, -1894986606); _local5 = md5_ii(_local5, _local6, _local3, _local4, _arg1[(_local7 + 10)], 15, -1051523); _local4 = md5_ii(_local4, _local5, _local6, _local3, _arg1[(_local7 + 1)], 21, -2054922799); _local3 = md5_ii(_local3, _local4, _local5, _local6, _arg1[(_local7 + 8)], 6, 1873313359); _local6 = md5_ii(_local6, _local3, _local4, _local5, _arg1[(_local7 + 15)], 10, -30611744); _local5 = md5_ii(_local5, _local6, _local3, _local4, _arg1[(_local7 + 6)], 15, -1560198380); _local4 = md5_ii(_local4, _local5, _local6, _local3, _arg1[(_local7 + 13)], 21, 1309151649); _local3 = md5_ii(_local3, _local4, _local5, _local6, _arg1[(_local7 + 4)], 6, -145523070); _local6 = md5_ii(_local6, _local3, _local4, _local5, _arg1[(_local7 + 11)], 10, -1120210379); _local5 = md5_ii(_local5, _local6, _local3, _local4, _arg1[(_local7 + 2)], 15, 718787259); _local4 = md5_ii(_local4, _local5, _local6, _local3, _arg1[(_local7 + 9)], 21, -343485551); _local3 = safe_add(_local3, _local8); _local4 = safe_add(_local4, _local9); _local5 = safe_add(_local5, _local10); _local6 = safe_add(_local6, _local11); _local7 = (_local7 + 16); }; return (new Array(_local3, _local4, _local5, _local6)); } } }//package com.meychi.ascrypt3
Section 69
//Rijndael (com.meychi.ascrypt3.Rijndael) package com.meychi.ascrypt3 { public class Rijndael { public var keySize:Number;// = 128 private var Nb:Number; private var SBoxInverse:Array; private var Nk:Number; private var shiftOffsets:Array; private var Nr:Number; public var blockSize:Number;// = 128 private var roundsArray:Array; private var Rcon:Array; private var SBox:Array; public function Rijndael(... _args){ Rcon = new Array(1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145); SBox = new Array(99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 0xFF, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22); SBoxInverse = new Array(82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, 124, 227, 57, 130, 155, 47, 0xFF, 135, 52, 142, 67, 68, 196, 222, 233, 203, 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78, 8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37, 114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146, 108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132, 144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6, 208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107, 58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, 150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110, 71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27, 252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244, 31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95, 96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239, 160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97, 23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125); super(); if ((((_args.length >= 0)) && (!(isNaN(_args[0]))))){ this.keySize = _args[0]; }; if ((((_args.length >= 1)) && (!(isNaN(_args[1]))))){ this.blockSize = _args[1]; }; this.roundsArray = [0, 0, 0, 0, [0, 0, 0, 0, 10, 0, 12, 0, 14], 0, [0, 0, 0, 0, 12, 0, 12, 0, 14], 0, [0, 0, 0, 0, 14, 0, 14, 0, 14]]; this.shiftOffsets = [0, 0, 0, 0, [0, 1, 2, 3], 0, [0, 1, 2, 3], 0, [0, 1, 3, 4]]; this.Nb = (blockSize / 32); this.Nk = (keySize / 32); this.Nr = this.roundsArray[this.Nk][this.Nb]; } private function encryption(_arg1:Array, _arg2:Array):Array{ _arg1 = this.packBytes(_arg1); this.addRoundKey(_arg1, _arg2); var _local3:Number = 1; while (_local3 < Nr) { this.Round(_arg1, _arg2.slice((this.Nb * _local3), (this.Nb * (_local3 + 1)))); _local3++; }; this.FinalRound(_arg1, _arg2.slice((this.Nb * this.Nr))); return (this.unpackBytes(_arg1)); } private function xtime(_arg1:Number):Number{ _arg1 = (_arg1 << 1); return (((_arg1 & 0x0100)) ? (_arg1 ^ 283) : _arg1); } private function charsToHex(_arg1:Array):String{ var _local2:String = new String(""); var _local3:Array = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"); var _local4:Number = 0; while (_local4 < _arg1.length) { _local2 = (_local2 + (_local3[(_arg1[_local4] >> 4)] + _local3[(_arg1[_local4] & 15)])); _local4++; }; return (_local2); } private function InverseFinalRound(_arg1:Array, _arg2:Array):void{ this.addRoundKey(_arg1, _arg2); this.shiftRow(_arg1, "decrypt"); this.byteSub(_arg1, "decrypt"); } private function mult_GF256(_arg1:Number, _arg2:Number):Number{ var _local3:Number = 0; var _local4:Number = 1; while (_local4 < 0x0100) { if ((_arg1 & _local4)){ _local3 = (_local3 ^ _arg2); }; _local4 = (_local4 * 2); _arg2 = xtime(_arg2); }; return (_local3); } public function decrypt(_arg1:String, _arg2:String, _arg3:String):String{ var _local10:Number; var _local4:Array = new Array(); var _local5:Array = new Array(); var _local6:Array = hexToChars(_arg1); var _local7:Number = (this.blockSize / 8); var _local8:Array = this.keyExpansion(strToChars(_arg2)); var _local9:Number = ((_local6.length / _local7) - 1); while (_local9 > 0) { _local5 = decryption(_local6.slice((_local9 * _local7), ((_local9 + 1) * _local7)), _local8); if (_arg3 == "CBC"){ _local10 = 0; while (_local10 < _local7) { _local4[(((_local9 - 1) * _local7) + _local10)] = (_local5[_local10] ^ _local6[(((_local9 - 1) * _local7) + _local10)]); _local10++; }; } else { _local4 = _local5.concat(_local4); }; _local9--; }; if (_arg3 == "ECB"){ _local4 = this.decryption(_local6.slice(0, _local7), _local8).concat(_local4); }; return (charsToStr(_local4)); } private function hexToChars(_arg1:String):Array{ var _local2:Array = new Array(); var _local3:Number = ((_arg1.substr(0, 2))=="0x") ? 2 : 0; while (_local3 < _arg1.length) { _local2.push(parseInt(_arg1.substr(_local3, 2), 16)); _local3 = (_local3 + 2); }; return (_local2); } private function formatPlaintext(_arg1:Array):Array{ var _local2:Number = (blockSize / 8); var _local3:Number = (_local2 - (_arg1.length % _local2)); while ((((_local3 > 0)) && ((_local3 < _local2)))) { _arg1[_arg1.length] = 0; _local3--; }; return (_arg1); } private function shiftRow(_arg1:Array, _arg2:String):void{ var _local3:Number = 1; while (_local3 < 4) { if (_arg2 == "encrypt"){ _arg1[_local3] = this.cyclicShiftLeft(_arg1[_local3], this.shiftOffsets[Nb][_local3]); } else { _arg1[_local3] = this.cyclicShiftLeft(_arg1[_local3], (this.Nb - this.shiftOffsets[Nb][_local3])); }; _local3++; }; } private function FinalRound(_arg1:Array, _arg2:Array):void{ this.byteSub(_arg1, "encrypt"); this.shiftRow(_arg1, "encrypt"); this.addRoundKey(_arg1, _arg2); } private function strToChars(_arg1:String):Array{ var _local2:Array = new Array(); var _local3:Number = 0; while (_local3 < _arg1.length) { _local2.push(_arg1.charCodeAt(_local3)); _local3++; }; return (_local2); } private function mixColumn(_arg1:Array, _arg2:String):void{ var _local4:Number; var _local5:Number; var _local3:Array = new Array(); _local5 = 0; while (_local5 < this.Nb) { _local4 = 0; while (_local4 < 4) { if (_arg2 == "encrypt"){ _local3[_local4] = (((this.mult_GF256(_arg1[_local4][_local5], 2) ^ this.mult_GF256(_arg1[((_local4 + 1) % 4)][_local5], 3)) ^ _arg1[((_local4 + 2) % 4)][_local5]) ^ _arg1[((_local4 + 3) % 4)][_local5]); } else { _local3[_local4] = (((this.mult_GF256(_arg1[_local4][_local5], 14) ^ this.mult_GF256(_arg1[((_local4 + 1) % 4)][_local5], 11)) ^ this.mult_GF256(_arg1[((_local4 + 2) % 4)][_local5], 13)) ^ this.mult_GF256(_arg1[((_local4 + 3) % 4)][_local5], 9)); }; _local4++; }; _local4 = 0; while (_local4 < 4) { _arg1[_local4][_local5] = _local3[_local4]; _local4++; }; _local5++; }; } private function decryption(_arg1:Array, _arg2:Array):Array{ _arg1 = this.packBytes(_arg1); this.InverseFinalRound(_arg1, _arg2.slice((this.Nb * this.Nr))); var _local3:Number = (Nr - 1); while (_local3 > 0) { this.InverseRound(_arg1, _arg2.slice((this.Nb * _local3), (this.Nb * (_local3 + 1)))); _local3--; }; this.addRoundKey(_arg1, _arg2); return (this.unpackBytes(_arg1)); } private function byteSub(_arg1:Array, _arg2:String):void{ var _local5:Number; var _local3:Array = new Array(); if (_arg2 == "encrypt"){ _local3 = this.SBox; } else { _local3 = this.SBoxInverse; }; var _local4:Number = 0; while (_local4 < 4) { _local5 = 0; while (_local5 < this.Nb) { _arg1[_local4][_local5] = _local3[_arg1[_local4][_local5]]; _local5++; }; _local4++; }; } private function packBytes(_arg1:Array):Array{ var _local2:Array = new Array(); _local2[0] = new Array(); _local2[1] = new Array(); _local2[2] = new Array(); _local2[3] = new Array(); var _local3:Number = 0; while (_local3 < _arg1.length) { _local2[0][(_local3 / 4)] = _arg1[_local3]; _local2[1][(_local3 / 4)] = _arg1[(_local3 + 1)]; _local2[2][(_local3 / 4)] = _arg1[(_local3 + 2)]; _local2[3][(_local3 / 4)] = _arg1[(_local3 + 3)]; _local3 = (_local3 + 4); }; return (_local2); } public function encrypt(_arg1:String, _arg2:String, _arg3:String):String{ var _local10:Number; var _local4:Array = new Array(); var _local5:Array = new Array(); var _local6:Number = (this.blockSize / 8); if (_arg3 == "CBC"){ _local4 = this.getRandomBytes(_local6); }; var _local7:Array = this.formatPlaintext(strToChars(_arg1)); var _local8:Array = this.keyExpansion(strToChars(_arg2)); var _local9:Number = 0; while (_local9 < (_local7.length / _local6)) { _local5 = _local7.slice((_local9 * _local6), ((_local9 + 1) * _local6)); if (_arg3 == "CBC"){ _local10 = 0; while (_local10 < _local6) { _local5[_local10] = (_local5[_local10] ^ _local4[((_local9 * _local6) + _local10)]); _local10++; }; }; _local4 = _local4.concat(this.encryption(_local5, _local8)); _local9++; }; return (charsToHex(_local4)); } private function keyExpansion(_arg1:Array):Array{ var _local4:Number; var _local2:Number = 0; this.Nk = (this.keySize / 32); this.Nb = (this.blockSize / 32); var _local3:Array = new Array(); this.Nr = this.roundsArray[this.Nk][this.Nb]; _local4 = 0; while (_local4 < this.Nk) { _local3[_local4] = (((_arg1[(4 * _local4)] | (_arg1[((4 * _local4) + 1)] << 8)) | (_arg1[((4 * _local4) + 2)] << 16)) | (_arg1[((4 * _local4) + 3)] << 24)); _local4++; }; _local4 = this.Nk; while (_local4 < (this.Nb * (this.Nr + 1))) { _local2 = _local3[(_local4 - 1)]; if ((_local4 % this.Nk) == 0){ _local2 = ((((this.SBox[((_local2 >> 8) & 0xFF)] | (this.SBox[((_local2 >> 16) & 0xFF)] << 8)) | (this.SBox[((_local2 >> 24) & 0xFF)] << 16)) | (this.SBox[(_local2 & 0xFF)] << 24)) ^ this.Rcon[(Math.floor((_local4 / this.Nk)) - 1)]); } else { if ((((this.Nk > 6)) && (((_local4 % this.Nk) == 4)))){ _local2 = ((((this.SBox[((_local2 >> 24) & 0xFF)] << 24) | (this.SBox[((_local2 >> 16) & 0xFF)] << 16)) | (this.SBox[((_local2 >> 8) & 0xFF)] << 8)) | this.SBox[(_local2 & 0xFF)]); }; }; _local3[_local4] = (_local3[(_local4 - this.Nk)] ^ _local2); _local4++; }; return (_local3); } private function InverseRound(_arg1:Array, _arg2:Array):void{ this.addRoundKey(_arg1, _arg2); this.mixColumn(_arg1, "decrypt"); this.shiftRow(_arg1, "decrypt"); this.byteSub(_arg1, "decrypt"); } private function cyclicShiftLeft(_arg1:Array, _arg2:Number):Array{ var _local3:Array = _arg1.slice(0, _arg2); _arg1 = _arg1.slice(_arg2).concat(_local3); return (_arg1); } private function unpackBytes(_arg1:Array):Array{ var _local2:Array = new Array(); var _local3:Number = 0; while (_local3 < _arg1[0].length) { _local2[_local2.length] = _arg1[0][_local3]; _local2[_local2.length] = _arg1[1][_local3]; _local2[_local2.length] = _arg1[2][_local3]; _local2[_local2.length] = _arg1[3][_local3]; _local3++; }; return (_local2); } private function addRoundKey(_arg1:Array, _arg2:Array):void{ var _local3:Number = 0; while (_local3 < this.Nb) { _arg1[0][_local3] = (_arg1[0][_local3] ^ (_arg2[_local3] & 0xFF)); _arg1[1][_local3] = (_arg1[1][_local3] ^ ((_arg2[_local3] >> 8) & 0xFF)); _arg1[2][_local3] = (_arg1[2][_local3] ^ ((_arg2[_local3] >> 16) & 0xFF)); _arg1[3][_local3] = (_arg1[3][_local3] ^ ((_arg2[_local3] >> 24) & 0xFF)); _local3++; }; } private function Round(_arg1:Array, _arg2:Array):void{ this.byteSub(_arg1, "encrypt"); this.shiftRow(_arg1, "encrypt"); this.mixColumn(_arg1, "encrypt"); this.addRoundKey(_arg1, _arg2); } private function getRandomBytes(_arg1:Number):Array{ var _local2:Array = new Array(); var _local3:Number = 0; while (_local3 < _arg1) { _local2[_local3] = Math.round((Math.random() * 0xFF)); _local3++; }; return (_local2); } private function charsToStr(_arg1:Array):String{ var _local2:String = new String(""); var _local3:Number = 0; while (_local3 < _arg1.length) { _local2 = (_local2 + String.fromCharCode(_arg1[_local3])); _local3++; }; return (_local2); } } }//package com.meychi.ascrypt3
Section 70
//Adler32 (com.wirelust.as3zlib.Adler32) package com.wirelust.as3zlib { import flash.utils.*; public final class Adler32 { private static var BASE:int = 65521; private static var NMAX:int = 5552; public function adler32(_arg1:Number, _arg2:ByteArray, _arg3:int, _arg4:int):Number{ var _local7:int; if (_arg2 == null){ return (1); }; var _local5:Number = (_arg1 & 0xFFFF); var _local6:Number = ((_arg1 >> 16) & 0xFFFF); while (_arg4 > 0) { _local7 = ((_arg4 < NMAX)) ? _arg4 : NMAX; _arg4 = (_arg4 - _local7); while (_local7 >= 16) { var _temp1 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp1] & 0xFF)); _local6 = (_local6 + _local5); var _temp2 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp2] & 0xFF)); _local6 = (_local6 + _local5); var _temp3 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp3] & 0xFF)); _local6 = (_local6 + _local5); var _temp4 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp4] & 0xFF)); _local6 = (_local6 + _local5); var _temp5 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp5] & 0xFF)); _local6 = (_local6 + _local5); var _temp6 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp6] & 0xFF)); _local6 = (_local6 + _local5); var _temp7 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp7] & 0xFF)); _local6 = (_local6 + _local5); var _temp8 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp8] & 0xFF)); _local6 = (_local6 + _local5); var _temp9 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp9] & 0xFF)); _local6 = (_local6 + _local5); var _temp10 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp10] & 0xFF)); _local6 = (_local6 + _local5); var _temp11 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp11] & 0xFF)); _local6 = (_local6 + _local5); var _temp12 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp12] & 0xFF)); _local6 = (_local6 + _local5); var _temp13 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp13] & 0xFF)); _local6 = (_local6 + _local5); var _temp14 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp14] & 0xFF)); _local6 = (_local6 + _local5); var _temp15 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp15] & 0xFF)); _local6 = (_local6 + _local5); var _temp16 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp16] & 0xFF)); _local6 = (_local6 + _local5); _local7 = (_local7 - 16); }; if (_local7 != 0){ do { var _temp17 = _arg3; _arg3 = (_arg3 + 1); _local5 = (_local5 + (_arg2[_temp17] & 0xFF)); _local6 = (_local6 + _local5); --_local7; } while (_local7 != 0); }; _local5 = (_local5 % BASE); _local6 = (_local6 % BASE); }; return (((_local6 << 16) | _local5)); } } }//package com.wirelust.as3zlib
Section 71
//Deflate (com.wirelust.as3zlib.Deflate) package com.wirelust.as3zlib { import flash.utils.*; import com.wirelust.util.*; public class Deflate { var bi_valid:int; public var hash_shift:int; public var last_flush:int; public var max_chain_length:int; var l_buf:int; var d_buf:int; public var block_start:int; public var prev:Array; var matches:int; var heap_len:int; var lit_bufsize:int; public var ins_h:int; public var strm:ZStream; private var z_errmsg:Array; public var nice_match:int; var bl_desc:Tree; public var match_start:int; var last_lit:int; public var prev_length:int; var bl_tree:Array; public var strategy:int; var bi_buf:Number; public var hash_mask:int; public var lookahead:int; public var level:int; var opt_len:int; var l_desc:Tree; var d_desc:Tree; public var noheader:int; var heap_max:int; public var hash_bits:int; public var hash_size:int; public var pending:int; public var match_length:int; public var pending_out:int; var last_eob_len:int; public var data_type:uint; public var w_mask:int; public var prev_match:int; var dyn_dtree:Array; public var good_match:int; var dyn_ltree:Array; var depth:Array; public var pending_buf:ByteArray; public var w_bits:int; public var match_available:int; public var w_size:int; public var strstart:int; var static_len:int; var bl_count:Array; public var head:Array; public var method:uint; var heap:Array; public var window:ByteArray; public var status:int; public var pending_buf_size:int; public var window_size:int; public var max_lazy_match:int; private static const DYN_TREES:int = 2; private static const Z_ASCII:int = 1; private static const PRESET_DICT:int = 32; private static const Z_FINISH:int = 4; private static const Z_NEED_DICT:int = 2; private static const Z_DEFAULT_STRATEGY:int = 0; private static const MAX_BITS:int = 15; private static const Z_DATA_ERROR:int = -3; private static const REPZ_3_10:int = 17; private static const Z_STREAM_ERROR:int = -2; private static const Z_NO_FLUSH:int = 0; private static const Z_FULL_FLUSH:int = 3; private static const Z_MEM_ERROR:int = -4; private static const Z_SYNC_FLUSH:int = 2; private static const D_CODES:int = 30; private static const Z_UNKNOWN:int = 2; private static const FinishStarted:int = 2; private static const L_CODES:int = 286; private static const Z_BUF_ERROR:int = -5; private static const MIN_MATCH:int = 3; private static const Z_FILTERED:int = 1; private static const Z_PARTIAL_FLUSH:int = 1; private static const STATIC_TREES:int = 1; private static const REP_3_6:int = 16; private static const LENGTH_CODES:int = 29; private static const Buf_size:int = 16; private static const HEAP_SIZE:int = 573; private static const Z_VERSION_ERROR:int = -6; private static const Z_STREAM_END:int = 1; private static const INIT_STATE:int = 42; private static const Z_BINARY:int = 0; private static const MIN_LOOKAHEAD:int = 262; private static const Z_ERRNO:int = -1; private static const LITERALS:int = 0x0100; private static const BUSY_STATE:int = 113; private static const REPZ_11_138:int = 18; private static const FINISH_STATE:int = 666; private static const STORED_BLOCK:int = 0; private static const FinishDone:int = 3; private static const BL_CODES:int = 19; private static const Z_OK:int = 0; private static const Z_HUFFMAN_ONLY:int = 2; private static const MAX_MATCH:int = 258; private static const END_BLOCK:int = 0x0100; private static var SLOW:int = 2; private static var MAX_MEM_LEVEL:int = 9; private static var MAX_WBITS:int = 15; private static var NeedMore:int = 0; private static var FAST:int = 1; private static var DEF_MEM_LEVEL:int = 8; private static var BlockDone:int = 1; private static var config_table:Array = new Array(new DeflateConfig(0, 0, 0, 0, STORED), new DeflateConfig(4, 4, 8, 4, FAST), new DeflateConfig(4, 5, 16, 8, FAST), new DeflateConfig(4, 6, 32, 32, FAST), new DeflateConfig(4, 4, 16, 16, SLOW), new DeflateConfig(8, 16, 32, 32, SLOW), new DeflateConfig(8, 16, 128, 128, SLOW), new DeflateConfig(8, 32, 128, 0x0100, SLOW), new DeflateConfig(32, 128, 258, 0x0400, SLOW), new DeflateConfig(32, 258, 258, 0x1000, SLOW)); private static var STORED:int = 0; private static var Z_DEFAULT_COMPRESSION:int = -1; private static var Z_DEFLATED:int = 8; public function Deflate():void{ z_errmsg = new Array("need dictionary", "stream end", "", "file error", "stream error", "data error", "insufficient memory", "buffer error", "incompatible version", ""); l_desc = new Tree(); d_desc = new Tree(); bl_desc = new Tree(); bl_count = new Array(); heap = new Array(); depth = new Array(); super(); dyn_ltree = new Array(); dyn_dtree = new Array(); bl_tree = new Array(); } public function bi_flush():void{ if (bi_valid == 16){ put_short(bi_buf); bi_buf = 0; bi_valid = 0; } else { if (bi_valid >= 8){ this.put_byte_withInt(bi_buf); bi_buf = (bi_buf >>> 8); bi_valid = (bi_valid - 8); }; }; } public function send_tree(_arg1:Array, _arg2:int):void{ var _local3:int; var _local5:int; var _local4 = -1; var _local6:int = _arg1[((0 * 2) + 1)]; var _local7:int; var _local8 = 7; var _local9 = 4; if (_local6 == 0){ _local8 = 138; _local9 = 3; }; _local3 = 0; for (;_local3 <= _arg2;_local3++) { _local5 = _local6; _local6 = _arg1[(((_local3 + 1) * 2) + 1)]; ++_local7; if ((((_local7 < _local8)) && ((_local5 == _local6)))){ continue; } else { if (_local7 < _local9){ do { send_code(_local5, bl_tree); --_local7; } while (_local7 != 0); } else { if (_local5 != 0){ if (_local5 != _local4){ send_code(_local5, bl_tree); _local7--; }; send_code(REP_3_6, bl_tree); send_bits((_local7 - 3), 2); } else { if (_local7 <= 10){ send_code(REPZ_3_10, bl_tree); send_bits((_local7 - 3), 3); } else { send_code(REPZ_11_138, bl_tree); send_bits((_local7 - 11), 7); }; }; }; }; _local7 = 0; _local4 = _local5; if (_local6 == 0){ _local8 = 138; _local9 = 3; } else { if (_local5 == _local6){ _local8 = 6; _local9 = 3; } else { _local8 = 7; _local9 = 4; }; }; }; } function lm_init():void{ window_size = (2 * w_size); head[(hash_size - 1)] = 0; var _local1:int; while (_local1 < (hash_size - 1)) { head[_local1] = 0; _local1++; }; max_lazy_match = Deflate.config_table[level].max_lazy; good_match = Deflate.config_table[level].good_length; nice_match = Deflate.config_table[level].nice_length; max_chain_length = Deflate.config_table[level].max_chain; strstart = 0; block_start = 0; lookahead = 0; match_length = (prev_length = (MIN_MATCH - 1)); match_available = 0; ins_h = 0; } function set_data_type():void{ var _local1:int; var _local2:int; var _local3:int; while (_local1 < 7) { _local3 = (_local3 + dyn_ltree[(_local1 * 2)]); _local1++; }; while (_local1 < 128) { _local2 = (_local2 + dyn_ltree[(_local1 * 2)]); _local1++; }; while (_local1 < LITERALS) { _local3 = (_local3 + dyn_ltree[(_local1 * 2)]); _local1++; }; data_type = ((_local3 > (_local2 >>> 2))) ? Z_BINARY : Z_ASCII; } public function deflate(_arg1:ZStream, _arg2:int):int{ var _local3:int; var _local4:int; var _local5:int; var _local6:int; var _local7:int; if ((((_arg2 > Z_FINISH)) || ((_arg2 < 0)))){ return (Z_STREAM_ERROR); }; if ((((((_arg1.next_out == null)) || ((((_arg1.next_in == null)) && (!((_arg1.avail_in == 0))))))) || ((((status == FINISH_STATE)) && (!((_arg2 == Z_FINISH))))))){ _arg1.msg = z_errmsg[(Z_NEED_DICT - Z_STREAM_ERROR)]; return (Z_STREAM_ERROR); }; if (_arg1.avail_out == 0){ _arg1.msg = z_errmsg[(Z_NEED_DICT - Z_BUF_ERROR)]; return (Z_BUF_ERROR); }; this.strm = _arg1; _local3 = last_flush; last_flush = _arg2; if (status == INIT_STATE){ _local4 = ((Z_DEFLATED + ((w_bits - 8) << 4)) << 8); _local5 = (((level - 1) & 0xFF) >> 1); if (_local5 > 3){ _local5 = 3; }; _local4 = (_local4 | (_local5 << 6)); if (strstart != 0){ _local4 = (_local4 | PRESET_DICT); }; _local4 = (_local4 + (31 - (_local4 % 31))); status = BUSY_STATE; putShortMSB(_local4); if (strstart != 0){ putShortMSB(int((_arg1.adler >>> 16))); putShortMSB(int((_arg1.adler & 0xFFFF))); }; _arg1.adler = _arg1._adler.adler32(0, null, 0, 0); }; if (pending != 0){ _arg1.flush_pending(); if (_arg1.avail_out == 0){ last_flush = -1; return (Z_OK); }; } else { if ((((((_arg1.avail_in == 0)) && ((_arg2 <= _local3)))) && (!((_arg2 == Z_FINISH))))){ _arg1.msg = z_errmsg[(Z_NEED_DICT - Z_BUF_ERROR)]; return (Z_BUF_ERROR); }; }; if ((((status == FINISH_STATE)) && (!((_arg1.avail_in == 0))))){ _arg1.msg = z_errmsg[(Z_NEED_DICT - Z_BUF_ERROR)]; return (Z_BUF_ERROR); }; if (((((!((_arg1.avail_in == 0))) || (!((lookahead == 0))))) || (((!((_arg2 == Z_NO_FLUSH))) && (!((status == FINISH_STATE))))))){ _local6 = -1; switch (config_table[level].func){ case STORED: _local6 = deflate_stored(_arg2); break; case FAST: _local6 = deflate_fast(_arg2); break; case SLOW: _local6 = deflate_slow(_arg2); break; }; if ((((_local6 == FinishStarted)) || ((_local6 == FinishDone)))){ status = FINISH_STATE; }; if ((((_local6 == NeedMore)) || ((_local6 == FinishStarted)))){ if (_arg1.avail_out == 0){ last_flush = -1; }; return (Z_OK); }; if (_local6 == BlockDone){ if (_arg2 == Z_PARTIAL_FLUSH){ _tr_align(); } else { _tr_stored_block(0, 0, false); if (_arg2 == Z_FULL_FLUSH){ _local7 = 0; while (_local7 < hash_size) { head[_local7] = 0; _local7++; }; }; }; _arg1.flush_pending(); if (_arg1.avail_out == 0){ last_flush = -1; return (Z_OK); }; }; }; if (_arg2 != Z_FINISH){ return (Z_OK); }; if (noheader != 0){ return (Z_STREAM_END); }; putShortMSB(int((_arg1.adler >>> 16))); putShortMSB(int((_arg1.adler & 0xFFFF))); _arg1.flush_pending(); noheader = -1; return (((pending)!=0) ? Z_OK : Z_STREAM_END); } function fill_window():void{ var _local1:int; var _local2:int; var _local3:int; var _local4:int; do { _local4 = ((window_size - lookahead) - strstart); if ((((((_local4 == 0)) && ((strstart == 0)))) && ((lookahead == 0)))){ _local4 = w_size; } else { if (_local4 == -1){ _local4--; } else { if (strstart >= ((w_size + w_size) - MIN_LOOKAHEAD)){ System.byteArrayCopy(window, w_size, window, 0, w_size); match_start = (match_start - w_size); strstart = (strstart - w_size); block_start = (block_start - w_size); _local1 = hash_size; _local3 = _local1; do { --_local3; _local2 = (head[_local3] & 0xFFFF); head[_local3] = ((_local2 >= w_size)) ? Cast.toShort((_local2 - w_size)) : 0; --_local1; } while (_local1 != 0); _local1 = w_size; _local3 = _local1; do { --_local3; _local2 = (prev[_local3] & 0xFFFF); prev[_local3] = ((_local2 >= w_size)) ? Cast.toShort((_local2 - w_size)) : 0; --_local1; } while (_local1 != 0); _local4 = (_local4 + w_size); }; }; }; if (strm.avail_in == 0){ return; }; _local1 = strm.read_buf(window, (strstart + lookahead), _local4); lookahead = (lookahead + _local1); if (lookahead >= MIN_MATCH){ ins_h = (window[strstart] & 0xFF); ins_h = (((ins_h << hash_shift) ^ (window[(strstart + 1)] & 0xFF)) & hash_mask); }; } while ((((lookahead < MIN_LOOKAHEAD)) && (!((strm.avail_in == 0))))); } function deflateSetDictionary(_arg1:ZStream, _arg2:ByteArray, _arg3:int):int{ var _local4:int = _arg3; var _local5:int; if ((((_arg2 == null)) || (!((status == INIT_STATE))))){ return (Z_STREAM_ERROR); }; _arg1.adler = _arg1._adler.adler32(_arg1.adler, _arg2, 0, _arg3); if (_local4 < MIN_MATCH){ return (Z_OK); }; if (_local4 > (w_size - MIN_LOOKAHEAD)){ _local4 = (w_size - MIN_LOOKAHEAD); _local5 = (_arg3 - _local4); }; System.byteArrayCopy(_arg2, _local5, window, 0, _local4); strstart = _local4; block_start = _local4; ins_h = (window[0] & 0xFF); ins_h = (((ins_h << hash_shift) ^ (window[1] & 0xFF)) & hash_mask); var _local6:int; while (_local6 <= (_local4 - MIN_MATCH)) { ins_h = (((ins_h << hash_shift) ^ (window[(_local6 + (MIN_MATCH - 1))] & 0xFF)) & hash_mask); prev[(_local6 & w_mask)] = head[ins_h]; head[ins_h] = Cast.toShort(_local6); _local6++; }; return (Z_OK); } function scan_tree(_arg1:Array, _arg2:int):void{ var _local3:int; var _local5:int; var _local4 = -1; var _local6:int = _arg1[((0 * 2) + 1)]; var _local7:int; var _local8 = 7; var _local9 = 4; if (_local6 == 0){ _local8 = 138; _local9 = 3; }; _arg1[(((_arg2 + 1) * 2) + 1)] = 0xFFFF; _local3 = 0; for (;_local3 <= _arg2;_local3++) { _local5 = _local6; _local6 = _arg1[(((_local3 + 1) * 2) + 1)]; ++_local7; if ((((_local7 < _local8)) && ((_local5 == _local6)))){ continue; } else { if (_local7 < _local9){ bl_tree[(_local5 * 2)] = (bl_tree[(_local5 * 2)] + _local7); } else { if (_local5 != 0){ if (_local5 != _local4){ var _local10 = bl_tree; var _local11 = (_local5 * 2); var _local12 = (_local10[_local11] + 1); _local10[_local11] = _local12; }; _local10 = bl_tree; _local11 = (REP_3_6 * 2); _local12 = (_local10[_local11] + 1); _local10[_local11] = _local12; } else { if (_local7 <= 10){ _local10 = bl_tree; _local11 = (REPZ_3_10 * 2); _local12 = (_local10[_local11] + 1); _local10[_local11] = _local12; } else { _local10 = bl_tree; _local11 = (REPZ_11_138 * 2); _local12 = (_local10[_local11] + 1); _local10[_local11] = _local12; }; }; }; }; _local7 = 0; _local4 = _local5; if (_local6 == 0){ _local8 = 138; _local9 = 3; } else { if (_local5 == _local6){ _local8 = 6; _local9 = 3; } else { _local8 = 7; _local9 = 4; }; }; }; } function tr_init():void{ l_desc.dyn_tree = dyn_ltree; l_desc.stat_desc = StaticTree.static_l_desc; d_desc.dyn_tree = dyn_dtree; d_desc.stat_desc = StaticTree.static_d_desc; bl_desc.dyn_tree = bl_tree; bl_desc.stat_desc = StaticTree.static_bl_desc; bi_buf = 0; bi_valid = 0; last_eob_len = 8; init_block(); } final public function put_byte(_arg1:ByteArray, _arg2:int, _arg3:int):void{ System.byteArrayCopy(_arg1, _arg2, pending_buf, pending, _arg3); pending = (pending + _arg3); } function flush_block_only(_arg1:Boolean):void{ _tr_flush_block(((block_start >= 0)) ? block_start : -1, (strstart - block_start), _arg1); block_start = strstart; strm.flush_pending(); } function copy_block(_arg1:int, _arg2:int, _arg3:Boolean):void{ var _local4:int; bi_windup(); last_eob_len = 8; if (_arg3){ put_short(_arg2); put_short((~(_arg2) & 0xFFFF)); }; put_byte(window, _arg1, _arg2); } final public function send_code(_arg1:int, _arg2:Array):void{ var _local3:int = (_arg1 * 2); send_bits((_arg2[_local3] & 0xFFFF), (_arg2[(_local3 + 1)] & 0xFFFF)); } public function deflate_stored(_arg1:int):int{ var _local3:int; var _local2:int; if (_local2 > (pending_buf_size - 5)){ _local2 = (pending_buf_size - 5); }; while (true) { if (lookahead <= 1){ fill_window(); if ((((lookahead == 0)) && ((_arg1 == Z_NO_FLUSH)))){ return (NeedMore); }; if (lookahead == 0){ break; }; }; strstart = (strstart + lookahead); lookahead = 0; _local3 = (block_start + _local2); if ((((strstart == 0)) || ((strstart >= _local3)))){ lookahead = int((strstart - _local3)); strstart = int(_local3); flush_block_only(false); if (strm.avail_out == 0){ return (NeedMore); }; }; if ((strstart - block_start) >= (w_size - MIN_LOOKAHEAD)){ flush_block_only(false); if (strm.avail_out == 0){ return (NeedMore); }; }; }; flush_block_only((_arg1 == Z_FINISH)); if (strm.avail_out == 0){ return (((_arg1)==Z_FINISH) ? FinishStarted : NeedMore); }; return (((_arg1 == Z_FINISH)) ? FinishDone : BlockDone); } public function put_byte_withInt(_arg1:int):void{ pending_buf.writeByte(_arg1); pending++; } public function put_short(_arg1:int):void{ this.put_byte_withInt(_arg1); this.put_byte_withInt((_arg1 >>> 8)); } public function send_bits(_arg1:int, _arg2:int):void{ var _local4:int; var _local3:int = _arg2; if (bi_valid > (int(Buf_size) - _local3)){ _local4 = _arg1; bi_buf = (bi_buf | ((_local4 << bi_valid) & 0xFFFF)); put_short(bi_buf); bi_buf = (_local4 >>> (Buf_size - bi_valid)); bi_buf = Cast.toShort((_local4 >>> (Buf_size - bi_valid))); bi_valid = (bi_valid + (_local3 - Buf_size)); } else { bi_buf = (bi_buf | ((_arg1 << bi_valid) & 0xFFFF)); bi_valid = (bi_valid + _local3); }; } public function _tr_align():void{ send_bits((STATIC_TREES << 1), 3); send_code(END_BLOCK, StaticTree.static_ltree); bi_flush(); if ((((1 + last_eob_len) + 10) - bi_valid) < 9){ send_bits((STATIC_TREES << 1), 3); send_code(END_BLOCK, StaticTree.static_ltree); bi_flush(); }; last_eob_len = 7; } public function compress_block(_arg1:Array, _arg2:Array):void{ var _local3:int; var _local4:int; var _local6:int; var _local7:int; var _local5:int; if (last_lit != 0){ do { _local3 = (((pending_buf[(d_buf + (_local5 * 2))] << 8) & 0xFF00) | (pending_buf[((d_buf + (_local5 * 2)) + 1)] & 0xFF)); _local4 = (pending_buf[(l_buf + _local5)] & 0xFF); _local5++; if (_local3 == 0){ send_code(_local4, _arg1); } else { _local6 = Tree._length_code[_local4]; send_code(((_local6 + LITERALS) + 1), _arg1); _local7 = Tree.extra_lbits[_local6]; if (_local7 != 0){ _local4 = (_local4 - Tree.base_length[_local6]); send_bits(_local4, _local7); }; _local3--; _local6 = Tree.d_code(_local3); send_code(_local6, _arg2); _local7 = Tree.extra_dbits[_local6]; if (_local7 != 0){ _local3 = (_local3 - Tree.base_dist[_local6]); send_bits(_local3, _local7); }; }; } while (_local5 < last_lit); }; send_code(END_BLOCK, _arg1); last_eob_len = _arg1[((END_BLOCK * 2) + 1)]; } function _tr_flush_block(_arg1:int, _arg2:int, _arg3:Boolean):void{ var _local4:int; var _local5:int; var _local6:int; if (level > 0){ if (data_type == Z_UNKNOWN){ set_data_type(); }; l_desc.build_tree(this); d_desc.build_tree(this); _local6 = build_bl_tree(); _local4 = (((opt_len + 3) + 7) >>> 3); _local5 = (((static_len + 3) + 7) >>> 3); if (_local5 <= _local4){ _local4 = _local5; }; } else { _local5 = (_arg2 + 5); _local4 = _local5; }; if (((((_arg2 + 4) <= _local4)) && (!((_arg1 == -1))))){ _tr_stored_block(_arg1, _arg2, _arg3); } else { if (_local5 == _local4){ send_bits(((STATIC_TREES << 1) + (_arg3) ? 1 : 0), 3); compress_block(StaticTree.static_ltree, StaticTree.static_dtree); } else { send_bits(((DYN_TREES << 1) + (_arg3) ? 1 : 0), 3); send_all_trees((l_desc.max_code + 1), (d_desc.max_code + 1), (_local6 + 1)); compress_block(dyn_ltree, dyn_dtree); }; }; init_block(); if (_arg3){ bi_windup(); }; } public function send_all_trees(_arg1:int, _arg2:int, _arg3:int):void{ var _local4:int; send_bits((_arg1 - 0x0101), 5); send_bits((_arg2 - 1), 5); send_bits((_arg3 - 4), 4); _local4 = 0; while (_local4 < _arg3) { send_bits(bl_tree[((Tree.bl_order[_local4] * 2) + 1)], 3); _local4++; }; send_tree(dyn_ltree, (_arg1 - 1)); send_tree(dyn_dtree, (_arg2 - 1)); } public function deflate_slow(_arg1:int):int{ var _local3:Boolean; var _local4:int; var _local2:int; while (true) { if (lookahead < MIN_LOOKAHEAD){ fill_window(); if ((((lookahead < MIN_LOOKAHEAD)) && ((_arg1 == Z_NO_FLUSH)))){ return (NeedMore); }; if (lookahead == 0){ break; }; }; if (lookahead >= MIN_MATCH){ ins_h = (((ins_h << hash_shift) ^ (window[(strstart + (MIN_MATCH - 1))] & 0xFF)) & hash_mask); _local2 = (head[ins_h] & 0xFFFF); prev[(strstart & w_mask)] = head[ins_h]; head[ins_h] = Cast.toShort(strstart); }; prev_length = match_length; prev_match = match_start; match_length = (MIN_MATCH - 1); if (((((!((_local2 == 0))) && ((prev_length < max_lazy_match)))) && ((((strstart - _local2) & 0xFFFF) <= (w_size - MIN_LOOKAHEAD))))){ if (strategy != Z_HUFFMAN_ONLY){ match_length = longest_match(_local2); }; if ((((match_length <= 5)) && ((((strategy == Z_FILTERED)) || ((((match_length == MIN_MATCH)) && (((strstart - match_start) > 0x1000)))))))){ match_length = (MIN_MATCH - 1); }; }; if ((((prev_length >= MIN_MATCH)) && ((match_length <= prev_length)))){ _local4 = ((strstart + lookahead) - MIN_MATCH); _local3 = _tr_tally(((strstart - 1) - prev_match), (prev_length - MIN_MATCH)); lookahead = (lookahead - (prev_length - 1)); prev_length = (prev_length - 2); do { if (++strstart <= _local4){ ins_h = (((ins_h << hash_shift) ^ (window[(strstart + (MIN_MATCH - 1))] & 0xFF)) & hash_mask); _local2 = (head[ins_h] & 0xFFFF); prev[(strstart & w_mask)] = head[ins_h]; head[ins_h] = Cast.toShort(strstart); }; } while (--prev_length != 0); match_available = 0; match_length = (MIN_MATCH - 1); strstart++; if (_local3){ flush_block_only(false); if (strm.avail_out == 0){ return (NeedMore); }; }; } else { if (match_available != 0){ _local3 = _tr_tally(0, (window[(strstart - 1)] & 0xFF)); if (_local3){ flush_block_only(false); }; strstart++; lookahead--; if (strm.avail_out == 0){ return (NeedMore); }; } else { match_available = 1; strstart++; lookahead--; }; }; }; if (match_available != 0){ _local3 = _tr_tally(0, (window[(strstart - 1)] & 0xFF)); match_available = 0; }; flush_block_only((_arg1 == Z_FINISH)); if (strm.avail_out == 0){ if (_arg1 == Z_FINISH){ return (FinishStarted); }; return (NeedMore); }; return (((_arg1 == Z_FINISH)) ? FinishDone : BlockDone); } public function bi_windup():void{ if (bi_valid > 8){ put_short(bi_buf); } else { if (bi_valid > 0){ this.put_byte_withInt(bi_buf); }; }; bi_buf = 0; bi_valid = 0; } function pqdownheap(_arg1:Array, _arg2:int):void{ var _local3:int = heap[_arg2]; var _local4 = (_arg2 << 1); while (_local4 <= heap_len) { if ((((_local4 < heap_len)) && (smaller(_arg1, heap[(_local4 + 1)], heap[_local4], depth)))){ _local4++; }; if (smaller(_arg1, _local3, heap[_local4], depth)){ break; }; heap[_arg2] = heap[_local4]; _arg2 = _local4; _local4 = (_local4 << 1); }; heap[_arg2] = _local3; } public function build_bl_tree():int{ var _local1:int; scan_tree(dyn_ltree, l_desc.max_code); scan_tree(dyn_dtree, d_desc.max_code); bl_desc.build_tree(this); _local1 = (BL_CODES - 1); while (_local1 >= 3) { if (bl_tree[((Tree.bl_order[_local1] * 2) + 1)] != 0){ break; }; _local1--; }; opt_len = (opt_len + ((((3 * (_local1 + 1)) + 5) + 5) + 4)); return (_local1); } function init_block():void{ var _local1:int; _local1 = 0; while (_local1 < L_CODES) { dyn_ltree[(_local1 * 2)] = 0; _local1++; }; _local1 = 0; while (_local1 < D_CODES) { dyn_dtree[(_local1 * 2)] = 0; _local1++; }; _local1 = 0; while (_local1 < BL_CODES) { bl_tree[(_local1 * 2)] = 0; _local1++; }; dyn_ltree[(END_BLOCK * 2)] = 1; opt_len = (static_len = 0); last_lit = (matches = 0); } function deflateEnd():int{ if (((((!((status == INIT_STATE))) && (!((status == BUSY_STATE))))) && (!((status == FINISH_STATE))))){ return (Z_STREAM_ERROR); }; pending_buf = null; head = null; prev = null; window = null; return (((status == BUSY_STATE)) ? Z_DATA_ERROR : Z_OK); } final public function putShortMSB(_arg1:int):void{ this.put_byte_withInt((_arg1 >> 8)); this.put_byte_withInt((_arg1 & 0xFF)); } function deflateParams(_arg1:ZStream, _arg2:int, _arg3:int):int{ var _local4:int = Z_OK; if (_arg2 == Z_DEFAULT_COMPRESSION){ _arg2 = 6; }; if ((((((((_arg2 < 0)) || ((_arg2 > 9)))) || ((_arg3 < 0)))) || ((_arg3 > Z_HUFFMAN_ONLY)))){ return (Z_STREAM_ERROR); }; if (((!((config_table[level].func == config_table[_arg2].func))) && (!((_arg1.total_in == 0))))){ _local4 = _arg1.deflate(Z_PARTIAL_FLUSH); }; if (level != _arg2){ level = _arg2; max_lazy_match = config_table[level].max_lazy; good_match = config_table[level].good_length; nice_match = config_table[level].nice_length; max_chain_length = config_table[level].max_chain; }; strategy = _arg3; return (_local4); } public function deflateInit2(_arg1:ZStream, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int):int{ var _local7:int; _arg1.msg = null; if (_arg2 == Z_DEFAULT_COMPRESSION){ _arg2 = 6; }; if (_arg4 < 0){ _local7 = 1; _arg4 = -(_arg4); }; if ((((((((((((((((((_arg5 < 1)) || ((_arg5 > MAX_MEM_LEVEL)))) || (!((_arg3 == Z_DEFLATED))))) || ((_arg4 < 9)))) || ((_arg4 > 15)))) || ((_arg2 < 0)))) || ((_arg2 > 9)))) || ((_arg6 < 0)))) || ((_arg6 > Z_HUFFMAN_ONLY)))){ return (Z_STREAM_ERROR); }; _arg1.dstate = Deflate(this); this.noheader = _local7; w_bits = _arg4; w_size = (1 << w_bits); w_mask = (w_size - 1); hash_bits = (_arg5 + 7); hash_size = (1 << hash_bits); hash_mask = (hash_size - 1); hash_shift = (((hash_bits + MIN_MATCH) - 1) / MIN_MATCH); window = new ByteArray(); prev = new Array(); head = new Array(); lit_bufsize = (1 << (_arg5 + 6)); pending_buf = new ByteArray(); pending_buf_size = (lit_bufsize * 4); d_buf = (lit_bufsize / 2); l_buf = ((1 + 2) * lit_bufsize); this.level = _arg2; this.strategy = _arg6; this.method = _arg3; return (deflateReset(_arg1)); } public function _tr_tally(_arg1:int, _arg2:int):Boolean{ var _local3:int; var _local4:int; var _local5:int; pending_buf[(d_buf + (last_lit * 2))] = Cast.toByte((_arg1 >>> 8)); pending_buf[((d_buf + (last_lit * 2)) + 1)] = Cast.toByte(_arg1); pending_buf[(l_buf + last_lit)] = _arg2; last_lit++; if (_arg1 == 0){ var _local6 = dyn_ltree; var _local7 = (_arg2 * 2); var _local8 = (_local6[_local7] + 1); _local6[_local7] = _local8; } else { matches++; _arg1--; _local6 = dyn_ltree; _local7 = (((Tree._length_code[_arg2] + LITERALS) + 1) * 2); _local8 = (_local6[_local7] + 1); _local6[_local7] = _local8; _local6 = dyn_dtree; _local7 = (Tree.d_code(_arg1) * 2); _local8 = (_local6[_local7] + 1); _local6[_local7] = _local8; }; if (((((last_lit & 1) == 0)) && ((level > 2)))){ _local3 = (last_lit * 8); _local4 = (strstart - block_start); _local5 = 0; while (_local5 < D_CODES) { _local3 = (_local3 + (int(dyn_dtree[(_local5 * 2)]) * (5 + Tree.extra_dbits[_local5]))); _local5++; }; _local3 = (_local3 >>> 3); if ((((matches < (last_lit / 2))) && ((_local3 < (_local4 / 2))))){ return (true); }; }; return ((last_lit == (lit_bufsize - 1))); } public function deflateInit(_arg1:ZStream, _arg2:int):int{ return (deflateInitWithBits(_arg1, _arg2, MAX_WBITS)); } function longest_match(_arg1:int):int{ var _local4:int; var _local5:int; var _local2:int = max_chain_length; var _local3:int = strstart; var _local6:int = prev_length; var _local7:int = ((strstart > (w_size - MIN_LOOKAHEAD))) ? (strstart - (w_size - MIN_LOOKAHEAD)) : 0; var _local8:int = this.nice_match; var _local9:int = w_mask; var _local10:int = (strstart + MAX_MATCH); var _local11:uint = window[((_local3 + _local6) - 1)]; var _local12:uint = window[(_local3 + _local6)]; if (prev_length >= good_match){ _local2 = (_local2 >> 2); }; if (_local8 > lookahead){ _local8 = lookahead; }; do { _local4 = _arg1; if (((((((!((window[(_local4 + _local6)] == _local12))) || (!((window[((_local4 + _local6) - 1)] == _local11))))) || (!((window[_local4] == window[_local3]))))) || (!((window[_temp2] == window[(_local3 + 1)]))))){ } else { _local3 = (_local3 + 2); _local4++; do { ++_local3; ++_local4; } while ((((((((((((((((((window[_local3] == window[_local4])) && ((window[_temp4] == window[_temp5])))) && ((window[_temp7] == window[_temp8])))) && ((window[_temp10] == window[_temp11])))) && ((window[_temp13] == window[_temp14])))) && ((window[_temp16] == window[_temp17])))) && ((window[_temp19] == window[_temp20])))) && ((window[_temp22] == window[_temp23])))) && ((_local3 < _local10)))); _local5 = (MAX_MATCH - int((_local10 - _local3))); _local3 = (_local10 - MAX_MATCH); if (_local5 > _local6){ match_start = _arg1; _local6 = _local5; if (_local5 >= _local8){ break; }; _local11 = window[((_local3 + _local6) - 1)]; _local12 = window[(_local3 + _local6)]; }; }; _arg1 = (prev[(_arg1 & _local9)] & 0xFFFF); } while ((((_arg1 > _local7)) && (!((_temp24 == 0))))); if (_local6 <= lookahead){ return (_local6); }; return (lookahead); } public function _tr_stored_block(_arg1:int, _arg2:int, _arg3:Boolean):void{ send_bits(((STORED_BLOCK << 1) + (_arg3) ? 1 : 0), 3); copy_block(_arg1, _arg2, true); } public function deflateInitWithBits(_arg1:ZStream, _arg2:int, _arg3:int):int{ return (deflateInit2(_arg1, _arg2, Z_DEFLATED, _arg3, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY)); } function deflateReset(_arg1:ZStream):int{ _arg1.total_in = (_arg1.total_out = 0); _arg1.msg = null; _arg1.data_type = Z_UNKNOWN; pending = 0; pending_out = 0; pending_buf = new ByteArray(); if (noheader < 0){ noheader = 0; }; status = ((noheader)!=0) ? BUSY_STATE : INIT_STATE; _arg1.adler = _arg1._adler.adler32(0, null, 0, 0); last_flush = Z_NO_FLUSH; tr_init(); lm_init(); return (Z_OK); } public function deflate_fast(_arg1:int):int{ var _local3:Boolean; var _local2:int; while (true) { if (lookahead < MIN_LOOKAHEAD){ fill_window(); if ((((lookahead < MIN_LOOKAHEAD)) && ((_arg1 == Z_NO_FLUSH)))){ return (NeedMore); }; if (lookahead == 0){ break; }; }; if (lookahead >= MIN_MATCH){ ins_h = (((ins_h << hash_shift) ^ (window[(strstart + (MIN_MATCH - 1))] & 0xFF)) & hash_mask); _local2 = head[ins_h]; prev[(strstart & w_mask)] = head[ins_h]; head[ins_h] = Cast.toShort(strstart); }; if (((!((_local2 == 0))) && (((strstart - _local2) <= (w_size - MIN_LOOKAHEAD))))){ if (strategy != Z_HUFFMAN_ONLY){ match_length = longest_match(_local2); }; }; if (match_length >= MIN_MATCH){ _local3 = _tr_tally((strstart - match_start), (match_length - MIN_MATCH)); lookahead = (lookahead - match_length); if ((((match_length <= max_lazy_match)) && ((lookahead >= MIN_MATCH)))){ match_length--; do { strstart++; ins_h = (((ins_h << hash_shift) ^ (window[(strstart + (MIN_MATCH - 1))] & 0xFF)) & hash_mask); _local2 = (head[ins_h] & 0xFFFF); prev[(strstart & w_mask)] = head[ins_h]; head[ins_h] = Cast.toShort(strstart); } while (--match_length != 0); strstart++; } else { strstart = (strstart + match_length); match_length = 0; ins_h = window[strstart]; ins_h = (((ins_h << hash_shift) ^ (window[(strstart + 1)] & 0xFF)) & hash_mask); }; } else { _local3 = _tr_tally(0, (window[strstart] & 0xFF)); lookahead--; strstart++; }; if (_local3){ flush_block_only(false); if (strm.avail_out == 0){ return (NeedMore); }; }; }; flush_block_only((_arg1 == Z_FINISH)); if (strm.avail_out == 0){ if (_arg1 == Z_FINISH){ return (FinishStarted); }; return (NeedMore); }; return (((_arg1 == Z_FINISH)) ? FinishDone : BlockDone); } static function smaller(_arg1:Array, _arg2:int, _arg3:int, _arg4:Array):Boolean{ var _local5:Number = _arg1[(_arg2 * 2)]; var _local6:Number = _arg1[(_arg3 * 2)]; return ((((_local5 < _local6)) || ((((_local5 == _local6)) && ((_arg4[_arg2] <= _arg4[_arg3])))))); } } }//package com.wirelust.as3zlib
Section 72
//DeflateConfig (com.wirelust.as3zlib.DeflateConfig) package com.wirelust.as3zlib { public class DeflateConfig { public var func:int; public var max_lazy:int; public var good_length:int; public var max_chain:int; public var nice_length:int; public function DeflateConfig(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int){ this.good_length = _arg1; this.max_lazy = _arg2; this.nice_length = _arg3; this.max_chain = _arg4; this.func = _arg5; } } }//package com.wirelust.as3zlib
Section 73
//InfBlocks (com.wirelust.as3zlib.InfBlocks) package com.wirelust.as3zlib { import flash.utils.*; import com.wirelust.util.*; public final class InfBlocks { public var left:int; public var check:Number; public var bb:Array; public var checkfn:Object; public var index:int; public var table:int; public var last:int; public var end:int; public var read:int; public var write:int; public var blens:Array; public var mode:int; public var codes:InfCodes; public var tb:Array; public var window:ByteArray; public var bitb:int; public var hufts:Array; public var bitk:int; public var inftree:InfTree; private static const Z_STREAM_END:int = 1; private static const LENS:int = 1; private static const DRY:int = 7; private static const CODES:int = 6; private static const Z_BUF_ERROR:int = -5; private static const Z_DATA_ERROR:int = -3; private static const Z_NEED_DICT:int = 2; private static const BTREE:int = 4; private static const Z_OK:int = 0; private static const STORED:int = 2; private static const inflate_mask:Array = new Array(0, 1, 3, 7, 15, 31, 63, 127, 0xFF, 511, 1023, 2047, 4095, 8191, 16383, 32767, 0xFFFF); private static const BAD:int = 9; private static const MANY:int = 1440; private static const Z_ERRNO:int = -1; private static const DTREE:int = 5; public static const border:Array = new Array(16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15); private static const Z_STREAM_ERROR:int = -2; private static const DONE:int = 8; private static const Z_MEM_ERROR:int = -4; private static const TYPE:int = 0; private static const Z_VERSION_ERROR:int = -6; private static const TABLE:int = 3; public function InfBlocks(_arg1:ZStream, _arg2:Object, _arg3:int){ bb = new Array(); tb = new Array(); codes = new InfCodes(); inftree = new InfTree(); super(); hufts = new Array(); window = new ByteArray(); end = _arg3; this.checkfn = _arg2; mode = TYPE; reset(_arg1, null); } public function sync_point():int{ return (((mode == LENS)) ? 1 : 0); } public function set_dictionary(_arg1:ByteArray, _arg2:int, _arg3:int):void{ System.byteArrayCopy(_arg1, _arg2, window, 0, _arg3); read = (write = _arg3); } public function reset(_arg1:ZStream, _arg2:Array):void{ if (_arg2 != null){ _arg2[0] = check; }; if ((((mode == BTREE)) || ((mode == DTREE)))){ }; if (mode == CODES){ codes.free(_arg1); }; mode = TYPE; bitk = 0; bitb = 0; read = (write = 0); if (checkfn != null){ _arg1.adler = (check = _arg1._adler.adler32(0, null, 0, 0)); }; } public function proc(_arg1:ZStream, _arg2:int):int{ var _local3:int; var _local4:int; var _local5:int; var _local6:int; var _local7:int; var _local8:int; var _local9:int; var _local10:Array; var _local11:Array; var _local12:Array; var _local13:Array; var _local14:Array; var _local15:int; var _local16:int; var _local17:int; var _local18:int; _local6 = _arg1.next_in_index; _local7 = _arg1.avail_in; _local4 = bitb; _local5 = bitk; _local8 = write; _local9 = int(((_local8 < read)) ? ((read - _local8) - 1) : (end - _local8)); while (true) { switch (mode){ case TYPE: while (_local5 < 3) { if (_local7 != 0){ _arg2 = Z_OK; } else { bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; _local7--; var _temp1 = _local6; _local6 = (_local6 + 1); _arg1.next_in.position = _temp1; _local18 = Cast.toByte(_arg1.next_in.readByte()); _local4 = (_local4 | ((_local18 & 0xFF) << _local5)); _local5 = (_local5 + 8); }; _local3 = int((_local4 & 7)); last = (_local3 & 1); switch ((_local3 >>> 1)){ case 0: _local4 = (_local4 >>> 3); _local5 = (_local5 - 3); _local3 = (_local5 & 7); _local4 = (_local4 >>> _local3); _local5 = (_local5 - _local3); mode = LENS; break; case 1: _local10 = new Array(1); _local11 = new Array(1); _local12 = new Array(); _local12[0] = new Array(); _local13 = new Array(); _local13[0] = new Array(); InfTree.inflate_trees_fixed(_local10, _local11, _local12, _local13, _arg1); codes.init(_local10[0], _local11[0], _local12[0], 0, _local13[0], 0, _arg1); _local4 = (_local4 >>> 3); _local5 = (_local5 - 3); mode = CODES; break; case 2: _local4 = (_local4 >>> 3); _local5 = (_local5 - 3); mode = TABLE; break; case 3: _local4 = (_local4 >>> 3); _local5 = (_local5 - 3); mode = BAD; _arg1.msg = "invalid block type"; _arg2 = Z_DATA_ERROR; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; break; case LENS: while (_local5 < 32) { if (_local7 != 0){ _arg2 = Z_OK; } else { bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; _local7--; var _temp2 = _local6; _local6 = (_local6 + 1); _local4 = (_local4 | ((_arg1.next_in[_temp2] & 0xFF) << _local5)); _local5 = (_local5 + 8); }; if (((~(_local4) >>> 16) & 0xFFFF) != (_local4 & 0xFFFF)){ mode = BAD; _arg1.msg = "invalid stored block lengths"; _arg2 = Z_DATA_ERROR; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; left = (_local4 & 0xFFFF); _local5 = 0; _local4 = _local5; mode = ((left)!=0) ? STORED : ((last)!=0) ? DRY : TYPE; break; case STORED: if (_local7 == 0){ bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; if (_local9 == 0){ if ((((_local8 == end)) && (!((read == 0))))){ _local8 = 0; _local9 = int(((_local8 < read)) ? ((read - _local8) - 1) : (end - _local8)); }; if (_local9 == 0){ write = _local8; _arg2 = inflate_flush(_arg1, _arg2); _local8 = write; _local9 = int(((_local8 < read)) ? ((read - _local8) - 1) : (end - _local8)); if ((((_local8 == end)) && (!((read == 0))))){ _local8 = 0; _local9 = int(((_local8 < read)) ? ((read - _local8) - 1) : (end - _local8)); }; if (_local9 == 0){ bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; }; }; _arg2 = Z_OK; _local3 = left; if (_local3 > _local7){ _local3 = _local7; }; if (_local3 > _local9){ _local3 = _local9; }; System.byteArrayCopy(_arg1.next_in, _local6, window, _local8, _local3); _local6 = (_local6 + _local3); _local7 = (_local7 - _local3); _local8 = (_local8 + _local3); _local9 = (_local9 - _local3); if ((left = (left - _local3)) != 0){ break; }; mode = ((last)!=0) ? DRY : TYPE; break; case TABLE: while (_local5 < 14) { if (_local7 != 0){ _arg2 = Z_OK; } else { bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; _local7--; var _temp3 = _local6; _local6 = (_local6 + 1); _local4 = (_local4 | ((_arg1.next_in[_temp3] & 0xFF) << _local5)); _local5 = (_local5 + 8); }; _local3 = (_local4 & 16383); table = _local3; if (((((_local3 & 31) > 29)) || ((((_local3 >> 5) & 31) > 29)))){ mode = BAD; _arg1.msg = "too many length or distance symbols"; _arg2 = Z_DATA_ERROR; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; _local3 = ((258 + (_local3 & 31)) + ((_local3 >> 5) & 31)); if ((((blens == null)) || ((blens.length < _local3)))){ blens = new Array(); } else { _local15 = 0; while (_local15 < _local3) { blens[_local15] = 0; _local15++; }; }; _local4 = (_local4 >>> 14); _local5 = (_local5 - 14); index = 0; mode = BTREE; case BTREE: while (index < (4 + (table >>> 10))) { while (_local5 < 3) { if (_local7 != 0){ _arg2 = Z_OK; } else { bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; _local7--; var _temp4 = _local6; _local6 = (_local6 + 1); _local4 = (_local4 | ((_arg1.next_in[_temp4] & 0xFF) << _local5)); _local5 = (_local5 + 8); }; blens[border[index++]] = (_local4 & 7); _local4 = (_local4 >>> 3); _local5 = (_local5 - 3); }; while (index < 19) { blens[border[index++]] = 0; }; bb[0] = 7; _local3 = inftree.inflate_trees_bits(blens, bb, tb, hufts, _arg1); if (_local3 != Z_OK){ _arg2 = _local3; if (_arg2 == Z_DATA_ERROR){ blens = null; mode = BAD; }; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; index = 0; mode = DTREE; case DTREE: while (true) { _local3 = table; if (!(index < ((258 + (_local3 & 31)) + ((_local3 >> 5) & 31)))){ break; }; _local3 = bb[0]; while (_local5 < _local3) { if (_local7 != 0){ _arg2 = Z_OK; } else { bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; _local7--; var _temp5 = _local6; _local6 = (_local6 + 1); _local4 = (_local4 | ((_arg1.next_in[_temp5] & 0xFF) << _local5)); _local5 = (_local5 + 8); }; if (tb[0] == -1){ }; _local3 = hufts[(((tb[0] + (_local4 & inflate_mask[_local3])) * 3) + 1)]; _local17 = hufts[(((tb[0] + (_local4 & inflate_mask[_local3])) * 3) + 2)]; if (_local17 < 16){ _local4 = (_local4 >>> _local3); _local5 = (_local5 - _local3); var _local19 = index++; blens[_local19] = _local17; } else { _local15 = ((_local17 == 18)) ? 7 : (_local17 - 14); _local16 = ((_local17 == 18)) ? 11 : 3; while (_local5 < (_local3 + _local15)) { if (_local7 != 0){ _arg2 = Z_OK; } else { bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; _local7--; var _temp6 = _local6; _local6 = (_local6 + 1); _local4 = (_local4 | ((_arg1.next_in[_temp6] & 0xFF) << _local5)); _local5 = (_local5 + 8); }; _local4 = (_local4 >>> _local3); _local5 = (_local5 - _local3); _local16 = (_local16 + (_local4 & inflate_mask[_local15])); _local4 = (_local4 >>> _local15); _local5 = (_local5 - _local15); _local15 = index; _local3 = table; if (((((_local15 + _local16) > ((258 + (_local3 & 31)) + ((_local3 >> 5) & 31)))) || ((((_local17 == 16)) && ((_local15 < 1)))))){ blens = null; mode = BAD; _arg1.msg = "invalid bit length repeat"; _arg2 = Z_DATA_ERROR; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; _local17 = ((_local17 == 16)) ? blens[(_local15 - 1)] : 0; do { var _temp7 = _local15; _local15 = (_local15 + 1); _local19 = _temp7; blens[_local19] = _local17; --_local16; } while (_local16 != 0); index = _local15; }; }; tb[0] = -1; _local10 = new Array(); _local11 = new Array(); _local12 = new Array(); _local13 = new Array(); _local10[0] = 9; _local11[0] = 6; _local3 = table; _local3 = inftree.inflate_trees_dynamic((0x0101 + (_local3 & 31)), (1 + ((_local3 >> 5) & 31)), blens, _local10, _local11, _local12, _local13, hufts, _arg1); if (_local3 != Z_OK){ if (_local3 == Z_DATA_ERROR){ blens = null; mode = BAD; }; _arg2 = _local3; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; codes.init(_local10[0], _local11[0], hufts, _local12[0], hufts, _local13[0], _arg1); mode = CODES; case CODES: bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; _arg2 = codes.proc(this, _arg1, _arg2); if (_arg2 != Z_STREAM_END){ return (inflate_flush(_arg1, _arg2)); }; _arg2 = Z_OK; codes.free(_arg1); _local6 = _arg1.next_in_index; _local7 = _arg1.avail_in; _local4 = bitb; _local5 = bitk; _local8 = write; _local9 = int(((_local8 < read)) ? ((read - _local8) - 1) : (end - _local8)); if (last == 0){ mode = TYPE; break; }; mode = DRY; case DRY: write = _local8; _arg2 = inflate_flush(_arg1, _arg2); _local8 = write; _local9 = int(((_local8 < read)) ? ((read - _local8) - 1) : (end - _local8)); if (read != write){ bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; mode = DONE; case DONE: _arg2 = Z_STREAM_END; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); case BAD: _arg2 = Z_DATA_ERROR; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); default: _arg2 = Z_STREAM_ERROR; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); }; }; _arg2 = Z_STREAM_ERROR; bitb = _local4; bitk = _local5; _arg1.avail_in = _local7; _arg1.total_in = (_arg1.total_in + (_local6 - _arg1.next_in_index)); _arg1.next_in_index = _local6; write = _local8; return (inflate_flush(_arg1, _arg2)); } public function inflate_flush(_arg1:ZStream, _arg2:int):int{ var _local3:int; var _local4:int; var _local5:int; _local4 = _arg1.next_out_index; _local5 = read; _local3 = int((((_local5 <= write)) ? write : end - _local5)); if (_local3 > _arg1.avail_out){ _local3 = _arg1.avail_out; }; if (((!((_local3 == 0))) && ((_arg2 == Z_BUF_ERROR)))){ _arg2 = Z_OK; }; _arg1.avail_out = (_arg1.avail_out - _local3); _arg1.total_out = (_arg1.total_out + _local3); if (checkfn != null){ _arg1.adler = (check = _arg1._adler.adler32(check, window, _local5, _local3)); }; System.byteArrayCopy(window, _local5, _arg1.next_out, _local4, _local3); _local4 = (_local4 + _local3); _local5 = (_local5 + _local3); if (_local5 == end){ _local5 = 0; if (write == end){ write = 0; }; _local3 = (write - _local5); if (_local3 > _arg1.avail_out){ _local3 = _arg1.avail_out; }; if (((!((_local3 == 0))) && ((_arg2 == Z_BUF_ERROR)))){ _arg2 = Z_OK; }; _arg1.avail_out = (_arg1.avail_out - _local3); _arg1.total_out = (_arg1.total_out + _local3); if (checkfn != null){ _arg1.adler = (check = _arg1._adler.adler32(check, window, _local5, _local3)); }; System.byteArrayCopy(window, _local5, _arg1.next_out, _local4, _local3); _local4 = (_local4 + _local3); _local5 = (_local5 + _local3); }; _arg1.next_out_index = _local4; read = _local5; return (_arg2); } public function free(_arg1:ZStream):void{ reset(_arg1, null); window = null; hufts = null; } } }//package com.wirelust.as3zlib
Section 74
//InfCodes (com.wirelust.as3zlib.InfCodes) package com.wirelust.as3zlib { import com.wirelust.as3zlib.*; final class InfCodes { public var dtree:Array; public var ltree:Array; public var len:int; public var need:int; public var lit:int; public var dtree_index:int; public var ltree_index:int; public var tree:Array; public var mode:int; public var dist:int; public var tree_index:int;// = 0 public var lbits:uint; public var dbits:uint; public var getBits:int; private static const Z_STREAM_END:int = 1; private static const COPY:int = 5; private static const START:int = 0; private static const BADCODE:int = 9; private static const Z_BUF_ERROR:int = -5; private static const Z_DATA_ERROR:int = -3; private static const Z_NEED_DICT:int = 2; private static const DISTEXT:int = 4; private static const Z_OK:int = 0; private static const inflate_mask:Array = new Array(0, 1, 3, 7, 15, 31, 63, 127, 0xFF, 511, 1023, 2047, 4095, 8191, 16383, 32767, 0xFFFF); private static const WASH:int = 7; private static const DIST:int = 3; private static const Z_ERRNO:int = -1; private static const LENEXT:int = 2; private static const Z_STREAM_ERROR:int = -2; private static const LEN:int = 1; private static const LIT:int = 6; private static const Z_MEM_ERROR:int = -4; private static const END:int = 8; private static const Z_VERSION_ERROR:int = -6; public function init(_arg1:int, _arg2:int, _arg3:Array, _arg4:int, _arg5:Array, _arg6:int, _arg7:ZStream):void{ mode = START; lbits = _arg1; dbits = _arg2; ltree = _arg3; ltree_index = _arg4; dtree = _arg5; dtree_index = _arg6; tree = null; } function proc(_arg1:InfBlocks, _arg2:ZStream, _arg3:int):int{ var _local4:int; var _local5:Array; var _local6:int; var _local7:int; var _local10:int; var _local11:int; var _local12:int; var _local13:int; var _local14:int; var _local8:int; var _local9:int; _local10 = 0; _local10 = _arg2.next_in_index; _local11 = _arg2.avail_in; _local8 = _arg1.bitb; _local9 = _arg1.bitk; _local12 = _arg1.write; _local13 = ((_local12 < _arg1.read)) ? ((_arg1.read - _local12) - 1) : (_arg1.end - _local12); while (true) { switch (mode){ case START: if ((((_local13 >= 258)) && ((_local11 >= 10)))){ _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; _arg3 = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, _arg1, _arg2); _local10 = _arg2.next_in_index; _local11 = _arg2.avail_in; _local8 = _arg1.bitb; _local9 = _arg1.bitk; _local12 = _arg1.write; _local13 = ((_local12 < _arg1.read)) ? ((_arg1.read - _local12) - 1) : (_arg1.end - _local12); if (_arg3 != Z_OK){ mode = ((_arg3 == Z_STREAM_END)) ? WASH : BADCODE; break; }; }; need = lbits; tree = ltree; tree_index = ltree_index; mode = LEN; case LEN: _local4 = need; while (_local9 < _local4) { if (_local11 != 0){ _arg3 = Z_OK; } else { _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); }; _local11--; var _temp1 = _local10; _local10 = (_local10 + 1); _local8 = (_local8 | ((_arg2.next_in[_temp1] & 0xFF) << _local9)); _local9 = (_local9 + 8); }; _local6 = ((tree_index + (_local8 & inflate_mask[_local4])) * 3); _local8 = (_local8 >>> tree[(_local6 + 1)]); _local9 = (_local9 - tree[(_local6 + 1)]); _local7 = tree[_local6]; if (_local7 == 0){ lit = tree[(_local6 + 2)]; mode = LIT; break; }; if ((_local7 & 16) != 0){ getBits = (_local7 & 15); len = tree[(_local6 + 2)]; mode = LENEXT; break; }; if ((_local7 & 64) == 0){ need = _local7; tree_index = ((_local6 / 3) + tree[(_local6 + 2)]); break; }; if ((_local7 & 32) != 0){ mode = WASH; break; }; mode = BADCODE; _arg2.msg = "invalid literal/length code"; _arg3 = Z_DATA_ERROR; _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); case LENEXT: _local4 = getBits; while (_local9 < _local4) { if (_local11 != 0){ _arg3 = Z_OK; } else { _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); }; _local11--; var _temp2 = _local10; _local10 = (_local10 + 1); _local8 = (_local8 | ((_arg2.next_in[_temp2] & 0xFF) << _local9)); _local9 = (_local9 + 8); }; len = (len + (_local8 & inflate_mask[_local4])); _local8 = (_local8 >> _local4); _local9 = (_local9 - _local4); need = dbits; tree = dtree; tree_index = dtree_index; mode = DIST; case DIST: _local4 = need; while (_local9 < _local4) { if (_local11 != 0){ _arg3 = Z_OK; } else { _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); }; _local11--; var _temp3 = _local10; _local10 = (_local10 + 1); _local8 = (_local8 | ((_arg2.next_in[_temp3] & 0xFF) << _local9)); _local9 = (_local9 + 8); }; _local6 = ((tree_index + (_local8 & inflate_mask[_local4])) * 3); _local8 = (_local8 >> tree[(_local6 + 1)]); _local9 = (_local9 - tree[(_local6 + 1)]); _local7 = tree[_local6]; if ((_local7 & 16) != 0){ getBits = (_local7 & 15); dist = tree[(_local6 + 2)]; mode = DISTEXT; break; }; if ((_local7 & 64) == 0){ need = _local7; tree_index = ((_local6 / 3) + tree[(_local6 + 2)]); break; }; mode = BADCODE; _arg2.msg = "invalid distance code"; _arg3 = Z_DATA_ERROR; _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); case DISTEXT: _local4 = getBits; while (_local9 < _local4) { if (_local11 != 0){ _arg3 = Z_OK; } else { _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); }; _local11--; var _temp4 = _local10; _local10 = (_local10 + 1); _local8 = (_local8 | ((_arg2.next_in[_temp4] & 0xFF) << _local9)); _local9 = (_local9 + 8); }; dist = (dist + (_local8 & inflate_mask[_local4])); _local8 = (_local8 >> _local4); _local9 = (_local9 - _local4); mode = COPY; case COPY: _local14 = (_local12 - dist); while (_local14 < 0) { _local14 = (_local14 + _arg1.end); }; while (len != 0) { if (_local13 == 0){ if ((((_local12 == _arg1.end)) && (!((_arg1.read == 0))))){ _local12 = 0; _local13 = ((_local12 < _arg1.read)) ? ((_arg1.read - _local12) - 1) : (_arg1.end - _local12); }; if (_local13 == 0){ _arg1.write = _local12; _arg3 = _arg1.inflate_flush(_arg2, _arg3); _local12 = _arg1.write; _local13 = ((_local12 < _arg1.read)) ? ((_arg1.read - _local12) - 1) : (_arg1.end - _local12); if ((((_local12 == _arg1.end)) && (!((_arg1.read == 0))))){ _local12 = 0; _local13 = ((_local12 < _arg1.read)) ? ((_arg1.read - _local12) - 1) : (_arg1.end - _local12); }; if (_local13 == 0){ _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); }; }; }; var _temp5 = _local12; _local12 = (_local12 + 1); var _local15 = _temp5; var _temp6 = _local14; _local14 = (_local14 + 1); _arg1.window[_local15] = _arg1.window[_temp6]; _local13--; if (_local14 == _arg1.end){ _local14 = 0; }; len--; }; mode = START; break; case LIT: if (_local13 == 0){ if ((((_local12 == _arg1.end)) && (!((_arg1.read == 0))))){ _local12 = 0; _local13 = ((_local12 < _arg1.read)) ? ((_arg1.read - _local12) - 1) : (_arg1.end - _local12); }; if (_local13 == 0){ _arg1.write = _local12; _arg3 = _arg1.inflate_flush(_arg2, _arg3); _local12 = _arg1.write; _local13 = ((_local12 < _arg1.read)) ? ((_arg1.read - _local12) - 1) : (_arg1.end - _local12); if ((((_local12 == _arg1.end)) && (!((_arg1.read == 0))))){ _local12 = 0; _local13 = ((_local12 < _arg1.read)) ? ((_arg1.read - _local12) - 1) : (_arg1.end - _local12); }; if (_local13 == 0){ _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); }; }; }; _arg3 = Z_OK; var _temp7 = _local12; _local12 = (_local12 + 1); _local15 = _temp7; _arg1.window[_local15] = lit; _local13--; mode = START; break; case WASH: if (_local9 > 7){ _local9 = (_local9 - 8); _local11++; _local10--; }; _arg1.write = _local12; _arg3 = _arg1.inflate_flush(_arg2, _arg3); _local12 = _arg1.write; _local13 = ((_local12 < _arg1.read)) ? ((_arg1.read - _local12) - 1) : (_arg1.end - _local12); if (_arg1.read != _arg1.write){ _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); }; mode = END; case END: _arg3 = Z_STREAM_END; _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); case BADCODE: _arg3 = Z_DATA_ERROR; _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); default: _arg3 = Z_STREAM_ERROR; _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); }; }; _arg3 = Z_STREAM_ERROR; _arg1.bitb = _local8; _arg1.bitk = _local9; _arg2.avail_in = _local11; _arg2.total_in = (_arg2.total_in + (_local10 - _arg2.next_in_index)); _arg2.next_in_index = _local10; _arg1.write = _local12; return (_arg1.inflate_flush(_arg2, _arg3)); } public function inflate_fast(_arg1:int, _arg2:int, _arg3:Array, _arg4:int, _arg5:Array, _arg6:int, _arg7:InfBlocks, _arg8:ZStream):int{ var _local9:int; var _local10:Array; var _local11:int; var _local12:int; var _local13:int; var _local14:int; var _local15:int; var _local16:int; var _local17:int; var _local18:int; var _local19:int; var _local20:int; var _local21:int; var _local22:int; var _local23:int; var _local24:int; var _local25:*; _local15 = _arg8.next_in_index; _local16 = _arg8.avail_in; _local13 = _arg7.bitb; _local14 = _arg7.bitk; _local17 = _arg7.write; _local18 = ((_local17 < _arg7.read)) ? ((_arg7.read - _local17) - 1) : (_arg7.end - _local17); _local19 = inflate_mask[_arg1]; _local20 = inflate_mask[_arg2]; do { _local25 = false; while (_local14 < 20) { _local16--; var _temp1 = _local15; _local15 = (_local15 + 1); _local13 = (_local13 | ((_arg8.next_in[_temp1] & 0xFF) << _local14)); _local14 = (_local14 + 8); }; _local9 = (_local13 & _local19); _local10 = _arg3; _local11 = _arg4; _local24 = ((_local11 + _local9) * 3); _local12 = _local10[_local24]; if (_local12 == 0){ _local13 = (_local13 >> _local10[(_local24 + 1)]); _local14 = (_local14 - _local10[(_local24 + 1)]); var _temp2 = _local17; _local17 = (_local17 + 1); var _local26 = _temp2; _arg7.window[_local26] = _local10[(_local24 + 2)]; _local18--; _local25 = true; }; if (!_local25){ do { _local13 = (_local13 >> _local10[(_local24 + 1)]); _local14 = (_local14 - _local10[(_local24 + 1)]); if ((_local12 & 16) != 0){ _local12 = (_local12 & 15); _local21 = (_local10[(_local24 + 2)] + (int(_local13) & inflate_mask[_local12])); _local13 = (_local13 >> _local12); _local14 = (_local14 - _local12); while (_local14 < 15) { _local16--; var _temp3 = _local15; _local15 = (_local15 + 1); _local13 = (_local13 | ((_arg8.next_in[_temp3] & 0xFF) << _local14)); _local14 = (_local14 + 8); }; _local9 = (_local13 & _local20); _local10 = _arg5; _local11 = _arg6; _local24 = ((_local11 + _local9) * 3); _local12 = _local10[_local24]; do { _local13 = (_local13 >> _local10[(_local24 + 1)]); _local14 = (_local14 - _local10[(_local24 + 1)]); if ((_local12 & 16) != 0){ _local12 = (_local12 & 15); while (_local14 < _local12) { _local16--; var _temp4 = _local15; _local15 = (_local15 + 1); _local13 = (_local13 | ((_arg8.next_in[_temp4] & 0xFF) << _local14)); _local14 = (_local14 + 8); }; _local22 = (_local10[(_local24 + 2)] + (_local13 & inflate_mask[_local12])); _local13 = (_local13 >> _local12); _local14 = (_local14 - _local12); _local18 = (_local18 - _local21); if (_local17 >= _local22){ _local23 = (_local17 - _local22); if (((((_local17 - _local23) > 0)) && ((2 > (_local17 - _local23))))){ var _temp5 = _local17; _local17 = (_local17 + 1); _local26 = _temp5; var _temp6 = _local23; _local23 = (_local23 + 1); _arg7.window[_local26] = _arg7.window[_temp6]; var _temp7 = _local17; _local17 = (_local17 + 1); var _local27 = _temp7; var _temp8 = _local23; _local23 = (_local23 + 1); _arg7.window[_local27] = _arg7.window[_temp8]; _local21 = (_local21 - 2); } else { System.byteArrayCopy(_arg7.window, _local23, _arg7.window, _local17, 2); _local17 = (_local17 + 2); _local23 = (_local23 + 2); _local21 = (_local21 - 2); }; } else { _local23 = (_local17 - _local22); do { _local23 = (_local23 + _arg7.end); } while (_local23 < 0); _local12 = (_arg7.end - _local23); if (_local21 > _local12){ _local21 = (_local21 - _local12); if (((((_local17 - _local23) > 0)) && ((_local12 > (_local17 - _local23))))){ do { var _temp9 = _local17; _local17 = (_local17 + 1); _local26 = _temp9; var _temp10 = _local23; _local23 = (_local23 + 1); _arg7.window[_local26] = _arg7.window[_temp10]; --_local12; } while (_local12 != 0); } else { System.byteArrayCopy(_arg7.window, _local23, _arg7.window, _local17, _local12); _local17 = (_local17 + _local12); _local23 = (_local23 + _local12); _local12 = 0; }; _local23 = 0; }; }; if (((((_local17 - _local23) > 0)) && ((_local21 > (_local17 - _local23))))){ do { var _temp11 = _local17; _local17 = (_local17 + 1); _local26 = _temp11; var _temp12 = _local23; _local23 = (_local23 + 1); _arg7.window[_local26] = _arg7.window[_temp12]; --_local21; } while (_local21 != 0); } else { System.byteArrayCopy(_arg7.window, _local23, _arg7.window, _local17, _local21); _local17 = (_local17 + _local21); _local23 = (_local23 + _local21); _local21 = 0; }; break; } else { if ((_local12 & 64) == 0){ _local9 = (_local9 + _local10[(_local24 + 2)]); _local9 = (_local9 + (_local13 & inflate_mask[_local12])); _local24 = ((_local11 + _local9) * 3); _local12 = _local10[_local24]; } else { _arg8.msg = "invalid distance code"; _local21 = (_arg8.avail_in - _local16); _local21 = (((_local14 >> 3) < _local21)) ? (_local14 >> 3) : _local21; _local16 = (_local16 + _local21); _local15 = (_local15 - _local21); _local14 = (_local14 - (_local21 << 3)); _arg7.bitb = _local13; _arg7.bitk = _local14; _arg8.avail_in = _local16; _arg8.total_in = (_arg8.total_in + (_local15 - _arg8.next_in_index)); _arg8.next_in_index = _local15; _arg7.write = _local17; return (Z_DATA_ERROR); }; }; } while (true); break; }; if ((_local12 & 64) == 0){ _local9 = (_local9 + _local10[(_local24 + 2)]); _local9 = (_local9 + (_local13 & inflate_mask[_local12])); _local24 = ((_local11 + _local9) * 3); _local12 = _local10[_local24]; if (_local12 == 0){ _local13 = (_local13 >> _local10[(_local24 + 1)]); _local14 = (_local14 - _local10[(_local24 + 1)]); var _temp13 = _local17; _local17 = (_local17 + 1); _local26 = _temp13; _arg7.window[_local26] = _local10[(_local24 + 2)]; _local18--; break; }; } else { if ((_local12 & 32) != 0){ _local21 = (_arg8.avail_in - _local16); _local21 = (((_local14 >> 3) < _local21)) ? (_local14 >> 3) : _local21; _local16 = (_local16 + _local21); _local15 = (_local15 - _local21); _local14 = (_local14 - (_local21 << 3)); _arg7.bitb = _local13; _arg7.bitk = _local14; _arg8.avail_in = _local16; _arg8.total_in = (_arg8.total_in + (_local15 - _arg8.next_in_index)); _arg8.next_in_index = _local15; _arg7.write = _local17; return (Z_STREAM_END); } else { _arg8.msg = "invalid literal/length code"; _local21 = (_arg8.avail_in - _local16); _local21 = (((_local14 >> 3) < _local21)) ? (_local14 >> 3) : _local21; _local16 = (_local16 + _local21); _local15 = (_local15 - _local21); _local14 = (_local14 - (_local21 << 3)); _arg7.bitb = _local13; _arg7.bitk = _local14; _arg8.avail_in = _local16; _arg8.total_in = (_arg8.total_in + (_local15 - _arg8.next_in_index)); _arg8.next_in_index = _local15; _arg7.write = _local17; return (Z_DATA_ERROR); }; }; } while (true); }; } while ((((_local18 >= 258)) && ((_local16 >= 10)))); _local21 = (_arg8.avail_in - _local16); _local21 = (((_local14 >> 3) < _local21)) ? (_local14 >> 3) : _local21; _local16 = (_local16 + _local21); _local15 = (_local15 - _local21); _local14 = (_local14 - (_local21 << 3)); _arg7.bitb = _local13; _arg7.bitk = _local14; _arg8.avail_in = _local16; _arg8.total_in = (_arg8.total_in + (_local15 - _arg8.next_in_index)); _arg8.next_in_index = _local15; _arg7.write = _local17; return (Z_OK); } public function free(_arg1:ZStream):void{ } } }//package com.wirelust.as3zlib
Section 75
//Inflate (com.wirelust.as3zlib.Inflate) package com.wirelust.as3zlib { import flash.utils.*; public final class Inflate { public var method:int; public var mode:int; public var wbits:int; public var was:Array; public var nowrap:int; public var blocks:InfBlocks; public var marker:int; public var need:Number; private static const Z_STREAM_END:int = 1; public static const BLOCKS:int = 7; public static const DONE:int = 12; private static const PRESET_DICT:int = 32; public static const Z_FINISH:int = 4; private static const Z_NEED_DICT:int = 2; private static const Z_DATA_ERROR:int = -3; private static const Z_ERRNO:int = -1; private static const MAX_WBITS:int = 15; public static const Z_NO_FLUSH:int = 0; private static const Z_STREAM_ERROR:int = -2; private static const Z_MEM_ERROR:int = -4; public static const DICT0:int = 6; public static const DICT1:int = 5; public static const DICT2:int = 4; public static const DICT3:int = 3; public static const DICT4:int = 2; public static const Z_FULL_FLUSH:int = 3; public static const Z_SYNC_FLUSH:int = 2; public static const CHECK2:int = 10; public static const CHECK3:int = 9; public static const CHECK4:int = 8; public static const CHECK1:int = 11; private static const Z_BUF_ERROR:int = -5; private static const Z_DEFLATED:int = 8; public static const METHOD:int = 0; public static const BAD:int = 13; public static const Z_PARTIAL_FLUSH:int = 1; public static const FLAG:int = 1; private static const Z_OK:int = 0; private static const Z_VERSION_ERROR:int = -6; private static var mark:Array = new Array(0, 0, 0xFF, 0xFF); public function Inflate(){ was = new Array(); super(); } public function inflate(_arg1:ZStream, _arg2:int):int{ var _local3:int; var _local4:int; var _local5:int; if ((((((_arg1 == null)) || ((_arg1.istate == null)))) || ((_arg1.next_in == null)))){ return (Z_STREAM_ERROR); }; _arg2 = ((_arg2 == Z_FINISH)) ? Z_BUF_ERROR : Z_OK; _local3 = Z_BUF_ERROR; while (true) { switch (_arg1.istate.mode){ case METHOD: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; if (((_arg1.istate.method = _arg1.next_in[_arg1.next_in_index++]) & 15) != Z_DEFLATED){ _arg1.istate.mode = BAD; _arg1.msg = "unknown compression method"; _arg1.istate.marker = 5; break; }; if (((_arg1.istate.method >> 4) + 8) > _arg1.istate.wbits){ _arg1.istate.mode = BAD; _arg1.msg = "invalid window size"; _arg1.istate.marker = 5; break; }; _arg1.istate.mode = FLAG; case FLAG: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; _local4 = (_arg1.next_in[_arg1.next_in_index++] & 0xFF); _local5 = (((_arg1.istate.method << 8) + _local4) % 31); if (_local5 != 0){ _arg1.istate.mode = BAD; _arg1.msg = "incorrect header check"; _arg1.istate.marker = 5; break; }; if ((_local4 & PRESET_DICT) == 0){ _arg1.istate.mode = BLOCKS; break; }; _arg1.istate.mode = DICT4; case DICT4: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; _arg1.istate.need = (((_arg1.next_in[_arg1.next_in_index++] & 0xFF) << 24) & 4278190080); _arg1.istate.mode = DICT3; case DICT3: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; _arg1.istate.need = (_arg1.istate.need + (((_arg1.next_in[_arg1.next_in_index++] & 0xFF) << 16) & 0xFF0000)); _arg1.istate.mode = DICT2; case DICT2: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; _arg1.istate.need = (_arg1.istate.need + (((_arg1.next_in[_arg1.next_in_index++] & 0xFF) << 8) & 0xFF00)); _arg1.istate.mode = DICT1; case DICT1: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; _arg1.istate.need = (_arg1.istate.need + (_arg1.next_in[_arg1.next_in_index++] & 0xFF)); _arg1.adler = _arg1.istate.need; _arg1.istate.mode = DICT0; return (Z_NEED_DICT); case DICT0: _arg1.istate.mode = BAD; _arg1.msg = "need dictionary"; _arg1.istate.marker = 0; return (Z_STREAM_ERROR); case BLOCKS: _local3 = _arg1.istate.blocks.proc(_arg1, _local3); if (_local3 == Z_DATA_ERROR){ _arg1.istate.mode = BAD; _arg1.istate.marker = 0; break; }; if (_local3 == Z_OK){ _local3 = _arg2; }; if (_local3 != Z_STREAM_END){ return (_local3); }; _local3 = _arg2; _arg1.istate.blocks.reset(_arg1, _arg1.istate.was); if (_arg1.istate.nowrap != 0){ _arg1.istate.mode = DONE; break; }; _arg1.istate.mode = CHECK4; case CHECK4: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; _arg1.istate.need = (((_arg1.next_in[_arg1.next_in_index++] & 0xFF) << 24) & 4278190080); _arg1.istate.mode = CHECK3; case CHECK3: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; _arg1.istate.need = (_arg1.istate.need + (((_arg1.next_in[_arg1.next_in_index++] & 0xFF) << 16) & 0xFF0000)); _arg1.istate.mode = CHECK2; case CHECK2: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; _arg1.istate.need = (_arg1.istate.need + (((_arg1.next_in[_arg1.next_in_index++] & 0xFF) << 8) & 0xFF00)); _arg1.istate.mode = CHECK1; case CHECK1: if (_arg1.avail_in == 0){ return (_local3); }; _local3 = _arg2; _arg1.avail_in--; _arg1.total_in++; _arg1.istate.need = (_arg1.istate.need + (_arg1.next_in[_arg1.next_in_index++] & 0xFF)); if (int(_arg1.istate.was[0]) != int(_arg1.istate.need)){ _arg1.istate.mode = BAD; _arg1.msg = "incorrect data check"; _arg1.istate.marker = 5; break; }; _arg1.istate.mode = DONE; case DONE: return (Z_STREAM_END); case BAD: return (Z_DATA_ERROR); default: return (Z_STREAM_ERROR); }; }; return (Z_STREAM_ERROR); } public function inflateReset(_arg1:ZStream):int{ if ((((_arg1 == null)) || ((_arg1.istate == null)))){ return (Z_STREAM_ERROR); }; _arg1.total_in = (_arg1.total_out = 0); _arg1.msg = null; _arg1.istate.mode = ((_arg1.istate.nowrap)!=0) ? BLOCKS : METHOD; _arg1.istate.blocks.reset(_arg1, null); return (Z_OK); } public function inflateSyncPoint(_arg1:ZStream):int{ if ((((((_arg1 == null)) || ((_arg1.istate == null)))) || ((_arg1.istate.blocks == null)))){ return (Z_STREAM_ERROR); }; return (_arg1.istate.blocks.sync_point()); } public function inflateSync(_arg1:ZStream):int{ var _local2:int; var _local3:int; var _local4:int; var _local5:Number; var _local6:Number; if ((((_arg1 == null)) || ((_arg1.istate == null)))){ return (Z_STREAM_ERROR); }; if (_arg1.istate.mode != BAD){ _arg1.istate.mode = BAD; _arg1.istate.marker = 0; }; _local2 = _arg1.avail_in; if (_local2 == 0){ return (Z_BUF_ERROR); }; _local3 = _arg1.next_in_index; _local4 = _arg1.istate.marker; while (((!((_local2 == 0))) && ((_local4 < 4)))) { if (_arg1.next_in[_local3] == mark[_local4]){ _local4++; } else { if (_arg1.next_in[_local3] != 0){ _local4 = 0; } else { _local4 = (4 - _local4); }; }; _local3++; _local2--; }; _arg1.total_in = (_arg1.total_in + (_local3 - _arg1.next_in_index)); _arg1.next_in_index = _local3; _arg1.avail_in = _local2; _arg1.istate.marker = _local4; if (_local4 != 4){ return (Z_DATA_ERROR); }; _local5 = _arg1.total_in; _local6 = _arg1.total_out; inflateReset(_arg1); _arg1.total_in = _local5; _arg1.total_out = _local6; _arg1.istate.mode = BLOCKS; return (Z_OK); } public function inflateSetDictionary(_arg1:ZStream, _arg2:ByteArray, _arg3:int):int{ var _local4:int; var _local5:int = _arg3; if ((((((_arg1 == null)) || ((_arg1.istate == null)))) || (!((_arg1.istate.mode == DICT0))))){ return (Z_STREAM_ERROR); }; if (_arg1._adler.adler32(1, _arg2, 0, _arg3) != _arg1.adler){ return (Z_DATA_ERROR); }; _arg1.adler = _arg1._adler.adler32(0, null, 0, 0); if (_local5 >= (1 << _arg1.istate.wbits)){ _local5 = ((1 << _arg1.istate.wbits) - 1); _local4 = (_arg3 - _local5); }; _arg1.istate.blocks.set_dictionary(_arg2, _local4, _local5); _arg1.istate.mode = BLOCKS; return (Z_OK); } public function inflateInit(_arg1:ZStream, _arg2:int):int{ _arg1.msg = null; blocks = null; nowrap = 0; if (_arg2 < 0){ _arg2 = -(_arg2); nowrap = 1; }; if ((((_arg2 < 8)) || ((_arg2 > 15)))){ inflateEnd(_arg1); return (Z_STREAM_ERROR); }; wbits = _arg2; _arg1.istate.blocks = new InfBlocks(_arg1, ((_arg1.istate.nowrap)!=0) ? null : this, (1 << _arg2)); inflateReset(_arg1); return (Z_OK); } public function inflateEnd(_arg1:ZStream):int{ if (blocks != null){ blocks.free(_arg1); }; blocks = null; return (Z_OK); } } }//package com.wirelust.as3zlib
Section 76
//InfTree (com.wirelust.as3zlib.InfTree) package com.wirelust.as3zlib { import com.wirelust.as3zlib.*; final class InfTree { public var c:Array;// = null public var hn:Array;// = null public var r:Array;// = null public var u:Array;// = null public var v:Array;// = null public var x:Array;// = null private static const Z_STREAM_END:int = 1; public static const cpdext:Array = new Array(0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13); public static const cpdist:Array = new Array(1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 0x0101, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577); private static const Z_BUF_ERROR:int = -5; private static const Z_DATA_ERROR:int = -3; private static const Z_NEED_DICT:int = 2; public static const fixed_td:Array = new Array(80, 5, 1, 87, 5, 0x0101, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577); private static const MANY:int = 1440; private static const Z_ERRNO:int = -1; public static const fixed_tl:Array = new Array(96, 7, 0x0100, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 0x0100, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 0x0100, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 0x0100, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 0xFF); public static const BMAX:int = 15; private static const Z_OK:int = 0; public static const cplens:Array = new Array(3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0); private static const fixed_bd:int = 5; private static const Z_STREAM_ERROR:int = -2; public static const cplext:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112); private static const fixed_bl:int = 9; private static const Z_MEM_ERROR:int = -4; private static const Z_VERSION_ERROR:int = -6; public function inflate_trees_bits(_arg1:Array, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:ZStream):int{ var _local6:int; initWorkArea(19); hn[0] = 0; _local6 = huft_build(_arg1, 0, 19, 19, null, null, _arg3, _arg2, _arg4, hn, v); if (_local6 == Z_DATA_ERROR){ _arg5.msg = "oversubscribed dynamic bit lengths tree"; } else { if ((((_local6 == Z_BUF_ERROR)) || ((_arg2[0] == 0)))){ _arg5.msg = "incomplete dynamic bit lengths tree"; _local6 = Z_DATA_ERROR; }; }; return (_local6); } private function initWorkArea(_arg1:int):void{ var _local2:int; if (hn == null){ hn = new Array(); v = new Array(); c = new Array(); r = new Array(); u = new Array(); x = new Array(); }; if (v.length < _arg1){ v = new Array(); }; _local2 = 0; while (_local2 < _arg1) { v[_local2] = 0; _local2++; }; _local2 = 0; while (_local2 < (BMAX + 1)) { c[_local2] = 0; _local2++; }; _local2 = 0; while (_local2 < 3) { r[_local2] = 0; _local2++; }; System.arrayCopy(c, 0, u, 0, BMAX); System.arrayCopy(c, 0, x, 0, (BMAX + 1)); } private function huft_build(_arg1:Array, _arg2:int, _arg3:int, _arg4:int, _arg5:Array, _arg6:Array, _arg7:Array, _arg8:Array, _arg9:Array, _arg10:Array, _arg11:Array):int{ var _local12:int; var _local13:int; var _local14:int; var _local15:int; var _local16:int; var _local17:int; var _local18:int; var _local19:int; var _local20:int; var _local21:int; var _local22:int; var _local23:int; var _local24:int; var _local25:int; var _local26:int; _local21 = 0; _local16 = _arg3; do { var _local27 = c; var _local28 = _arg1[(_arg2 + _local21)]; var _local29 = (_local27[_local28] + 1); _local27[_local28] = _local29; _local21++; --_local16; } while (_local16 != 0); if (c[0] == _arg3){ _arg7[0] = -1; _arg8[0] = 0; return (Z_OK); }; _local19 = _arg8[0]; _local17 = 1; while (_local17 <= BMAX) { if (c[_local17] != 0){ break; }; _local17++; }; _local18 = _local17; if (_local19 < _local17){ _local19 = _local17; }; _local16 = BMAX; while (_local16 != 0) { if (c[_local16] != 0){ break; }; _local16--; }; _local14 = _local16; if (_local19 > _local16){ _local19 = _local16; }; _arg8[0] = _local19; _local25 = (1 << _local17); while (_local17 < _local16) { _local25 = (_local25 - c[_local17]); if (_local25 < 0){ return (Z_DATA_ERROR); }; _local17++; _local25 = (_local25 << 1); }; _local25 = (_local25 - c[_local16]); if (_local25 < 0){ return (Z_DATA_ERROR); }; c[_local16] = (c[_local16] + _local25); _local17 = 0; x[1] = _local17; _local21 = 1; _local24 = 2; while (--_local16 != 0) { _local17 = (_local17 + c[_local21]); x[_local24] = _local17; _local24++; _local21++; }; _local16 = 0; _local21 = 0; do { _local17 = _arg1[(_arg2 + _local21)]; if (_local17 != 0){ _local28 = x; _local29 = _local17; var _local30 = (_local28[_local29] + 1); _local28[_local29] = _local30; _local27 = _local28[_local29]; _arg11[_local27] = _local16; }; _local21++; ++_local16; } while (_local16 < _arg3); _arg3 = x[_local14]; _local16 = 0; x[0] = _local16; _local21 = 0; _local15 = -1; _local23 = -(_local19); u[0] = 0; _local22 = 0; _local26 = 0; while (_local18 <= _local14) { _local12 = c[_local18]; while (_local12-- != 0) { while (_local18 > (_local23 + _local19)) { _local15++; _local23 = (_local23 + _local19); _local26 = (_local14 - _local23); _local26 = ((_local26)>_local19) ? _local19 : _local26; _local17 = (_local18 - _local23); _local13 = (1 << _local17); if (_local13 > (_local12 + 1)){ _local13 = (_local13 - (_local12 + 1)); _local24 = _local18; if (_local17 < _local26){ while (++_local17 < _local26) { _local13 = (_local13 << 1); ++_local24; if (_local13 <= c[_local24]){ break; }; _local13 = (_local13 - c[_local24]); }; }; }; _local26 = (1 << _local17); if ((_arg10[0] + _local26) > MANY){ return (Z_DATA_ERROR); }; _local22 = _arg10[0]; u[_local15] = _local22; _arg10[0] = (_arg10[0] + _local26); if (_local15 != 0){ x[_local15] = _local16; r[0] = _local17; r[1] = _local19; _local17 = (_local16 >>> (_local23 - _local19)); r[2] = int(((_local22 - u[(_local15 - 1)]) - _local17)); System.arrayCopy(r, 0, _arg9, ((u[(_local15 - 1)] + _local17) * 3), 3); } else { _arg7[0] = _local22; }; }; r[1] = (_local18 - _local23); if (_local21 >= _arg3){ r[0] = (128 + 64); } else { if (_arg11[_local21] < _arg4){ r[0] = ((_arg11[_local21] < 0x0100)) ? 0 : (32 + 64); var _temp1 = _local21; _local21 = (_local21 + 1); r[2] = _arg11[_temp1]; } else { r[0] = ((_arg6[(_arg11[_local21] - _arg4)] + 16) + 64); var _temp2 = _local21; _local21 = (_local21 + 1); r[2] = _arg5[(_arg11[_temp2] - _arg4)]; }; }; _local13 = (1 << (_local18 - _local23)); _local17 = (_local16 >>> _local23); while (_local17 < _local26) { System.arrayCopy(r, 0, _arg9, ((_local22 + _local17) * 3), 3); _local17 = (_local17 + _local13); }; _local17 = (1 << (_local18 - 1)); while ((_local16 & _local17) != 0) { _local16 = (_local16 ^ _local17); _local17 = (_local17 >>> 1); }; _local16 = (_local16 ^ _local17); _local20 = ((1 << _local23) - 1); while ((_local16 & _local20) != x[_local15]) { _local15--; _local23 = (_local23 - _local19); _local20 = ((1 << _local23) - 1); }; }; _local18++; }; return ((((!((_local25 == 0))) && (!((_local14 == 1))))) ? Z_BUF_ERROR : Z_OK); } public function inflate_trees_dynamic(_arg1:int, _arg2:int, _arg3:Array, _arg4:Array, _arg5:Array, _arg6:Array, _arg7:Array, _arg8:Array, _arg9:ZStream):int{ var _local10:int; initWorkArea(288); hn[0] = 0; _local10 = huft_build(_arg3, 0, _arg1, 0x0101, cplens, cplext, _arg6, _arg4, _arg8, hn, v); if (((!((_local10 == Z_OK))) || ((_arg4[0] == 0)))){ if (_local10 == Z_DATA_ERROR){ _arg9.msg = "oversubscribed literal/length tree"; } else { if (_local10 != Z_MEM_ERROR){ _arg9.msg = "incomplete literal/length tree"; _local10 = Z_DATA_ERROR; }; }; return (_local10); }; initWorkArea(288); _local10 = huft_build(_arg3, _arg1, _arg2, 0, cpdist, cpdext, _arg7, _arg5, _arg8, hn, v); if (((!((_local10 == Z_OK))) || ((((_arg5[0] == 0)) && ((_arg1 > 0x0101)))))){ if (_local10 == Z_DATA_ERROR){ _arg9.msg = "oversubscribed distance tree"; } else { if (_local10 == Z_BUF_ERROR){ _arg9.msg = "incomplete distance tree"; _local10 = Z_DATA_ERROR; } else { if (_local10 != Z_MEM_ERROR){ _arg9.msg = "empty distance tree with lengths"; _local10 = Z_DATA_ERROR; }; }; }; return (_local10); }; return (Z_OK); } public static function inflate_trees_fixed(_arg1:Array, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:ZStream):int{ _arg1[0] = fixed_bl; _arg2[0] = fixed_bd; _arg3[0] = fixed_tl; _arg4[0] = fixed_td; return (Z_OK); } } }//package com.wirelust.as3zlib
Section 77
//JZlib (com.wirelust.as3zlib.JZlib) package com.wirelust.as3zlib { public final class JZlib { public var version:String;// = "1.0.2" public static var Z_MEM_ERROR:int = -4; public static var Z_STREAM_END:int = 1; public static var Z_DEFAULT_COMPRESSION:int = -1; public static var Z_SYNC_FLUSH:int = 2; public static var Z_VERSION_ERROR:int = -6; public static var Z_NO_COMPRESSION:int = 0; public static var Z_ERRNO:int = -1; public static var Z_BEST_SPEED:int = 1; public static var Z_DEFAULT_STRATEGY:int = 0; public static var Z_BUF_ERROR:int = -5; public static var Z_FINISH:int = 4; public static var Z_FILTERED:int = 1; public static var Z_PARTIAL_FLUSH:int = 1; public static var Z_HUFFMAN_ONLY:int = 2; public static var Z_DATA_ERROR:int = -3; public static var Z_OK:int = 0; public static var Z_NO_FLUSH:int = 0; public static var Z_STREAM_ERROR:int = -2; public static var Z_BEST_COMPRESSION:int = 9; public static var Z_FULL_FLUSH:int = 3; public static var Z_NEED_DICT:int = 2; public static function get version():String{ return (version); } } }//package com.wirelust.as3zlib
Section 78
//StaticTree (com.wirelust.as3zlib.StaticTree) package com.wirelust.as3zlib { import com.wirelust.as3zlib.*; final class StaticTree { var extra_base:int; var max_length:int; var elems:int; var extra_bits:Array; var static_tree:Array; public static const MAX_BL_BITS:int = 7; private static const MAX_BITS:int = 15; private static const LITERALS:int = 0x0100; private static const D_CODES:int = 30; private static const LENGTH_CODES:int = 29; private static const BL_CODES:int = 19; private static const L_CODES:int = 286; public static const static_dtree:Array = new Array(0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5); public static const static_ltree:Array = new Array(12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 0xFF, 9, 511, 9, 0, 7, 64, 7, 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8); static var static_l_desc:StaticTree = new StaticTree(static_ltree, Tree.extra_lbits, (LITERALS + 1), L_CODES, MAX_BITS); ; static var static_bl_desc:StaticTree = new StaticTree(null, Tree.extra_blbits, 0, BL_CODES, MAX_BL_BITS); ; static var static_d_desc:StaticTree = new StaticTree(static_dtree, Tree.extra_dbits, 0, D_CODES, MAX_BITS); ; function StaticTree(_arg1:Array, _arg2:Array, _arg3:int, _arg4:int, _arg5:int){ this.static_tree = _arg1; this.extra_bits = _arg2; this.extra_base = _arg3; this.elems = _arg4; this.max_length = _arg5; } } }//package com.wirelust.as3zlib
Section 79
//System (com.wirelust.as3zlib.System) package com.wirelust.as3zlib { import flash.utils.*; import flash.external.*; public class System { public static function byteArrayCopy(_arg1:ByteArray, _arg2:int, _arg3:ByteArray, _arg4:int, _arg5:int):void{ var _local6:int; while (_local6 < _arg5) { _arg3[(_arg4 + _local6)] = _arg1[(_arg2 + _local6)]; _local6++; }; } public static function arrayCopy(_arg1:Array, _arg2:int, _arg3:Array, _arg4:int, _arg5:int):void{ var _local6:int; while (_local6 < _arg5) { _arg3[(_arg4 + _local6)] = _arg1[(_arg2 + _local6)]; _local6++; }; } public static function println(_arg1:String):void{ trace(_arg1); ExternalInterface.call("console.log", _arg1); } } }//package com.wirelust.as3zlib
Section 80
//Tree (com.wirelust.as3zlib.Tree) package com.wirelust.as3zlib { import com.wirelust.util.*; public final class Tree { public var dyn_tree:Array; public var max_code:int; public var stat_desc:StaticTree; public static const extra_lbits:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0); public static const REPZ_3_10:int = 17; private static const D_CODES:int = 30; public static const Buf_size:int = 16; private static const BL_CODES:int = 19; private static const L_CODES:int = 286; public static const base_length:Array = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0); public static const bl_order:Array = new Array(16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15); public static const base_dist:Array = new Array(0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 0x0100, 384, 0x0200, 0x0300, 0x0400, 0x0600, 0x0800, 0x0C00, 0x1000, 0x1800, 0x2000, 0x3000, 0x4000, 0x6000); public static const DIST_CODE_LEN:int = 0x0200; public static const extra_blbits:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7); public static const MAX_BL_BITS:int = 7; private static const MAX_BITS:int = 15; private static const LITERALS:int = 0x0100; public static const _dist_code:Array = new Array(0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29); public static const END_BLOCK:int = 0x0100; private static const LENGTH_CODES:int = 29; public static const _length_code:Array = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28); public static const REP_3_6:int = 16; private static const HEAP_SIZE:int = 573; public static const REPZ_11_138:int = 18; public static const extra_dbits:Array = new Array(0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13); public function build_tree(_arg1:Deflate):void{ var _local5:int; var _local6:int; var _local8:int; var _local2:Array = dyn_tree; var _local3:Array = stat_desc.static_tree; var _local4:int = stat_desc.elems; var _local7 = -1; _arg1.heap_len = 0; _arg1.heap_max = HEAP_SIZE; _local5 = 0; while (_local5 < _local4) { if (_local2[(_local5 * 2)] != 0){ var _local9 = ++_arg1.heap_len; _local7 = _local5; _arg1.heap[_local9] = _local7; _arg1.depth[_local5] = 0; } else { _local2[((_local5 * 2) + 1)] = 0; }; _local5++; }; while (_arg1.heap_len < 2) { _local9 = ++_arg1.heap_len; _local8 = (_arg1.heap[_local9] = ((_local7 < 2)) ? ++_local7; _local7 : 0); _local2[(_local8 * 2)] = 1; _arg1.depth[_local8] = 0; _arg1.opt_len--; if (_local3 != null){ _arg1.static_len = (_arg1.static_len - _local3[((_local8 * 2) + 1)]); }; }; this.max_code = _local7; _local5 = (_arg1.heap_len / 2); while (_local5 >= 1) { _arg1.pqdownheap(_local2, _local5); _local5--; }; _local8 = _local4; do { _local5 = _arg1.heap[1]; _arg1.heap[1] = _arg1.heap[_arg1.heap_len--]; _arg1.pqdownheap(_local2, 1); _local6 = _arg1.heap[1]; _local9 = --_arg1.heap_max; _arg1.heap[_local9] = _local5; var _local10 = --_arg1.heap_max; _arg1.heap[_local10] = _local6; _local2[(_local8 * 2)] = (_local2[(_local5 * 2)] + _local2[(_local6 * 2)]); _arg1.depth[_local8] = (Math.max(_arg1.depth[_local5], _arg1.depth[_local6]) + 1); _local2[((_local5 * 2) + 1)] = (_local2[((_local6 * 2) + 1)] = _local8); var _temp1 = _local8; _local8 = (_local8 + 1); _arg1.heap[1] = _temp1; _arg1.pqdownheap(_local2, 1); } while (_arg1.heap_len >= 2); _local9 = --_arg1.heap_max; _arg1.heap[_local9] = _arg1.heap[1]; gen_bitlen(_arg1); gen_codes(_local2, _local7, _arg1.bl_count); } public function gen_bitlen(_arg1:Deflate):void{ var _local7:int; var _local8:int; var _local9:int; var _local10:int; var _local11:int; var _local12:Number; var _local2:Array = dyn_tree; var _local3:Array = stat_desc.static_tree; var _local4:Array = stat_desc.extra_bits; var _local5:int = stat_desc.extra_base; var _local6:int = stat_desc.max_length; var _local13:int; _local10 = 0; while (_local10 <= MAX_BITS) { _arg1.bl_count[_local10] = 0; _local10++; }; _local2[((_arg1.heap[_arg1.heap_max] * 2) + 1)] = 0; _local7 = (_arg1.heap_max + 1); while (_local7 < HEAP_SIZE) { _local8 = _arg1.heap[_local7]; _local10 = (_local2[((_local2[((_local8 * 2) + 1)] * 2) + 1)] + 1); if (_local10 > _local6){ _local10 = _local6; _local13++; }; _local2[((_local8 * 2) + 1)] = Cast.toShort(_local10); if (_local8 > max_code){ } else { var _local14 = _arg1.bl_count; var _local15 = _local10; var _local16 = (_local14[_local15] + 1); _local14[_local15] = _local16; _local11 = 0; if (_local8 >= _local5){ _local11 = _local4[(_local8 - _local5)]; }; _local12 = _local2[(_local8 * 2)]; _arg1.opt_len = (_arg1.opt_len + (_local12 * (_local10 + _local11))); if (_local3 != null){ _arg1.static_len = (_arg1.static_len + (_local12 * (_local3[((_local8 * 2) + 1)] + _local11))); }; }; _local7++; }; if (_local13 == 0){ return; }; do { _local10 = (_local6 - 1); while (_arg1.bl_count[_local10] == 0) { _local10--; }; _local14 = _arg1.bl_count; _local15 = _local10; _local16 = (_local14[_local15] - 1); _local14[_local15] = _local16; _arg1.bl_count[(_local10 + 1)] = (_arg1.bl_count[(_local10 + 1)] + 2); _local14 = _arg1.bl_count; _local15 = _local6; _local16 = (_local14[_local15] - 1); _local14[_local15] = _local16; _local13 = (_local13 - 2); } while (_local13 > 0); _local10 = _local6; while (_local10 != 0) { _local8 = _arg1.bl_count[_local10]; while (_local8 != 0) { --_local7; _local9 = _arg1.heap[_local7]; if (_local9 > max_code){ } else { if (_local2[((_local9 * 2) + 1)] != _local10){ _arg1.opt_len = (_arg1.opt_len + ((_local10 - _local2[((_local9 * 2) + 1)]) * _local2[(_local9 * 2)])); _local2[((_local9 * 2) + 1)] = Cast.toShort(_local10); }; _local8--; }; }; _local10--; }; } public static function bi_reverse(_arg1:int, _arg2:int):int{ var _local3:int; do { _local3 = (_local3 | (_arg1 & 1)); _arg1 = (_arg1 >>> 1); _local3 = (_local3 << 1); --_arg2; } while (_arg2 > 0); return ((_local3 >>> 1)); } public static function d_code(_arg1:int):int{ return (((_arg1 < 0x0100)) ? _dist_code[_arg1] : _dist_code[(0x0100 + (_arg1 >>> 7))]); } public static function gen_codes(_arg1:Array, _arg2:int, _arg3:Array):void{ var _local6:int; var _local7:int; var _local8:int; var _local4:Array = new Array(); var _local5:Number = 0; _local6 = 1; while (_local6 <= MAX_BITS) { _local5 = ((_local5 + _arg3[(_local6 - 1)]) << 1); _local4[_local6] = _local5; _local6++; }; _local7 = 0; while (_local7 <= _arg2) { _local8 = _arg1[((_local7 * 2) + 1)]; if (_local8 == 0){ } else { var _local9 = _local4; var _local10 = _local8; var _local11 = (_local9[_local10] + 1); _local9[_local10] = _local11; _arg1[(_local7 * 2)] = bi_reverse(_local9[_local10], _local8); }; _local7++; }; } } }//package com.wirelust.as3zlib
Section 81
//ZStream (com.wirelust.as3zlib.ZStream) package com.wirelust.as3zlib { import flash.utils.*; public final class ZStream { public var total_in:Number; public var msg:String; public var next_out:ByteArray; public var next_in_index:int; public var istate:Inflate; public var total_out:Number; public var next_out_index:int; public var adler:Number; public var _adler:Adler32; public var dstate:Deflate; public var data_type:int; public var next_in:ByteArray; public var avail_in:int; public var avail_out:int; private static var Z_MEM_ERROR:int = -4; private static var Z_STREAM_END:int = 1; private static var DEF_WBITS:int = MAX_WBITS; private static var Z_SYNC_FLUSH:int = 2; private static var Z_VERSION_ERROR:int = -6; private static var Z_BUF_ERROR:int = -5; private static var Z_FINISH:int = 4; private static var MAX_MEM_LEVEL:int = 9; private static var Z_PARTIAL_FLUSH:int = 1; private static var MAX_WBITS:int = 15; private static var Z_DATA_ERROR:int = -3; private static var Z_ERRNO:int = -1; private static var Z_NO_FLUSH:int = 0; private static var Z_STREAM_ERROR:int = -2; private static var Z_OK:int = 0; private static var Z_FULL_FLUSH:int = 3; private static var Z_NEED_DICT:int = 2; public function ZStream(){ _adler = new Adler32(); super(); } public function read_buf(_arg1:ByteArray, _arg2:int, _arg3:int):int{ var _local4:int = avail_in; if (_local4 > _arg3){ _local4 = _arg3; }; if (_local4 == 0){ return (0); }; avail_in = (avail_in - _local4); if (dstate.noheader == 0){ adler = _adler.adler32(adler, next_in, next_in_index, _local4); }; System.byteArrayCopy(next_in, next_in_index, _arg1, _arg2, _local4); next_in_index = (next_in_index + _local4); total_in = (total_in + _local4); return (_local4); } public function inflate(_arg1:int):int{ if (istate == null){ return (Z_STREAM_ERROR); }; return (istate.inflate(this, _arg1)); } public function inflateSync():int{ if (istate == null){ return (Z_STREAM_ERROR); }; return (istate.inflateSync(this)); } public function inflateEnd():int{ if (istate == null){ return (Z_STREAM_ERROR); }; var _local1:int = istate.inflateEnd(this); istate = null; return (_local1); } public function inflateSetDictionary(_arg1:ByteArray, _arg2:int):int{ if (istate == null){ return (Z_STREAM_ERROR); }; return (istate.inflateSetDictionary(this, _arg1, _arg2)); } public function deflateInit(_arg1:int):int{ return (this.deflateInitWithIntInt(_arg1, MAX_WBITS)); } public function flush_pending():void{ var _local1:int = dstate.pending; if (_local1 > avail_out){ _local1 = avail_out; }; if (_local1 == 0){ return; }; if ((((((((dstate.pending_buf.length <= dstate.pending_out)) || ((next_out.length <= next_out_index)))) || ((dstate.pending_buf.length < (dstate.pending_out + _local1))))) || ((next_out.length < (next_out_index + _local1))))){ }; System.byteArrayCopy(dstate.pending_buf, dstate.pending_out, next_out, next_out_index, _local1); next_out_index = (next_out_index + _local1); dstate.pending_out = (dstate.pending_out + _local1); total_out = (total_out + _local1); avail_out = (avail_out - _local1); dstate.pending = (dstate.pending - _local1); if (dstate.pending == 0){ dstate.pending_out = 0; dstate.pending_buf = new ByteArray(); }; } public function deflateInitWithIntIntBoolean(_arg1:int, _arg2:int, _arg3:Boolean):int{ dstate = new Deflate(); return (dstate.deflateInitWithBits(this, _arg1, (_arg3) ? -(_arg2) : _arg2)); } public function inflateInitWithWbits(_arg1:int):int{ return (this.inflateInitWithWbitsNoWrap(_arg1, false)); } public function deflateInitWithIntInt(_arg1:int, _arg2:int):int{ return (deflateInitWithIntIntBoolean(_arg1, _arg2, false)); } public function deflateInitWithBoolean(_arg1:int, _arg2:Boolean):int{ return (this.deflateInitWithIntIntBoolean(_arg1, MAX_WBITS, _arg2)); } public function inflateInitWithNoWrap(_arg1:Boolean):int{ return (inflateInitWithWbitsNoWrap(DEF_WBITS, _arg1)); } public function deflateParams(_arg1:int, _arg2:int):int{ if (dstate == null){ return (Z_STREAM_ERROR); }; return (dstate.deflateParams(this, _arg1, _arg2)); } public function inflateInitWithWbitsNoWrap(_arg1:int, _arg2:Boolean):int{ istate = new Inflate(); return (istate.inflateInit(this, (_arg2) ? -(_arg1) : _arg1)); } public function deflateEnd():int{ if (dstate == null){ return (Z_STREAM_ERROR); }; var _local1:int = dstate.deflateEnd(); dstate = null; return (_local1); } public function deflate(_arg1:int):int{ if (dstate == null){ return (Z_STREAM_ERROR); }; return (dstate.deflate(this, _arg1)); } public function free():void{ next_in = null; next_out = null; msg = null; _adler = null; } public function deflateSetDictionary(_arg1:ByteArray, _arg2:int):int{ if (dstate == null){ return (Z_STREAM_ERROR); }; return (dstate.deflateSetDictionary(this, _arg1, _arg2)); } public function inflateInit():int{ return (inflateInitWithWbits(DEF_WBITS)); } } }//package com.wirelust.as3zlib
Section 82
//Cast (com.wirelust.util.Cast) package com.wirelust.util { public class Cast { public static function toShort(_arg1:int):int{ var _local2:Number = (_arg1 & 32767); var _local3:Number = _local2; if ((_arg1 >> 15) == 1){ _local3 = (_local2 - 0x8000); }; return (_local3); } public static function toByte(_arg1:int):int{ var _local2:Number = (_arg1 & 127); var _local3:Number = _local2; var _local4:Number = ((_arg1 & 0xFF) >> 7); if (_local4 == 1){ _local3 = (_local2 - 128); }; return (_local3); } } }//package com.wirelust.util
Section 83
//BindabilityInfo (mx.binding.BindabilityInfo) package mx.binding { import mx.events.*; import mx.core.*; public class BindabilityInfo { private var classChangeEvents:Object; private var typeDescription:XML; private var childChangeEvents:Object; public static const METHOD:String = "method"; public static const ACCESSOR:String = "accessor"; public static const CHANGE_EVENT:String = "ChangeEvent"; public static const NON_COMMITTING_CHANGE_EVENT:String = "NonCommittingChangeEvent"; public static const BINDABLE:String = "Bindable"; mx_internal static const VERSION:String = "3.4.0.9271"; public static const MANAGED:String = "Managed"; public function BindabilityInfo(_arg1:XML){ childChangeEvents = {}; super(); this.typeDescription = _arg1; } private function addChangeEvents(_arg1:XMLList, _arg2:Object, _arg3:Boolean):void{ var _local4:XML; var _local5:XMLList; var _local6:String; for each (_local4 in _arg1) { _local5 = _local4.arg; if (_local5.length() > 0){ _local6 = _local5[0].@value; _arg2[_local6] = _arg3; } else { trace((("warning: unconverted Bindable metadata in class '" + typeDescription.@name) + "'")); }; }; } private function getClassChangeEvents():Object{ if (!classChangeEvents){ classChangeEvents = {}; addBindabilityEvents(typeDescription.metadata, classChangeEvents); if (typeDescription.metadata.(@name == MANAGED).length() > 0){ classChangeEvents[PropertyChangeEvent.PROPERTY_CHANGE] = true; }; }; return (classChangeEvents); } private function addBindabilityEvents(_arg1:XMLList, _arg2:Object):void{ var metadata = _arg1; var eventListObj = _arg2; addChangeEvents(metadata.(@name == BINDABLE), eventListObj, true); addChangeEvents(metadata.(@name == CHANGE_EVENT), eventListObj, true); addChangeEvents(metadata.(@name == NON_COMMITTING_CHANGE_EVENT), eventListObj, false); } private function copyProps(_arg1:Object, _arg2:Object):Object{ var _local3:String; for (_local3 in _arg1) { _arg2[_local3] = _arg1[_local3]; }; return (_arg2); } public function getChangeEvents(_arg1:String):Object{ var childDesc:XMLList; var numChildren:int; var childName = _arg1; var changeEvents:Object = childChangeEvents[childName]; if (!changeEvents){ changeEvents = copyProps(getClassChangeEvents(), {}); childDesc = (typeDescription.accessor.(@name == childName) + typeDescription.method.(@name == childName)); numChildren = childDesc.length(); if (numChildren == 0){ if (!typeDescription.@dynamic){ trace((((("warning: no describeType entry for '" + childName) + "' on non-dynamic type '") + typeDescription.@name) + "'")); }; } else { if (numChildren > 1){ trace(((((("warning: multiple describeType entries for '" + childName) + "' on type '") + typeDescription.@name) + "':\n") + childDesc)); }; addBindabilityEvents(childDesc.metadata, changeEvents); }; childChangeEvents[childName] = changeEvents; }; return (changeEvents); } } }//package mx.binding
Section 84
//CollectionViewError (mx.collections.errors.CollectionViewError) package mx.collections.errors { import mx.core.*; public class CollectionViewError extends Error { mx_internal static const VERSION:String = "3.4.0.9271"; public function CollectionViewError(_arg1:String){ super(_arg1); } } }//package mx.collections.errors
Section 85
//CursorError (mx.collections.errors.CursorError) package mx.collections.errors { import mx.core.*; public class CursorError extends Error { mx_internal static const VERSION:String = "3.4.0.9271"; public function CursorError(_arg1:String){ super(_arg1); } } }//package mx.collections.errors
Section 86
//ItemPendingError (mx.collections.errors.ItemPendingError) package mx.collections.errors { import mx.rpc.*; import mx.core.*; public class ItemPendingError extends Error { private var _responders:Array; mx_internal static const VERSION:String = "3.4.0.9271"; public function ItemPendingError(_arg1:String){ super(_arg1); } public function get responders():Array{ return (_responders); } public function addResponder(_arg1:IResponder):void{ if (!_responders){ _responders = []; }; _responders.push(_arg1); } } }//package mx.collections.errors
Section 87
//SortError (mx.collections.errors.SortError) package mx.collections.errors { import mx.core.*; public class SortError extends Error { mx_internal static const VERSION:String = "3.4.0.9271"; public function SortError(_arg1:String){ super(_arg1); } } }//package mx.collections.errors
Section 88
//ArrayCollection (mx.collections.ArrayCollection) package mx.collections { import flash.utils.*; import mx.core.*; public class ArrayCollection extends ListCollectionView implements IExternalizable { mx_internal static const VERSION:String = "3.4.0.9271"; public function ArrayCollection(_arg1:Array=null){ this.source = _arg1; } public function set source(_arg1:Array):void{ list = new ArrayList(_arg1); } public function readExternal(_arg1:IDataInput):void{ if ((list is IExternalizable)){ IExternalizable(list).readExternal(_arg1); } else { source = (_arg1.readObject() as Array); }; } public function writeExternal(_arg1:IDataOutput):void{ if ((list is IExternalizable)){ IExternalizable(list).writeExternal(_arg1); } else { _arg1.writeObject(source); }; } public function get source():Array{ if (((list) && ((list is ArrayList)))){ return (ArrayList(list).source); }; return (null); } } }//package mx.collections
Section 89
//ArrayList (mx.collections.ArrayList) package mx.collections { import flash.events.*; import flash.utils.*; import mx.events.*; import mx.resources.*; import mx.utils.*; import mx.core.*; public class ArrayList extends EventDispatcher implements IList, IExternalizable, IPropertyChangeNotifier { private var _source:Array; private var _dispatchEvents:int;// = 0 private var _uid:String; private var resourceManager:IResourceManager; mx_internal static const VERSION:String = "3.4.0.9271"; public function ArrayList(_arg1:Array=null){ resourceManager = ResourceManager.getInstance(); super(); disableEvents(); this.source = _arg1; enableEvents(); _uid = UIDUtil.createUID(); } public function addAll(_arg1:IList):void{ addAllAt(_arg1, length); } public function readExternal(_arg1:IDataInput):void{ source = _arg1.readObject(); } private function internalDispatchEvent(_arg1:String, _arg2:Object=null, _arg3:int=-1):void{ var _local4:CollectionEvent; var _local5:PropertyChangeEvent; if (_dispatchEvents == 0){ if (hasEventListener(CollectionEvent.COLLECTION_CHANGE)){ _local4 = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); _local4.kind = _arg1; _local4.items.push(_arg2); _local4.location = _arg3; dispatchEvent(_local4); }; if (((hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE)) && ((((_arg1 == CollectionEventKind.ADD)) || ((_arg1 == CollectionEventKind.REMOVE)))))){ _local5 = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE); _local5.property = _arg3; if (_arg1 == CollectionEventKind.ADD){ _local5.newValue = _arg2; } else { _local5.oldValue = _arg2; }; dispatchEvent(_local5); }; }; } public function removeAll():void{ var _local1:int; var _local2:int; if (length > 0){ _local1 = length; _local2 = 0; while (_local2 < _local1) { stopTrackUpdates(source[_local2]); _local2++; }; source.splice(0, length); internalDispatchEvent(CollectionEventKind.RESET); }; } public function getItemIndex(_arg1:Object):int{ return (ArrayUtil.getItemIndex(_arg1, source)); } public function removeItemAt(_arg1:int):Object{ var _local3:String; if ((((_arg1 < 0)) || ((_arg1 >= length)))){ _local3 = resourceManager.getString("collections", "outOfBounds", [_arg1]); throw (new RangeError(_local3)); }; var _local2:Object = source.splice(_arg1, 1)[0]; stopTrackUpdates(_local2); internalDispatchEvent(CollectionEventKind.REMOVE, _local2, _arg1); return (_local2); } public function addAllAt(_arg1:IList, _arg2:int):void{ var _local3:int = _arg1.length; var _local4:int; while (_local4 < _local3) { this.addItemAt(_arg1.getItemAt(_local4), (_local4 + _arg2)); _local4++; }; } public function itemUpdated(_arg1:Object, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{ var _local5:PropertyChangeEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE); _local5.kind = PropertyChangeEventKind.UPDATE; _local5.source = _arg1; _local5.property = _arg2; _local5.oldValue = _arg3; _local5.newValue = _arg4; itemUpdateHandler(_local5); } public function get uid():String{ return (_uid); } public function writeExternal(_arg1:IDataOutput):void{ _arg1.writeObject(_source); } public function addItem(_arg1:Object):void{ addItemAt(_arg1, length); } public function toArray():Array{ return (source.concat()); } public function get source():Array{ return (_source); } public function getItemAt(_arg1:int, _arg2:int=0):Object{ var _local3:String; if ((((_arg1 < 0)) || ((_arg1 >= length)))){ _local3 = resourceManager.getString("collections", "outOfBounds", [_arg1]); throw (new RangeError(_local3)); }; return (source[_arg1]); } public function set uid(_arg1:String):void{ _uid = _arg1; } public function setItemAt(_arg1:Object, _arg2:int):Object{ var _local4:String; var _local5:Boolean; var _local6:Boolean; var _local7:PropertyChangeEvent; var _local8:CollectionEvent; if ((((_arg2 < 0)) || ((_arg2 >= length)))){ _local4 = resourceManager.getString("collections", "outOfBounds", [_arg2]); throw (new RangeError(_local4)); }; var _local3:Object = source[_arg2]; source[_arg2] = _arg1; stopTrackUpdates(_local3); startTrackUpdates(_arg1); if (_dispatchEvents == 0){ _local5 = hasEventListener(CollectionEvent.COLLECTION_CHANGE); _local6 = hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE); if (((_local5) || (_local6))){ _local7 = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE); _local7.kind = PropertyChangeEventKind.UPDATE; _local7.oldValue = _local3; _local7.newValue = _arg1; _local7.property = _arg2; }; if (_local5){ _local8 = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); _local8.kind = CollectionEventKind.REPLACE; _local8.location = _arg2; _local8.items.push(_local7); dispatchEvent(_local8); }; if (_local6){ dispatchEvent(_local7); }; }; return (_local3); } public function get length():int{ if (source){ return (source.length); }; return (0); } private function disableEvents():void{ _dispatchEvents--; } protected function itemUpdateHandler(_arg1:PropertyChangeEvent):void{ var _local2:PropertyChangeEvent; var _local3:uint; internalDispatchEvent(CollectionEventKind.UPDATE, _arg1); if ((((_dispatchEvents == 0)) && (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE)))){ _local2 = PropertyChangeEvent(_arg1.clone()); _local3 = getItemIndex(_arg1.target); _local2.property = ((_local3.toString() + ".") + _arg1.property); dispatchEvent(_local2); }; } public function addItemAt(_arg1:Object, _arg2:int):void{ var _local3:String; if ((((_arg2 < 0)) || ((_arg2 > length)))){ _local3 = resourceManager.getString("collections", "outOfBounds", [_arg2]); throw (new RangeError(_local3)); }; source.splice(_arg2, 0, _arg1); startTrackUpdates(_arg1); internalDispatchEvent(CollectionEventKind.ADD, _arg1, _arg2); } public function removeItem(_arg1:Object):Boolean{ var _local2:int = getItemIndex(_arg1); var _local3 = (_local2 >= 0); if (_local3){ removeItemAt(_local2); }; return (_local3); } protected function stopTrackUpdates(_arg1:Object):void{ if (((_arg1) && ((_arg1 is IEventDispatcher)))){ IEventDispatcher(_arg1).removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE, itemUpdateHandler); }; } protected function startTrackUpdates(_arg1:Object):void{ if (((_arg1) && ((_arg1 is IEventDispatcher)))){ IEventDispatcher(_arg1).addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, itemUpdateHandler, false, 0, true); }; } override public function toString():String{ if (source){ return (source.toString()); }; return (getQualifiedClassName(this)); } private function enableEvents():void{ _dispatchEvents++; if (_dispatchEvents > 0){ _dispatchEvents = 0; }; } public function set source(_arg1:Array):void{ var _local2:int; var _local3:int; var _local4:CollectionEvent; if (((_source) && (_source.length))){ _local3 = _source.length; _local2 = 0; while (_local2 < _local3) { stopTrackUpdates(_source[_local2]); _local2++; }; }; _source = (_arg1) ? _arg1 : []; _local3 = _source.length; _local2 = 0; while (_local2 < _local3) { startTrackUpdates(_source[_local2]); _local2++; }; if (_dispatchEvents == 0){ _local4 = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); _local4.kind = CollectionEventKind.RESET; dispatchEvent(_local4); }; } } }//package mx.collections
Section 90
//CursorBookmark (mx.collections.CursorBookmark) package mx.collections { import mx.core.*; public class CursorBookmark { private var _value:Object; mx_internal static const VERSION:String = "3.4.0.9271"; private static var _first:CursorBookmark; private static var _last:CursorBookmark; private static var _current:CursorBookmark; public function CursorBookmark(_arg1:Object){ _value = _arg1; } public function get value():Object{ return (_value); } public function getViewIndex():int{ return (-1); } public static function get LAST():CursorBookmark{ if (!_last){ _last = new CursorBookmark("${L}"); }; return (_last); } public static function get FIRST():CursorBookmark{ if (!_first){ _first = new CursorBookmark("${F}"); }; return (_first); } public static function get CURRENT():CursorBookmark{ if (!_current){ _current = new CursorBookmark("${C}"); }; return (_current); } } }//package mx.collections
Section 91
//ICollectionView (mx.collections.ICollectionView) package mx.collections { import flash.events.*; public interface ICollectionView extends IEventDispatcher { function set filterFunction(_arg1:Function):void; function enableAutoUpdate():void; function get length():int; function disableAutoUpdate():void; function itemUpdated(_arg1:Object, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void; function get filterFunction():Function; function createCursor():IViewCursor; function refresh():Boolean; function set sort(_arg1:Sort):void; function get sort():Sort; function contains(_arg1:Object):Boolean; } }//package mx.collections
Section 92
//IList (mx.collections.IList) package mx.collections { import flash.events.*; public interface IList extends IEventDispatcher { function addItem(_arg1:Object):void; function get length():int; function addItemAt(_arg1:Object, _arg2:int):void; function itemUpdated(_arg1:Object, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void; function getItemIndex(_arg1:Object):int; function removeItemAt(_arg1:int):Object; function getItemAt(_arg1:int, _arg2:int=0):Object; function removeAll():void; function toArray():Array; function setItemAt(_arg1:Object, _arg2:int):Object; } }//package mx.collections
Section 93
//ItemResponder (mx.collections.ItemResponder) package mx.collections { import mx.rpc.*; import mx.core.*; public class ItemResponder implements IResponder { private var _faultHandler:Function; private var _token:Object; private var _resultHandler:Function; mx_internal static const VERSION:String = "3.4.0.9271"; public function ItemResponder(_arg1:Function, _arg2:Function, _arg3:Object=null){ _resultHandler = _arg1; _faultHandler = _arg2; _token = _arg3; } public function result(_arg1:Object):void{ _resultHandler(_arg1, _token); } public function fault(_arg1:Object):void{ _faultHandler(_arg1, _token); } } }//package mx.collections
Section 94
//IViewCursor (mx.collections.IViewCursor) package mx.collections { import flash.events.*; public interface IViewCursor extends IEventDispatcher { function get current():Object; function moveNext():Boolean; function get view():ICollectionView; function movePrevious():Boolean; function remove():Object; function findLast(_arg1:Object):Boolean; function get beforeFirst():Boolean; function get afterLast():Boolean; function findAny(_arg1:Object):Boolean; function get bookmark():CursorBookmark; function findFirst(_arg1:Object):Boolean; function seek(_arg1:CursorBookmark, _arg2:int=0, _arg3:int=0):void; function insert(_arg1:Object):void; } }//package mx.collections
Section 95
//ListCollectionView (mx.collections.ListCollectionView) package mx.collections { import flash.events.*; import flash.utils.*; import mx.events.*; import mx.resources.*; import mx.utils.*; import mx.core.*; import mx.collections.errors.*; public class ListCollectionView extends Proxy implements ICollectionView, IList, IMXMLObject { private var autoUpdateCounter:int; private var _list:IList; private var _filterFunction:Function; protected var localIndex:Array; mx_internal var dispatchResetEvent:Boolean;// = true private var pendingUpdates:Array; private var resourceManager:IResourceManager; private var eventDispatcher:EventDispatcher; private var revision:int; private var _sort:Sort; mx_internal static const VERSION:String = "3.4.0.9271"; public function ListCollectionView(_arg1:IList=null){ resourceManager = ResourceManager.getInstance(); super(); eventDispatcher = new EventDispatcher(this); this.list = _arg1; } private function handlePendingUpdates():void{ var _local1:Array; var _local2:CollectionEvent; var _local3:int; var _local4:CollectionEvent; var _local5:int; if (pendingUpdates){ _local1 = pendingUpdates; pendingUpdates = null; _local3 = 0; while (_local3 < _local1.length) { _local4 = _local1[_local3]; if (_local4.kind == CollectionEventKind.UPDATE){ if (!_local2){ _local2 = _local4; } else { _local5 = 0; while (_local5 < _local4.items.length) { _local2.items.push(_local4.items[_local5]); _local5++; }; }; } else { listChangeHandler(_local4); }; _local3++; }; if (_local2){ listChangeHandler(_local2); }; }; } public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{ eventDispatcher.removeEventListener(_arg1, _arg2, _arg3); } private function replaceItemsInView(_arg1:Array, _arg2:int, _arg3:Boolean=true):void{ var _local4:int; var _local5:Array; var _local6:Array; var _local7:int; var _local8:PropertyChangeEvent; var _local9:CollectionEvent; if (localIndex){ _local4 = _arg1.length; _local5 = []; _local6 = []; _local7 = 0; while (_local7 < _local4) { _local8 = _arg1[_local7]; _local5.push(_local8.oldValue); _local6.push(_local8.newValue); _local7++; }; removeItemsFromView(_local5, _arg2, _arg3); addItemsToView(_local6, _arg2, _arg3); } else { _local9 = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); _local9.kind = CollectionEventKind.REPLACE; _local9.location = _arg2; _local9.items = _arg1; dispatchEvent(_local9); }; } private function getFilteredItemIndex(_arg1:Object):int{ var _local4:Object; var _local5:int; var _local6:int; var _local2:int = list.getItemIndex(_arg1); if (_local2 == 0){ return (0); }; var _local3:int = (_local2 - 1); while (_local3 >= 0) { _local4 = list.getItemAt(_local3); if (filterFunction(_local4)){ _local5 = localIndex.length; _local6 = 0; while (_local6 < _local5) { if (localIndex[_local6] == _local4){ return ((_local6 + 1)); }; _local6++; }; }; _local3--; }; return (0); } public function willTrigger(_arg1:String):Boolean{ return (eventDispatcher.willTrigger(_arg1)); } mx_internal function findItem(_arg1:Object, _arg2:String, _arg3:Boolean=false):int{ var _local4:String; if (!sort){ _local4 = resourceManager.getString("collections", "itemNotFound"); throw (new CollectionViewError(_local4)); }; if (localIndex.length == 0){ return ((_arg3) ? 0 : -1); }; return (sort.findItem(localIndex, _arg1, _arg2, _arg3)); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(_arg1:int):String{ return ((_arg1 - 1).toString()); } public function removeAll():void{ var _local2:int; var _local1:int = length; if (_local1 > 0){ if (localIndex){ _local2 = (_local1 - 1); while (_local2 >= 0) { removeItemAt(_local2); _local2--; }; } else { list.removeAll(); }; }; } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(_arg1):Boolean{ var n:Number; var name = _arg1; if ((name is QName)){ name = name.localName; }; var index = -1; try { n = parseInt(String(name)); if (!isNaN(n)){ index = int(n); }; } catch(e:Error) { }; if (index == -1){ return (false); }; return ((((index >= 0)) && ((index < length)))); } public function addAllAt(_arg1:IList, _arg2:int):void{ var _local3:int = _arg1.length; var _local4:int; while (_local4 < _local3) { this.addItemAt(_arg1.getItemAt(_local4), (_local4 + _arg2)); _local4++; }; } public function getItemAt(_arg1:int, _arg2:int=0):Object{ var _local3:String; if ((((_arg1 < 0)) || ((_arg1 >= length)))){ _local3 = resourceManager.getString("collections", "outOfBounds", [_arg1]); throw (new RangeError(_local3)); }; if (localIndex){ return (localIndex[_arg1]); }; if (list){ return (list.getItemAt(_arg1, _arg2)); }; return (null); } private function moveItemInView(_arg1:Object, _arg2:Boolean=true, _arg3:Array=null):void{ var _local4:int; var _local5:int; var _local6:int; var _local7:CollectionEvent; if (localIndex){ _local4 = -1; _local5 = 0; while (_local5 < localIndex.length) { if (localIndex[_local5] == _arg1){ _local4 = _local5; break; }; _local5++; }; if (_local4 > -1){ localIndex.splice(_local4, 1); }; _local6 = addItemsToView([_arg1], _local4, false); if (_arg2){ _local7 = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); _local7.items.push(_arg1); if (((((_arg3) && ((_local6 == _local4)))) && ((_local6 > -1)))){ _arg3.push(_arg1); return; }; if ((((_local6 > -1)) && ((_local4 > -1)))){ _local7.kind = CollectionEventKind.MOVE; _local7.location = _local6; _local7.oldLocation = _local4; } else { if (_local6 > -1){ _local7.kind = CollectionEventKind.ADD; _local7.location = _local6; } else { if (_local4 > -1){ _local7.kind = CollectionEventKind.REMOVE; _local7.location = _local4; } else { _arg2 = false; }; }; }; if (_arg2){ dispatchEvent(_local7); }; }; }; } public function contains(_arg1:Object):Boolean{ return (!((getItemIndex(_arg1) == -1))); } public function get sort():Sort{ return (_sort); } private function removeItemsFromView(_arg1:Array, _arg2:int, _arg3:Boolean=true):void{ var _local6:int; var _local7:Object; var _local8:int; var _local9:CollectionEvent; var _local4:Array = (localIndex) ? [] : _arg1; var _local5:int = _arg2; if (localIndex){ _local6 = 0; while (_local6 < _arg1.length) { _local7 = _arg1[_local6]; _local8 = getItemIndex(_local7); if (_local8 > -1){ localIndex.splice(_local8, 1); _local4.push(_local7); _local5 = _local8; }; _local6++; }; }; if (((_arg3) && ((_local4.length > 0)))){ _local9 = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); _local9.kind = CollectionEventKind.REMOVE; _local9.location = (((!(localIndex)) || ((_local4.length == 1)))) ? _local5 : -1; _local9.items = _local4; dispatchEvent(_local9); }; } public function get list():IList{ return (_list); } public function addItemAt(_arg1:Object, _arg2:int):void{ var _local4:String; if ((((((_arg2 < 0)) || (!(list)))) || ((_arg2 > length)))){ _local4 = resourceManager.getString("collections", "outOfBounds", [_arg2]); throw (new RangeError(_local4)); }; var _local3:int = _arg2; if (((localIndex) && (sort))){ _local3 = list.length; } else { if (((localIndex) && (!((filterFunction == null))))){ if (_local3 == localIndex.length){ _local3 = list.length; } else { _local3 = list.getItemIndex(localIndex[_arg2]); }; }; }; list.addItemAt(_arg1, _local3); } public function itemUpdated(_arg1:Object, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{ list.itemUpdated(_arg1, _arg2, _arg3, _arg4); } private function populateLocalIndex():void{ if (list){ localIndex = list.toArray(); } else { localIndex = []; }; } private function handlePropertyChangeEvents(_arg1:Array):void{ var _local3:Array; var _local4:Object; var _local5:int; var _local6:Array; var _local7:int; var _local8:PropertyChangeEvent; var _local9:Object; var _local10:Boolean; var _local11:int; var _local12:int; var _local13:int; var _local14:int; var _local15:CollectionEvent; var _local2:Array = _arg1; if (((sort) || (!((filterFunction == null))))){ _local3 = []; _local5 = 0; while (_local5 < _arg1.length) { _local8 = _arg1[_local5]; if (_local8.target){ _local9 = _local8.target; _local10 = !((_local8.target == _local8.source)); } else { _local9 = _local8.source; _local10 = false; }; _local11 = 0; while (_local11 < _local3.length) { if (_local3[_local11].item == _local9){ _arg1 = _local3[_local11].events; _local12 = _arg1.length; _local13 = 0; while (_local13 < _local12) { if (_arg1[_local13].property != _local8.property){ _arg1.push(_local8); break; }; _local13++; }; break; }; _local11++; }; if (_local11 < _local3.length){ _local4 = _local3[_local11]; } else { _local4 = {item:_local9, move:_local10, events:[_local8]}; _local3.push(_local4); }; _local4.move = ((((((_local4.move) || (filterFunction))) || (!(_local8.property)))) || (((sort) && (sort.propertyAffectsSort(String(_local8.property)))))); _local5++; }; _local2 = []; _local5 = 0; while (_local5 < _local3.length) { _local4 = _local3[_local5]; if (_local4.move){ moveItemInView(_local4.item, _local4.item, _local2); } else { _local2.push(_local4.item); }; _local5++; }; _local6 = []; _local7 = 0; while (_local7 < _local2.length) { _local14 = 0; while (_local14 < _local3.length) { if (_local2[_local7] == _local3[_local14].item){ _local6 = _local6.concat(_local3[_local14].events); }; _local14++; }; _local7++; }; _local2 = _local6; }; if (_local2.length > 0){ _local15 = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); _local15.kind = CollectionEventKind.UPDATE; _local15.items = _local2; dispatchEvent(_local15); }; } public function set sort(_arg1:Sort):void{ _sort = _arg1; dispatchEvent(new Event("sortChanged")); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextValue(_arg1:int){ return (getItemAt((_arg1 - 1))); } public function setItemAt(_arg1:Object, _arg2:int):Object{ var _local4:String; var _local5:Object; if ((((((_arg2 < 0)) || (!(list)))) || ((_arg2 >= length)))){ _local4 = resourceManager.getString("collections", "outOfBounds", [_arg2]); throw (new RangeError(_local4)); }; var _local3:int = _arg2; if (localIndex){ if (_arg2 > localIndex.length){ _local3 = list.length; } else { _local5 = localIndex[_arg2]; _local3 = list.getItemIndex(_local5); }; }; return (list.setItemAt(_arg1, _local3)); } mx_internal function getBookmark(_arg1:int):ListCollectionViewBookmark{ var value:Object; var message:String; var index = _arg1; if ((((index < 0)) || ((index > length)))){ message = resourceManager.getString("collections", "invalidIndex", [index]); throw (new CollectionViewError(message)); }; try { value = getItemAt(index); } catch(e:Error) { value = null; }; return (new ListCollectionViewBookmark(value, this, revision, index)); } private function addItemsToView(_arg1:Array, _arg2:int, _arg3:Boolean=true):int{ var _local7:int; var _local8:int; var _local9:Object; var _local10:String; var _local11:CollectionEvent; var _local4:Array = (localIndex) ? [] : _arg1; var _local5:int = _arg2; var _local6:Boolean; if (localIndex){ _local7 = _arg2; _local8 = 0; while (_local8 < _arg1.length) { _local9 = _arg1[_local8]; if ((((filterFunction == null)) || (filterFunction(_local9)))){ if (sort){ _local7 = findItem(_local9, Sort.ANY_INDEX_MODE, true); if (_local6){ _local5 = _local7; _local6 = false; }; } else { _local7 = getFilteredItemIndex(_local9); if (_local6){ _local5 = _local7; _local6 = false; }; }; if (((((sort) && (sort.unique))) && ((sort.compareFunction(_local9, localIndex[_local7]) == 0)))){ _local10 = resourceManager.getString("collections", "incorrectAddition"); throw (new CollectionViewError(_local10)); }; var _temp1 = _local7; _local7 = (_local7 + 1); localIndex.splice(_temp1, 0, _local9); _local4.push(_local9); } else { _local5 = -1; }; _local8++; }; }; if (((localIndex) && ((_local4.length > 1)))){ _local5 = -1; }; if (((_arg3) && ((_local4.length > 0)))){ _local11 = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); _local11.kind = CollectionEventKind.ADD; _local11.location = _local5; _local11.items = _local4; dispatchEvent(_local11); }; return (_local5); } public function addAll(_arg1:IList):void{ addAllAt(_arg1, length); } public function set list(_arg1:IList):void{ var _local2:Boolean; var _local3:Boolean; if (_list != _arg1){ if (_list){ _list.removeEventListener(CollectionEvent.COLLECTION_CHANGE, listChangeHandler); _local2 = (_list.length > 0); }; _list = _arg1; if (_list){ _list.addEventListener(CollectionEvent.COLLECTION_CHANGE, listChangeHandler, false, 0, true); _local3 = (_list.length > 0); }; if (((_local2) || (_local3))){ reset(); }; dispatchEvent(new Event("listChanged")); }; } public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{ eventDispatcher.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5); } public function dispatchEvent(_arg1:Event):Boolean{ return (eventDispatcher.dispatchEvent(_arg1)); } public function getItemIndex(_arg1:Object):int{ var _local2:int; var _local3:int; var _local4:int; var _local5:int; if (sort){ _local3 = sort.findItem(localIndex, _arg1, Sort.FIRST_INDEX_MODE); if (_local3 == -1){ return (-1); }; _local4 = sort.findItem(localIndex, _arg1, Sort.LAST_INDEX_MODE); _local2 = _local3; while (_local2 <= _local4) { if (localIndex[_local2] == _arg1){ return (_local2); }; _local2++; }; return (-1); } else { if (filterFunction != null){ _local5 = localIndex.length; _local2 = 0; while (_local2 < _local5) { if (localIndex[_local2] == _arg1){ return (_local2); }; _local2++; }; return (-1); }; }; return (list.getItemIndex(_arg1)); } public function removeItemAt(_arg1:int):Object{ var _local3:String; var _local4:Object; if ((((_arg1 < 0)) || ((_arg1 >= length)))){ _local3 = resourceManager.getString("collections", "outOfBounds", [_arg1]); throw (new RangeError(_local3)); }; var _local2:int = _arg1; if (localIndex){ _local4 = localIndex[_arg1]; _local2 = list.getItemIndex(_local4); }; return (list.removeItemAt(_local2)); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){ var n:Number; var message:String; var name = _arg1; if ((name is QName)){ name = name.localName; }; var index = -1; try { n = parseInt(String(name)); if (!isNaN(n)){ index = int(n); }; } catch(e:Error) { }; if (index == -1){ message = resourceManager.getString("collections", "unknownProperty", [name]); throw (new Error(message)); }; return (getItemAt(index)); } public function enableAutoUpdate():void{ if (autoUpdateCounter > 0){ autoUpdateCounter--; if (autoUpdateCounter == 0){ handlePendingUpdates(); }; }; } mx_internal function reset():void{ var _local1:CollectionEvent; internalRefresh(false); if (dispatchResetEvent){ _local1 = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); _local1.kind = CollectionEventKind.RESET; dispatchEvent(_local1); }; } public function toArray():Array{ var _local1:Array; if (localIndex){ _local1 = localIndex.concat(); } else { _local1 = list.toArray(); }; return (_local1); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function callProperty(_arg1, ... _args){ return (null); } public function initialized(_arg1:Object, _arg2:String):void{ refresh(); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{ var n:Number; var message:String; var name = _arg1; var value = _arg2; if ((name is QName)){ name = name.localName; }; var index = -1; try { n = parseInt(String(name)); if (!isNaN(n)){ index = int(n); }; } catch(e:Error) { }; if (index == -1){ message = resourceManager.getString("collections", "unknownProperty", [name]); throw (new Error(message)); }; setItemAt(value, index); } public function addItem(_arg1:Object):void{ addItemAt(_arg1, length); } private function internalRefresh(_arg1:Boolean):Boolean{ var tmp:Array; var len:int; var i:int; var item:Object; var refreshEvent:CollectionEvent; var dispatch = _arg1; if (((sort) || (!((filterFunction == null))))){ try { populateLocalIndex(); } catch(pending:ItemPendingError) { pending.addResponder(new ItemResponder(function (_arg1:Object, _arg2:Object=null):void{ internalRefresh(dispatch); }, function (_arg1:Object, _arg2:Object=null):void{ })); return (false); }; if (filterFunction != null){ tmp = []; len = localIndex.length; i = 0; while (i < len) { item = localIndex[i]; if (filterFunction(item)){ tmp.push(item); }; i = (i + 1); }; localIndex = tmp; }; if (sort){ sort.sort(localIndex); dispatch = true; }; } else { if (localIndex){ localIndex = null; }; }; revision++; pendingUpdates = null; if (dispatch){ refreshEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); refreshEvent.kind = CollectionEventKind.REFRESH; dispatchEvent(refreshEvent); }; return (true); } public function set filterFunction(_arg1:Function):void{ _filterFunction = _arg1; dispatchEvent(new Event("filterFunctionChanged")); } mx_internal function getBookmarkIndex(_arg1:CursorBookmark):int{ var _local3:String; if (((!((_arg1 is ListCollectionViewBookmark))) || (!((ListCollectionViewBookmark(_arg1).view == this))))){ _local3 = resourceManager.getString("collections", "bookmarkNotFound"); throw (new CollectionViewError(_local3)); }; var _local2:ListCollectionViewBookmark = ListCollectionViewBookmark(_arg1); if (_local2.viewRevision != revision){ if ((((((_local2.index < 0)) || ((_local2.index >= length)))) || (!((getItemAt(_local2.index) == _local2.value))))){ _local2.index = getItemIndex(_local2.value); }; _local2.viewRevision = revision; }; return (_local2.index); } public function refresh():Boolean{ return (internalRefresh(true)); } public function get filterFunction():Function{ return (_filterFunction); } public function createCursor():IViewCursor{ return (new ListCollectionViewCursor(this)); } public function hasEventListener(_arg1:String):Boolean{ return (eventDispatcher.hasEventListener(_arg1)); } public function get length():int{ if (localIndex){ return (localIndex.length); }; if (list){ return (list.length); }; return (0); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(_arg1:int):int{ return (((_arg1 < length)) ? (_arg1 + 1) : 0); } public function disableAutoUpdate():void{ autoUpdateCounter++; } public function toString():String{ if (localIndex){ return (ObjectUtil.toString(localIndex)); }; if (((list) && (Object(list).toString))){ return (Object(list).toString()); }; return (getQualifiedClassName(this)); } private function listChangeHandler(_arg1:CollectionEvent):void{ if (autoUpdateCounter > 0){ if (!pendingUpdates){ pendingUpdates = []; }; pendingUpdates.push(_arg1); } else { switch (_arg1.kind){ case CollectionEventKind.ADD: addItemsToView(_arg1.items, _arg1.location); break; case CollectionEventKind.RESET: reset(); break; case CollectionEventKind.REMOVE: removeItemsFromView(_arg1.items, _arg1.location); break; case CollectionEventKind.REPLACE: replaceItemsInView(_arg1.items, _arg1.location); break; case CollectionEventKind.UPDATE: handlePropertyChangeEvents(_arg1.items); break; default: dispatchEvent(_arg1); }; }; } } }//package mx.collections import flash.events.*; import mx.events.*; import mx.resources.*; import mx.core.*; import mx.collections.errors.*; class ListCollectionViewBookmark extends CursorBookmark { mx_internal var viewRevision:int; mx_internal var index:int; mx_internal var view:ListCollectionView; private function ListCollectionViewBookmark(_arg1:Object, _arg2:ListCollectionView, _arg3:int, _arg4:int){ super(_arg1); this.view = _arg2; this.viewRevision = _arg3; this.index = _arg4; } override public function getViewIndex():int{ return (view.getBookmarkIndex(this)); } } class ListCollectionViewCursor extends EventDispatcher implements IViewCursor { private var _view:ListCollectionView; private var invalid:Boolean; private var resourceManager:IResourceManager; private var currentIndex:int; private var currentValue:Object; private static const BEFORE_FIRST_INDEX:int = -1; private static const AFTER_LAST_INDEX:int = -2; private function ListCollectionViewCursor(_arg1:ListCollectionView){ var view = _arg1; resourceManager = ResourceManager.getInstance(); super(); _view = view; _view.addEventListener(CollectionEvent.COLLECTION_CHANGE, collectionEventHandler, false, 0, true); currentIndex = ((view.length > 0)) ? 0 : AFTER_LAST_INDEX; if (currentIndex == 0){ try { setCurrent(view.getItemAt(0), false); } catch(e:ItemPendingError) { currentIndex = BEFORE_FIRST_INDEX; setCurrent(null, false); }; }; } public function findAny(_arg1:Object):Boolean{ var index:int; var values = _arg1; checkValid(); var lcView:ListCollectionView = ListCollectionView(view); try { index = lcView.findItem(values, Sort.ANY_INDEX_MODE); } catch(e:SortError) { throw (new CursorError(e.message)); }; if (index > -1){ currentIndex = index; setCurrent(lcView.getItemAt(currentIndex)); }; return ((index > -1)); } public function remove():Object{ var oldIndex:int; var message:String; if (((beforeFirst) || (afterLast))){ message = resourceManager.getString("collections", "invalidRemove"); throw (new CursorError(message)); }; oldIndex = currentIndex; currentIndex++; if (currentIndex >= view.length){ currentIndex = AFTER_LAST_INDEX; setCurrent(null); } else { try { setCurrent(ListCollectionView(view).getItemAt(currentIndex)); } catch(e:ItemPendingError) { setCurrent(null, false); ListCollectionView(view).removeItemAt(oldIndex); throw (e); }; }; var removed:Object = ListCollectionView(view).removeItemAt(oldIndex); return (removed); } private function setCurrent(_arg1:Object, _arg2:Boolean=true):void{ currentValue = _arg1; if (_arg2){ dispatchEvent(new FlexEvent(FlexEvent.CURSOR_UPDATE)); }; } public function seek(_arg1:CursorBookmark, _arg2:int=0, _arg3:int=0):void{ var message:String; var bookmark = _arg1; var offset = _arg2; var prefetch = _arg3; checkValid(); if (view.length == 0){ currentIndex = AFTER_LAST_INDEX; setCurrent(null, false); return; }; var newIndex:int = currentIndex; if (bookmark == CursorBookmark.FIRST){ newIndex = 0; } else { if (bookmark == CursorBookmark.LAST){ newIndex = (view.length - 1); } else { if (bookmark != CursorBookmark.CURRENT){ try { newIndex = ListCollectionView(view).getBookmarkIndex(bookmark); if (newIndex < 0){ setCurrent(null); message = resourceManager.getString("collections", "bookmarkInvalid"); throw (new CursorError(message)); }; } catch(bmError:CollectionViewError) { message = resourceManager.getString("collections", "bookmarkInvalid"); throw (new CursorError(message)); }; }; }; }; newIndex = (newIndex + offset); var newCurrent:Object; if (newIndex >= view.length){ currentIndex = AFTER_LAST_INDEX; } else { if (newIndex < 0){ currentIndex = BEFORE_FIRST_INDEX; } else { newCurrent = ListCollectionView(view).getItemAt(newIndex, prefetch); currentIndex = newIndex; }; }; setCurrent(newCurrent); } public function insert(_arg1:Object):void{ var _local2:int; var _local3:String; if (afterLast){ _local2 = view.length; } else { if (beforeFirst){ if (view.length > 0){ _local3 = resourceManager.getString("collections", "invalidInsert"); throw (new CursorError(_local3)); }; _local2 = 0; } else { _local2 = currentIndex; }; }; ListCollectionView(view).addItemAt(_arg1, _local2); } public function get afterLast():Boolean{ checkValid(); return ((((currentIndex == AFTER_LAST_INDEX)) || ((view.length == 0)))); } private function checkValid():void{ var _local1:String; if (invalid){ _local1 = resourceManager.getString("collections", "invalidCursor"); throw (new CursorError(_local1)); }; } private function collectionEventHandler(_arg1:CollectionEvent):void{ var event = _arg1; switch (event.kind){ case CollectionEventKind.ADD: if (event.location <= currentIndex){ currentIndex = (currentIndex + event.items.length); }; break; case CollectionEventKind.REMOVE: if (event.location < currentIndex){ currentIndex = (currentIndex - event.items.length); } else { if (event.location == currentIndex){ if (currentIndex < view.length){ try { setCurrent(ListCollectionView(view).getItemAt(currentIndex)); } catch(error:ItemPendingError) { setCurrent(null, false); }; } else { currentIndex = AFTER_LAST_INDEX; setCurrent(null); }; }; }; break; case CollectionEventKind.MOVE: if (event.oldLocation == currentIndex){ currentIndex = event.location; } else { if (event.oldLocation < currentIndex){ currentIndex = (currentIndex - event.items.length); }; if (event.location <= currentIndex){ currentIndex = (currentIndex + event.items.length); }; }; break; case CollectionEventKind.REFRESH: if (!((beforeFirst) || (afterLast))){ currentIndex = ListCollectionView(view).getItemIndex(currentValue); if (currentIndex == -1){ setCurrent(null); }; }; break; case CollectionEventKind.REPLACE: if (event.location == currentIndex){ try { setCurrent(ListCollectionView(view).getItemAt(currentIndex)); } catch(error:ItemPendingError) { setCurrent(null, false); }; }; break; case CollectionEventKind.RESET: currentIndex = BEFORE_FIRST_INDEX; setCurrent(null); break; }; } public function moveNext():Boolean{ if (afterLast){ return (false); }; var _local1:int = (beforeFirst) ? 0 : (currentIndex + 1); if (_local1 >= view.length){ _local1 = AFTER_LAST_INDEX; setCurrent(null); } else { setCurrent(ListCollectionView(view).getItemAt(_local1)); }; currentIndex = _local1; return (!(afterLast)); } public function get view():ICollectionView{ checkValid(); return (_view); } public function movePrevious():Boolean{ if (beforeFirst){ return (false); }; var _local1:int = (afterLast) ? (view.length - 1) : (currentIndex - 1); if (_local1 == -1){ _local1 = BEFORE_FIRST_INDEX; setCurrent(null); } else { setCurrent(ListCollectionView(view).getItemAt(_local1)); }; currentIndex = _local1; return (!(beforeFirst)); } public function findLast(_arg1:Object):Boolean{ var index:int; var values = _arg1; checkValid(); var lcView:ListCollectionView = ListCollectionView(view); try { index = lcView.findItem(values, Sort.LAST_INDEX_MODE); } catch(sortError:SortError) { throw (new CursorError(sortError.message)); }; if (index > -1){ currentIndex = index; setCurrent(lcView.getItemAt(currentIndex)); }; return ((index > -1)); } public function get beforeFirst():Boolean{ checkValid(); return ((((currentIndex == BEFORE_FIRST_INDEX)) || ((view.length == 0)))); } public function get bookmark():CursorBookmark{ checkValid(); if ((((view.length == 0)) || (beforeFirst))){ return (CursorBookmark.FIRST); }; if (afterLast){ return (CursorBookmark.LAST); }; return (ListCollectionView(view).getBookmark(currentIndex)); } public function findFirst(_arg1:Object):Boolean{ var index:int; var values = _arg1; checkValid(); var lcView:ListCollectionView = ListCollectionView(view); try { index = lcView.findItem(values, Sort.FIRST_INDEX_MODE); } catch(sortError:SortError) { throw (new CursorError(sortError.message)); }; if (index > -1){ currentIndex = index; setCurrent(lcView.getItemAt(currentIndex)); }; return ((index > -1)); } public function get current():Object{ checkValid(); return (currentValue); } }
Section 96
//Sort (mx.collections.Sort) package mx.collections { import flash.events.*; import mx.resources.*; import mx.utils.*; import mx.core.*; import mx.collections.errors.*; public class Sort extends EventDispatcher { private var noFieldsDescending:Boolean;// = false private var usingCustomCompareFunction:Boolean; private var defaultEmptyField:SortField; private var _fields:Array; private var _compareFunction:Function; private var _unique:Boolean; private var fieldList:Array; private var resourceManager:IResourceManager; public static const ANY_INDEX_MODE:String = "any"; mx_internal static const VERSION:String = "3.4.0.9271"; public static const LAST_INDEX_MODE:String = "last"; public static const FIRST_INDEX_MODE:String = "first"; public function Sort(){ resourceManager = ResourceManager.getInstance(); fieldList = []; super(); } public function get unique():Boolean{ return (_unique); } public function get compareFunction():Function{ return ((usingCustomCompareFunction) ? _compareFunction : internalCompare); } public function set unique(_arg1:Boolean):void{ _unique = _arg1; } public function sort(_arg1:Array):void{ var fixedCompareFunction:Function; var message:String; var uniqueRet1:Object; var fields:Array; var i:int; var sortArgs:Object; var uniqueRet2:Object; var items = _arg1; if (((!(items)) || ((items.length <= 1)))){ return; }; if (usingCustomCompareFunction){ fixedCompareFunction = function (_arg1:Object, _arg2:Object):int{ return (compareFunction(_arg1, _arg2, _fields)); }; if (unique){ uniqueRet1 = items.sort(fixedCompareFunction, Array.UNIQUESORT); if (uniqueRet1 == 0){ message = resourceManager.getString("collections", "nonUnique"); throw (new SortError(message)); }; } else { items.sort(fixedCompareFunction); }; } else { fields = this.fields; if (((fields) && ((fields.length > 0)))){ sortArgs = initSortFields(items[0], true); if (unique){ if (((sortArgs) && ((fields.length == 1)))){ uniqueRet2 = items.sortOn(sortArgs.fields[0], (sortArgs.options[0] | Array.UNIQUESORT)); } else { uniqueRet2 = items.sort(internalCompare, Array.UNIQUESORT); }; if (uniqueRet2 == 0){ message = resourceManager.getString("collections", "nonUnique"); throw (new SortError(message)); }; } else { if (sortArgs){ items.sortOn(sortArgs.fields, sortArgs.options); } else { items.sort(internalCompare); }; }; } else { items.sort(internalCompare); }; }; } public function propertyAffectsSort(_arg1:String):Boolean{ var _local3:SortField; if (((usingCustomCompareFunction) || (!(fields)))){ return (true); }; var _local2:int; while (_local2 < fields.length) { _local3 = fields[_local2]; if ((((_local3.name == _arg1)) || (_local3.usingCustomCompareFunction))){ return (true); }; _local2++; }; return (false); } private function internalCompare(_arg1:Object, _arg2:Object, _arg3:Array=null):int{ var _local5:int; var _local6:int; var _local7:SortField; var _local4:int; if (!_fields){ _local4 = noFieldsCompare(_arg1, _arg2); } else { _local5 = 0; _local6 = (_arg3) ? _arg3.length : _fields.length; while ((((_local4 == 0)) && ((_local5 < _local6)))) { _local7 = SortField(_fields[_local5]); _local4 = _local7.internalCompare(_arg1, _arg2); _local5++; }; }; return (_local4); } public function reverse():void{ var _local1:int; if (fields){ _local1 = 0; while (_local1 < fields.length) { SortField(fields[_local1]).reverse(); _local1++; }; }; noFieldsDescending = !(noFieldsDescending); } private function noFieldsCompare(_arg1:Object, _arg2:Object, _arg3:Array=null):int{ var message:String; var a = _arg1; var b = _arg2; var fields = _arg3; if (!defaultEmptyField){ defaultEmptyField = new SortField(); try { defaultEmptyField.initCompare(a); } catch(e:SortError) { message = resourceManager.getString("collections", "noComparator", [a]); throw (new SortError(message)); }; }; var result:int = defaultEmptyField.compareFunction(a, b); if (noFieldsDescending){ result = (result * -1); }; return (result); } public function findItem(_arg1:Array, _arg2:Object, _arg3:String, _arg4:Boolean=false, _arg5:Function=null):int{ var compareForFind:Function; var fieldsForCompare:Array; var message:String; var index:int; var fieldName:String; var hadPreviousFieldName:Boolean; var i:int; var hasFieldName:Boolean; var objIndex:int; var match:Boolean; var prevCompare:int; var nextCompare:int; var items = _arg1; var values = _arg2; var mode = _arg3; var returnInsertionIndex = _arg4; var compareFunction = _arg5; if (!items){ message = resourceManager.getString("collections", "noItems"); throw (new SortError(message)); }; if (items.length == 0){ return ((returnInsertionIndex) ? 1 : -1); }; if (compareFunction == null){ compareForFind = this.compareFunction; if (((values) && ((fieldList.length > 0)))){ fieldsForCompare = []; hadPreviousFieldName = true; i = 0; while (i < fieldList.length) { fieldName = fieldList[i]; if (fieldName){ try { hasFieldName = !((values[fieldName] === undefined)); } catch(e:Error) { hasFieldName = false; }; if (hasFieldName){ if (!hadPreviousFieldName){ message = resourceManager.getString("collections", "findCondition", [fieldName]); throw (new SortError(message)); }; fieldsForCompare.push(fieldName); } else { hadPreviousFieldName = false; }; } else { fieldsForCompare.push(null); }; i = (i + 1); }; if (fieldsForCompare.length == 0){ message = resourceManager.getString("collections", "findRestriction"); throw (new SortError(message)); }; try { initSortFields(items[0]); } catch(initSortError:SortError) { }; }; } else { compareForFind = compareFunction; }; var found:Boolean; var objFound:Boolean; index = 0; var lowerBound:int; var upperBound:int = (items.length - 1); var obj:Object; var direction = 1; while (((!(objFound)) && ((lowerBound <= upperBound)))) { index = Math.round(((lowerBound + upperBound) / 2)); obj = items[index]; direction = (fieldsForCompare) ? compareForFind(values, obj, fieldsForCompare) : compareForFind(values, obj); switch (direction){ case -1: upperBound = (index - 1); break; case 0: objFound = true; switch (mode){ case ANY_INDEX_MODE: found = true; break; case FIRST_INDEX_MODE: found = (index == lowerBound); objIndex = (index - 1); match = true; while (((((match) && (!(found)))) && ((objIndex >= lowerBound)))) { obj = items[objIndex]; prevCompare = (fieldsForCompare) ? compareForFind(values, obj, fieldsForCompare) : compareForFind(values, obj); match = (prevCompare == 0); if (((!(match)) || (((match) && ((objIndex == lowerBound)))))){ found = true; index = (objIndex + (match) ? 0 : 1); }; objIndex = (objIndex - 1); }; break; case LAST_INDEX_MODE: found = (index == upperBound); objIndex = (index + 1); match = true; while (((((match) && (!(found)))) && ((objIndex <= upperBound)))) { obj = items[objIndex]; nextCompare = (fieldsForCompare) ? compareForFind(values, obj, fieldsForCompare) : compareForFind(values, obj); match = (nextCompare == 0); if (((!(match)) || (((match) && ((objIndex == upperBound)))))){ found = true; index = (objIndex - (match) ? 0 : 1); }; objIndex = (objIndex + 1); }; break; default: message = resourceManager.getString("collections", "unknownMode"); throw (new SortError(message)); }; break; case 1: lowerBound = (index + 1); break; }; }; if (((!(found)) && (!(returnInsertionIndex)))){ return (-1); }; return (((direction)>0) ? (index + 1) : index); } private function initSortFields(_arg1:Object, _arg2:Boolean=false):Object{ var _local4:int; var _local5:SortField; var _local6:int; var _local3:Object; _local4 = 0; while (_local4 < fields.length) { SortField(fields[_local4]).initCompare(_arg1); _local4++; }; if (_arg2){ _local3 = {fields:[], options:[]}; _local4 = 0; while (_local4 < fields.length) { _local5 = fields[_local4]; _local6 = _local5.getArraySortOnOptions(); if (_local6 == -1){ return (null); }; _local3.fields.push(_local5.name); _local3.options.push(_local6); _local4++; }; }; return (_local3); } public function set fields(_arg1:Array):void{ var _local2:SortField; var _local3:int; _fields = _arg1; fieldList = []; if (_fields){ _local3 = 0; while (_local3 < _fields.length) { _local2 = SortField(_fields[_local3]); fieldList.push(_local2.name); _local3++; }; }; dispatchEvent(new Event("fieldsChanged")); } public function get fields():Array{ return (_fields); } public function set compareFunction(_arg1:Function):void{ _compareFunction = _arg1; usingCustomCompareFunction = !((_compareFunction == null)); } override public function toString():String{ return (ObjectUtil.toString(this)); } } }//package mx.collections
Section 97
//SortField (mx.collections.SortField) package mx.collections { import flash.events.*; import mx.resources.*; import mx.utils.*; import mx.core.*; import mx.collections.errors.*; public class SortField extends EventDispatcher { private var _caseInsensitive:Boolean; private var _numeric:Object; private var _descending:Boolean; private var _compareFunction:Function; private var _usingCustomCompareFunction:Boolean; private var _name:String; private var resourceManager:IResourceManager; mx_internal static const VERSION:String = "3.4.0.9271"; public function SortField(_arg1:String=null, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Object=null){ resourceManager = ResourceManager.getInstance(); super(); _name = _arg1; _caseInsensitive = _arg2; _descending = _arg3; _numeric = _arg4; _compareFunction = stringCompare; } public function get caseInsensitive():Boolean{ return (_caseInsensitive); } mx_internal function get usingCustomCompareFunction():Boolean{ return (_usingCustomCompareFunction); } public function set caseInsensitive(_arg1:Boolean):void{ if (_arg1 != _caseInsensitive){ _caseInsensitive = _arg1; dispatchEvent(new Event("caseInsensitiveChanged")); }; } public function get name():String{ return (_name); } public function get numeric():Object{ return (_numeric); } public function set name(_arg1:String):void{ _name = _arg1; dispatchEvent(new Event("nameChanged")); } private function numericCompare(_arg1:Object, _arg2:Object):int{ var fa:Number; var fb:Number; var a = _arg1; var b = _arg2; try { fa = ((_name == null)) ? Number(a) : Number(a[_name]); } catch(error:Error) { }; try { fb = ((_name == null)) ? Number(b) : Number(b[_name]); } catch(error:Error) { }; return (ObjectUtil.numericCompare(fa, fb)); } public function set numeric(_arg1:Object):void{ if (_numeric != _arg1){ _numeric = _arg1; dispatchEvent(new Event("numericChanged")); }; } private function stringCompare(_arg1:Object, _arg2:Object):int{ var fa:String; var fb:String; var a = _arg1; var b = _arg2; try { fa = ((_name == null)) ? String(a) : String(a[_name]); } catch(error:Error) { }; try { fb = ((_name == null)) ? String(b) : String(b[_name]); } catch(error:Error) { }; return (ObjectUtil.stringCompare(fa, fb, _caseInsensitive)); } public function get compareFunction():Function{ return (_compareFunction); } public function reverse():void{ descending = !(descending); } mx_internal function getArraySortOnOptions():int{ if (((((((usingCustomCompareFunction) || ((name == null)))) || ((_compareFunction == xmlCompare)))) || ((_compareFunction == dateCompare)))){ return (-1); }; var _local1:int; if (caseInsensitive){ _local1 = (_local1 | Array.CASEINSENSITIVE); }; if (descending){ _local1 = (_local1 | Array.DESCENDING); }; if ((((numeric == true)) || ((_compareFunction == numericCompare)))){ _local1 = (_local1 | Array.NUMERIC); }; return (_local1); } private function dateCompare(_arg1:Object, _arg2:Object):int{ var fa:Date; var fb:Date; var a = _arg1; var b = _arg2; try { fa = ((_name == null)) ? (a as Date) : (a[_name] as Date); } catch(error:Error) { }; try { fb = ((_name == null)) ? (b as Date) : (b[_name] as Date); } catch(error:Error) { }; return (ObjectUtil.dateCompare(fa, fb)); } mx_internal function internalCompare(_arg1:Object, _arg2:Object):int{ var _local3:int = compareFunction(_arg1, _arg2); if (descending){ _local3 = (_local3 * -1); }; return (_local3); } override public function toString():String{ return (ObjectUtil.toString(this)); } private function nullCompare(_arg1:Object, _arg2:Object):int{ var value:Object; var left:Object; var right:Object; var message:String; var a = _arg1; var b = _arg2; var found:Boolean; if ((((a == null)) && ((b == null)))){ return (0); }; if (_name){ try { left = a[_name]; } catch(error:Error) { }; try { right = b[_name]; } catch(error:Error) { }; }; if ((((left == null)) && ((right == null)))){ return (0); }; if (left == null){ left = a; }; if (right == null){ right = b; }; var typeLeft = typeof(left); var typeRight = typeof(right); if ((((typeLeft == "string")) || ((typeRight == "string")))){ found = true; _compareFunction = stringCompare; } else { if ((((typeLeft == "object")) || ((typeRight == "object")))){ if ((((left is Date)) || ((right is Date)))){ found = true; _compareFunction = dateCompare; }; } else { if ((((typeLeft == "xml")) || ((typeRight == "xml")))){ found = true; _compareFunction = xmlCompare; } else { if ((((((((typeLeft == "number")) || ((typeRight == "number")))) || ((typeLeft == "boolean")))) || ((typeRight == "boolean")))){ found = true; _compareFunction = numericCompare; }; }; }; }; if (found){ return (_compareFunction(left, right)); }; message = resourceManager.getString("collections", "noComparatorSortField", [name]); throw (new SortError(message)); } public function set descending(_arg1:Boolean):void{ if (_descending != _arg1){ _descending = _arg1; dispatchEvent(new Event("descendingChanged")); }; } mx_internal function initCompare(_arg1:Object):void{ var value:Object; var typ:String; var test:String; var obj = _arg1; if (!usingCustomCompareFunction){ if (numeric == true){ _compareFunction = numericCompare; } else { if (((caseInsensitive) || ((numeric == false)))){ _compareFunction = stringCompare; } else { if (_name){ try { value = obj[_name]; } catch(error:Error) { }; }; if (value == null){ value = obj; }; typ = typeof(value); switch (typ){ case "string": _compareFunction = stringCompare; break; case "object": if ((value is Date)){ _compareFunction = dateCompare; } else { _compareFunction = stringCompare; try { test = value.toString(); } catch(error2:Error) { }; if (((!(test)) || ((test == "[object Object]")))){ _compareFunction = nullCompare; }; }; break; case "xml": _compareFunction = xmlCompare; break; case "boolean": case "number": _compareFunction = numericCompare; break; }; }; }; }; } public function get descending():Boolean{ return (_descending); } public function set compareFunction(_arg1:Function):void{ _compareFunction = _arg1; _usingCustomCompareFunction = !((_arg1 == null)); } private function xmlCompare(_arg1:Object, _arg2:Object):int{ var sa:String; var sb:String; var a = _arg1; var b = _arg2; try { sa = ((_name == null)) ? a.toString() : a[_name].toString(); } catch(error:Error) { }; try { sb = ((_name == null)) ? b.toString() : b[_name].toString(); } catch(error:Error) { }; if (numeric == true){ return (ObjectUtil.numericCompare(parseFloat(sa), parseFloat(sb))); }; return (ObjectUtil.stringCompare(sa, sb, _caseInsensitive)); } } }//package mx.collections
Section 98
//IButton (mx.core.IButton) package mx.core { public interface IButton extends IUIComponent { function get emphasized():Boolean; function set emphasized(_arg1:Boolean):void; function callLater(_arg1:Function, _arg2:Array=null):void; } }//package mx.core
Section 99
//IChildList (mx.core.IChildList) package mx.core { import flash.display.*; import flash.geom.*; public interface IChildList { function get numChildren():int; function removeChild(_arg1:DisplayObject):DisplayObject; function getChildByName(_arg1:String):DisplayObject; function removeChildAt(_arg1:int):DisplayObject; function getChildIndex(_arg1:DisplayObject):int; function addChildAt(_arg1:DisplayObject, _arg2:int):DisplayObject; function getObjectsUnderPoint(_arg1:Point):Array; function setChildIndex(_arg1:DisplayObject, _arg2:int):void; function getChildAt(_arg1:int):DisplayObject; function addChild(_arg1:DisplayObject):DisplayObject; function contains(_arg1:DisplayObject):Boolean; } }//package mx.core
Section 100
//IFlexDisplayObject (mx.core.IFlexDisplayObject) package mx.core { import flash.events.*; import flash.display.*; import flash.geom.*; import flash.accessibility.*; public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher { function get visible():Boolean; function get rotation():Number; function localToGlobal(_arg1:Point):Point; function get name():String; function set width(_arg1:Number):void; function get measuredHeight():Number; function get blendMode():String; function get scale9Grid():Rectangle; function set name(_arg1:String):void; function set scaleX(_arg1:Number):void; function set scaleY(_arg1:Number):void; function get measuredWidth():Number; function get accessibilityProperties():AccessibilityProperties; function set scrollRect(_arg1:Rectangle):void; function get cacheAsBitmap():Boolean; function globalToLocal(_arg1:Point):Point; function get height():Number; function set blendMode(_arg1:String):void; function get parent():DisplayObjectContainer; function getBounds(_arg1:DisplayObject):Rectangle; function get opaqueBackground():Object; function set scale9Grid(_arg1:Rectangle):void; function setActualSize(_arg1:Number, _arg2:Number):void; function set alpha(_arg1:Number):void; function set accessibilityProperties(_arg1:AccessibilityProperties):void; function get width():Number; function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean; function set cacheAsBitmap(_arg1:Boolean):void; function get scaleX():Number; function get scaleY():Number; function get scrollRect():Rectangle; function get mouseX():Number; function get mouseY():Number; function set height(_arg1:Number):void; function set mask(_arg1:DisplayObject):void; function getRect(_arg1:DisplayObject):Rectangle; function get alpha():Number; function set transform(_arg1:Transform):void; function move(_arg1:Number, _arg2:Number):void; function get loaderInfo():LoaderInfo; function get root():DisplayObject; function hitTestObject(_arg1:DisplayObject):Boolean; function set opaqueBackground(_arg1:Object):void; function set visible(_arg1:Boolean):void; function get mask():DisplayObject; function set x(_arg1:Number):void; function set y(_arg1:Number):void; function get transform():Transform; function set filters(_arg1:Array):void; function get x():Number; function get y():Number; function get filters():Array; function set rotation(_arg1:Number):void; function get stage():Stage; } }//package mx.core
Section 101
//IFlexModuleFactory (mx.core.IFlexModuleFactory) package mx.core { import flash.utils.*; public interface IFlexModuleFactory { function get preloadedRSLs():Dictionary; function allowInsecureDomain(... _args):void; function create(... _args):Object; function allowDomain(... _args):void; function info():Object; } }//package mx.core
Section 102
//IMXMLObject (mx.core.IMXMLObject) package mx.core { public interface IMXMLObject { function initialized(_arg1:Object, _arg2:String):void; } }//package mx.core
Section 103
//IPropertyChangeNotifier (mx.core.IPropertyChangeNotifier) package mx.core { import flash.events.*; public interface IPropertyChangeNotifier extends IEventDispatcher, IUID { } }//package mx.core
Section 104
//ISWFBridgeGroup (mx.core.ISWFBridgeGroup) package mx.core { import flash.events.*; public interface ISWFBridgeGroup { function getChildBridgeProvider(_arg1:IEventDispatcher):ISWFBridgeProvider; function removeChildBridge(_arg1:IEventDispatcher):void; function get parentBridge():IEventDispatcher; function addChildBridge(_arg1:IEventDispatcher, _arg2:ISWFBridgeProvider):void; function set parentBridge(_arg1:IEventDispatcher):void; function containsBridge(_arg1:IEventDispatcher):Boolean; function getChildBridges():Array; } }//package mx.core
Section 105
//ISWFBridgeProvider (mx.core.ISWFBridgeProvider) package mx.core { import flash.events.*; public interface ISWFBridgeProvider { function get childAllowsParent():Boolean; function get swfBridge():IEventDispatcher; function get parentAllowsChild():Boolean; } }//package mx.core
Section 106
//IUIComponent (mx.core.IUIComponent) package mx.core { import flash.display.*; import mx.managers.*; public interface IUIComponent extends IFlexDisplayObject { function set focusPane(_arg1:Sprite):void; function get enabled():Boolean; function set enabled(_arg1:Boolean):void; function set isPopUp(_arg1:Boolean):void; function get explicitMinHeight():Number; function get percentWidth():Number; function get isPopUp():Boolean; function get owner():DisplayObjectContainer; function get percentHeight():Number; function get baselinePosition():Number; function owns(_arg1:DisplayObject):Boolean; function initialize():void; function get maxWidth():Number; function get minWidth():Number; function getExplicitOrMeasuredWidth():Number; function get explicitMaxWidth():Number; function get explicitMaxHeight():Number; function set percentHeight(_arg1:Number):void; function get minHeight():Number; function set percentWidth(_arg1:Number):void; function get document():Object; function get focusPane():Sprite; function getExplicitOrMeasuredHeight():Number; function set tweeningProperties(_arg1:Array):void; function set explicitWidth(_arg1:Number):void; function set measuredMinHeight(_arg1:Number):void; function get explicitMinWidth():Number; function get tweeningProperties():Array; function get maxHeight():Number; function set owner(_arg1:DisplayObjectContainer):void; function set includeInLayout(_arg1:Boolean):void; function setVisible(_arg1:Boolean, _arg2:Boolean=false):void; function parentChanged(_arg1:DisplayObjectContainer):void; function get explicitWidth():Number; function get measuredMinHeight():Number; function set measuredMinWidth(_arg1:Number):void; function set explicitHeight(_arg1:Number):void; function get includeInLayout():Boolean; function get measuredMinWidth():Number; function get explicitHeight():Number; function set systemManager(_arg1:ISystemManager):void; function set document(_arg1:Object):void; function get systemManager():ISystemManager; } }//package mx.core
Section 107
//IUID (mx.core.IUID) package mx.core { public interface IUID { function get uid():String; function set uid(_arg1:String):void; } }//package mx.core
Section 108
//mx_internal (mx.core.mx_internal) package mx.core { public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal"; }//package mx.core
Section 109
//Singleton (mx.core.Singleton) package mx.core { public class Singleton { mx_internal static const VERSION:String = "3.4.0.9271"; private static var classMap:Object = {}; public static function registerClass(_arg1:String, _arg2:Class):void{ var _local3:Class = classMap[_arg1]; if (!_local3){ classMap[_arg1] = _arg2; }; } public static function getClass(_arg1:String):Class{ return (classMap[_arg1]); } public static function getInstance(_arg1:String):Object{ var _local2:Class = classMap[_arg1]; if (!_local2){ throw (new Error((("No class registered for interface '" + _arg1) + "'."))); }; return (_local2["getInstance"]()); } } }//package mx.core
Section 110
//CollectionEvent (mx.events.CollectionEvent) package mx.events { import flash.events.*; import mx.core.*; public class CollectionEvent extends Event { public var kind:String; public var location:int; public var items:Array; public var oldLocation:int; mx_internal static const VERSION:String = "3.4.0.9271"; public static const COLLECTION_CHANGE:String = "collectionChange"; public function CollectionEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:String=null, _arg5:int=-1, _arg6:int=-1, _arg7:Array=null){ super(_arg1, _arg2, _arg3); this.kind = _arg4; this.location = _arg5; this.oldLocation = _arg6; this.items = (_arg7) ? _arg7 : []; } override public function toString():String{ return (formatToString("CollectionEvent", "kind", "location", "oldLocation", "type", "bubbles", "cancelable", "eventPhase")); } override public function clone():Event{ return (new CollectionEvent(type, bubbles, cancelable, kind, location, oldLocation, items)); } } }//package mx.events
Section 111
//CollectionEventKind (mx.events.CollectionEventKind) package mx.events { import mx.core.*; public final class CollectionEventKind { public static const ADD:String = "add"; public static const REMOVE:String = "remove"; public static const UPDATE:String = "update"; public static const MOVE:String = "move"; mx_internal static const EXPAND:String = "expand"; public static const REPLACE:String = "replace"; mx_internal static const VERSION:String = "3.4.0.9271"; public static const REFRESH:String = "refresh"; public static const RESET:String = "reset"; } }//package mx.events
Section 112
//FlexEvent (mx.events.FlexEvent) package mx.events { import flash.events.*; import mx.core.*; public class FlexEvent extends Event { public static const ADD:String = "add"; public static const TRANSFORM_CHANGE:String = "transformChange"; public static const ENTER_FRAME:String = "flexEventEnterFrame"; public static const INIT_COMPLETE:String = "initComplete"; public static const REMOVE:String = "remove"; public static const BUTTON_DOWN:String = "buttonDown"; public static const EXIT_STATE:String = "exitState"; public static const CREATION_COMPLETE:String = "creationComplete"; public static const REPEAT:String = "repeat"; public static const LOADING:String = "loading"; public static const RENDER:String = "flexEventRender"; public static const REPEAT_START:String = "repeatStart"; public static const INITIALIZE:String = "initialize"; public static const ENTER_STATE:String = "enterState"; public static const URL_CHANGED:String = "urlChanged"; public static const REPEAT_END:String = "repeatEnd"; mx_internal static const VERSION:String = "3.4.0.9271"; public static const HIDE:String = "hide"; public static const ENTER:String = "enter"; public static const PRELOADER_DONE:String = "preloaderDone"; public static const CURSOR_UPDATE:String = "cursorUpdate"; public static const PREINITIALIZE:String = "preinitialize"; public static const INVALID:String = "invalid"; public static const IDLE:String = "idle"; public static const VALID:String = "valid"; public static const DATA_CHANGE:String = "dataChange"; public static const APPLICATION_COMPLETE:String = "applicationComplete"; public static const VALUE_COMMIT:String = "valueCommit"; public static const UPDATE_COMPLETE:String = "updateComplete"; public static const INIT_PROGRESS:String = "initProgress"; public static const SHOW:String = "show"; public function FlexEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){ super(_arg1, _arg2, _arg3); } override public function clone():Event{ return (new FlexEvent(type, bubbles, cancelable)); } } }//package mx.events
Section 113
//ModuleEvent (mx.events.ModuleEvent) package mx.events { import flash.events.*; import mx.modules.*; import mx.core.*; public class ModuleEvent extends ProgressEvent { public var errorText:String; private var _module:IModuleInfo; public static const READY:String = "ready"; public static const ERROR:String = "error"; public static const PROGRESS:String = "progress"; mx_internal static const VERSION:String = "3.4.0.9271"; public static const SETUP:String = "setup"; public static const UNLOAD:String = "unload"; public function ModuleEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:uint=0, _arg5:uint=0, _arg6:String=null, _arg7:IModuleInfo=null){ super(_arg1, _arg2, _arg3, _arg4, _arg5); this.errorText = _arg6; this._module = _arg7; } public function get module():IModuleInfo{ if (_module){ return (_module); }; return ((target as IModuleInfo)); } override public function clone():Event{ return (new ModuleEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText, module)); } } }//package mx.events
Section 114
//PropertyChangeEvent (mx.events.PropertyChangeEvent) package mx.events { import flash.events.*; import mx.core.*; public class PropertyChangeEvent extends Event { public var newValue:Object; public var kind:String; public var property:Object; public var oldValue:Object; public var source:Object; mx_internal static const VERSION:String = "3.4.0.9271"; public static const PROPERTY_CHANGE:String = "propertyChange"; public function PropertyChangeEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:String=null, _arg5:Object=null, _arg6:Object=null, _arg7:Object=null, _arg8:Object=null){ super(_arg1, _arg2, _arg3); this.kind = _arg4; this.property = _arg5; this.oldValue = _arg6; this.newValue = _arg7; this.source = _arg8; } override public function clone():Event{ return (new PropertyChangeEvent(type, bubbles, cancelable, kind, property, oldValue, newValue, source)); } public static function createUpdateEvent(_arg1:Object, _arg2:Object, _arg3:Object, _arg4:Object):PropertyChangeEvent{ var _local5:PropertyChangeEvent = new PropertyChangeEvent(PROPERTY_CHANGE); _local5.kind = PropertyChangeEventKind.UPDATE; _local5.oldValue = _arg3; _local5.newValue = _arg4; _local5.source = _arg1; _local5.property = _arg2; return (_local5); } } }//package mx.events
Section 115
//PropertyChangeEventKind (mx.events.PropertyChangeEventKind) package mx.events { import mx.core.*; public final class PropertyChangeEventKind { mx_internal static const VERSION:String = "3.4.0.9271"; public static const UPDATE:String = "update"; public static const DELETE:String = "delete"; } }//package mx.events
Section 116
//ResourceEvent (mx.events.ResourceEvent) package mx.events { import flash.events.*; import mx.core.*; public class ResourceEvent extends ProgressEvent { public var errorText:String; mx_internal static const VERSION:String = "3.4.0.9271"; public static const COMPLETE:String = "complete"; public static const PROGRESS:String = "progress"; public static const ERROR:String = "error"; public function ResourceEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:uint=0, _arg5:uint=0, _arg6:String=null){ super(_arg1, _arg2, _arg3, _arg4, _arg5); this.errorText = _arg6; } override public function clone():Event{ return (new ResourceEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText)); } } }//package mx.events
Section 117
//IFocusManager (mx.managers.IFocusManager) package mx.managers { import flash.events.*; import flash.display.*; import mx.core.*; public interface IFocusManager { function get focusPane():Sprite; function getFocus():IFocusManagerComponent; function deactivate():void; function set defaultButton(_arg1:IButton):void; function set focusPane(_arg1:Sprite):void; function set showFocusIndicator(_arg1:Boolean):void; function moveFocus(_arg1:String, _arg2:DisplayObject=null):void; function addSWFBridge(_arg1:IEventDispatcher, _arg2:DisplayObject):void; function removeSWFBridge(_arg1:IEventDispatcher):void; function get defaultButtonEnabled():Boolean; function findFocusManagerComponent(_arg1:InteractiveObject):IFocusManagerComponent; function get nextTabIndex():int; function get defaultButton():IButton; function get showFocusIndicator():Boolean; function setFocus(_arg1:IFocusManagerComponent):void; function activate():void; function showFocus():void; function set defaultButtonEnabled(_arg1:Boolean):void; function hideFocus():void; function getNextFocusManagerComponent(_arg1:Boolean=false):IFocusManagerComponent; } }//package mx.managers
Section 118
//IFocusManagerComponent (mx.managers.IFocusManagerComponent) package mx.managers { public interface IFocusManagerComponent { function set focusEnabled(_arg1:Boolean):void; function drawFocus(_arg1:Boolean):void; function setFocus():void; function get focusEnabled():Boolean; function get tabEnabled():Boolean; function get tabIndex():int; function get mouseFocusEnabled():Boolean; } }//package mx.managers
Section 119
//IFocusManagerContainer (mx.managers.IFocusManagerContainer) package mx.managers { import flash.events.*; import flash.display.*; public interface IFocusManagerContainer extends IEventDispatcher { function set focusManager(_arg1:IFocusManager):void; function get focusManager():IFocusManager; function get systemManager():ISystemManager; function contains(_arg1:DisplayObject):Boolean; } }//package mx.managers
Section 120
//ISystemManager (mx.managers.ISystemManager) package mx.managers { import flash.events.*; import flash.display.*; import mx.core.*; import flash.geom.*; import flash.text.*; public interface ISystemManager extends IEventDispatcher, IChildList, IFlexModuleFactory { function set focusPane(_arg1:Sprite):void; function get toolTipChildren():IChildList; function useSWFBridge():Boolean; function isFontFaceEmbedded(_arg1:TextFormat):Boolean; function deployMouseShields(_arg1:Boolean):void; function get rawChildren():IChildList; function get topLevelSystemManager():ISystemManager; function dispatchEventFromSWFBridges(_arg1:Event, _arg2:IEventDispatcher=null, _arg3:Boolean=false, _arg4:Boolean=false):void; function getSandboxRoot():DisplayObject; function get swfBridgeGroup():ISWFBridgeGroup; function removeFocusManager(_arg1:IFocusManagerContainer):void; function addChildToSandboxRoot(_arg1:String, _arg2:DisplayObject):void; function get document():Object; function get focusPane():Sprite; function get loaderInfo():LoaderInfo; function addChildBridge(_arg1:IEventDispatcher, _arg2:DisplayObject):void; function getTopLevelRoot():DisplayObject; function removeChildBridge(_arg1:IEventDispatcher):void; function isDisplayObjectInABridgedApplication(_arg1:DisplayObject):Boolean; function get popUpChildren():IChildList; function get screen():Rectangle; function removeChildFromSandboxRoot(_arg1:String, _arg2:DisplayObject):void; function getDefinitionByName(_arg1:String):Object; function activate(_arg1:IFocusManagerContainer):void; function deactivate(_arg1:IFocusManagerContainer):void; function get cursorChildren():IChildList; function set document(_arg1:Object):void; function get embeddedFontList():Object; function set numModalWindows(_arg1:int):void; function isTopLevel():Boolean; function isTopLevelRoot():Boolean; function get numModalWindows():int; function addFocusManager(_arg1:IFocusManagerContainer):void; function get stage():Stage; function getVisibleApplicationRect(_arg1:Rectangle=null):Rectangle; } }//package mx.managers
Section 121
//IModuleInfo (mx.modules.IModuleInfo) package mx.modules { import flash.events.*; import flash.utils.*; import flash.system.*; import mx.core.*; public interface IModuleInfo extends IEventDispatcher { function get ready():Boolean; function get loaded():Boolean; function load(_arg1:ApplicationDomain=null, _arg2:SecurityDomain=null, _arg3:ByteArray=null):void; function release():void; function get error():Boolean; function get data():Object; function publish(_arg1:IFlexModuleFactory):void; function get factory():IFlexModuleFactory; function set data(_arg1:Object):void; function get url():String; function get setup():Boolean; function unload():void; } }//package mx.modules
Section 122
//ModuleManager (mx.modules.ModuleManager) package mx.modules { import mx.core.*; public class ModuleManager { mx_internal static const VERSION:String = "3.4.0.9271"; public static function getModule(_arg1:String):IModuleInfo{ return (getSingleton().getModule(_arg1)); } private static function getSingleton():Object{ if (!ModuleManagerGlobals.managerSingleton){ ModuleManagerGlobals.managerSingleton = new ModuleManagerImpl(); }; return (ModuleManagerGlobals.managerSingleton); } public static function getAssociatedFactory(_arg1:Object):IFlexModuleFactory{ return (getSingleton().getAssociatedFactory(_arg1)); } } }//package mx.modules import flash.events.*; import flash.display.*; import flash.utils.*; import flash.net.*; import mx.events.*; import flash.system.*; import mx.core.*; class ModuleInfoProxy extends EventDispatcher implements IModuleInfo { private var _data:Object; private var info:ModuleInfo; private var referenced:Boolean;// = false private function ModuleInfoProxy(_arg1:ModuleInfo){ this.info = _arg1; _arg1.addEventListener(ModuleEvent.SETUP, moduleEventHandler, false, 0, true); _arg1.addEventListener(ModuleEvent.PROGRESS, moduleEventHandler, false, 0, true); _arg1.addEventListener(ModuleEvent.READY, moduleEventHandler, false, 0, true); _arg1.addEventListener(ModuleEvent.ERROR, moduleEventHandler, false, 0, true); _arg1.addEventListener(ModuleEvent.UNLOAD, moduleEventHandler, false, 0, true); } public function get loaded():Boolean{ return (info.loaded); } public function release():void{ if (referenced){ info.removeReference(); referenced = false; }; } public function get error():Boolean{ return (info.error); } public function get factory():IFlexModuleFactory{ return (info.factory); } public function publish(_arg1:IFlexModuleFactory):void{ info.publish(_arg1); } public function set data(_arg1:Object):void{ _data = _arg1; } public function get ready():Boolean{ return (info.ready); } public function load(_arg1:ApplicationDomain=null, _arg2:SecurityDomain=null, _arg3:ByteArray=null):void{ var _local4:ModuleEvent; info.resurrect(); if (!referenced){ info.addReference(); referenced = true; }; if (info.error){ dispatchEvent(new ModuleEvent(ModuleEvent.ERROR)); } else { if (info.loaded){ if (info.setup){ dispatchEvent(new ModuleEvent(ModuleEvent.SETUP)); if (info.ready){ _local4 = new ModuleEvent(ModuleEvent.PROGRESS); _local4.bytesLoaded = info.size; _local4.bytesTotal = info.size; dispatchEvent(_local4); dispatchEvent(new ModuleEvent(ModuleEvent.READY)); }; }; } else { info.load(_arg1, _arg2, _arg3); }; }; } private function moduleEventHandler(_arg1:ModuleEvent):void{ dispatchEvent(_arg1); } public function get url():String{ return (info.url); } public function get data():Object{ return (_data); } public function get setup():Boolean{ return (info.setup); } public function unload():void{ info.unload(); info.removeEventListener(ModuleEvent.SETUP, moduleEventHandler); info.removeEventListener(ModuleEvent.PROGRESS, moduleEventHandler); info.removeEventListener(ModuleEvent.READY, moduleEventHandler); info.removeEventListener(ModuleEvent.ERROR, moduleEventHandler); info.removeEventListener(ModuleEvent.UNLOAD, moduleEventHandler); } } class ModuleManagerImpl extends EventDispatcher { private var moduleList:Object; private function ModuleManagerImpl(){ moduleList = {}; super(); } public function getModule(_arg1:String):IModuleInfo{ var _local2:ModuleInfo = (moduleList[_arg1] as ModuleInfo); if (!_local2){ _local2 = new ModuleInfo(_arg1); moduleList[_arg1] = _local2; }; return (new ModuleInfoProxy(_local2)); } public function getAssociatedFactory(_arg1:Object):IFlexModuleFactory{ var m:Object; var info:ModuleInfo; var domain:ApplicationDomain; var cls:Class; var object = _arg1; var className:String = getQualifiedClassName(object); for each (m in moduleList) { info = (m as ModuleInfo); if (!info.ready){ } else { domain = info.applicationDomain; try { cls = Class(domain.getDefinition(className)); if ((object is cls)){ return (info.factory); }; } catch(error:Error) { }; }; }; return (null); } } class ModuleInfo extends EventDispatcher { private var _error:Boolean;// = false private var loader:Loader; private var factoryInfo:FactoryInfo; private var limbo:Dictionary; private var _loaded:Boolean;// = false private var _ready:Boolean;// = false private var numReferences:int;// = 0 private var _url:String; private var _setup:Boolean;// = false private function ModuleInfo(_arg1:String){ _url = _arg1; } private function clearLoader():void{ if (loader){ if (loader.contentLoaderInfo){ loader.contentLoaderInfo.removeEventListener(Event.INIT, initHandler); loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandler); loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler); loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler); loader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler); }; try { if (loader.content){ loader.content.removeEventListener("ready", readyHandler); loader.content.removeEventListener("error", moduleErrorHandler); }; } catch(error:Error) { }; if (_loaded){ try { loader.close(); } catch(error:Error) { }; }; try { loader.unload(); } catch(error:Error) { }; loader = null; }; } public function get size():int{ return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.bytesTotal : 0); } public function get loaded():Boolean{ return ((limbo) ? false : _loaded); } public function release():void{ if (((_ready) && (!(limbo)))){ limbo = new Dictionary(true); limbo[factoryInfo] = 1; factoryInfo = null; } else { unload(); }; } public function get error():Boolean{ return ((limbo) ? false : _error); } public function get factory():IFlexModuleFactory{ return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.factory : null); } public function completeHandler(_arg1:Event):void{ var _local2:ModuleEvent = new ModuleEvent(ModuleEvent.PROGRESS, _arg1.bubbles, _arg1.cancelable); _local2.bytesLoaded = loader.contentLoaderInfo.bytesLoaded; _local2.bytesTotal = loader.contentLoaderInfo.bytesTotal; dispatchEvent(_local2); } public function publish(_arg1:IFlexModuleFactory):void{ if (factoryInfo){ return; }; if (_url.indexOf("published://") != 0){ return; }; factoryInfo = new FactoryInfo(); factoryInfo.factory = _arg1; _loaded = true; _setup = true; _ready = true; _error = false; dispatchEvent(new ModuleEvent(ModuleEvent.SETUP)); dispatchEvent(new ModuleEvent(ModuleEvent.PROGRESS)); dispatchEvent(new ModuleEvent(ModuleEvent.READY)); } public function initHandler(_arg1:Event):void{ var moduleEvent:ModuleEvent; var event = _arg1; factoryInfo = new FactoryInfo(); try { factoryInfo.factory = (loader.content as IFlexModuleFactory); } catch(error:Error) { }; if (!factoryInfo.factory){ moduleEvent = new ModuleEvent(ModuleEvent.ERROR, event.bubbles, event.cancelable); moduleEvent.bytesLoaded = 0; moduleEvent.bytesTotal = 0; moduleEvent.errorText = "SWF is not a loadable module"; dispatchEvent(moduleEvent); return; }; loader.content.addEventListener("ready", readyHandler); loader.content.addEventListener("error", moduleErrorHandler); try { factoryInfo.applicationDomain = loader.contentLoaderInfo.applicationDomain; } catch(error:Error) { }; _setup = true; dispatchEvent(new ModuleEvent(ModuleEvent.SETUP)); } public function resurrect():void{ var _local1:Object; if (((!(factoryInfo)) && (limbo))){ for (_local1 in limbo) { factoryInfo = (_local1 as FactoryInfo); break; }; limbo = null; }; if (!factoryInfo){ if (_loaded){ dispatchEvent(new ModuleEvent(ModuleEvent.UNLOAD)); }; loader = null; _loaded = false; _setup = false; _ready = false; _error = false; }; } public function errorHandler(_arg1:ErrorEvent):void{ _error = true; var _local2:ModuleEvent = new ModuleEvent(ModuleEvent.ERROR, _arg1.bubbles, _arg1.cancelable); _local2.bytesLoaded = 0; _local2.bytesTotal = 0; _local2.errorText = _arg1.text; dispatchEvent(_local2); } public function get ready():Boolean{ return ((limbo) ? false : _ready); } private function loadBytes(_arg1:ApplicationDomain, _arg2:ByteArray):void{ var _local3:LoaderContext = new LoaderContext(); _local3.applicationDomain = (_arg1) ? _arg1 : new ApplicationDomain(ApplicationDomain.currentDomain); if (("allowLoadBytesCodeExecution" in _local3)){ _local3["allowLoadBytesCodeExecution"] = true; }; loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler); loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler); loader.loadBytes(_arg2, _local3); } public function removeReference():void{ numReferences--; if (numReferences == 0){ release(); }; } public function addReference():void{ numReferences++; } public function progressHandler(_arg1:ProgressEvent):void{ var _local2:ModuleEvent = new ModuleEvent(ModuleEvent.PROGRESS, _arg1.bubbles, _arg1.cancelable); _local2.bytesLoaded = _arg1.bytesLoaded; _local2.bytesTotal = _arg1.bytesTotal; dispatchEvent(_local2); } public function load(_arg1:ApplicationDomain=null, _arg2:SecurityDomain=null, _arg3:ByteArray=null):void{ if (_loaded){ return; }; _loaded = true; limbo = null; if (_arg3){ loadBytes(_arg1, _arg3); return; }; if (_url.indexOf("published://") == 0){ return; }; var _local4:URLRequest = new URLRequest(_url); var _local5:LoaderContext = new LoaderContext(); _local5.applicationDomain = (_arg1) ? _arg1 : new ApplicationDomain(ApplicationDomain.currentDomain); _local5.securityDomain = _arg2; if ((((_arg2 == null)) && ((Security.sandboxType == Security.REMOTE)))){ _local5.securityDomain = SecurityDomain.currentDomain; }; loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler); loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler); loader.load(_local4, _local5); } public function get url():String{ return (_url); } public function get applicationDomain():ApplicationDomain{ return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.applicationDomain : null); } public function moduleErrorHandler(_arg1:Event):void{ var _local2:ModuleEvent; _ready = true; factoryInfo.bytesTotal = loader.contentLoaderInfo.bytesTotal; clearLoader(); if ((_arg1 is ModuleEvent)){ _local2 = ModuleEvent(_arg1); } else { _local2 = new ModuleEvent(ModuleEvent.ERROR); }; dispatchEvent(_local2); } public function readyHandler(_arg1:Event):void{ _ready = true; factoryInfo.bytesTotal = loader.contentLoaderInfo.bytesTotal; var _local2:ModuleEvent = new ModuleEvent(ModuleEvent.READY); _local2.bytesLoaded = loader.contentLoaderInfo.bytesLoaded; _local2.bytesTotal = loader.contentLoaderInfo.bytesTotal; clearLoader(); dispatchEvent(_local2); } public function get setup():Boolean{ return ((limbo) ? false : _setup); } public function unload():void{ clearLoader(); if (_loaded){ dispatchEvent(new ModuleEvent(ModuleEvent.UNLOAD)); }; limbo = null; factoryInfo = null; _loaded = false; _setup = false; _ready = false; _error = false; } } class FactoryInfo { public var bytesTotal:int;// = 0 public var factory:IFlexModuleFactory; public var applicationDomain:ApplicationDomain; private function FactoryInfo(){ } }
Section 123
//ModuleManagerGlobals (mx.modules.ModuleManagerGlobals) package mx.modules { public class ModuleManagerGlobals { public static var managerSingleton:Object = null; } }//package mx.modules
Section 124
//IResourceBundle (mx.resources.IResourceBundle) package mx.resources { public interface IResourceBundle { function get content():Object; function get locale():String; function get bundleName():String; } }//package mx.resources
Section 125
//IResourceManager (mx.resources.IResourceManager) package mx.resources { import flash.events.*; import flash.system.*; public interface IResourceManager extends IEventDispatcher { function loadResourceModule(_arg1:String, _arg2:Boolean=true, _arg3:ApplicationDomain=null, _arg4:SecurityDomain=null):IEventDispatcher; function getBoolean(_arg1:String, _arg2:String, _arg3:String=null):Boolean; function getClass(_arg1:String, _arg2:String, _arg3:String=null):Class; function getLocales():Array; function removeResourceBundlesForLocale(_arg1:String):void; function getResourceBundle(_arg1:String, _arg2:String):IResourceBundle; function get localeChain():Array; function getInt(_arg1:String, _arg2:String, _arg3:String=null):int; function update():void; function set localeChain(_arg1:Array):void; function getUint(_arg1:String, _arg2:String, _arg3:String=null):uint; function addResourceBundle(_arg1:IResourceBundle):void; function getStringArray(_arg1:String, _arg2:String, _arg3:String=null):Array; function getBundleNamesForLocale(_arg1:String):Array; function removeResourceBundle(_arg1:String, _arg2:String):void; function getObject(_arg1:String, _arg2:String, _arg3:String=null); function getString(_arg1:String, _arg2:String, _arg3:Array=null, _arg4:String=null):String; function installCompiledResourceBundles(_arg1:ApplicationDomain, _arg2:Array, _arg3:Array):void; function unloadResourceModule(_arg1:String, _arg2:Boolean=true):void; function getPreferredLocaleChain():Array; function findResourceBundleWithResource(_arg1:String, _arg2:String):IResourceBundle; function initializeLocaleChain(_arg1:Array):void; function getNumber(_arg1:String, _arg2:String, _arg3:String=null):Number; } }//package mx.resources
Section 126
//IResourceModule (mx.resources.IResourceModule) package mx.resources { public interface IResourceModule { function get resourceBundles():Array; } }//package mx.resources
Section 127
//LocaleSorter (mx.resources.LocaleSorter) package mx.resources { import mx.core.*; public class LocaleSorter { mx_internal static const VERSION:String = "3.4.0.9271"; private static function normalizeLocale(_arg1:String):String{ return (_arg1.toLowerCase().replace(/-/g, "_")); } public static function sortLocalesByPreference(_arg1:Array, _arg2:Array, _arg3:String=null, _arg4:Boolean=false):Array{ var result:Array; var hasLocale:Object; var i:int; var j:int; var k:int; var l:int; var locale:String; var plocale:LocaleID; var appLocales = _arg1; var systemPreferences = _arg2; var ultimateFallbackLocale = _arg3; var addAll = _arg4; var promote:Function = function (_arg1:String):void{ if (typeof(hasLocale[_arg1]) != "undefined"){ result.push(appLocales[hasLocale[_arg1]]); delete hasLocale[_arg1]; }; }; result = []; hasLocale = {}; var locales:Array = trimAndNormalize(appLocales); var preferenceLocales:Array = trimAndNormalize(systemPreferences); addUltimateFallbackLocale(preferenceLocales, ultimateFallbackLocale); j = 0; while (j < locales.length) { hasLocale[locales[j]] = j; j = (j + 1); }; i = 0; l = preferenceLocales.length; while (i < l) { plocale = LocaleID.fromString(preferenceLocales[i]); promote(preferenceLocales[i]); promote(plocale.toString()); while (plocale.transformToParent()) { promote(plocale.toString()); }; plocale = LocaleID.fromString(preferenceLocales[i]); j = 0; while (j < l) { locale = preferenceLocales[j]; if (plocale.isSiblingOf(LocaleID.fromString(locale))){ promote(locale); }; j = (j + 1); }; j = 0; k = locales.length; while (j < k) { locale = locales[j]; if (plocale.isSiblingOf(LocaleID.fromString(locale))){ promote(locale); }; j = (j + 1); }; i = (i + 1); }; if (addAll){ j = 0; k = locales.length; while (j < k) { promote(locales[j]); j = (j + 1); }; }; return (result); } private static function addUltimateFallbackLocale(_arg1:Array, _arg2:String):void{ var _local3:String; if (((!((_arg2 == null))) && (!((_arg2 == ""))))){ _local3 = normalizeLocale(_arg2); if (_arg1.indexOf(_local3) == -1){ _arg1.push(_local3); }; }; } private static function trimAndNormalize(_arg1:Array):Array{ var _local2:Array = []; var _local3:int; while (_local3 < _arg1.length) { _local2.push(normalizeLocale(_arg1[_local3])); _local3++; }; return (_local2); } } }//package mx.resources class LocaleID { private var privateLangs:Boolean;// = false private var script:String;// = "" private var variants:Array; private var privates:Array; private var extensions:Object; private var lang:String;// = "" private var region:String;// = "" private var extended_langs:Array; public static const STATE_PRIMARY_LANGUAGE:int = 0; public static const STATE_REGION:int = 3; public static const STATE_EXTENDED_LANGUAGES:int = 1; public static const STATE_EXTENSIONS:int = 5; public static const STATE_SCRIPT:int = 2; public static const STATE_VARIANTS:int = 4; public static const STATE_PRIVATES:int = 6; private function LocaleID(){ extended_langs = []; variants = []; extensions = {}; privates = []; super(); } public function equals(_arg1:LocaleID):Boolean{ return ((toString() == _arg1.toString())); } public function canonicalize():void{ var _local1:String; for (_local1 in extensions) { if (extensions.hasOwnProperty(_local1)){ if (extensions[_local1].length == 0){ delete extensions[_local1]; } else { extensions[_local1] = extensions[_local1].sort(); }; }; }; extended_langs = extended_langs.sort(); variants = variants.sort(); privates = privates.sort(); if (script == ""){ script = LocaleRegistry.getScriptByLang(lang); }; if ((((script == "")) && (!((region == ""))))){ script = LocaleRegistry.getScriptByLangAndRegion(lang, region); }; if ((((region == "")) && (!((script == ""))))){ region = LocaleRegistry.getDefaultRegionForLangAndScript(lang, script); }; } public function toString():String{ var _local2:String; var _local1:Array = [lang]; Array.prototype.push.apply(_local1, extended_langs); if (script != ""){ _local1.push(script); }; if (region != ""){ _local1.push(region); }; Array.prototype.push.apply(_local1, variants); for (_local2 in extensions) { if (extensions.hasOwnProperty(_local2)){ _local1.push(_local2); Array.prototype.push.apply(_local1, extensions[_local2]); }; }; if (privates.length > 0){ _local1.push("x"); Array.prototype.push.apply(_local1, privates); }; return (_local1.join("_")); } public function isSiblingOf(_arg1:LocaleID):Boolean{ return ((((lang == _arg1.lang)) && ((script == _arg1.script)))); } public function transformToParent():Boolean{ var _local2:String; var _local3:Array; var _local4:String; if (privates.length > 0){ privates.splice((privates.length - 1), 1); return (true); }; var _local1:String; for (_local2 in extensions) { if (extensions.hasOwnProperty(_local2)){ _local1 = _local2; }; }; if (_local1){ _local3 = extensions[_local1]; if (_local3.length == 1){ delete extensions[_local1]; return (true); }; _local3.splice((_local3.length - 1), 1); return (true); }; if (variants.length > 0){ variants.splice((variants.length - 1), 1); return (true); }; if (script != ""){ if (LocaleRegistry.getScriptByLang(lang) != ""){ script = ""; return (true); }; if (region == ""){ _local4 = LocaleRegistry.getDefaultRegionForLangAndScript(lang, script); if (_local4 != ""){ region = _local4; script = ""; return (true); }; }; }; if (region != ""){ if (!(((script == "")) && ((LocaleRegistry.getScriptByLang(lang) == "")))){ region = ""; return (true); }; }; if (extended_langs.length > 0){ extended_langs.splice((extended_langs.length - 1), 1); return (true); }; return (false); } public static function fromString(_arg1:String):LocaleID{ var _local5:Array; var _local8:String; var _local9:int; var _local10:String; var _local2:LocaleID = new (LocaleID); var _local3:int = STATE_PRIMARY_LANGUAGE; var _local4:Array = _arg1.replace(/-/g, "_").split("_"); var _local6:int; var _local7:int = _local4.length; while (_local6 < _local7) { _local8 = _local4[_local6].toLowerCase(); if (_local3 == STATE_PRIMARY_LANGUAGE){ if (_local8 == "x"){ _local2.privateLangs = true; } else { if (_local8 == "i"){ _local2.lang = (_local2.lang + "i-"); } else { _local2.lang = (_local2.lang + _local8); _local3 = STATE_EXTENDED_LANGUAGES; }; }; } else { _local9 = _local8.length; if (_local9 == 0){ } else { _local10 = _local8.charAt(0).toLowerCase(); if ((((_local3 <= STATE_EXTENDED_LANGUAGES)) && ((_local9 == 3)))){ _local2.extended_langs.push(_local8); if (_local2.extended_langs.length == 3){ _local3 = STATE_SCRIPT; }; } else { if ((((_local3 <= STATE_SCRIPT)) && ((_local9 == 4)))){ _local2.script = _local8; _local3 = STATE_REGION; } else { if ((((_local3 <= STATE_REGION)) && ((((_local9 == 2)) || ((_local9 == 3)))))){ _local2.region = _local8; _local3 = STATE_VARIANTS; } else { if ((((_local3 <= STATE_VARIANTS)) && ((((((((_local10 >= "a")) && ((_local10 <= "z")))) && ((_local9 >= 5)))) || ((((((_local10 >= "0")) && ((_local10 <= "9")))) && ((_local9 >= 4)))))))){ _local2.variants.push(_local8); _local3 = STATE_VARIANTS; } else { if ((((_local3 < STATE_PRIVATES)) && ((_local9 == 1)))){ if (_local8 == "x"){ _local3 = STATE_PRIVATES; _local5 = _local2.privates; } else { _local3 = STATE_EXTENSIONS; _local5 = ((_local2.extensions[_local8]) || ([])); _local2.extensions[_local8] = _local5; }; } else { if (_local3 >= STATE_EXTENSIONS){ _local5.push(_local8); }; }; }; }; }; }; }; }; _local6++; }; _local2.canonicalize(); return (_local2); } } class LocaleRegistry { private static const SCRIPT_ID_BY_LANG:Object = {ab:5, af:1, am:2, ar:3, as:4, ay:1, be:5, bg:5, bn:4, bs:1, ca:1, ch:1, cs:1, cy:1, da:1, de:1, dv:6, dz:7, el:8, en:1, eo:1, es:1, et:1, eu:1, fa:3, fi:1, fj:1, fo:1, fr:1, frr:1, fy:1, ga:1, gl:1, gn:1, gu:9, gv:1, he:10, hi:11, hr:1, ht:1, hu:1, hy:12, id:1, in:1, is:1, it:1, iw:10, ja:13, ka:14, kk:5, kl:1, km:15, kn:16, ko:17, la:1, lb:1, ln:1, lo:18, lt:1, lv:1, mg:1, mh:1, mk:5, ml:19, mo:1, mr:11, ms:1, mt:1, my:20, na:1, nb:1, nd:1, ne:11, nl:1, nn:1, no:1, nr:1, ny:1, om:1, or:21, pa:22, pl:1, ps:3, pt:1, qu:1, rn:1, ro:1, ru:5, rw:1, sg:1, si:23, sk:1, sl:1, sm:1, so:1, sq:1, ss:1, st:1, sv:1, sw:1, ta:24, te:25, th:26, ti:2, tl:1, tn:1, to:1, tr:1, ts:1, uk:5, ur:3, ve:1, vi:1, wo:1, xh:1, yi:10, zu:1, cpe:1, dsb:1, frs:1, gsw:1, hsb:1, kok:11, mai:11, men:1, nds:1, niu:1, nqo:27, nso:1, son:1, tem:1, tkl:1, tmh:1, tpi:1, tvl:1, zbl:28}; private static const SCRIPTS:Array = ["", "latn", "ethi", "arab", "beng", "cyrl", "thaa", "tibt", "grek", "gujr", "hebr", "deva", "armn", "jpan", "geor", "khmr", "knda", "kore", "laoo", "mlym", "mymr", "orya", "guru", "sinh", "taml", "telu", "thai", "nkoo", "blis", "hans", "hant", "mong", "syrc"]; private static const DEFAULT_REGION_BY_LANG_AND_SCRIPT:Object = {bg:{5:"bg"}, ca:{1:"es"}, zh:{30:"tw", 29:"cn"}, cs:{1:"cz"}, da:{1:"dk"}, de:{1:"de"}, el:{8:"gr"}, en:{1:"us"}, es:{1:"es"}, fi:{1:"fi"}, fr:{1:"fr"}, he:{10:"il"}, hu:{1:"hu"}, is:{1:"is"}, it:{1:"it"}, ja:{13:"jp"}, ko:{17:"kr"}, nl:{1:"nl"}, nb:{1:"no"}, pl:{1:"pl"}, pt:{1:"br"}, ro:{1:"ro"}, ru:{5:"ru"}, hr:{1:"hr"}, sk:{1:"sk"}, sq:{1:"al"}, sv:{1:"se"}, th:{26:"th"}, tr:{1:"tr"}, ur:{3:"pk"}, id:{1:"id"}, uk:{5:"ua"}, be:{5:"by"}, sl:{1:"si"}, et:{1:"ee"}, lv:{1:"lv"}, lt:{1:"lt"}, fa:{3:"ir"}, vi:{1:"vn"}, hy:{12:"am"}, az:{1:"az", 5:"az"}, eu:{1:"es"}, mk:{5:"mk"}, af:{1:"za"}, ka:{14:"ge"}, fo:{1:"fo"}, hi:{11:"in"}, ms:{1:"my"}, kk:{5:"kz"}, ky:{5:"kg"}, sw:{1:"ke"}, uz:{1:"uz", 5:"uz"}, tt:{5:"ru"}, pa:{22:"in"}, gu:{9:"in"}, ta:{24:"in"}, te:{25:"in"}, kn:{16:"in"}, mr:{11:"in"}, sa:{11:"in"}, mn:{5:"mn"}, gl:{1:"es"}, kok:{11:"in"}, syr:{32:"sy"}, dv:{6:"mv"}, nn:{1:"no"}, sr:{1:"cs", 5:"cs"}, cy:{1:"gb"}, mi:{1:"nz"}, mt:{1:"mt"}, quz:{1:"bo"}, tn:{1:"za"}, xh:{1:"za"}, zu:{1:"za"}, nso:{1:"za"}, se:{1:"no"}, smj:{1:"no"}, sma:{1:"no"}, sms:{1:"fi"}, smn:{1:"fi"}, bs:{1:"ba"}}; private static const SCRIPT_BY_ID:Object = {latn:1, ethi:2, arab:3, beng:4, cyrl:5, thaa:6, tibt:7, grek:8, gujr:9, hebr:10, deva:11, armn:12, jpan:13, geor:14, khmr:15, knda:16, kore:17, laoo:18, mlym:19, mymr:20, orya:21, guru:22, sinh:23, taml:24, telu:25, thai:26, nkoo:27, blis:28, hans:29, hant:30, mong:31, syrc:32}; private static const SCRIPT_ID_BY_LANG_AND_REGION:Object = {zh:{cn:29, sg:29, tw:30, hk:30, mo:30}, mn:{cn:31, sg:5}, pa:{pk:3, in:22}, ha:{gh:1, ne:1}}; private function LocaleRegistry(){ } public static function getScriptByLangAndRegion(_arg1:String, _arg2:String):String{ var _local3:Object = SCRIPT_ID_BY_LANG_AND_REGION[_arg1]; if (_local3 == null){ return (""); }; var _local4:Object = _local3[_arg2]; if (_local4 == null){ return (""); }; return (SCRIPTS[int(_local4)].toLowerCase()); } public static function getScriptByLang(_arg1:String):String{ var _local2:Object = SCRIPT_ID_BY_LANG[_arg1]; if (_local2 == null){ return (""); }; return (SCRIPTS[int(_local2)].toLowerCase()); } public static function getDefaultRegionForLangAndScript(_arg1:String, _arg2:String):String{ var _local3:Object = DEFAULT_REGION_BY_LANG_AND_SCRIPT[_arg1]; var _local4:Object = SCRIPT_BY_ID[_arg2]; if ((((_local3 == null)) || ((_local4 == null)))){ return (""); }; return (((_local3[int(_local4)]) || (""))); } }
Section 128
//ResourceBundle (mx.resources.ResourceBundle) package mx.resources { import flash.system.*; import mx.utils.*; import mx.core.*; public class ResourceBundle implements IResourceBundle { mx_internal var _locale:String; private var _content:Object; mx_internal var _bundleName:String; mx_internal static const VERSION:String = "3.4.0.9271"; mx_internal static var backupApplicationDomain:ApplicationDomain; mx_internal static var locale:String; public function ResourceBundle(_arg1:String=null, _arg2:String=null){ _content = {}; super(); mx_internal::_locale = _arg1; mx_internal::_bundleName = _arg2; _content = getContent(); } protected function getContent():Object{ return ({}); } public function getString(_arg1:String):String{ return (String(_getObject(_arg1))); } public function get content():Object{ return (_content); } public function getBoolean(_arg1:String, _arg2:Boolean=true):Boolean{ var _local3:String = _getObject(_arg1).toLowerCase(); if (_local3 == "false"){ return (false); }; if (_local3 == "true"){ return (true); }; return (_arg2); } public function getStringArray(_arg1:String):Array{ var _local2:Array = _getObject(_arg1).split(","); var _local3:int = _local2.length; var _local4:int; while (_local4 < _local3) { _local2[_local4] = StringUtil.trim(_local2[_local4]); _local4++; }; return (_local2); } public function getObject(_arg1:String):Object{ return (_getObject(_arg1)); } private function _getObject(_arg1:String):Object{ var _local2:Object = content[_arg1]; if (!_local2){ throw (new Error(((("Key " + _arg1) + " was not found in resource bundle ") + bundleName))); }; return (_local2); } public function get locale():String{ return (mx_internal::_locale); } public function get bundleName():String{ return (mx_internal::_bundleName); } public function getNumber(_arg1:String):Number{ return (Number(_getObject(_arg1))); } private static function getClassByName(_arg1:String, _arg2:ApplicationDomain):Class{ var _local3:Class; if (_arg2.hasDefinition(_arg1)){ _local3 = (_arg2.getDefinition(_arg1) as Class); }; return (_local3); } public static function getResourceBundle(_arg1:String, _arg2:ApplicationDomain=null):ResourceBundle{ var _local3:String; var _local4:Class; var _local5:Object; var _local6:ResourceBundle; if (!_arg2){ _arg2 = ApplicationDomain.currentDomain; }; _local3 = (((mx_internal::locale + "$") + _arg1) + "_properties"); _local4 = getClassByName(_local3, _arg2); if (!_local4){ _local3 = (_arg1 + "_properties"); _local4 = getClassByName(_local3, _arg2); }; if (!_local4){ _local3 = _arg1; _local4 = getClassByName(_local3, _arg2); }; if (((!(_local4)) && (mx_internal::backupApplicationDomain))){ _local3 = (_arg1 + "_properties"); _local4 = getClassByName(_local3, mx_internal::backupApplicationDomain); if (!_local4){ _local3 = _arg1; _local4 = getClassByName(_local3, mx_internal::backupApplicationDomain); }; }; if (_local4){ _local5 = new (_local4); if ((_local5 is ResourceBundle)){ _local6 = ResourceBundle(_local5); return (_local6); }; }; throw (new Error(("Could not find resource bundle " + _arg1))); } } }//package mx.resources
Section 129
//ResourceManager (mx.resources.ResourceManager) package mx.resources { import mx.core.*; public class ResourceManager { mx_internal static const VERSION:String = "3.4.0.9271"; private static var implClassDependency:ResourceManagerImpl; private static var instance:IResourceManager; public static function getInstance():IResourceManager{ if (!instance){ try { instance = IResourceManager(Singleton.getInstance("mx.resources::IResourceManager")); } catch(e:Error) { instance = new ResourceManagerImpl(); }; }; return (instance); } } }//package mx.resources
Section 130
//ResourceManagerImpl (mx.resources.ResourceManagerImpl) package mx.resources { import flash.events.*; import flash.utils.*; import mx.events.*; import flash.system.*; import mx.modules.*; import mx.utils.*; import mx.core.*; public class ResourceManagerImpl extends EventDispatcher implements IResourceManager { private var resourceModules:Object; private var initializedForNonFrameworkApp:Boolean;// = false private var localeMap:Object; private var _localeChain:Array; mx_internal static const VERSION:String = "3.4.0.9271"; private static var instance:IResourceManager; public function ResourceManagerImpl(){ localeMap = {}; resourceModules = {}; super(); } public function get localeChain():Array{ return (_localeChain); } public function set localeChain(_arg1:Array):void{ _localeChain = _arg1; update(); } public function getStringArray(_arg1:String, _arg2:String, _arg3:String=null):Array{ var _local4:IResourceBundle = findBundle(_arg1, _arg2, _arg3); if (!_local4){ return (null); }; var _local5:* = _local4.content[_arg2]; var _local6:Array = String(_local5).split(","); var _local7:int = _local6.length; var _local8:int; while (_local8 < _local7) { _local6[_local8] = StringUtil.trim(_local6[_local8]); _local8++; }; return (_local6); } mx_internal function installCompiledResourceBundle(_arg1:ApplicationDomain, _arg2:String, _arg3:String):void{ var _local4:String; var _local5:String = _arg3; var _local6:int = _arg3.indexOf(":"); if (_local6 != -1){ _local4 = _arg3.substring(0, _local6); _local5 = _arg3.substring((_local6 + 1)); }; if (getResourceBundle(_arg2, _arg3)){ return; }; var _local7 = (((_arg2 + "$") + _local5) + "_properties"); if (_local4 != null){ _local7 = ((_local4 + ".") + _local7); }; var _local8:Class; if (_arg1.hasDefinition(_local7)){ _local8 = Class(_arg1.getDefinition(_local7)); }; if (!_local8){ _local7 = _arg3; if (_arg1.hasDefinition(_local7)){ _local8 = Class(_arg1.getDefinition(_local7)); }; }; if (!_local8){ _local7 = (_arg3 + "_properties"); if (_arg1.hasDefinition(_local7)){ _local8 = Class(_arg1.getDefinition(_local7)); }; }; if (!_local8){ throw (new Error((((("Could not find compiled resource bundle '" + _arg3) + "' for locale '") + _arg2) + "'."))); }; var _local9:ResourceBundle = ResourceBundle(new (_local8)); _local9.mx_internal::_locale = _arg2; _local9.mx_internal::_bundleName = _arg3; addResourceBundle(_local9); } public function getString(_arg1:String, _arg2:String, _arg3:Array=null, _arg4:String=null):String{ var _local5:IResourceBundle = findBundle(_arg1, _arg2, _arg4); if (!_local5){ return (null); }; var _local6:String = String(_local5.content[_arg2]); if (_arg3){ _local6 = StringUtil.substitute(_local6, _arg3); }; return (_local6); } public function loadResourceModule(_arg1:String, _arg2:Boolean=true, _arg3:ApplicationDomain=null, _arg4:SecurityDomain=null):IEventDispatcher{ var moduleInfo:IModuleInfo; var resourceEventDispatcher:ResourceEventDispatcher; var timer:Timer; var timerHandler:Function; var url = _arg1; var updateFlag = _arg2; var applicationDomain = _arg3; var securityDomain = _arg4; moduleInfo = ModuleManager.getModule(url); resourceEventDispatcher = new ResourceEventDispatcher(moduleInfo); var readyHandler:Function = function (_arg1:ModuleEvent):void{ var _local2:* = _arg1.module.factory.create(); resourceModules[_arg1.module.url].resourceModule = _local2; if (updateFlag){ update(); }; }; moduleInfo.addEventListener(ModuleEvent.READY, readyHandler, false, 0, true); var errorHandler:Function = function (_arg1:ModuleEvent):void{ var _local3:ResourceEvent; var _local2:String = ("Unable to load resource module from " + url); if (resourceEventDispatcher.willTrigger(ResourceEvent.ERROR)){ _local3 = new ResourceEvent(ResourceEvent.ERROR, _arg1.bubbles, _arg1.cancelable); _local3.bytesLoaded = 0; _local3.bytesTotal = 0; _local3.errorText = _local2; resourceEventDispatcher.dispatchEvent(_local3); } else { throw (new Error(_local2)); }; }; moduleInfo.addEventListener(ModuleEvent.ERROR, errorHandler, false, 0, true); resourceModules[url] = new ResourceModuleInfo(moduleInfo, readyHandler, errorHandler); timer = new Timer(0); timerHandler = function (_arg1:TimerEvent):void{ timer.removeEventListener(TimerEvent.TIMER, timerHandler); timer.stop(); moduleInfo.load(applicationDomain, securityDomain); }; timer.addEventListener(TimerEvent.TIMER, timerHandler, false, 0, true); timer.start(); return (resourceEventDispatcher); } public function getLocales():Array{ var _local2:String; var _local1:Array = []; for (_local2 in localeMap) { _local1.push(_local2); }; return (_local1); } public function removeResourceBundlesForLocale(_arg1:String):void{ delete localeMap[_arg1]; } public function getResourceBundle(_arg1:String, _arg2:String):IResourceBundle{ var _local3:Object = localeMap[_arg1]; if (!_local3){ return (null); }; return (_local3[_arg2]); } private function dumpResourceModule(_arg1):void{ var _local2:ResourceBundle; var _local3:String; for each (_local2 in _arg1.resourceBundles) { trace(_local2.locale, _local2.bundleName); for (_local3 in _local2.content) { }; }; } public function addResourceBundle(_arg1:IResourceBundle):void{ var _local2:String = _arg1.locale; var _local3:String = _arg1.bundleName; if (!localeMap[_local2]){ localeMap[_local2] = {}; }; localeMap[_local2][_local3] = _arg1; } public function getObject(_arg1:String, _arg2:String, _arg3:String=null){ var _local4:IResourceBundle = findBundle(_arg1, _arg2, _arg3); if (!_local4){ return (undefined); }; return (_local4.content[_arg2]); } public function getInt(_arg1:String, _arg2:String, _arg3:String=null):int{ var _local4:IResourceBundle = findBundle(_arg1, _arg2, _arg3); if (!_local4){ return (0); }; var _local5:* = _local4.content[_arg2]; return (int(_local5)); } private function findBundle(_arg1:String, _arg2:String, _arg3:String):IResourceBundle{ supportNonFrameworkApps(); return (((_arg3)!=null) ? getResourceBundle(_arg3, _arg1) : findResourceBundleWithResource(_arg1, _arg2)); } private function supportNonFrameworkApps():void{ if (initializedForNonFrameworkApp){ return; }; initializedForNonFrameworkApp = true; if (getLocales().length > 0){ return; }; var _local1:ApplicationDomain = ApplicationDomain.currentDomain; if (!_local1.hasDefinition("_CompiledResourceBundleInfo")){ return; }; var _local2:Class = Class(_local1.getDefinition("_CompiledResourceBundleInfo")); var _local3:Array = _local2.compiledLocales; var _local4:Array = _local2.compiledResourceBundleNames; installCompiledResourceBundles(_local1, _local3, _local4); localeChain = _local3; } public function getBundleNamesForLocale(_arg1:String):Array{ var _local3:String; var _local2:Array = []; for (_local3 in localeMap[_arg1]) { _local2.push(_local3); }; return (_local2); } public function getPreferredLocaleChain():Array{ return (LocaleSorter.sortLocalesByPreference(getLocales(), getSystemPreferredLocales(), null, true)); } public function getNumber(_arg1:String, _arg2:String, _arg3:String=null):Number{ var _local4:IResourceBundle = findBundle(_arg1, _arg2, _arg3); if (!_local4){ return (NaN); }; var _local5:* = _local4.content[_arg2]; return (Number(_local5)); } public function update():void{ dispatchEvent(new Event(Event.CHANGE)); } public function getClass(_arg1:String, _arg2:String, _arg3:String=null):Class{ var _local4:IResourceBundle = findBundle(_arg1, _arg2, _arg3); if (!_local4){ return (null); }; var _local5:* = _local4.content[_arg2]; return ((_local5 as Class)); } public function removeResourceBundle(_arg1:String, _arg2:String):void{ delete localeMap[_arg1][_arg2]; if (getBundleNamesForLocale(_arg1).length == 0){ delete localeMap[_arg1]; }; } public function initializeLocaleChain(_arg1:Array):void{ localeChain = LocaleSorter.sortLocalesByPreference(_arg1, getSystemPreferredLocales(), null, true); } public function findResourceBundleWithResource(_arg1:String, _arg2:String):IResourceBundle{ var _local5:String; var _local6:Object; var _local7:ResourceBundle; if (!_localeChain){ return (null); }; var _local3:int = _localeChain.length; var _local4:int; while (_local4 < _local3) { _local5 = localeChain[_local4]; _local6 = localeMap[_local5]; if (!_local6){ } else { _local7 = _local6[_arg1]; if (!_local7){ } else { if ((_arg2 in _local7.content)){ return (_local7); }; }; }; _local4++; }; return (null); } public function getUint(_arg1:String, _arg2:String, _arg3:String=null):uint{ var _local4:IResourceBundle = findBundle(_arg1, _arg2, _arg3); if (!_local4){ return (0); }; var _local5:* = _local4.content[_arg2]; return (uint(_local5)); } private function getSystemPreferredLocales():Array{ var _local1:Array; if (Capabilities["languages"]){ _local1 = Capabilities["languages"]; } else { _local1 = [Capabilities.language]; }; return (_local1); } public function installCompiledResourceBundles(_arg1:ApplicationDomain, _arg2:Array, _arg3:Array):void{ var _local7:String; var _local8:int; var _local9:String; var _local4:int = (_arg2) ? _arg2.length : 0; var _local5:int = (_arg3) ? _arg3.length : 0; var _local6:int; while (_local6 < _local4) { _local7 = _arg2[_local6]; _local8 = 0; while (_local8 < _local5) { _local9 = _arg3[_local8]; mx_internal::installCompiledResourceBundle(_arg1, _local7, _local9); _local8++; }; _local6++; }; } public function getBoolean(_arg1:String, _arg2:String, _arg3:String=null):Boolean{ var _local4:IResourceBundle = findBundle(_arg1, _arg2, _arg3); if (!_local4){ return (false); }; var _local5:* = _local4.content[_arg2]; return ((String(_local5).toLowerCase() == "true")); } public function unloadResourceModule(_arg1:String, _arg2:Boolean=true):void{ var _local4:Array; var _local5:int; var _local6:int; var _local7:String; var _local8:String; var _local3:ResourceModuleInfo = resourceModules[_arg1]; if (!_local3){ return; }; if (_local3.resourceModule){ _local4 = _local3.resourceModule.resourceBundles; if (_local4){ _local5 = _local4.length; _local6 = 0; while (_local6 < _local5) { _local7 = _local4[_local6].locale; _local8 = _local4[_local6].bundleName; removeResourceBundle(_local7, _local8); _local6++; }; }; }; resourceModules[_arg1] = null; delete resourceModules[_arg1]; _local3.moduleInfo.unload(); if (_arg2){ this.update(); }; } public static function getInstance():IResourceManager{ if (!instance){ instance = new (ResourceManagerImpl); }; return (instance); } } }//package mx.resources import flash.events.*; import mx.events.*; import mx.modules.*; class ResourceModuleInfo { public var resourceModule:IResourceModule; public var errorHandler:Function; public var readyHandler:Function; public var moduleInfo:IModuleInfo; private function ResourceModuleInfo(_arg1:IModuleInfo, _arg2:Function, _arg3:Function){ this.moduleInfo = _arg1; this.readyHandler = _arg2; this.errorHandler = _arg3; } } class ResourceEventDispatcher extends EventDispatcher { private function ResourceEventDispatcher(_arg1:IModuleInfo){ _arg1.addEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler, false, 0, true); _arg1.addEventListener(ModuleEvent.PROGRESS, moduleInfo_progressHandler, false, 0, true); _arg1.addEventListener(ModuleEvent.READY, moduleInfo_readyHandler, false, 0, true); } private function moduleInfo_progressHandler(_arg1:ModuleEvent):void{ var _local2:ResourceEvent = new ResourceEvent(ResourceEvent.PROGRESS, _arg1.bubbles, _arg1.cancelable); _local2.bytesLoaded = _arg1.bytesLoaded; _local2.bytesTotal = _arg1.bytesTotal; dispatchEvent(_local2); } private function moduleInfo_readyHandler(_arg1:ModuleEvent):void{ var _local2:ResourceEvent = new ResourceEvent(ResourceEvent.COMPLETE); dispatchEvent(_local2); } private function moduleInfo_errorHandler(_arg1:ModuleEvent):void{ var _local2:ResourceEvent = new ResourceEvent(ResourceEvent.ERROR, _arg1.bubbles, _arg1.cancelable); _local2.bytesLoaded = _arg1.bytesLoaded; _local2.bytesTotal = _arg1.bytesTotal; _local2.errorText = _arg1.errorText; dispatchEvent(_local2); } }
Section 131
//IResponder (mx.rpc.IResponder) package mx.rpc { public interface IResponder { function fault(_arg1:Object):void; function result(_arg1:Object):void; } }//package mx.rpc
Section 132
//ArrayUtil (mx.utils.ArrayUtil) package mx.utils { import mx.core.*; public class ArrayUtil { mx_internal static const VERSION:String = "3.4.0.9271"; public static function getItemIndex(_arg1:Object, _arg2:Array):int{ var _local3:int = _arg2.length; var _local4:int; while (_local4 < _local3) { if (_arg2[_local4] === _arg1){ return (_local4); }; _local4++; }; return (-1); } public static function toArray(_arg1:Object):Array{ if (!_arg1){ return ([]); }; if ((_arg1 is Array)){ return ((_arg1 as Array)); }; return ([_arg1]); } } }//package mx.utils
Section 133
//Base64Encoder (mx.utils.Base64Encoder) package mx.utils { import flash.utils.*; public class Base64Encoder { private var _line:uint; private var _count:uint; private var _buffers:Array; public var insertNewLines:Boolean;// = true private var _work:Array; public static const MAX_BUFFER_SIZE:uint = 32767; private static const ALPHABET_CHAR_CODES:Array = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47]; public static const CHARSET_UTF_8:String = "UTF-8"; private static const ESCAPE_CHAR_CODE:Number = 61; public static var newLine:int = 10; public function Base64Encoder(){ _work = [0, 0, 0]; super(); reset(); } public function flush():String{ if (_count > 0){ encodeBlock(); }; var _local1:String = drain(); reset(); return (_local1); } public function toString():String{ return (flush()); } public function reset():void{ _buffers = []; _buffers.push([]); _count = 0; _line = 0; _work[0] = 0; _work[1] = 0; _work[2] = 0; } public function encodeBytes(_arg1:ByteArray, _arg2:uint=0, _arg3:uint=0):void{ if (_arg3 == 0){ _arg3 = _arg1.length; }; var _local4:uint = _arg1.position; _arg1.position = _arg2; var _local5:uint = _arg2; var _local6:uint = (_arg2 + _arg3); if (_local6 > _arg1.length){ _local6 = _arg1.length; }; while (_local5 < _local6) { _work[_count] = _arg1[_local5]; _count++; if ((((_count == _work.length)) || (((_local6 - _local5) == 1)))){ encodeBlock(); _count = 0; _work[0] = 0; _work[1] = 0; _work[2] = 0; }; _local5++; }; _arg1.position = _local4; } public function encode(_arg1:String, _arg2:uint=0, _arg3:uint=0):void{ if (_arg3 == 0){ _arg3 = _arg1.length; }; var _local4:uint = _arg2; var _local5:uint = (_arg2 + _arg3); if (_local5 > _arg1.length){ _local5 = _arg1.length; }; while (_local4 < _local5) { _work[_count] = _arg1.charCodeAt(_local4); _count++; if ((((_count == _work.length)) || (((_local5 - _local4) == 1)))){ encodeBlock(); _count = 0; _work[0] = 0; _work[1] = 0; _work[2] = 0; }; _local4++; }; } private function encodeBlock():void{ var _local1:Array = (_buffers[(_buffers.length - 1)] as Array); if (_local1.length >= MAX_BUFFER_SIZE){ _local1 = []; _buffers.push(_local1); }; _local1.push(ALPHABET_CHAR_CODES[((_work[0] & 0xFF) >> 2)]); _local1.push(ALPHABET_CHAR_CODES[(((_work[0] & 3) << 4) | ((_work[1] & 240) >> 4))]); if (_count > 1){ _local1.push(ALPHABET_CHAR_CODES[(((_work[1] & 15) << 2) | ((_work[2] & 192) >> 6))]); } else { _local1.push(ESCAPE_CHAR_CODE); }; if (_count > 2){ _local1.push(ALPHABET_CHAR_CODES[(_work[2] & 63)]); } else { _local1.push(ESCAPE_CHAR_CODE); }; if (insertNewLines){ if ((_line = (_line + 4)) == 76){ _local1.push(newLine); _line = 0; }; }; } public function encodeUTFBytes(_arg1:String):void{ var _local2:ByteArray = new ByteArray(); _local2.writeUTFBytes(_arg1); _local2.position = 0; encodeBytes(_local2); } public function drain():String{ var _local3:Array; var _local1 = ""; var _local2:uint; while (_local2 < _buffers.length) { _local3 = (_buffers[_local2] as Array); _local1 = (_local1 + String.fromCharCode.apply(null, _local3)); _local2++; }; _buffers = []; _buffers.push([]); return (_local1); } } }//package mx.utils
Section 134
//DescribeTypeCache (mx.utils.DescribeTypeCache) package mx.utils { import flash.utils.*; import mx.core.*; import mx.binding.*; public class DescribeTypeCache { mx_internal static const VERSION:String = "3.4.0.9271"; private static var cacheHandlers:Object = {}; private static var typeCache:Object = {}; public static function describeType(_arg1):DescribeTypeCacheRecord{ var _local2:String; var _local3:XML; var _local4:DescribeTypeCacheRecord; if ((_arg1 is String)){ _local2 = _arg1; } else { _local2 = getQualifiedClassName(_arg1); }; if ((_local2 in typeCache)){ return (typeCache[_local2]); }; if ((_arg1 is String)){ _arg1 = getDefinitionByName(_arg1); }; _local3 = describeType(_arg1); _local4 = new DescribeTypeCacheRecord(); _local4.typeDescription = _local3; _local4.typeName = _local2; typeCache[_local2] = _local4; return (_local4); } public static function registerCacheHandler(_arg1:String, _arg2:Function):void{ cacheHandlers[_arg1] = _arg2; } static function extractValue(_arg1:String, _arg2:DescribeTypeCacheRecord){ if ((_arg1 in cacheHandlers)){ return (cacheHandlers[_arg1](_arg2)); }; return (undefined); } private static function bindabilityInfoHandler(_arg1:DescribeTypeCacheRecord){ return (new BindabilityInfo(_arg1.typeDescription)); } registerCacheHandler("bindabilityInfo", bindabilityInfoHandler); } }//package mx.utils
Section 135
//DescribeTypeCacheRecord (mx.utils.DescribeTypeCacheRecord) package mx.utils { import flash.utils.*; public dynamic class DescribeTypeCacheRecord extends Proxy { public var typeDescription:XML; public var typeName:String; private var cache:Object; public function DescribeTypeCacheRecord(){ cache = {}; super(); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){ var _local2:* = cache[_arg1]; if (_local2 === undefined){ _local2 = DescribeTypeCache.extractValue(_arg1, this); cache[_arg1] = _local2; }; return (_local2); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(_arg1):Boolean{ if ((_arg1 in cache)){ return (true); }; var _local2:* = DescribeTypeCache.extractValue(_arg1, this); if (_local2 === undefined){ return (false); }; cache[_arg1] = _local2; return (true); } } }//package mx.utils
Section 136
//IXMLNotifiable (mx.utils.IXMLNotifiable) package mx.utils { public interface IXMLNotifiable { function xmlNotification(_arg1:Object, _arg2:String, _arg3:Object, _arg4:Object, _arg5:Object):void; } }//package mx.utils
Section 137
//object_proxy (mx.utils.object_proxy) package mx.utils { public namespace object_proxy = "http://www.adobe.com/2006/actionscript/flash/objectproxy"; }//package mx.utils
Section 138
//ObjectProxy (mx.utils.ObjectProxy) package mx.utils { import flash.events.*; import flash.utils.*; import mx.events.*; import mx.core.*; public dynamic class ObjectProxy extends Proxy implements IExternalizable, IPropertyChangeNotifier { private var _id:String; protected var notifiers:Object; protected var propertyList:Array; private var _proxyLevel:int; private var _type:QName; protected var dispatcher:EventDispatcher; protected var proxyClass:Class; private var _item:Object; public function ObjectProxy(_arg1:Object=null, _arg2:String=null, _arg3:int=-1){ proxyClass = ObjectProxy; super(); if (!_arg1){ _arg1 = {}; }; _item = _arg1; _proxyLevel = _arg3; notifiers = {}; dispatcher = new EventDispatcher(this); if (_arg2){ _id = _arg2; }; } public function dispatchEvent(_arg1:Event):Boolean{ return (dispatcher.dispatchEvent(_arg1)); } public function hasEventListener(_arg1:String):Boolean{ return (dispatcher.hasEventListener(_arg1)); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{ var _local4:IPropertyChangeNotifier; var _local5:PropertyChangeEvent; var _local3:* = _item[_arg1]; if (_local3 !== _arg2){ _item[_arg1] = _arg2; _local4 = IPropertyChangeNotifier(notifiers[_arg1]); if (_local4){ _local4.removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangeHandler); delete notifiers[_arg1]; }; if (dispatcher.hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE)){ if ((_arg1 is QName)){ _arg1 = QName(_arg1).localName; }; _local5 = PropertyChangeEvent.createUpdateEvent(this, _arg1.toString(), _local3, _arg2); dispatcher.dispatchEvent(_local5); }; }; } public function willTrigger(_arg1:String):Boolean{ return (dispatcher.willTrigger(_arg1)); } public function readExternal(_arg1:IDataInput):void{ var _local2:Object = _arg1.readObject(); _item = _local2; } public function writeExternal(_arg1:IDataOutput):void{ _arg1.writeObject(_item); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){ var _local2:*; if (notifiers[_arg1.toString()]){ return (notifiers[_arg1]); }; _local2 = _item[_arg1]; if (_local2){ if ((((_proxyLevel == 0)) || (ObjectUtil.isSimple(_local2)))){ return (_local2); }; _local2 = getComplexProperty(_arg1, _local2); }; return (_local2); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(_arg1):Boolean{ return ((_arg1 in _item)); } public function get uid():String{ if (_id === null){ _id = UIDUtil.createUID(); }; return (_id); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(_arg1:int):int{ if (_arg1 == 0){ setupPropertyList(); }; if (_arg1 < propertyList.length){ return ((_arg1 + 1)); }; return (0); } public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{ dispatcher.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(_arg1:int):String{ return (propertyList[(_arg1 - 1)]); } public function set uid(_arg1:String):void{ _id = _arg1; } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function callProperty(_arg1, ... _args){ return (_item[_arg1].apply(_item, _args)); } public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{ dispatcher.removeEventListener(_arg1, _arg2, _arg3); } protected function setupPropertyList():void{ var _local1:String; if (getQualifiedClassName(_item) == "Object"){ propertyList = []; for (_local1 in _item) { propertyList.push(_local1); }; } else { propertyList = ObjectUtil.getClassInfo(_item, null, {includeReadOnly:true, uris:["*"]}).properties; }; } object_proxy function getComplexProperty(_arg1, _arg2){ if ((_arg2 is IPropertyChangeNotifier)){ _arg2.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangeHandler); notifiers[_arg1] = _arg2; return (_arg2); }; if (getQualifiedClassName(_arg2) == "Object"){ _arg2 = new proxyClass(_item[_arg1], null, ((_proxyLevel > 0)) ? (_proxyLevel - 1) : _proxyLevel); _arg2.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangeHandler); notifiers[_arg1] = _arg2; return (_arg2); }; return (_arg2); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(_arg1):Boolean{ var _local5:PropertyChangeEvent; var _local2:IPropertyChangeNotifier = IPropertyChangeNotifier(notifiers[_arg1]); if (_local2){ _local2.removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangeHandler); delete notifiers[_arg1]; }; var _local3:* = _item[_arg1]; var _local4 = delete _item[_arg1]; if (dispatcher.hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE)){ _local5 = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE); _local5.kind = PropertyChangeEventKind.DELETE; _local5.property = _arg1; _local5.oldValue = _local3; _local5.source = this; dispatcher.dispatchEvent(_local5); }; return (_local4); } object_proxy function get type():QName{ return (_type); } object_proxy function set type(_arg1:QName):void{ _type = _arg1; } public function propertyChangeHandler(_arg1:PropertyChangeEvent):void{ dispatcher.dispatchEvent(_arg1); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextValue(_arg1:int){ return (_item[propertyList[(_arg1 - 1)]]); } object_proxy function get object():Object{ return (_item); } } }//package mx.utils
Section 139
//ObjectUtil (mx.utils.ObjectUtil) package mx.utils { import flash.xml.*; import flash.utils.*; import mx.collections.*; import mx.core.*; public class ObjectUtil { mx_internal static const VERSION:String = "3.4.0.9271"; private static var defaultToStringExcludes:Array = ["password", "credentials"]; private static var CLASS_INFO_CACHE:Object = {}; private static var refCount:int = 0; public static function isSimple(_arg1:Object):Boolean{ var _local2 = typeof(_arg1); switch (_local2){ case "number": case "string": case "boolean": return (true); case "object": return ((((_arg1 is Date)) || ((_arg1 is Array)))); }; return (false); } private static function internalToString(_arg1:Object, _arg2:int=0, _arg3:Dictionary=null, _arg4:Array=null, _arg5:Array=null):String{ var str:String; var classInfo:Object; var properties:Array; var isArray:Boolean; var isDict:Boolean; var prop:*; var j:int; var id:Object; var value = _arg1; var indent = _arg2; var refs = _arg3; var namespaceURIs = _arg4; var exclude = _arg5; var type:String = ((value == null)) ? "null" : typeof(value); switch (type){ case "boolean": case "number": return (value.toString()); case "string": return ((("\"" + value.toString()) + "\"")); case "object": if ((value is Date)){ return (value.toString()); }; if ((value is XMLNode)){ return (value.toString()); }; if ((value is Class)){ return ((("(" + getQualifiedClassName(value)) + ")")); }; classInfo = getClassInfo(value, exclude, {includeReadOnly:true, uris:namespaceURIs}); properties = classInfo.properties; str = (("(" + classInfo.name) + ")"); if (refs == null){ refs = new Dictionary(true); }; try { id = refs[value]; if (id != null){ str = (str + ("#" + int(id))); return (str); }; } catch(e:Error) { return (String(value)); }; if (value != null){ str = (str + ("#" + refCount.toString())); refs[value] = refCount; refCount++; }; isArray = (value is Array); isDict = (value is Dictionary); indent = (indent + 2); j = 0; while (j < properties.length) { str = newline(str, indent); prop = properties[j]; if (isArray){ str = (str + "["); } else { if (isDict){ str = (str + "{"); }; }; if (isDict){ str = (str + internalToString(prop, indent, refs, namespaceURIs, exclude)); } else { str = (str + prop.toString()); }; if (isArray){ str = (str + "] "); } else { if (isDict){ str = (str + "} = "); } else { str = (str + " = "); }; }; try { str = (str + internalToString(value[prop], indent, refs, namespaceURIs, exclude)); } catch(e:Error) { str = (str + "?"); }; j = (j + 1); }; indent = (indent - 2); return (str); case "xml": return (value.toString()); default: return ((("(" + type) + ")")); }; } public static function getClassInfo(_arg1:Object, _arg2:Array=null, _arg3:Object=null):Object{ var n:int; var i:int; var result:Object; var cacheKey:String; var className:String; var classAlias:String; var properties:XMLList; var prop:XML; var metadataInfo:Object; var classInfo:XML; var numericIndex:Boolean; var key:*; var p:String; var pi:Number; var uris:Array; var uri:String; var qName:QName; var j:int; var obj = _arg1; var excludes = _arg2; var options = _arg3; if ((obj is ObjectProxy)){ obj = ObjectProxy(obj).object_proxy::object; }; if (options == null){ options = {includeReadOnly:true, uris:null, includeTransient:true}; }; var propertyNames:Array = []; var dynamic:Boolean; if (typeof(obj) == "xml"){ className = "XML"; properties = obj.text(); if (properties.length()){ propertyNames.push("*"); }; properties = obj.attributes(); } else { classInfo = DescribeTypeCache.describeType(obj).typeDescription; className = classInfo.@name.toString(); classAlias = classInfo.@alias.toString(); dynamic = (classInfo.@isDynamic.toString() == "true"); if (options.includeReadOnly){ properties = (classInfo..accessor.(@access != "writeonly") + classInfo..variable); } else { properties = (classInfo..accessor.(@access == "readwrite") + classInfo..variable); }; numericIndex = false; }; if (!dynamic){ cacheKey = getCacheKey(obj, excludes, options); result = CLASS_INFO_CACHE[cacheKey]; if (result != null){ return (result); }; }; result = {}; result["name"] = className; result["alias"] = classAlias; result["properties"] = propertyNames; result["dynamic"] = dynamic; var _local5 = recordMetadata(properties); metadataInfo = _local5; result["metadata"] = _local5; var excludeObject:Object = {}; if (excludes){ n = excludes.length; i = 0; while (i < n) { excludeObject[excludes[i]] = 1; i = (i + 1); }; }; var isArray = (className == "Array"); var isDict = (className == "flash.utils::Dictionary"); if (isDict){ for (key in obj) { propertyNames.push(key); }; } else { if (dynamic){ for (p in obj) { if (excludeObject[p] != 1){ if (isArray){ pi = parseInt(p); if (isNaN(pi)){ propertyNames.push(new QName("", p)); } else { propertyNames.push(pi); }; } else { propertyNames.push(new QName("", p)); }; }; }; numericIndex = ((isArray) && (!(isNaN(Number(p))))); }; }; if (((((isArray) || (isDict))) || ((className == "Object")))){ } else { if (className == "XML"){ n = properties.length(); i = 0; while (i < n) { p = properties[i].name(); if (excludeObject[p] != 1){ propertyNames.push(new QName("", ("@" + p))); }; i = (i + 1); }; } else { n = properties.length(); uris = options.uris; i = 0; while (i < n) { prop = properties[i]; p = prop.@name.toString(); uri = prop.@uri.toString(); if (excludeObject[p] == 1){ } else { if (((!(options.includeTransient)) && (internalHasMetadata(metadataInfo, p, "Transient")))){ } else { if (uris != null){ if ((((uris.length == 1)) && ((uris[0] == "*")))){ qName = new QName(uri, p); try { obj[qName]; propertyNames.push(); } catch(e:Error) { }; } else { j = 0; while (j < uris.length) { uri = uris[j]; if (prop.@uri.toString() == uri){ qName = new QName(uri, p); try { obj[qName]; propertyNames.push(qName); } catch(e:Error) { }; }; j = (j + 1); }; }; } else { if (uri.length == 0){ qName = new QName(uri, p); try { obj[qName]; propertyNames.push(qName); } catch(e:Error) { }; }; }; }; }; i = (i + 1); }; }; }; propertyNames.sort((Array.CASEINSENSITIVE | (numericIndex) ? Array.NUMERIC : 0)); if (!isDict){ i = 0; while (i < (propertyNames.length - 1)) { if (propertyNames[i].toString() == propertyNames[(i + 1)].toString()){ propertyNames.splice(i, 1); i = (i - 1); }; i = (i + 1); }; }; if (!dynamic){ cacheKey = getCacheKey(obj, excludes, options); CLASS_INFO_CACHE[cacheKey] = result; }; return (result); } private static function arrayCompare(_arg1:Array, _arg2:Array, _arg3:int, _arg4:int, _arg5:Dictionary):int{ var _local7:Object; var _local6:int; if (_arg1.length != _arg2.length){ if (_arg1.length < _arg2.length){ _local6 = -1; } else { _local6 = 1; }; } else { for (_local7 in _arg1) { if (_arg2.hasOwnProperty(_local7)){ _local6 = internalCompare(_arg1[_local7], _arg2[_local7], _arg3, _arg4, _arg5); if (_local6 != 0){ return (_local6); }; } else { return (-1); }; }; for (_local7 in _arg2) { if (!_arg1.hasOwnProperty(_local7)){ return (1); }; }; }; return (_local6); } public static function stringCompare(_arg1:String, _arg2:String, _arg3:Boolean=false):int{ if ((((_arg1 == null)) && ((_arg2 == null)))){ return (0); }; if (_arg1 == null){ return (1); }; if (_arg2 == null){ return (-1); }; if (_arg3){ _arg1 = _arg1.toLocaleLowerCase(); _arg2 = _arg2.toLocaleLowerCase(); }; var _local4:int = _arg1.localeCompare(_arg2); if (_local4 < -1){ _local4 = -1; } else { if (_local4 > 1){ _local4 = 1; }; }; return (_local4); } public static function dateCompare(_arg1:Date, _arg2:Date):int{ if ((((_arg1 == null)) && ((_arg2 == null)))){ return (0); }; if (_arg1 == null){ return (1); }; if (_arg2 == null){ return (-1); }; var _local3:Number = _arg1.getTime(); var _local4:Number = _arg2.getTime(); if (_local3 < _local4){ return (-1); }; if (_local3 > _local4){ return (1); }; return (0); } public static function numericCompare(_arg1:Number, _arg2:Number):int{ if (((isNaN(_arg1)) && (isNaN(_arg2)))){ return (0); }; if (isNaN(_arg1)){ return (1); }; if (isNaN(_arg2)){ return (-1); }; if (_arg1 < _arg2){ return (-1); }; if (_arg1 > _arg2){ return (1); }; return (0); } private static function newline(_arg1:String, _arg2:int=0):String{ var _local3:String = _arg1; _local3 = (_local3 + "\n"); var _local4:int; while (_local4 < _arg2) { _local3 = (_local3 + " "); _local4++; }; return (_local3); } private static function recordMetadata(_arg1:XMLList):Object{ var prop:XML; var propName:String; var metadataList:XMLList; var metadata:Object; var md:XML; var mdName:String; var argsList:XMLList; var value:Object; var arg:XML; var existing:Object; var argKey:String; var argValue:String; var existingArray:Array; var properties = _arg1; var result:Object; try { for each (prop in properties) { propName = prop.attribute("name").toString(); metadataList = prop.metadata; if (metadataList.length() > 0){ if (result == null){ result = {}; }; metadata = {}; result[propName] = metadata; for each (md in metadataList) { mdName = md.attribute("name").toString(); argsList = md.arg; value = {}; for each (arg in argsList) { argKey = arg.attribute("key").toString(); if (argKey != null){ argValue = arg.attribute("value").toString(); value[argKey] = argValue; }; }; existing = metadata[mdName]; if (existing != null){ if ((existing is Array)){ existingArray = (existing as Array); } else { existingArray = [existing]; delete metadata[mdName]; }; existingArray.push(value); existing = existingArray; } else { existing = value; }; metadata[mdName] = existing; }; }; }; } catch(e:Error) { }; return (result); } public static function compare(_arg1:Object, _arg2:Object, _arg3:int=-1):int{ return (internalCompare(_arg1, _arg2, 0, _arg3, new Dictionary(true))); } private static function listCompare(_arg1:IList, _arg2:IList, _arg3:int, _arg4:int, _arg5:Dictionary):int{ var _local7:int; var _local6:int; if (_arg1.length != _arg2.length){ if (_arg1.length < _arg2.length){ _local6 = -1; } else { _local6 = 1; }; } else { _local7 = 0; while (_local7 < _arg1.length) { _local6 = internalCompare(_arg1.getItemAt(_local7), _arg2.getItemAt(_local7), (_arg3 + 1), _arg4, _arg5); if (_local6 != 0){ _local7 = _arg1.length; }; _local7++; }; }; return (_local6); } private static function internalCompare(_arg1:Object, _arg2:Object, _arg3:int, _arg4:int, _arg5:Dictionary):int{ var _local9:int; var _local10:Boolean; var _local11:Boolean; var _local12:Array; var _local13:Array; var _local14:QName; var _local15:Object; var _local16:Object; var _local17:int; if ((((_arg1 == null)) && ((_arg2 == null)))){ return (0); }; if (_arg1 == null){ return (1); }; if (_arg2 == null){ return (-1); }; if ((_arg1 is ObjectProxy)){ _arg1 = ObjectProxy(_arg1).object_proxy::object; }; if ((_arg2 is ObjectProxy)){ _arg2 = ObjectProxy(_arg2).object_proxy::object; }; var _local6 = typeof(_arg1); var _local7 = typeof(_arg2); var _local8:int; if (_local6 == _local7){ switch (_local6){ case "boolean": _local8 = numericCompare(Number(_arg1), Number(_arg2)); break; case "number": _local8 = numericCompare((_arg1 as Number), (_arg2 as Number)); break; case "string": _local8 = stringCompare((_arg1 as String), (_arg2 as String)); break; case "object": _local9 = ((_arg4 > 0)) ? (_arg4 - 1) : _arg4; _local10 = _arg5[_arg1]; _local11 = _arg5[_arg2]; if (((_local10) && (!(_local11)))){ return (1); }; if (((_local11) && (!(_local10)))){ return (-1); }; if (((_local11) && (_local10))){ return (0); }; _arg5[_arg1] = true; _arg5[_arg2] = true; if (((!((_arg4 == -1))) && ((_arg3 > _arg4)))){ _local8 = stringCompare(_arg1.toString(), _arg2.toString()); } else { if ((((_arg1 is Array)) && ((_arg2 is Array)))){ _local8 = arrayCompare((_arg1 as Array), (_arg2 as Array), _arg3, _arg4, _arg5); } else { if ((((_arg1 is Date)) && ((_arg2 is Date)))){ _local8 = dateCompare((_arg1 as Date), (_arg2 as Date)); } else { if ((((_arg1 is IList)) && ((_arg2 is IList)))){ _local8 = listCompare((_arg1 as IList), (_arg2 as IList), _arg3, _arg4, _arg5); } else { if ((((_arg1 is ByteArray)) && ((_arg2 is ByteArray)))){ _local8 = byteArrayCompare((_arg1 as ByteArray), (_arg2 as ByteArray)); } else { if (getQualifiedClassName(_arg1) == getQualifiedClassName(_arg2)){ _local12 = getClassInfo(_arg1).properties; if (getQualifiedClassName(_arg1) == "Object"){ _local13 = getClassInfo(_arg2).properties; _local8 = arrayCompare(_local12, _local13, _arg3, _local9, _arg5); }; if (_local8 != 0){ return (_local8); }; _local17 = 0; while (_local17 < _local12.length) { _local14 = _local12[_local17]; _local15 = _arg1[_local14]; _local16 = _arg2[_local14]; _local8 = internalCompare(_local15, _local16, (_arg3 + 1), _local9, _arg5); if (_local8 != 0){ _local17 = _local12.length; }; _local17++; }; } else { return (1); }; }; }; }; }; }; break; }; } else { return (stringCompare(_local6, _local7)); }; return (_local8); } public static function hasMetadata(_arg1:Object, _arg2:String, _arg3:String, _arg4:Array=null, _arg5:Object=null):Boolean{ var _local6:Object = getClassInfo(_arg1, _arg4, _arg5); var _local7:Object = _local6["metadata"]; return (internalHasMetadata(_local7, _arg2, _arg3)); } private static function internalHasMetadata(_arg1:Object, _arg2:String, _arg3:String):Boolean{ var _local4:Object; if (_arg1 != null){ _local4 = _arg1[_arg2]; if (_local4 != null){ if (_local4[_arg3] != null){ return (true); }; }; }; return (false); } public static function toString(_arg1:Object, _arg2:Array=null, _arg3:Array=null):String{ if (_arg3 == null){ _arg3 = defaultToStringExcludes; }; refCount = 0; return (internalToString(_arg1, 0, null, _arg2, _arg3)); } private static function byteArrayCompare(_arg1:ByteArray, _arg2:ByteArray):int{ var _local4:int; var _local3:int; if (_arg1 == _arg2){ return (_local3); }; if (_arg1.length != _arg2.length){ if (_arg1.length < _arg2.length){ _local3 = -1; } else { _local3 = 1; }; } else { _local4 = 0; while (_local4 < _arg1.length) { _local3 = numericCompare(_arg1[_local4], _arg2[_local4]); if (_local3 != 0){ _local4 = _arg1.length; }; _local4++; }; }; return (_local3); } public static function copy(_arg1:Object):Object{ var _local2:ByteArray = new ByteArray(); _local2.writeObject(_arg1); _local2.position = 0; var _local3:Object = _local2.readObject(); return (_local3); } private static function getCacheKey(_arg1:Object, _arg2:Array=null, _arg3:Object=null):String{ var _local5:uint; var _local6:String; var _local7:String; var _local8:String; var _local4:String = getQualifiedClassName(_arg1); if (_arg2 != null){ _local5 = 0; while (_local5 < _arg2.length) { _local6 = (_arg2[_local5] as String); if (_local6 != null){ _local4 = (_local4 + _local6); }; _local5++; }; }; if (_arg3 != null){ for (_local7 in _arg3) { _local4 = (_local4 + _local7); _local8 = (_arg3[_local7] as String); if (_local8 != null){ _local4 = (_local4 + _local8); }; }; }; return (_local4); } } }//package mx.utils
Section 140
//StringUtil (mx.utils.StringUtil) package mx.utils { import mx.core.*; public class StringUtil { mx_internal static const VERSION:String = "3.4.0.9271"; public static function trim(_arg1:String):String{ if (_arg1 == null){ return (""); }; var _local2:int; while (isWhitespace(_arg1.charAt(_local2))) { _local2++; }; var _local3:int = (_arg1.length - 1); while (isWhitespace(_arg1.charAt(_local3))) { _local3--; }; if (_local3 >= _local2){ return (_arg1.slice(_local2, (_local3 + 1))); }; return (""); } public static function isWhitespace(_arg1:String):Boolean{ switch (_arg1){ case " ": case "\t": case "\r": case "\n": case "\f": return (true); default: return (false); }; } public static function substitute(_arg1:String, ... _args):String{ var _local4:Array; if (_arg1 == null){ return (""); }; var _local3:uint = _args.length; if ((((_local3 == 1)) && ((_args[0] is Array)))){ _local4 = (_args[0] as Array); _local3 = _local4.length; } else { _local4 = _args; }; var _local5:int; while (_local5 < _local3) { _arg1 = _arg1.replace(new RegExp((("\\{" + _local5) + "\\}"), "g"), _local4[_local5]); _local5++; }; return (_arg1); } public static function trimArrayElements(_arg1:String, _arg2:String):String{ var _local3:Array; var _local4:int; var _local5:int; if (((!((_arg1 == ""))) && (!((_arg1 == null))))){ _local3 = _arg1.split(_arg2); _local4 = _local3.length; _local5 = 0; while (_local5 < _local4) { _local3[_local5] = StringUtil.trim(_local3[_local5]); _local5++; }; if (_local4 > 0){ _arg1 = _local3.join(_arg2); }; }; return (_arg1); } } }//package mx.utils
Section 141
//UIDUtil (mx.utils.UIDUtil) package mx.utils { import flash.utils.*; import mx.core.*; public class UIDUtil { mx_internal static const VERSION:String = "3.4.0.9271"; private static const ALPHA_CHAR_CODES:Array = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70]; private static var uidDictionary:Dictionary = new Dictionary(true); public static function fromByteArray(_arg1:ByteArray):String{ var _local2:Array; var _local3:uint; var _local4:uint; var _local5:int; if (((((!((_arg1 == null))) && ((_arg1.length >= 16)))) && ((_arg1.bytesAvailable >= 16)))){ _local2 = new Array(36); _local3 = 0; _local4 = 0; while (_local4 < 16) { if ((((((((_local4 == 4)) || ((_local4 == 6)))) || ((_local4 == 8)))) || ((_local4 == 10)))){ var _temp1 = _local3; _local3 = (_local3 + 1); var _local6 = _temp1; _local2[_local6] = 45; }; _local5 = _arg1.readByte(); var _temp2 = _local3; _local3 = (_local3 + 1); _local6 = _temp2; _local2[_local6] = ALPHA_CHAR_CODES[((_local5 & 240) >>> 4)]; var _temp3 = _local3; _local3 = (_local3 + 1); var _local7 = _temp3; _local2[_local7] = ALPHA_CHAR_CODES[(_local5 & 15)]; _local4++; }; return (String.fromCharCode.apply(null, _local2)); }; return (null); } public static function isUID(_arg1:String):Boolean{ var _local2:uint; var _local3:Number; if (((!((_arg1 == null))) && ((_arg1.length == 36)))){ _local2 = 0; while (_local2 < 36) { _local3 = _arg1.charCodeAt(_local2); if ((((((((_local2 == 8)) || ((_local2 == 13)))) || ((_local2 == 18)))) || ((_local2 == 23)))){ if (_local3 != 45){ return (false); }; } else { if ((((((_local3 < 48)) || ((_local3 > 70)))) || ((((_local3 > 57)) && ((_local3 < 65)))))){ return (false); }; }; _local2++; }; return (true); }; return (false); } public static function createUID():String{ var _local3:int; var _local4:int; var _local1:Array = new Array(36); var _local2:int; _local3 = 0; while (_local3 < 8) { var _temp1 = _local2; _local2 = (_local2 + 1); var _local7 = _temp1; _local1[_local7] = ALPHA_CHAR_CODES[Math.floor((Math.random() * 16))]; _local3++; }; _local3 = 0; while (_local3 < 3) { var _temp2 = _local2; _local2 = (_local2 + 1); _local7 = _temp2; _local1[_local7] = 45; _local4 = 0; while (_local4 < 4) { var _temp3 = _local2; _local2 = (_local2 + 1); var _local8 = _temp3; _local1[_local8] = ALPHA_CHAR_CODES[Math.floor((Math.random() * 16))]; _local4++; }; _local3++; }; var _temp4 = _local2; _local2 = (_local2 + 1); _local7 = _temp4; _local1[_local7] = 45; var _local5:Number = new Date().getTime(); var _local6:String = ("0000000" + _local5.toString(16).toUpperCase()).substr(-8); _local3 = 0; while (_local3 < 8) { var _temp5 = _local2; _local2 = (_local2 + 1); _local8 = _temp5; _local1[_local8] = _local6.charCodeAt(_local3); _local3++; }; _local3 = 0; while (_local3 < 4) { var _temp6 = _local2; _local2 = (_local2 + 1); _local8 = _temp6; _local1[_local8] = ALPHA_CHAR_CODES[Math.floor((Math.random() * 16))]; _local3++; }; return (String.fromCharCode.apply(null, _local1)); } public static function toByteArray(_arg1:String):ByteArray{ var _local2:ByteArray; var _local3:uint; var _local4:String; var _local5:uint; var _local6:uint; if (isUID(_arg1)){ _local2 = new ByteArray(); _local3 = 0; while (_local3 < _arg1.length) { _local4 = _arg1.charAt(_local3); if (_local4 == "-"){ } else { _local5 = getDigit(_local4); _local3++; _local6 = getDigit(_arg1.charAt(_local3)); _local2.writeByte((((_local5 << 4) | _local6) & 0xFF)); }; _local3++; }; _local2.position = 0; return (_local2); }; return (null); } private static function getDigit(_arg1:String):uint{ switch (_arg1){ case "A": case "a": return (10); case "B": case "b": return (11); case "C": case "c": return (12); case "D": case "d": return (13); case "E": case "e": return (14); case "F": case "f": return (15); default: return (new uint(_arg1)); }; } public static function getUID(_arg1:Object):String{ var result:String; var xitem:XML; var nodeKind:String; var notificationFunction:Function; var item = _arg1; result = null; if (item == null){ return (result); }; if ((item is IUID)){ result = IUID(item).uid; if ((((result == null)) || ((result.length == 0)))){ result = createUID(); IUID(item).uid = result; }; } else { if ((((item is IPropertyChangeNotifier)) && (!((item is IUIComponent))))){ result = IPropertyChangeNotifier(item).uid; if ((((result == null)) || ((result.length == 0)))){ result = createUID(); IPropertyChangeNotifier(item).uid = result; }; } else { if ((item is String)){ return ((item as String)); }; try { if ((((item is XMLList)) && ((item.length == 1)))){ item = item[0]; }; if ((item is XML)){ xitem = XML(item); nodeKind = xitem.nodeKind(); if ((((nodeKind == "text")) || ((nodeKind == "attribute")))){ return (xitem.toString()); }; notificationFunction = xitem.notification(); if (!(notificationFunction is Function)){ notificationFunction = XMLNotifier.initializeXMLForNotification(); xitem.setNotification(notificationFunction); }; if (notificationFunction["uid"] == undefined){ result = (notificationFunction["uid"] = createUID()); }; result = notificationFunction["uid"]; } else { if (("mx_internal_uid" in item)){ return (item.mx_internal_uid); }; if (("uid" in item)){ return (item.uid); }; result = uidDictionary[item]; if (!result){ result = createUID(); try { item.mx_internal_uid = result; } catch(e:Error) { uidDictionary[item] = result; }; }; }; } catch(e:Error) { result = item.toString(); }; }; }; return (result); } } }//package mx.utils
Section 142
//XMLNotifier (mx.utils.XMLNotifier) package mx.utils { import flash.utils.*; import mx.core.*; public class XMLNotifier { mx_internal static const VERSION:String = "3.4.0.9271"; private static var instance:XMLNotifier; public function XMLNotifier(_arg1:XMLNotifierSingleton){ } public function watchXML(_arg1:Object, _arg2:IXMLNotifiable, _arg3:String=null):void{ var _local6:Dictionary; var _local4:XML = XML(_arg1); var _local5:Object = _local4.notification(); if (!(_local5 is Function)){ _local5 = initializeXMLForNotification(); _local4.setNotification((_local5 as Function)); if (((_arg3) && ((_local5["uid"] == null)))){ _local5["uid"] = _arg3; }; }; if (_local5["watched"] == undefined){ _local6 = new Dictionary(true); _local5["watched"] = _local6; } else { _local6 = _local5["watched"]; }; _local6[_arg2] = true; } public function unwatchXML(_arg1:Object, _arg2:IXMLNotifiable):void{ var _local5:Dictionary; var _local3:XML = XML(_arg1); var _local4:Object = _local3.notification(); if (!(_local4 is Function)){ return; }; if (_local4["watched"] != undefined){ _local5 = _local4["watched"]; delete _local5[_arg2]; }; } public static function getInstance():XMLNotifier{ if (!instance){ instance = new XMLNotifier(new XMLNotifierSingleton()); }; return (instance); } mx_internal static function initializeXMLForNotification():Function{ var notificationFunction:Function = function (_arg1:Object, _arg2:String, _arg3:Object, _arg4:Object, _arg5:Object):void{ var _local8:Object; var _local7:Dictionary = arguments.callee.watched; if (_local7 != null){ for (_local8 in _local7) { IXMLNotifiable(_local8).xmlNotification(_arg1, _arg2, _arg3, _arg4, _arg5); }; }; }; return (notificationFunction); } } }//package mx.utils class XMLNotifierSingleton { private function XMLNotifierSingleton(){ } }
Section 143
//Anonymous (org.jivesoftware.xiff.auth.Anonymous) package org.jivesoftware.xiff.auth { import flash.xml.*; import org.jivesoftware.xiff.core.*; public class Anonymous extends SASLAuth { public function Anonymous(_arg1:XMPPConnection):void{ var _local2:Object = {mechanism:"ANONYMOUS", xmlns:"urn:ietf:params:xml:ns:xmpp-sasl"}; req = new XMLNode(1, "auth"); req.attributes = _local2; stage = 0; } override public function handleResponse(_arg1:int, _arg2:XMLNode):Object{ var _local3 = (_arg2.nodeName == "success"); var _temp1 = _arg1; _arg1 = (_arg1 + 1); return ({authComplete:true, authSuccess:_local3, authStage:_temp1}); } } }//package org.jivesoftware.xiff.auth
Section 144
//Plain (org.jivesoftware.xiff.auth.Plain) package org.jivesoftware.xiff.auth { import flash.xml.*; import org.jivesoftware.xiff.core.*; import mx.utils.*; public class Plain extends SASLAuth { public function Plain(_arg1:XMPPConnection):void{ var _local2:JID = _arg1.jid; var _local3:String = _local2.toBareJID(); _local3 = (_local3 + "\x00"); _local3 = (_local3 + _local2.node); _local3 = (_local3 + "\x00"); _local3 = (_local3 + _arg1.password); var _local4:Base64Encoder = new Base64Encoder(); _local4.insertNewLines = false; _local4.encode(_local3); _local3 = _local4.flush(); var _local5:Object = {mechanism:"PLAIN", xmlns:"urn:ietf:params:xml:ns:xmpp-sasl"}; req = new XMLNode(1, "auth"); req.appendChild(new XMLNode(3, _local3)); req.attributes = _local5; stage = 0; } override public function handleResponse(_arg1:int, _arg2:XMLNode):Object{ var _local3 = (_arg2.nodeName == "success"); var _temp1 = _arg1; _arg1 = (_arg1 + 1); return ({authComplete:true, authSuccess:_local3, authStage:_temp1}); } } }//package org.jivesoftware.xiff.auth
Section 145
//SASLAuth (org.jivesoftware.xiff.auth.SASLAuth) package org.jivesoftware.xiff.auth { import flash.xml.*; public class SASLAuth { protected var stage:int; protected var req:XMLNode; public function handleResponse(_arg1:int, _arg2:XMLNode):Object{ throw (new Error("Don't call this method on SASLAuth; use a subclass")); } public function get request():XMLNode{ return (req); } } }//package org.jivesoftware.xiff.auth
Section 146
//Room (org.jivesoftware.xiff.conference.Room) package org.jivesoftware.xiff.conference { import org.jivesoftware.xiff.data.*; import org.jivesoftware.xiff.core.*; import org.jivesoftware.xiff.events.*; import org.jivesoftware.xiff.data.muc.*; import org.jivesoftware.xiff.data.forms.*; import mx.collections.*; public class Room extends ArrayCollection { private var active:Boolean; private var myAffiliation:String; private var pendingNickname:String; private var myConnection:XMPPConnection; private var myIsReserved:Boolean; private var myNickname:String; private var myRole:String; private var mySubject:String; private var myPassword:String; private var _anonymous:Boolean;// = true private var myJID:JID; public static const ADMIN_AFFILIATION:String = MUC.ADMIN_AFFILIATION; public static const OWNER_AFFILIATION:String = MUC.OWNER_AFFILIATION; public static const PARTICIPANT_ROLE:String = MUC.PARTICIPANT_ROLE; public static const VISITOR_ROLE:String = MUC.VISITOR_ROLE; public static const MODERATOR_ROLE:String = MUC.MODERATOR_ROLE; public static const NO_AFFILIATION:String = MUC.NO_AFFILIATION; public static const NO_ROLE:String = MUC.NO_ROLE; public static const MEMBER_AFFILIATION:String = MUC.MEMBER_AFFILIATION; public static const OUTCAST_AFFILIATION:String = MUC.OUTCAST_AFFILIATION; private static var roomStaticConstructed:Boolean = RoomStaticConstructor(); private static var staticConstructorDependencies:Array = [FormExtension, MUC]; public function Room(_arg1:XMPPConnection=null){ active = false; if (_arg1 != null){ connection = _arg1; }; } public function destroy(_arg1:String, _arg2:JID=null, _arg3:Function=null):void{ var _local4:IQ = new IQ(roomJID, IQ.SET_TYPE); var _local5:MUCOwnerExtension = new MUCOwnerExtension(); _local4.callback = _arg3; _local5.destroy(_arg1, _arg2); _local4.addExtension(_local5); myConnection.send(_local4); } public function invite(_arg1:JID, _arg2:String):void{ var _local3:Message = new Message(roomJID); var _local4:MUCUserExtension = new MUCUserExtension(); _local4.invite(_arg1, undefined, _arg2); _local3.addExtension(_local4); myConnection.send(_local3); } public function revoke(_arg1:Array):void{ grant(Room.NO_AFFILIATION, _arg1); } public function get conferenceServer():String{ return (myJID.domain); } public function ban(_arg1:Array):void{ var _local4:JID; var _local2:IQ = new IQ(roomJID, IQ.SET_TYPE); var _local3:MUCAdminExtension = new MUCAdminExtension(); _local2.callbackScope = this; _local2.callback = finish_admin; for each (_local4 in _arg1) { _local3.addItem(Room.OUTCAST_AFFILIATION, null, null, _local4, null, null); }; _local2.addExtension(_local3); connection.send(_local2); } private function finish_requestAffiliates(_arg1:IQ):void{ var _local2:MUCOwnerExtension; var _local3:Array; var _local4:RoomEvent; finish_admin(_arg1); if (_arg1.type == IQ.RESULT_TYPE){ _local2 = _arg1.getAllExtensionsByNS(MUCOwnerExtension.NS)[0]; _local3 = _local2.getAllItems(); _local4 = new RoomEvent(RoomEvent.AFFILIATIONS); _local4.data = _local3; dispatchEvent(_local4); }; } public function set roomName(_arg1:String):void{ roomJID = new JID(((_arg1 + "@") + conferenceServer)); } public function get roomName():String{ return (myJID.node); } public function get password():String{ return (myPassword); } public function grant(_arg1:String, _arg2:Array):void{ var _local5:JID; var _local3:IQ = new IQ(roomJID, IQ.SET_TYPE); var _local4:MUCOwnerExtension = new MUCOwnerExtension(); _local3.callbackScope = this; _local3.callback = finish_admin; for each (_local5 in _arg2) { _local4.addItem(_arg1, null, null, _local5, null, null); }; _local3.addExtension(_local4); connection.send(_local3); } public function set nickname(_arg1:String):void{ var _local2:Presence; if (isActive){ pendingNickname = _arg1; _local2 = new Presence(new JID(((userJID + "/") + pendingNickname))); myConnection.send(_local2); } else { myNickname = _arg1; }; } public function cancelConfiguration():void{ var _local1:IQ = new IQ(roomJID, IQ.SET_TYPE); var _local2:MUCOwnerExtension = new MUCOwnerExtension(); var _local3:FormExtension = new FormExtension(); _local3.type = FormExtension.CANCEL_TYPE; _local2.addExtension(_local3); _local1.addExtension(_local2); myConnection.send(_local1); } public function requestConfiguration():void{ var _local1:IQ = new IQ(roomJID, IQ.GET_TYPE); var _local2:MUCOwnerExtension = new MUCOwnerExtension(); _local1.callbackScope = this; _local1.callbackName = "finish_requestConfiguration"; _local1.addExtension(_local2); myConnection.send(_local1); } public function get roomJID():JID{ return (myJID); } public function sendPrivateMessage(_arg1:String, _arg2:String=null, _arg3:String=null):void{ var _local4:Message; if (isActive){ _local4 = new Message(new JID(((roomJID + "/") + _arg1)), null, _arg2, _arg3, Message.CHAT_TYPE); myConnection.send(_local4); }; } public function kickOccupant(_arg1:String, _arg2:String):void{ var _local3:IQ; var _local4:MUCAdminExtension; if (isActive){ _local3 = new IQ(roomJID, IQ.SET_TYPE, XMPPStanza.generateID("kick_occupant_")); _local4 = new MUCAdminExtension(_local3.getNode()); _local4.addItem(null, MUC.NO_ROLE, _arg1, null, null, _arg2); _local3.addExtension(_local4); myConnection.send(_local3); }; } public function setOccupantVoice(_arg1:String, _arg2:Boolean):void{ var _local3:IQ; var _local4:MUCAdminExtension; if (isActive){ _local3 = new IQ(roomJID, IQ.SET_TYPE, XMPPStanza.generateID("voice_")); _local4 = new MUCAdminExtension(_local3.getNode()); _local4.addItem(null, (_arg2) ? MUC.PARTICIPANT_ROLE : MUC.VISITOR_ROLE); _local3.addExtension(_local4); myConnection.send(_local3); }; } public function get fullRoomName():String{ return (roomJID.toString()); } public function set password(_arg1:String):void{ myPassword = _arg1; } public function leave():void{ var _local1:Presence; if (isActive){ _local1 = new Presence(userJID, null, Presence.UNAVAILABLE_TYPE); myConnection.send(_local1); removeAll(); myConnection.removeEventListener(MessageEvent.MESSAGE, handleEvent); myConnection.removeEventListener(DisconnectionEvent.DISCONNECT, handleEvent); }; } public function join(_arg1:Boolean=false, _arg2:String=null, _arg3:String=null, _arg4:Number=0, _arg5:Array=null):Boolean{ var _local8:*; if (((!(myConnection.isActive())) || (isActive))){ return (false); }; myIsReserved = ((_arg1 == true)) ? true : false; var _local6:Presence = new Presence(userJID); if (_arg5 != null){ for each (_local8 in _arg5) { _local6.addExtension(_local8); }; }; var _local7:MUCExtension = new MUCExtension(); if (_arg3 != null){ _local7.history = true; if (_arg3 == "seconds"){ _local7.seconds = _arg4; }; if (_arg3 == "maxstanzas"){ _local7.maxstanzas = _arg4; }; if (_arg3 == "maxchars"){ _local7.maxchars = _arg4; }; }; if (_arg2 != null){ _local6.status = _arg2; }; if (password != null){ _local7.password = password; }; _local6.addExtension(_local7); myConnection.send(_local6); return (true); } public function get userJID():JID{ return (new JID(((roomJID.toBareJID() + "/") + nickname))); } private function finish_admin(_arg1:IQ):void{ var _local2:RoomEvent; if (_arg1.type == IQ.ERROR_TYPE){ _local2 = new RoomEvent(RoomEvent.ADMIN_ERROR); _local2.errorCondition = _arg1.errorCondition; _local2.errorMessage = _arg1.errorMessage; _local2.errorType = _arg1.errorType; _local2.errorCode = _arg1.errorCode; dispatchEvent(_local2); }; } public function set connection(_arg1:XMPPConnection):void{ if (myConnection != null){ myConnection.removeEventListener(MessageEvent.MESSAGE, handleEvent); myConnection.removeEventListener(PresenceEvent.PRESENCE, handleEvent); myConnection.removeEventListener(DisconnectionEvent.DISCONNECT, handleEvent); }; myConnection = _arg1; myConnection.addEventListener(MessageEvent.MESSAGE, handleEvent, false, 0, true); myConnection.addEventListener(PresenceEvent.PRESENCE, handleEvent, false, 0, true); myConnection.addEventListener(DisconnectionEvent.DISCONNECT, handleEvent, false, 0, true); } private function unlockRoom(_arg1:Boolean):void{ var _local2:IQ; var _local3:MUCOwnerExtension; var _local4:FormExtension; if (_arg1){ requestConfiguration(); } else { _local2 = new IQ(roomJID, IQ.SET_TYPE); _local3 = new MUCOwnerExtension(); _local4 = new FormExtension(); _local4.type = FormExtension.SUBMIT_TYPE; _local3.addExtension(_local4); _local2.addExtension(_local3); myConnection.send(_local2); }; } public function get subject():String{ return (mySubject); } public function getOccupantNamed(_arg1:String):RoomOccupant{ var _local2:RoomOccupant; for each (_local2 in this) { if (_local2.displayName == _arg1){ return (_local2); }; }; return (null); } public function allow(_arg1:Array):void{ grant(Room.NO_AFFILIATION, _arg1); } public function get isActive():Boolean{ return (active); } public function getMessage(_arg1:String=null, _arg2:String=null):Message{ var _local3:Message = new Message(roomJID, null, _arg1, _arg2, Message.GROUPCHAT_TYPE); return (_local3); } private function handleEvent(_arg1:Object):void{ var _local2:Message; var _local3:RoomEvent; var _local4:Array; var _local5:Array; var _local6:MUCUserExtension; var _local7:Presence; var _local8:MUCUserExtension; var _local9:MUCStatus; switch (_arg1.type){ case "message": _local2 = _arg1.data; if (isThisRoom(_local2.from)){ if (_local2.type == Message.GROUPCHAT_TYPE){ if (_local2.subject != null){ mySubject = _local2.subject; _local3 = new RoomEvent(RoomEvent.SUBJECT_CHANGE); _local3.subject = _local2.subject; dispatchEvent(_local3); } else { _local3 = new RoomEvent(RoomEvent.GROUP_MESSAGE); _local3.data = _local2; dispatchEvent(_local3); }; } else { if (_local2.type == Message.NORMAL_TYPE){ _local4 = _local2.getAllExtensionsByNS(FormExtension.NS)[0]; if (_local4){ _local3 = new RoomEvent(RoomEvent.CONFIGURE_ROOM); _local3.data = _local4; dispatchEvent(_local3); }; }; }; } else { if (((isThisUser(_local2.to)) && ((_local2.type == Message.CHAT_TYPE)))){ _local3 = new RoomEvent(RoomEvent.PRIVATE_MESSAGE); _local3.data = _local2; dispatchEvent(_local3); } else { _local5 = _local2.getAllExtensionsByNS(MUCUserExtension.NS); if (((!((_local5 == null))) && ((_local5.length > 0)))){ _local6 = _local5[0]; if (((_local6) && ((_local6.type == MUCUserExtension.DECLINE_TYPE)))){ _local3 = new RoomEvent(RoomEvent.DECLINED); _local3.from = _local6.reason; _local3.reason = _local6.reason; _local3.data = _local2; dispatchEvent(_local3); }; }; }; }; break; case "presence": for each (_local7 in _arg1.data) { if (_local7.type == Presence.ERROR_TYPE){ switch (_local7.errorCode){ case 401: _local3 = new RoomEvent(RoomEvent.PASSWORD_ERROR); break; case 403: _local3 = new RoomEvent(RoomEvent.BANNED_ERROR); break; case 404: _local3 = new RoomEvent(RoomEvent.LOCKED_ERROR); break; case 407: _local3 = new RoomEvent(RoomEvent.REGISTRATION_REQ_ERROR); break; case 409: _local3 = new RoomEvent(RoomEvent.NICK_CONFLICT); _local3.nickname = nickname; break; case 503: _local3 = new RoomEvent(RoomEvent.MAX_USERS_ERROR); break; default: _local3 = new RoomEvent(("MUC Error of type: " + _local7.errorCode)); break; }; dispatchEvent(_local3); } else { if (isThisRoom(_local7.from)){ if (_local7.from.resource == pendingNickname){ myNickname = pendingNickname; pendingNickname = null; }; _local8 = _local7.getAllExtensionsByNS(MUCUserExtension.NS)[0]; for each (_local9 in _local8.statuses) { switch (_local9.code){ case 100: case 172: anonymous = false; break; case 174: anonymous = true; break; case 201: unlockRoom(myIsReserved); break; case 307: _local3 = new RoomEvent(RoomEvent.USER_KICKED); _local3.nickname = _local7.from.resource; dispatchEvent(_local3); break; case 301: _local3 = new RoomEvent(RoomEvent.USER_BANNED); _local3.nickname = _local7.from.resource; dispatchEvent(_local3); break; }; }; updateRoomRoster(_local7); if ((((((_local7.type == Presence.UNAVAILABLE_TYPE)) && (isActive))) && (isThisUser(_local7.from)))){ active = false; _local3 = new RoomEvent(RoomEvent.ROOM_LEAVE); dispatchEvent(_local3); myConnection.removeEventListener(PresenceEvent.PRESENCE, handleEvent); }; }; }; }; break; case "disconnection": active = false; removeAll(); _local3 = new RoomEvent(RoomEvent.ROOM_LEAVE); dispatchEvent(_local3); break; }; } public function finish_requestConfiguration(_arg1:IQ):void{ var _local4:RoomEvent; if (_arg1.type == IQ.ERROR_TYPE){ finish_admin(_arg1); return; }; var _local2:MUCOwnerExtension = _arg1.getAllExtensionsByNS(MUCOwnerExtension.NS)[0]; var _local3:FormExtension = _local2.getAllExtensionsByNS(FormExtension.NS)[0]; if (_local3.type == FormExtension.REQUEST_TYPE){ _local4 = new RoomEvent(RoomEvent.CONFIGURE_ROOM); _local4.data = _local3; dispatchEvent(_local4); }; } public function isThisUser(_arg1:JID):Boolean{ return ((_arg1.toString().toLowerCase() == userJID.toString().toLowerCase())); } public function set roomJID(_arg1:JID):void{ myJID = _arg1; } public function get connection():XMPPConnection{ return (myConnection); } public function sendMessage(_arg1:String=null, _arg2:String=null):void{ var _local3:Message; if (isActive){ _local3 = new Message(roomJID, null, _arg1, _arg2, Message.GROUPCHAT_TYPE); myConnection.send(_local3); }; } public function set anonymous(_arg1:Boolean):void{ _anonymous = _arg1; } public function changeSubject(_arg1:String):void{ var _local2:Message; if (isActive){ _local2 = new Message(roomJID, null, null, null, Message.GROUPCHAT_TYPE, _arg1); myConnection.send(_local2); }; } public function set status(_arg1:String):void{ var _local2:Presence = new Presence(userJID); _local2.status = _arg1; var _local3:MUCExtension = new MUCExtension(); _local2.addExtension(_local3); myConnection.send(_local2); } public function configure(_arg1:Object):void{ var _local4:FormExtension; var _local2:IQ = new IQ(roomJID, IQ.SET_TYPE); var _local3:MUCOwnerExtension = new MUCOwnerExtension(); if ((_arg1 is FormExtension)){ _local4 = FormExtension(_arg1); } else { _local4 = new FormExtension(); _arg1["FORM_TYPE"] = [MUCOwnerExtension.NS]; _local4.setFields(_arg1); }; _local4.type = FormExtension.SUBMIT_TYPE; _local3.addExtension(_local4); _local2.addExtension(_local3); myConnection.send(_local2); } public function isThisRoom(_arg1:JID):Boolean{ return (((roomJID) && ((_arg1.toBareJID().toLowerCase() == roomJID.toBareJID().toLowerCase())))); } public function requestAffiliations(_arg1:String):void{ var _local2:IQ = new IQ(roomJID, IQ.GET_TYPE); var _local3:MUCOwnerExtension = new MUCOwnerExtension(); _local2.callbackScope = this; _local2.callbackName = "finish_requestAffiliates"; _local3.addItem(_arg1); _local2.addExtension(_local3); connection.send(_local2); } override public function toString():String{ return ("[object Room]"); } public function get anonymous():Boolean{ return (_anonymous); } private function updateRoomRoster(_arg1:Presence):void{ var _local5:RoomEvent; var _local7:MUCUserExtension; var _local8:MUCStatus; var _local2:String = _arg1.from.resource; var _local3:Array = _arg1.getAllExtensionsByNS(MUCUserExtension.NS); var _local4:MUCItem = _local3[0].getAllItems()[0]; if (isThisUser(_arg1.from)){ myAffiliation = _local4.affiliation; myRole = _local4.role; if (((!(isActive)) && (!((_arg1.type == Presence.UNAVAILABLE_TYPE))))){ active = true; _local5 = new RoomEvent(RoomEvent.ROOM_JOIN); dispatchEvent(_local5); }; }; var _local6:RoomOccupant = getOccupantNamed(_local2); if (_local6){ if (_arg1.type == Presence.UNAVAILABLE_TYPE){ removeItemAt(getItemIndex(_local6)); _local7 = _arg1.getAllExtensionsByNS(MUCUserExtension.NS)[0]; for each (_local8 in _local7.statuses) { if ((((_local8.code == 307)) || ((_local8.code == 301)))){ return; }; }; _local5 = new RoomEvent(RoomEvent.USER_DEPARTURE); _local5.nickname = _local2; _local5.data = _arg1; dispatchEvent(_local5); } else { _local6.affiliation = _local4.affiliation; _local6.role = _local4.role; _local6.show = _arg1.show; _local5 = new RoomEvent(RoomEvent.USER_CHANGED); _local5.nickname = _local2; _local5.data = _arg1; dispatchEvent(_local5); }; } else { if (_arg1.type != Presence.UNAVAILABLE_TYPE){ addItem(new RoomOccupant(_local2, _arg1.show, _arg1.status, _local4.affiliation, _local4.role, _local4.jid, this)); _local5 = new RoomEvent(RoomEvent.USER_JOIN); _local5.nickname = _local2; _local5.data = _arg1; dispatchEvent(_local5); }; }; } public function get affiliation():String{ return (myAffiliation); } public function get nickname():String{ return (((myNickname == null)) ? myConnection.username : myNickname); } public function decline(_arg1:JID, _arg2:String):void{ var _local3:Message = new Message(roomJID); var _local4:MUCUserExtension = new MUCUserExtension(); _local4.decline(_arg1, undefined, _arg2); _local3.addExtension(_local4); myConnection.send(_local3); } public function sendMessageWithExtension(_arg1:Message):void{ if (isActive){ myConnection.send(_arg1); }; } public function get role():String{ return (myRole); } public function set conferenceServer(_arg1:String):void{ roomJID = new JID(((roomName + "@") + _arg1)); } private static function RoomStaticConstructor():Boolean{ MUC.enable(); FormExtension.enable(); return (true); } } }//package org.jivesoftware.xiff.conference
Section 147
//RoomOccupant (org.jivesoftware.xiff.conference.RoomOccupant) package org.jivesoftware.xiff.conference { import org.jivesoftware.xiff.core.*; import flash.events.*; import mx.events.*; import org.jivesoftware.xiff.data.im.*; public class RoomOccupant extends EventDispatcher implements Contact { private var _uid:String; private var _status:String; private var _affiliation:String; private var _room:Room; private var _jid:JID; private var _nickname:String; private var _role:String; private var _show:String; public function RoomOccupant(_arg1:String, _arg2:String, _arg3:String, _arg4:String, _arg5:String, _arg6:JID, _arg7:Room){ this.displayName = _arg1; this.show = _arg2; this.status = _arg3; this.affiliation = _arg4; this.role = _arg5; this.jid = _arg6; this.room = _arg7; } public function get show():String{ return (_show); } public function get jid():JID{ return (_jid); } private function set _3506395room(_arg1:Room):void{ _room = _arg1; } private function set _1714148973displayName(_arg1:String):void{ _nickname = _arg1; } private function set _892481550status(_arg1:String):void{ _status = _arg1; } public function set jid(_arg1:JID):void{ var _local2:Object = this.jid; if (_local2 !== _arg1){ this._105221jid = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "jid", _local2, _arg1)); }; } public function set online(_arg1:Boolean):void{ var _local2:Object = this.online; if (_local2 !== _arg1){ this._1012222381online = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "online", _local2, _arg1)); }; } public function set uid(_arg1:String):void{ _uid = _arg1; } private function set _2019918576affiliation(_arg1:String):void{ _affiliation = _arg1; } public function set room(_arg1:Room):void{ var _local2:Object = this.room; if (_local2 !== _arg1){ this._3506395room = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "room", _local2, _arg1)); }; } private function set _3506294role(_arg1:String):void{ _role = _arg1; } public function get rosterItem():RosterItemVO{ if (!jid){ return (null); }; return (RosterItemVO.get(jid, true)); } public function get uid():String{ return (_uid); } public function get online():Boolean{ return (true); } private function set _105221jid(_arg1:JID):void{ _jid = _arg1; } private function set _1012222381online(_arg1:Boolean):void{ } public function get room():Room{ return (_room); } private function set _3529469show(_arg1:String):void{ _show = _arg1; } public function set affiliation(_arg1:String):void{ var _local2:Object = this.affiliation; if (_local2 !== _arg1){ this._2019918576affiliation = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "affiliation", _local2, _arg1)); }; } public function set displayName(_arg1:String):void{ var _local2:Object = this.displayName; if (_local2 !== _arg1){ this._1714148973displayName = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "displayName", _local2, _arg1)); }; } public function set status(_arg1:String):void{ var _local2:Object = this.status; if (_local2 !== _arg1){ this._892481550status = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "status", _local2, _arg1)); }; } public function set role(_arg1:String):void{ var _local2:Object = this.role; if (_local2 !== _arg1){ this._3506294role = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "role", _local2, _arg1)); }; } public function get displayName():String{ return (_nickname); } public function get affiliation():String{ return (_affiliation); } public function get status():String{ return (_status); } public function get role():String{ return (_role); } public function set show(_arg1:String):void{ var _local2:Object = this.show; if (_local2 !== _arg1){ this._3529469show = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "show", _local2, _arg1)); }; } } }//package org.jivesoftware.xiff.conference
Section 148
//JID (org.jivesoftware.xiff.core.JID) package org.jivesoftware.xiff.core { public class JID { private var bareJID:String; private var jid:String; private var jidNodeValidator:RegExp; public function JID(_arg1:String, _arg2:Boolean=false):void{ jidNodeValidator = /^([\x29\x23-\x25\x28-\x2E\x30-\x39\x3B\x3D\x3F\x41-\x7E\xA0      -  -​۝ ܏᠎‌-‍
-
€-Ÿ ⁠-⁣---uFDD0-uFDEF uFFFE-uFFFF?-?-�⿰-⿻]{1,1023})/; super(); if (_arg2){ if (((!(jidNodeValidator.test(_arg1))) || ((_arg1.indexOf(" ") > -1)))){ trace("Invalid JID: %s", _arg1); throw ("Invalid JID"); }; }; jid = (_arg1) ? _arg1 : ""; } public function get domain():String{ var _local1:int = jid.indexOf("@"); var _local2:int = jid.indexOf("/"); if (_local1 < 0){ _local1 = -1; }; if (_local2 < 0){ return (jid.slice((_local1 + 1))); }; return (jid.slice((_local1 + 1), _local2)); } public function get node():String{ var _local1:int = jid.indexOf("@"); if (_local1 < 0){ return (null); }; return (jid.slice(0, _local1)); } public function toString():String{ return (jid); } public function get resource():String{ var _local1:int = this.jid.indexOf("/"); if (_local1 < 0){ return (null); }; return (jid.slice((_local1 + 1))); } public function get bareJid():JID{ return (new JID(this.toBareJID())); } public function toBareJID():String{ var _local1:int; if (!bareJID){ _local1 = jid.indexOf("/"); if (_local1 < 0){ bareJID = jid; } else { bareJID = jid.slice(0, _local1); }; }; return (bareJID); } public function equals(_arg1:JID, _arg2:Boolean):Boolean{ if (_arg2){ return ((_arg1.toBareJID() == toBareJID())); }; return ((_arg1.jid == jid)); } } }//package org.jivesoftware.xiff.core
Section 149
//XMPPBOSHConnection (org.jivesoftware.xiff.core.XMPPBOSHConnection) package org.jivesoftware.xiff.core { import flash.xml.*; import org.jivesoftware.xiff.data.*; import flash.events.*; import org.jivesoftware.xiff.events.*; import flash.utils.*; import flash.net.*; import org.jivesoftware.xiff.auth.*; import org.jivesoftware.xiff.data.bind.*; import org.jivesoftware.xiff.data.session.*; public class XMPPBOSHConnection extends XMPPConnection { private const responseTimer:Timer; private var authHandler:Function; private var headers:Object; private var rid:Number; private var boshVersion:Number;// = 1.6 private var maxConcurrentRequests:uint;// = 2 private var saslEnabled:Boolean;// = true private var auth:SASLAuth; private var pendingHttpRequests:Array; private var httpResponses:Array; private var inactivity:int; private var expectedRid:Number; private var isDisconnecting:Boolean;// = false private var requestCount:int;// = 0 private var requestQueue:Array; private var sid:String; private var responseQueue:Array; private var callbacks:Object; private var _port:Number;// = -1 private var boshPollingInterval:Number;// = 10000 private var https:Boolean;// = false private var wait:int; private static const saslMechanisms:Object = {PLAIN:Plain, ANONYMOUS:Anonymous}; public static var logger:Object = null; public function XMPPBOSHConnection(){ headers = {post:[], get:["Cache-Control", "no-store", "Cache-Control", "no-cache", "Pragma", "no-cache"]}; requestQueue = []; responseQueue = []; pendingHttpRequests = []; httpResponses = []; responseTimer = new Timer(0, 1); callbacks = {}; super(); } override public function get port():Number{ if (_port == -1){ return ((https) ? 8483 : 8080); }; return (_port); } override public function set port(_arg1:Number):void{ _port = _arg1; } private function bindConnection():void{ var _local1:IQ = new IQ(null, "set"); var _local2:BindExtension = new BindExtension(); if (resource){ _local2.resource = resource; }; _local1.addExtension(_local2); _local1.callbackName = "handleBindResponse"; _local1.callbackScope = this; send(_local1); } public function processConnectionResponse(_arg1:XMLNode):void{ var _local2:Object = _arg1.attributes; sid = _local2.sid; boshPollingInterval = (_local2.polling * 1000); if ((((boshPollingInterval <= 1000)) && ((boshPollingInterval > 0)))){ boshPollingInterval = (boshPollingInterval + 1000); }; wait = _local2.wait; inactivity = _local2.inactivity; var _local3:int = _local2.requests; if (_local3){ maxConcurrentRequests = Math.min(_local3, maxConcurrentRequests); }; active = true; configureConnection(_arg1); responseTimer.addEventListener(TimerEvent.TIMER_COMPLETE, processResponse); } private function configureAuthMechanisms(_arg1:XMLNode):SASLAuth{ var _local2:SASLAuth; var _local3:Class; var _local4:XMLNode; for each (_local4 in _arg1.childNodes) { _local3 = saslMechanisms[_local4.firstChild.nodeValue]; if (_local3){ return (new _local3(this)); }; }; if (!_local2){ throw (new Error("No auth mechanisms found")); }; return (_local2); } private function establishSession():void{ var _local1:IQ = new IQ(null, "set"); _local1.addExtension(new SessionExtension()); _local1.callbackName = "handleSessionResponse"; _local1.callbackScope = this; send(_local1); } override public function sendKeepAlive():void{ } private function get nextRID():Number{ if (!rid){ rid = Math.floor((Math.random() * 1000000)); }; return (++rid); } public function set useSasl(_arg1:Boolean):void{ saslEnabled = _arg1; } public function handleSessionResponse(_arg1:IQ):void{ dispatchEvent(new LoginEvent()); } override public function disconnect():void{ super.disconnect(); } private function handleAuthentication(_arg1:XMLNode):void{ var _local2:Object = auth.handleResponse(0, _arg1); if (_local2.authComplete){ if (_local2.authSuccess){ bindConnection(); } else { dispatchEvent(new ErrorEvent(ErrorEvent.ERROR)); disconnect(); }; }; } private function resetResponseProcessor():void{ if (responseQueue.length > 0){ responseTimer.reset(); responseTimer.start(); }; } public function get useSasl():Boolean{ return (saslEnabled); } private function logIncomingData(_arg1:XMLDocument):void{ if (logger){ logger.log(_arg1.toString(), "INCOMING"); }; var _local2:IncomingDataEvent = new IncomingDataEvent(); _local2.data = _arg1; dispatchEvent(_local2); } private function processResponse(_arg1:TimerEvent=null):void{ if (((!(active)) || ((responseQueue.length == 0)))){ return; }; var _local2:XMLNode = responseQueue.shift(); var _local3:String = _local2.nodeName.toLowerCase(); switch (_local3){ case "stream:features": break; case "stream:error": handleStreamError(_local2); break; case "iq": handleIQ(_local2); break; case "message": handleMessage(_local2); break; case "presence": handlePresence(_local2); break; case "success": handleAuthentication(_local2); break; default: dispatchError("undefined-condition", "Unknown Error", "modify", 500); break; }; resetResponseProcessor(); } private function pollServer():void{ if (((!(isActive())) || (sendQueuedRequests()))){ return; }; if (requestCount > 0){ return; }; sendRequests(null, true); } private function configureConnection(_arg1:XMLNode):void{ var _local4:XMLNode; var _local2:XMLNode = _arg1.firstChild; var _local3:Object = {}; for each (_local4 in _local2.childNodes) { if (_local4.nodeName == "mechanisms"){ _local3.auth = configureAuthMechanisms(_local4); } else { if (_local4.nodeName == "bind"){ _local3.bind = true; } else { if (_local4.nodeName == "session"){ _local3.session = true; }; }; }; }; dispatchEvent(new ConnectionSuccessEvent()); if (useSasl){ auth = _local3.auth; authHandler = handleAuthentication; sendXML(auth.request); } else { beginAuthentication(); }; } private function httpError(_arg1:XMLNode, _arg2:Boolean, _arg3:Event):void{ var _local4:DisconnectionEvent; if (isActive()){ active = false; _local4 = new DisconnectionEvent(); dispatchEvent(_local4); } else { dispatchError("service-unavailable", "Service Unavailable", "cancel", 503); }; } private function httpResponse(_arg1:XMLNode, _arg2:Boolean, _arg3:Event):void{ var _local9:DisconnectionEvent; requestCount--; var _local4:URLLoader = URLLoader(_arg3.target); var _local5:String = _local4.data; var _local6:XMLDocument = new XMLDocument(); _local6.ignoreWhite = this.ignoreWhite; _local6.parseXML(_local5); var _local7:XMLNode = _local6.firstChild; if (((active) && ((_local7.attributes["type"] == "terminate")))){ logIncomingData(_local6); _local9 = new DisconnectionEvent(); dispatchEvent(_local9); active = false; return; }; logIncomingData(_local6); var _local8:Object = getPendingRequest(_local4); httpResponses.push({rid:_local8.rid, xml:_local7}); httpResponses.sortOn("rid", Array.NUMERIC); processHttpResponses(); processResponse(); sendQueuedRequests(); pollServer(); } override public function connect(_arg1:String=null):Boolean{ if (logger){ logger.log("CONNECT()", "INFO"); }; BindExtension.enable(); active = false; loggedIn = false; var _local2:Object = {xmlns:"http://jabber.org/protocol/httpbind", hold:(maxConcurrentRequests - 1), rid:nextRID, secure:https, wait:30, ver:boshVersion}; pendingHttpRequests = []; httpResponses = []; requestQueue = []; responseQueue = []; var _local3:XMLNode = new XMLNode(1, "body"); _local3.attributes = _local2; sendRequests(_local3); expectedRid = _local2.rid; return (true); } private function sendRequests(_arg1:XMLNode=null, _arg2:Boolean=false):Boolean{ var onResponse:Function; var onError:Function; var temp:Array; var i:uint; var data = _arg1; var isPoll = _arg2; if (requestCount >= maxConcurrentRequests){ return (false); }; if (isPoll){ trace(("Polling at: " + new Date().getSeconds())); }; requestCount++; if (!data){ if (isPoll){ data = createRequest(); } else { temp = []; i = 0; while ((((i < 10)) && ((requestQueue.length > 0)))) { temp.push(requestQueue.shift()); i = (i + 1); }; data = createRequest(temp); }; }; onResponse = function (_arg1:Event):void{ removeEventListeners((_arg1.target as URLLoader)); httpResponse(data, isPoll, _arg1); }; onError = function (_arg1:Event):void{ removeEventListeners((_arg1.target as URLLoader)); httpError(data, isPoll, _arg1); }; var removeEventListeners:Function = function (_arg1:URLLoader):void{ _arg1.removeEventListener(Event.COMPLETE, onResponse); _arg1.removeEventListener(IOErrorEvent.IO_ERROR, onError); _arg1.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onError); }; var request:URLRequest = new URLRequest(httpServer); request.method = URLRequestMethod.POST; request.requestHeaders = headers["post"]; request.contentType = "text/xml"; request.data = data.toString(); var loader:URLLoader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.TEXT; loader.addEventListener(Event.COMPLETE, onResponse); loader.addEventListener(IOErrorEvent.IO_ERROR, onError); loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError); pendingHttpRequests.push({loader:loader, rid:data.attributes.rid}); if (logger){ logger.log(data, "OUTGOING"); }; loader.load(request); return (true); } public function handleBindResponse(_arg1:IQ):void{ var _local2:BindExtension = (_arg1.getExtension("bind") as BindExtension); var _local3:String = _local2.getJID(); var _local4:Array = _local3.split("/"); myResource = _local4[1]; _local4 = _local4[0].split("@"); myUsername = _local4[0]; server = _local4[1]; establishSession(); } public function set secure(_arg1:Boolean):void{ https = _arg1; } override protected function sendXML(_arg1):void{ sendQueuedRequests(_arg1); } public function get httpServer():String{ return (((((((https) ? "https" : "http" + "://") + serverAddress) + ":") + port) + "/http-bind/")); } private function createRequest(_arg1:Array=null):XMLNode{ var _local4:XMLNode; var _local2:Object = {xmlns:"http://jabber.org/protocol/httpbind", rid:nextRID, sid:sid}; var _local3:XMLNode = new XMLNode(1, "body"); if (_arg1){ for each (_local4 in _arg1) { _local3.appendChild(_local4); }; }; _local3.attributes = _local2; return (_local3); } private function processHttpResponses():void{ var _local2:Object; var _local3:XMLNode; var _local4:XMLNode; var _local1:Array = []; while (((httpResponses[0]) && ((httpResponses[0].rid == expectedRid)))) { _local1.push(httpResponses.shift()); expectedRid++; }; for each (_local2 in _local1) { _local3 = _local2.xml; for each (_local4 in _local3.childNodes) { if (_local4.nodeName == "stream:features"){ _expireTagSearch = false; processConnectionResponse(_local3); } else { responseQueue.push(_local4); }; }; }; resetResponseProcessor(); } private function getPendingRequest(_arg1:URLLoader):Object{ var _local3:Object; var _local2:int; while (_local2 < pendingHttpRequests.length) { if (pendingHttpRequests[_local2].loader == _arg1){ _local3 = pendingHttpRequests[_local2]; pendingHttpRequests.slice(_local2, 1); return (_local3); }; _local2++; }; return (null); } private function sendQueuedRequests(_arg1=null):Boolean{ if (_arg1){ requestQueue.push(_arg1); } else { if (requestQueue.length == 0){ return (false); }; }; return (sendRequests()); } public static function disableSASLMechanism(_arg1:String):void{ saslMechanisms[_arg1] = null; } public static function registerSASLMechanism(_arg1:String, _arg2:Class):void{ saslMechanisms[_arg1] = _arg2; } } }//package org.jivesoftware.xiff.core
Section 150
//XMPPConnection (org.jivesoftware.xiff.core.XMPPConnection) package org.jivesoftware.xiff.core { import flash.xml.*; import org.jivesoftware.xiff.data.*; import flash.events.*; import org.jivesoftware.xiff.events.*; import flash.utils.*; import flash.net.*; import org.jivesoftware.xiff.data.register.*; import org.jivesoftware.xiff.data.forms.*; import org.jivesoftware.xiff.data.auth.*; import org.jivesoftware.xiff.exception.*; public class XMPPConnection extends EventDispatcher { protected var openingStreamTag:String; protected var myServer:String; protected var _socket:XMLSocket; private var presenceQueueTimer:Timer; protected var myUsername:String; protected var _active:Boolean; protected var sessionID:String; protected var closingStreamTag:String; protected var loggedIn:Boolean; protected var _expireTagSearch:Boolean; protected var myPort:Number; protected var pendingIQs:Object; protected var myResource:String; private var presenceQueue:Array; protected var _useAnonymousLogin:Boolean; protected var myServerAddress:String; protected var myPassword:String; protected var ignoreWhitespace:Boolean; protected static var _openConnections:Array = []; public function XMPPConnection(){ presenceQueue = []; super(); pendingIQs = new Object(); _useAnonymousLogin = false; active = false; loggedIn = false; ignoreWhitespace = true; resource = "xiff"; port = 5222; AuthExtension.enable(); RegisterExtension.enable(); FormExtension.enable(); } protected function beginAuthentication():void{ var _local1:IQ = new IQ(null, IQ.GET_TYPE, XMPPStanza.generateID("log_user_"), "beginAuthentication_result", this, null); var _local2:AuthExtension = new AuthExtension(_local1.getNode()); _local2.username = username; _local1.addExtension(_local2); send(_local1); } public function get jid():JID{ return (new JID(((((myUsername + "@") + myServer) + "/") + myResource))); } protected function get active():Boolean{ return (_active); } protected function sendRegistrationFields_result(_arg1:IQ):void{ var _local2:RegistrationSuccessEvent; if (_arg1.type == IQ.RESULT_TYPE){ _local2 = new RegistrationSuccessEvent(); dispatchEvent(_local2); } else { dispatchError("unexpected-request", "Unexpected Request", "wait", 400); }; } protected function set active(_arg1:Boolean):void{ if (_arg1){ _openConnections.push(this); } else { _openConnections.splice(_openConnections.indexOf(this), 1); }; _active = _arg1; } public function set server(_arg1:String):void{ myServer = _arg1; } public function get port():Number{ return (myPort); } public function isLoggedIn():Boolean{ return (loggedIn); } public function get resource():String{ return (myResource); } public function send(_arg1:XMPPStanza):void{ var _local2:XMLNode; var _local3:IQ; if (isActive()){ if ((_arg1 is IQ)){ _local3 = (_arg1 as IQ); if (((((!((_local3.callbackName == null))) && (!((_local3.callbackScope == null))))) || (!((_local3.callback == null))))){ addIQCallbackToPending(_local3.id, _local3.callbackName, _local3.callbackScope, _local3.callback); }; }; _local2 = _arg1.getNode().parentNode; if (_local2 == null){ _local2 = new XMLDocument(); }; if (_arg1.serialize(_local2)){ sendXML(_local2.firstChild); } else { throw (new SerializationException()); }; }; } protected function sendAnonymousLogin_result(_arg1:IQ):void{ var _local2:JID; var _local3:LoginEvent; if (_arg1.type == IQ.RESULT_TYPE){ _local2 = _arg1.to; resource = _local2.resource; username = _local2.node; loggedIn = true; _local3 = new LoginEvent(); dispatchEvent(_local3); }; } protected function beginAuthentication_result(_arg1:IQ):void{ var authIQ:IQ; var resultAuth:*; var responseAuth:AuthExtension; var resultIQ = _arg1; var connectionType = "none"; if (resultIQ.type == IQ.RESULT_TYPE){ authIQ = new IQ(null, IQ.SET_TYPE, XMPPStanza.generateID("log_user2_"), "sendAuthentication_result", this, null); try { resultAuth = resultIQ.getAllExtensionsByNS(AuthExtension.NS)[0]; responseAuth = new AuthExtension(authIQ.getNode()); responseAuth.password = password; responseAuth.username = username; responseAuth.resource = resource; authIQ.addExtension(responseAuth); send(authIQ); } catch(e:Error) { trace("Error : null trapped. Resuming."); }; } else { dispatchError("unexpected-request", "Unexpected Request", "wait", 400); }; } public function disconnect():void{ var event:DisconnectionEvent; if (isActive()){ try { sendXML(closingStreamTag); if (_socket){ _socket.close(); }; } catch(e:Error) { }; active = false; loggedIn = false; event = new DisconnectionEvent(); dispatchEvent(event); }; } protected function handleStreamError(_arg1:XMLNode):void{ var node = _arg1; dispatchError("service-unavailable", node.firstChild.nodeName.toLowerCase(), "cancel", 502); try { _socket.close(); } catch(error:Error) { }; active = false; loggedIn = false; var event:DisconnectionEvent = new DisconnectionEvent(); dispatchEvent(event); } protected function sendAuthentication_result(_arg1:IQ):void{ var _local2:LoginEvent; if (_arg1.type == IQ.RESULT_TYPE){ loggedIn = true; _local2 = new LoginEvent(); dispatchEvent(_local2); } else { dispatchError("unexpected-request", "Unexpected Request", "wait", 400); }; } public function sendKeepAlive():void{ if (isActive()){ sendXML(" "); }; } public function get password():String{ return (myPassword); } protected function sendAnonymousLogin():void{ var _local1:IQ = new IQ(null, IQ.SET_TYPE, XMPPStanza.generateID("log_anom_"), "sendAnonymousLogin_result", this, null); var _local2:AuthExtension = new AuthExtension(_local1.getNode()); _local1.addExtension(_local2); send(_local1); } protected function dispatchError(_arg1:String, _arg2:String, _arg3:String, _arg4:Number):void{ var _local5:XIFFErrorEvent = new XIFFErrorEvent(); _local5.errorCondition = _arg1; _local5.errorMessage = _arg2; _local5.errorType = _arg3; _local5.errorCode = _arg4; dispatchEvent(_local5); } protected function securityError(_arg1:SecurityErrorEvent):void{ dispatchError("service-unavailable-security", "Service Unavailable", "cancel", 503); } protected function flushPresenceQueue(_arg1:TimerEvent):void{ var _local2:PresenceEvent = new PresenceEvent(); _local2.data = presenceQueue; dispatchEvent(_local2); presenceQueue = []; } public function set password(_arg1:String):void{ myPassword = _arg1; } public function get serverAddress():String{ if (myServerAddress != null){ return (myServerAddress); }; return (myServer); } public function set username(_arg1:String):void{ myUsername = _arg1; } private function _createXmlSocket():XMLSocket{ if (_socket != null){ _socket.removeEventListener(Event.CONNECT, socketConnected); _socket.removeEventListener(IOErrorEvent.IO_ERROR, onIOError); _socket.removeEventListener(Event.CLOSE, socketClosed); _socket.removeEventListener(DataEvent.DATA, socketReceivedData); _socket.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityError); }; var _local1:XMLSocket = new XMLSocket(serverAddress, port); _local1.addEventListener(Event.CONNECT, socketConnected); _local1.addEventListener(IOErrorEvent.IO_ERROR, onIOError); _local1.addEventListener(Event.CLOSE, socketClosed); _local1.addEventListener(DataEvent.DATA, socketReceivedData); _local1.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityError); return (_local1); } protected function socketReceivedData(_arg1:DataEvent):void{ var _local6:RegExp; var _local7:Object; if (!_expireTagSearch){ _local6 = new RegExp("<flash:stream"); _local7 = _local6.exec(_arg1.data); if (_local7 != null){ _arg1.data = _arg1.data.concat("</flash:stream>"); _expireTagSearch = true; }; }; if (_arg1.data == "</flash:stream>"){ socketClosed(null); return; }; var _local2:XMLDocument = new XMLDocument(); _local2.ignoreWhite = this.ignoreWhite; _local2.parseXML(_arg1.data); var _local3:IncomingDataEvent = new IncomingDataEvent(); _local3.data = _local2; dispatchEvent(_local3); var _local4:XMLNode = _local2.firstChild; var _local5:String = _local4.nodeName.toLowerCase(); switch (_local5){ case "stream:stream": case "flash:stream": _expireTagSearch = false; handleStream(_local4); break; case "stream:error": handleStreamError(_local4); break; case "iq": handleIQ(_local4); break; case "message": handleMessage(_local4); break; case "presence": handlePresence(_local4); break; case "stream:features": break; default: dispatchError("undefined-condition", "Unknown Error", "modify", 500); break; }; } protected function socketClosed(_arg1:Event):void{ var _local2:DisconnectionEvent; if (isActive()){ active = false; loggedIn = false; _local2 = new DisconnectionEvent(); dispatchEvent(_local2); }; } protected function handlePresence(_arg1:XMLNode):Presence{ if (!presenceQueueTimer){ presenceQueueTimer = new Timer(1, 1); presenceQueueTimer.addEventListener(TimerEvent.TIMER_COMPLETE, flushPresenceQueue); }; var _local2:Presence = new Presence(); if (!_local2.deserialize(_arg1)){ throw (new SerializationException()); }; presenceQueue.push(_local2); presenceQueueTimer.reset(); presenceQueueTimer.start(); return (_local2); } protected function handleMessage(_arg1:XMLNode):Message{ var _local3:MessageEvent; var _local2:Message = new Message(); if (!_local2.deserialize(_arg1)){ throw (new SerializationException()); }; if (_local2.type == Message.ERROR_TYPE){ dispatchError(_local2.errorCondition, _local2.errorMessage, _local2.errorType, _local2.errorCode); } else { _local3 = new MessageEvent(); _local3.data = _local2; dispatchEvent(_local3); }; return (_local2); } protected function handleStream(_arg1:XMLNode):void{ sessionID = _arg1.attributes.id; server = _arg1.attributes.from; if (_useAnonymousLogin){ sendAnonymousLogin(); } else { if (((!((username == null))) && ((username.length > 0)))){ beginAuthentication(); } else { getRegistrationFields(); }; }; } public function set resource(_arg1:String):void{ if (_arg1.length > 0){ myResource = _arg1; }; } public function isActive():Boolean{ return (active); } protected function onIOError(_arg1:IOErrorEvent):void{ dispatchError("service-unavailable-io", "Service Unavailable", "cancel", 503); } protected function addIQCallbackToPending(_arg1:String, _arg2:String, _arg3:Object, _arg4:Function):void{ pendingIQs[_arg1] = {methodName:_arg2, methodScope:_arg3, func:_arg4}; } protected function socketConnected(_arg1:Event):void{ active = true; sendXML(openingStreamTag); var _local2:ConnectionSuccessEvent = new ConnectionSuccessEvent(); dispatchEvent(_local2); } public function getRegistrationFields():void{ var _local1:IQ = new IQ(new JID(server), IQ.GET_TYPE, XMPPStanza.generateID("reg_info_"), "getRegistrationFields_result", this, null); _local1.addExtension(new RegisterExtension(_local1.getNode())); send(_local1); } public function get server():String{ return (myServer); } protected function handleIQ(_arg1:XMLNode):IQ{ var _local3:*; var _local4:Array; var _local5:String; var _local6:IExtension; var _local7:IQEvent; var _local2:IQ = new IQ(); if (!_local2.deserialize(_arg1)){ throw (new SerializationException()); }; if ((((_local2.type == IQ.ERROR_TYPE)) && (!(pendingIQs[_local2.id])))){ dispatchError(_local2.errorCondition, _local2.errorMessage, _local2.errorType, _local2.errorCode); } else { if (pendingIQs[_local2.id] !== undefined){ _local3 = pendingIQs[_local2.id]; if (((_local3.methodScope) && (_local3.methodName))){ _local3.methodScope[_local3.methodName].apply(_local3.methodScope, [_local2]); }; if (_local3.func != null){ _local3.func(_local2); }; pendingIQs[_local2.id] = null; delete pendingIQs[_local2.id]; } else { _local4 = _local2.getAllExtensions(); for (_local5 in _local4) { _local6 = (_local4[_local5] as IExtension); if (_local6 != null){ _local7 = new IQEvent(_local6.getNS()); _local7.data = _local6; _local7.iq = _local2; dispatchEvent(_local7); }; }; }; }; return (_local2); } public function get useAnonymousLogin():Boolean{ return (_useAnonymousLogin); } public function set useAnonymousLogin(_arg1:Boolean):void{ if (!isActive()){ _useAnonymousLogin = _arg1; }; } public function set serverAddress(_arg1:String):void{ myServerAddress = _arg1; } public function connect(_arg1:String="terminatedStandard"):Boolean{ _socket = _createXmlSocket(); active = false; loggedIn = false; switch (_arg1){ case "flash": openingStreamTag = new String((("<?xml version=\"1.0\"?><flash:stream to=\"" + server) + "\" xmlns=\"jabber:client\" xmlns:flash=\"http://www.jabber.com/streams/flash\" version=\"1.0\">")); closingStreamTag = new String("</flash:stream>"); break; case "terminatedFlash": openingStreamTag = new String((("<?xml version=\"1.0\"?><flash:stream to=\"" + server) + "\" xmlns=\"jabber:client\" xmlns:flash=\"http://www.jabber.com/streams/flash\" version=\"1.0\" />")); closingStreamTag = new String("</flash:stream>"); break; case "standard": openingStreamTag = new String((("<?xml version=\"1.0\"?><stream:stream to=\"" + server) + "\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">")); closingStreamTag = new String("</stream:stream>"); break; case "terminatedStandard": default: openingStreamTag = new String((("<?xml version=\"1.0\"?><stream:stream to=\"" + server) + "\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\" />")); closingStreamTag = new String("</stream:stream>"); break; }; _socket.connect(serverAddress, port); return (true); } public function changePassword(_arg1:String):void{ var _local2:IQ = new IQ(new JID(server), IQ.SET_TYPE, XMPPStanza.generateID("pswd_change_"), "changePassword_result", this, null); var _local3:RegisterExtension = new RegisterExtension(_local2.getNode()); _local3.username = jid.toBareJID(); _local3.password = _arg1; _local2.addExtension(_local3); send(_local2); } public function get username():String{ return (myUsername); } protected function changePassword_result(_arg1:IQ):void{ var _local2:ChangePasswordSuccessEvent; if (_arg1.type == IQ.RESULT_TYPE){ _local2 = new ChangePasswordSuccessEvent(); dispatchEvent(_local2); } else { dispatchError("unexpected-request", "Unexpected Request", "wait", 400); }; } protected function getRegistrationFields_result(_arg1:IQ):void{ var ext:RegisterExtension; var fields:Array; var event:RegistrationFieldsEvent; var resultIQ = _arg1; try { ext = resultIQ.getAllExtensionsByNS(RegisterExtension.NS)[0]; fields = ext.getRequiredFieldNames(); event = new RegistrationFieldsEvent(); event.fields = fields; event.data = ext; } catch(e:Error) { trace(e.getStackTrace()); }; } public function set port(_arg1:Number):void{ myPort = _arg1; } protected function sendXML(_arg1):void{ _socket.send(_arg1); var _local2:OutgoingDataEvent = new OutgoingDataEvent(); _local2.data = _arg1; dispatchEvent(_local2); } public function get ignoreWhite():Boolean{ return (ignoreWhitespace); } public function sendRegistrationFields(_arg1:Object, _arg2:String):void{ var _local5:String; var _local3:IQ = new IQ(new JID(server), IQ.SET_TYPE, XMPPStanza.generateID("reg_attempt_"), "sendRegistrationFields_result", this, null); var _local4:RegisterExtension = new RegisterExtension(_local3.getNode()); for (_local5 in _arg1) { _local4[_local5] = _arg1[_local5]; }; if (_arg2 != null){ _local4.key = _arg2; }; _local3.addExtension(_local4); send(_local3); } public function set ignoreWhite(_arg1:Boolean):void{ ignoreWhitespace = _arg1; } public static function get openConnections():Array{ return (_openConnections); } } }//package org.jivesoftware.xiff.core
Section 151
//XMPPSocketConnection (org.jivesoftware.xiff.core.XMPPSocketConnection) package org.jivesoftware.xiff.core { import flash.xml.*; import flash.events.*; import org.jivesoftware.xiff.events.*; import com.kongregate.as3.common.util.*; import org.jivesoftware.xiff.util.*; public class XMPPSocketConnection extends XMPPConnection { private var _streamNode:XMLNode;// = null private var _compress:Boolean;// = false private var _incompleteRawXML:String;// = "" protected var binarySocket:SocketConn; private var _compressedSessionInitialized:Boolean;// = false public function XMPPSocketConnection(_arg1:Boolean=false){ _compress = _arg1; configureSocket(); } protected function bSocketReceivedData(_arg1:SocketDataEvent):void{ var pattern:RegExp; var resultObj:Object; var pattern2:RegExp; var resultObj2:Object; var isComplete:Boolean; var event:IncomingDataEvent; var i:int; var currentNode:XMLNode; var nodeName:String; var ev = _arg1; var rawXML:String = ((_incompleteRawXML + ev.data) as String); if (rawXML == null){ Log.error("Bad socket data event detected, disconnecting"); disconnect(); return; }; if (rawXML.length == 0){ return; }; rawXML = rawXML.replace("</flash:stream>", ""); rawXML = rawXML.replace("</stream:stream>", ""); if (!_expireTagSearch){ pattern = new RegExp("<flash:stream"); resultObj = pattern.exec(rawXML); if (resultObj != null){ rawXML = rawXML.concat("</flash:stream>"); _expireTagSearch = true; }; }; if (!_expireTagSearch){ pattern2 = new RegExp("<stream:stream"); resultObj2 = pattern2.exec(rawXML); if (resultObj2 != null){ rawXML = rawXML.concat("</stream:stream>"); _expireTagSearch = true; }; }; var xmlData:XMLDocument = new XMLDocument(); xmlData.ignoreWhite = this.ignoreWhite; try { isComplete = true; xmlData.parseXML(rawXML); _incompleteRawXML = ""; } catch(err:Error) { isComplete = false; _incompleteRawXML = (_incompleteRawXML + (ev.data as String)); }; if (isComplete){ event = new IncomingDataEvent(); event.data = xmlData; dispatchEvent(event); i = 0; while (i < xmlData.childNodes.length) { currentNode = xmlData.childNodes[i]; nodeName = currentNode.nodeName.toLowerCase(); switch (nodeName){ case "stream:stream": _expireTagSearch = false; handleStream(currentNode); break; case "flash:stream": _expireTagSearch = false; handleStream(currentNode); break; case "stream:error": handleStreamError(currentNode); break; case "compressed": handleCompressed(currentNode); break; case "failure": handleFailure(currentNode); break; case "iq": handleIQ(currentNode); break; case "message": handleMessage(currentNode); break; case "presence": handlePresence(currentNode); break; case "stream:features": break; default: dispatchError("undefined-condition", "Unknown Error", "modify", 500); break; }; i = (i + 1); }; }; } override public function disconnect():void{ var event:DisconnectionEvent; if (isActive()){ try { sendXML(closingStreamTag); if (binarySocket){ binarySocket.close(); }; } catch(e:Error) { }; active = false; loggedIn = false; event = new DisconnectionEvent(); dispatchEvent(event); }; } override public function connect(_arg1:String="terminatedStandard"):Boolean{ active = false; loggedIn = false; _compressedSessionInitialized = false; _streamNode = null; switch (_arg1){ case "flash": binarySocket.flash = true; openingStreamTag = (("<?xml version=\"1.0\"?><flash:stream to=\"" + server) + "\" xmlns=\"jabber:client\" xmlns:flash=\"http://www.jabber.com/streams/flash\" version=\"1.0\">"); closingStreamTag = "</flash:stream>"; break; case "terminatedFlash": binarySocket.flash = true; openingStreamTag = (("<?xml version=\"1.0\"?><flash:stream to=\"" + server) + "\" xmlns=\"jabber:client\" xmlns:flash=\"http://www.jabber.com/streams/flash\" version=\"1.0\" />"); closingStreamTag = "</flash:stream>"; break; case "standard": binarySocket.flash = false; openingStreamTag = (("<?xml version=\"1.0\"?><stream:stream to=\"" + server) + "\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">"); closingStreamTag = "</stream:stream>"; break; case "terminatedStandard": default: binarySocket.flash = false; openingStreamTag = (("<?xml version=\"1.0\"?><stream:stream to=\"" + server) + "\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\" />"); closingStreamTag = "</stream:stream>"; break; }; binarySocket.connect(serverAddress, port); return (true); } protected function handleCompressed(_arg1:XMLNode):void{ _compressedSessionInitialized = true; binarySocket.compress = true; Log.info("Compressed stream initialized"); sendXML(openingStreamTag); } protected function handleFailure(_arg1:XMLNode):void{ if (_arg1.attributes.xmlns == "http://jabber.org/protocol/compress"){ Log.warn("Compression disabled on server, reverting to normal stream"); _compress = false; super.handleStream(_streamNode); _streamNode = null; }; } override protected function sendXML(_arg1):void{ binarySocket.sendString(_arg1); var _local2:OutgoingDataEvent = new OutgoingDataEvent(); _local2.data = _arg1; dispatchEvent(_local2); } override protected function handleStream(_arg1:XMLNode):void{ if (((_compress) && (!(this._compressedSessionInitialized)))){ _streamNode = _arg1; sendXML("<compress xmlns='http://jabber.org/protocol/compress'><method>zlib</method></compress>"); Log.info("Initializing compression"); } else { super.handleStream(_arg1); }; } private function configureSocket():void{ binarySocket = new SocketConn(); binarySocket.addEventListener(Event.CLOSE, socketClosed); binarySocket.addEventListener(Event.CONNECT, socketConnected); binarySocket.addEventListener(IOErrorEvent.IO_ERROR, onIOError); binarySocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityError); binarySocket.addEventListener(SocketDataEvent.SOCKET_DATA_RECEIVED, bSocketReceivedData); } } }//package org.jivesoftware.xiff.core
Section 152
//AuthExtension (org.jivesoftware.xiff.data.auth.AuthExtension) package org.jivesoftware.xiff.data.auth { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class AuthExtension extends Extension implements IExtension, ISerializable { private var myUsernameNode:XMLNode; private var myPasswordNode:XMLNode; private var myDigestNode:XMLNode; private var myResourceNode:XMLNode; public static var NS:String = "jabber:iq:auth"; public static var ELEMENT:String = "query"; public function AuthExtension(_arg1:XMLNode=null){ super(_arg1); } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; setNode(_arg1); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case "username": myUsernameNode = _local2[_local3]; break; case "password": myPasswordNode = _local2[_local3]; break; case "digest": myDigestNode = _local2[_local3]; break; case "resource": myResourceNode = _local2[_local3]; break; }; }; return (true); } public function get digest():String{ return (myDigestNode.firstChild.nodeValue); } public function isDigest():Boolean{ return (exists(myDigestNode)); } public function set digest(_arg1:String):void{ myPasswordNode.removeNode(); myPasswordNode = null; myDigestNode = replaceTextNode(getNode(), myDigestNode, "digest", _arg1); } public function get resource():String{ return (myResourceNode.firstChild.nodeValue); } public function get username():String{ return (myUsernameNode.firstChild.nodeValue); } public function set resource(_arg1:String):void{ myResourceNode = replaceTextNode(getNode(), myResourceNode, "resource", _arg1); } public function serialize(_arg1:XMLNode):Boolean{ if (!exists(getNode().parentNode)){ _arg1.appendChild(getNode().cloneNode(true)); }; return (true); } public function get password():String{ return (myPasswordNode.firstChild.nodeValue); } public function isPassword():Boolean{ return (exists(myPasswordNode)); } public function getNS():String{ return (AuthExtension.NS); } public function set username(_arg1:String):void{ myUsernameNode = replaceTextNode(getNode(), myUsernameNode, "username", _arg1); } public function set password(_arg1:String):void{ myDigestNode = ((myDigestNode)==null) ? XMLStanza.XMLFactory.createElement("") : myDigestNode; myDigestNode.removeNode(); myDigestNode = null; myPasswordNode = replaceTextNode(getNode(), myPasswordNode, "password", _arg1); } public function getElementName():String{ return (AuthExtension.ELEMENT); } public static function enable():void{ ExtensionClassRegistry.register(AuthExtension); } public static function computeDigest(_arg1:String, _arg2:String):String{ return (SHA1.calcSHA1((_arg1 + _arg2)).toLowerCase()); } } }//package org.jivesoftware.xiff.data.auth
Section 153
//SHA1 (org.jivesoftware.xiff.data.auth.SHA1) package org.jivesoftware.xiff.data.auth { public class SHA1 { private static var hex_chr:String = "0123456789abcdef"; private static function kt(_arg1:Number):Number{ return (((_arg1)<20) ? 1518500249 : ((_arg1)<40) ? 1859775393 : ((_arg1)<60) ? -1894007588 : -899497514); } private static function str2blks(_arg1:String):Array{ var _local2:Number = (((_arg1.length + 8) >> 6) + 1); var _local3:Array = new Array((_local2 * 16)); var _local4:Number = 0; while (_local4 < (_local2 * 16)) { _local3[_local4] = 0; _local4++; }; var _local5:Number = 0; while (_local5 < _arg1.length) { _local3[(_local5 >> 2)] = (_local3[(_local5 >> 2)] | (_arg1.charCodeAt(_local5) << (24 - ((_local5 % 4) * 8)))); _local5++; }; _local3[(_local5 >> 2)] = (_local3[(_local5 >> 2)] | (128 << (24 - ((_local5 % 4) * 8)))); _local3[((_local2 * 16) - 1)] = (_arg1.length * 8); return (_local3); } private static function rol(_arg1:Number, _arg2:Number):Number{ return (((_arg1 << _arg2) | (_arg1 >>> (32 - _arg2)))); } public static function calcSHA1(_arg1:String):String{ var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local2:Array = SHA1.str2blks(_arg1); var _local3:Array = new Array(80); var _local4:Number = 1732584193; var _local5:Number = -271733879; var _local6:Number = -1732584194; var _local7:Number = 271733878; var _local8:Number = -1009589776; var _local9:Number = 0; while (_local9 < _local2.length) { _local10 = _local4; _local11 = _local5; _local12 = _local6; _local13 = _local7; _local14 = _local8; _local15 = 0; while (_local15 < 80) { if (_local15 < 16){ _local3[_local15] = _local2[(_local9 + _local15)]; } else { _local3[_local15] = SHA1.rol((((_local3[(_local15 - 3)] ^ _local3[(_local15 - 8)]) ^ _local3[(_local15 - 14)]) ^ _local3[(_local15 - 16)]), 1); }; _local16 = SHA1.safe_add(SHA1.safe_add(SHA1.rol(_local4, 5), SHA1.ft(_local15, _local5, _local6, _local7)), SHA1.safe_add(SHA1.safe_add(_local8, _local3[_local15]), SHA1.kt(_local15))); _local8 = _local7; _local7 = _local6; _local6 = SHA1.rol(_local5, 30); _local5 = _local4; _local4 = _local16; _local15++; }; _local4 = SHA1.safe_add(_local4, _local10); _local5 = SHA1.safe_add(_local5, _local11); _local6 = SHA1.safe_add(_local6, _local12); _local7 = SHA1.safe_add(_local7, _local13); _local8 = SHA1.safe_add(_local8, _local14); _local9 = (_local9 + 16); }; return (((((SHA1.hex(_local4) + SHA1.hex(_local5)) + SHA1.hex(_local6)) + SHA1.hex(_local7)) + SHA1.hex(_local8))); } private static function hex(_arg1:Number):String{ var _local2 = ""; var _local3:Number = 7; while (_local3 >= 0) { _local2 = (_local2 + hex_chr.charAt(((_arg1 >> (_local3 * 4)) & 15))); _local3--; }; return (_local2); } private static function ft(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{ if (_arg1 < 20){ return (((_arg2 & _arg3) | (~(_arg2) & _arg4))); }; if (_arg1 < 40){ return (((_arg2 ^ _arg3) ^ _arg4)); }; if (_arg1 < 60){ return ((((_arg2 & _arg3) | (_arg2 & _arg4)) | (_arg3 & _arg4))); }; return (((_arg2 ^ _arg3) ^ _arg4)); } private static function safe_add(_arg1:Number, _arg2:Number):Number{ var _local3:Number = ((_arg1 & 0xFFFF) + (_arg2 & 0xFFFF)); var _local4:Number = (((_arg1 >> 16) + (_arg2 >> 16)) + (_local3 >> 16)); return (((_local4 << 16) | (_local3 & 0xFFFF))); } } }//package org.jivesoftware.xiff.data.auth
Section 154
//BindExtension (org.jivesoftware.xiff.data.bind.BindExtension) package org.jivesoftware.xiff.data.bind { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class BindExtension extends Extension implements IExtension, ISerializable { private var jid:String; private var _resource:String; public static var NS:String = "urn:ietf:params:xml:ns:xmpp-bind"; public static var ELEMENT_NAME:String = "bind"; public function BindExtension(_arg1:XMLNode=null){ super(_arg1); } public function serialize(_arg1:XMLNode):Boolean{ var _local2:XMLNode; var _local3:XMLNode; if (!exists(getNode().parentNode)){ _local2 = getNode().cloneNode(true); _local3 = new XMLNode(1, "resource"); _local3.appendChild(XMLStanza.XMLFactory.createTextNode((resource) ? resource : "xiff")); _local2.appendChild(_local3); _arg1.appendChild(_local2); }; return (true); } public function get resource():String{ return (_resource); } public function getJID():String{ return (jid); } public function getElementName():String{ return (BindExtension.ELEMENT_NAME); } public function getNS():String{ return (BindExtension.NS); } public function set resource(_arg1:String):void{ _resource = _arg1; } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; setNode(_arg1); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case "jid": jid = _local2[_local3].firstChild.nodeValue; break; default: throw (("Unknown element: " + _local2[_local3].nodeName)); }; }; return (true); } public static function enable():void{ ExtensionClassRegistry.register(BindExtension); } } }//package org.jivesoftware.xiff.data.bind
Section 155
//FormExtension (org.jivesoftware.xiff.data.forms.FormExtension) package org.jivesoftware.xiff.data.forms { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class FormExtension extends Extension implements IExtension, ISerializable { private var myFields:Array; private var myReportedFields:Array; private var myInstructionsNode:XMLNode; private var myTitleNode:XMLNode; private var myItems:Array; public static var SUBMIT_TYPE:String = "submit"; public static var FIELD_TYPE_JID_MULTI:String = "jid-multi"; public static var FIELD_TYPE_TEXT_MULTI:String = "text-multi"; public static var FIELD_TYPE_BOOLEAN:String = "boolean"; public static var FIELD_TYPE_LIST_SINGLE:String = "list-single"; public static var REQUEST_TYPE:String = "form"; public static var NS:String = "jabber:x:data"; public static var FIELD_TYPE_TEXT_PRIVATE:String = "text-private"; public static var FIELD_TYPE_TEXT_SINGLE:String = "text-single"; public static var FIELD_TYPE_FIXED:String = "fixed"; public static var RESULT_TYPE:String = "result"; public static var CANCEL_TYPE:String = "cancel"; public static var FIELD_TYPE_JID_SINGLE:String = "jid-single"; public static var FIELD_TYPE_HIDDEN:String = "hidden"; public static var ELEMENT:String = "x"; public static var FIELD_TYPE_LIST_MULTI:String = "list-multi"; public function FormExtension(_arg1:XMLNode=null){ super(_arg1); myItems = new Array(); myFields = new Array(); myReportedFields = new Array(); } public function removeAllItems():void{ var _local1:String; var _local2:String; for (_local1 in myItems) { for (_local2 in myItems) { myItems[_local1][_local2].getNode().removeNode(); myItems[_local1][_local2].setNode(null); }; }; myItems = new Array(); } public function getAllFields():Array{ return (myFields); } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; var _local4:XMLNode; var _local5:FormField; var _local6:Array; var _local7:XMLNode; var _local8:XMLNode; setNode(_arg1); removeAllItems(); removeAllFields(); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { _local4 = _local2[_local3]; switch (_local2[_local3].nodeName){ case "instructions": myInstructionsNode = _local4; break; case "title": myTitleNode = _local4; break; case "reported": for each (_local7 in _local4.childNodes) { _local5 = new FormField(); _local5.deserialize(_local7); myReportedFields.push(_local5); }; break; case "item": _local6 = new Array(); for each (_local8 in _local4.childNodes) { _local5 = new FormField(); _local5.deserialize(_local8); _local6.push(_local5); }; myItems.push(_local6); break; case "field": _local5 = new FormField(); _local5.deserialize(_local4); myFields.push(_local5); break; }; }; return (true); } public function set type(_arg1:String):void{ getNode().attributes.type = _arg1; } public function set instructions(_arg1:String):void{ myInstructionsNode = replaceTextNode(getNode(), myInstructionsNode, "instructions", _arg1); } public function getFormType():String{ var _local1:int; while (_local1 < myFields.length) { if (myFields[_local1].name == "FORM_TYPE"){ return (myFields[_local1].value); }; _local1++; }; return (""); } public function getAllItems():Array{ return (myItems); } public function removeAllFields():void{ var _local1:String; var _local2:String; for (_local1 in myFields) { for (_local2 in myFields[_local1]) { myFields[_local1][_local2].getNode().removeNode(); myFields[_local1][_local2].setNode(null); }; }; myFields = new Array(); } public function get title():String{ return (myTitleNode.firstChild.nodeValue); } public function serialize(_arg1:XMLNode):Boolean{ var _local3:String; var _local2:XMLNode = getNode(); for (_local3 in myFields) { if (!myFields[_local3].serialize(_local2)){ return (false); }; }; if (_arg1 != _local2.parentNode){ _arg1.appendChild(_local2.cloneNode(true)); }; return (true); } public function getNS():String{ return (FormExtension.NS); } public function get instructions():String{ return (myInstructionsNode.firstChild.nodeValue); } public function getFormField(_arg1:String):FormField{ var _local2:FormField; var _local3:int = myFields.length; for each (_local2 in myFields) { if (_local2.name == _arg1){ break; }; }; return (_local2); } public function getReportedFields():Array{ return (myReportedFields); } public function set title(_arg1:String):void{ myTitleNode = replaceTextNode(getNode(), myTitleNode, "Title", _arg1); } public function getElementName():String{ return (FormExtension.ELEMENT); } public function get type():String{ return (getNode().attributes.type); } public function setFields(_arg1:Object):void{ var _local2:String; var _local3:FormField; removeAllFields(); for (_local2 in _arg1) { _local3 = new FormField(); _local3.name = _local2; _local3.setAllValues(_arg1[_local2]); myFields.push(_local3); }; } public static function enable():Boolean{ ExtensionClassRegistry.register(FormExtension); return (true); } } }//package org.jivesoftware.xiff.data.forms
Section 156
//FormField (org.jivesoftware.xiff.data.forms.FormField) package org.jivesoftware.xiff.data.forms { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class FormField extends XMLStanza implements ISerializable { private var myDescNode:XMLNode; private var myValueNodes:Array; private var myRequiredNode:XMLNode; private var myOptionNodes:Array; public static var ELEMENT:String = "field"; public function serialize(_arg1:XMLNode):Boolean{ getNode().nodeName = FormField.ELEMENT; if (_arg1 != getNode().parentNode){ _arg1.appendChild(getNode().cloneNode(true)); }; return (true); } public function get type():String{ return (getNode().attributes.type); } public function set value(_arg1:String):void{ if (myValueNodes == null){ myValueNodes = new Array(); }; myValueNodes[0] = replaceTextNode(getNode(), myValueNodes[0], "value", _arg1); } public function set label(_arg1:String):void{ getNode().attributes.label = _arg1; } public function get name():String{ return (getNode().attributes["var"]); } public function get value():String{ try { if (((!((myValueNodes[0] == null))) && (!((myValueNodes[0].firstChild == null))))){ return (myValueNodes[0].firstChild.nodeValue); }; } catch(error:Error) { trace(error.getStackTrace()); }; return (null); } public function set type(_arg1:String):void{ getNode().attributes.type = _arg1; } public function getAllOptions():Array{ var _local1:Array = new Array(); var _local2:int; while (_local2 < myOptionNodes.length) { _local1.push({label:myOptionNodes[_local2].attributes.label, value:myOptionNodes[_local2].firstChild.firstChild.nodeValue}); _local2++; }; return (_local1); } public function set name(_arg1:String):void{ getNode().attributes["var"] = _arg1; } public function setAllOptions(_arg1:Array):void{ var _local2:String; var _local3:int; var _local4:XMLNode; for (_local2 in myOptionNodes) { myOptionNodes[_local2].removeNode(); }; myOptionNodes = new Array(); _local3 = 0; while (_local3 < _arg1.length) { _local4 = replaceTextNode(getNode(), undefined, "value", _arg1[_local3].value); _local4.attributes.label = _arg1[_local3].label; myOptionNodes[_local3] = _local4; _local3++; }; } public function setAllValues(_arg1:Array):void{ var _local2:String; var _local3:int; for (_local2 in myValueNodes) { myValueNodes[_local2].removeNode(); }; myValueNodes = new Array(); _local3 = 0; while (_local3 < _arg1.length) { myValueNodes[_local3] = replaceTextNode(getNode(), undefined, "value", _arg1[_local3]); _local3++; }; } public function get label():String{ return (getNode().attributes.label); } public function getAllValues():Array{ var _local1:Array = new Array(); var _local2:int; while (_local2 < myValueNodes.length) { _local1.push(myValueNodes[_local2].firstChild.nodeValue); _local2++; }; return (_local1); } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; var _local4:XMLNode; setNode(_arg1); myValueNodes = new Array(); myOptionNodes = new Array(); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { _local4 = _local2[_local3]; switch (_local2[_local3].nodeName){ case "desc": myDescNode = _local4; break; case "required": myRequiredNode = _local4; break; case "value": myValueNodes.push(_local4); break; case "option": myOptionNodes.push(_local4); break; }; }; return (true); } } }//package org.jivesoftware.xiff.data.forms
Section 157
//IIDGenerator (org.jivesoftware.xiff.data.id.IIDGenerator) package org.jivesoftware.xiff.data.id { public interface IIDGenerator { function getID(_arg1:String):String; } }//package org.jivesoftware.xiff.data.id
Section 158
//IncrementalGenerator (org.jivesoftware.xiff.data.id.IncrementalGenerator) package org.jivesoftware.xiff.data.id { public class IncrementalGenerator implements IIDGenerator { private var myCounter:Number; private static var instance:IIDGenerator; public function IncrementalGenerator(){ myCounter = 0; } public function getID(_arg1:String):String{ var _local2:String; myCounter++; if (_arg1 != null){ _local2 = (_arg1 + myCounter); } else { _local2 = myCounter.toString(); }; return (_local2); } public static function getInstance():IIDGenerator{ if (instance == null){ instance = new (IncrementalGenerator); }; return (instance); } } }//package org.jivesoftware.xiff.data.id
Section 159
//Contact (org.jivesoftware.xiff.data.im.Contact) package org.jivesoftware.xiff.data.im { import org.jivesoftware.xiff.core.*; import mx.core.*; public interface Contact extends IPropertyChangeNotifier { function set jid(_arg1:JID):void; function get online():Boolean; function get show():String; function get jid():JID; function set online(_arg1:Boolean):void; function set show(_arg1:String):void; function set displayName(_arg1:String):void; function get displayName():String; } }//package org.jivesoftware.xiff.data.im
Section 160
//RosterExtension (org.jivesoftware.xiff.data.im.RosterExtension) package org.jivesoftware.xiff.data.im { import flash.xml.*; import org.jivesoftware.xiff.data.*; import org.jivesoftware.xiff.core.*; public class RosterExtension extends Extension implements IExtension, ISerializable { private var myItems:Array; public static var NS:String = "jabber:iq:roster"; public static var SUBSCRIBE_TYPE_NONE:String = "none"; public static var SUBSCRIBE_TYPE_TO:String = "to"; public static var SUBSCRIBE_TYPE_BOTH:String = "both"; public static var ASK_TYPE_SUBSCRIBE:String = "subscribe"; public static var SUBSCRIBE_TYPE_REMOVE:String = "remove"; public static var ASK_TYPE_UNSUBSCRIBE:String = "unsubscribe"; public static var ELEMENT:String = "query"; public static var SHOW_PENDING:String = "Pending"; public static var ASK_TYPE_NONE:String = "none"; private static var staticDepends:Array = [ExtensionClassRegistry]; public static var SUBSCRIBE_TYPE_FROM:String = "from"; public static var SHOW_UNAVAILABLE:String = "unavailable"; public function RosterExtension(_arg1:XMLNode=null){ myItems = []; super(_arg1); } public function serialize(_arg1:XMLNode):Boolean{ var _local3:String; var _local2:XMLNode = getNode(); for (_local3 in myItems) { if (!myItems[_local3].serialize(_local2)){ return (false); }; }; if (!exists(getNode().parentNode)){ _arg1.appendChild(getNode().cloneNode(true)); }; return (true); } public function getNS():String{ return (RosterExtension.NS); } public function addItem(_arg1:JID=null, _arg2:String="", _arg3:String="", _arg4:Array=null):void{ var _local6:String; var _local5:RosterItem = new RosterItem(getNode()); if (exists(_arg1)){ _local5.jid = _arg1; }; if (exists(_arg2)){ _local5.subscription = _arg2; }; if (exists(_arg3)){ _local5.name = _arg3; }; if (exists(_arg4)){ for each (_local6 in _arg4) { _local5.addGroupNamed(_local6); }; }; } public function getItemByJID(_arg1:JID):RosterItem{ var _local2:String; for (_local2 in myItems) { if (myItems[_local2].jid == _arg1.toString()){ return (myItems[_local2]); }; }; return (null); } public function removeAllItems():void{ var _local1:String; for (_local1 in myItems) { myItems[_local1].setNode(null); }; myItems = new Array(); } public function getAllItems():Array{ return (myItems); } public function getElementName():String{ return (RosterExtension.ELEMENT); } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; var _local4:RosterItem; setNode(_arg1); removeAllItems(); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case "item": _local4 = new RosterItem(getNode()); if (!_local4.deserialize(_local2[_local3])){ return (false); }; myItems.push(_local4); break; }; }; return (true); } public static function enable():void{ ExtensionClassRegistry.register(RosterExtension); } } }//package org.jivesoftware.xiff.data.im
Section 161
//RosterItem (org.jivesoftware.xiff.data.im.RosterItem) package org.jivesoftware.xiff.data.im { import flash.xml.*; import org.jivesoftware.xiff.data.*; import org.jivesoftware.xiff.core.*; public class RosterItem extends XMLStanza implements ISerializable { private var myGroupNodes:Array; public static var ELEMENT:String = "item"; public function RosterItem(_arg1:XMLNode=null){ getNode().nodeName = ELEMENT; myGroupNodes = new Array(); if (exists(_arg1)){ _arg1.appendChild(getNode()); }; } public function serialize(_arg1:XMLNode):Boolean{ if (!exists(jid)){ trace("Warning: required roster item attributes 'jid' missing"); return (false); }; if (_arg1 != getNode().parentNode){ _arg1.appendChild(getNode().cloneNode(true)); }; return (true); } public function get askType():String{ return (getNode().attributes.ask); } public function get subscription():String{ return (getNode().attributes.subscription); } public function get jid():JID{ return (new JID(getNode().attributes.jid)); } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; setNode(_arg1); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case "group": myGroupNodes.push(_local2[_local3]); break; }; }; return (true); } public function get groupNames():Array{ var _local2:String; var _local3:XMLNode; var _local1:Array = new Array(); for (_local2 in myGroupNodes) { _local3 = myGroupNodes[_local2].firstChild; if (_local3 != null){ _local1.push(_local3.nodeValue); }; }; return (_local1); } public function set jid(_arg1:JID):void{ getNode().attributes.jid = _arg1.toString(); } public function get name():String{ return (getNode().attributes.name); } public function set askType(_arg1:String):void{ getNode().attributes.ask = _arg1; } public function get groupCount():Number{ return (myGroupNodes.length); } public function removeAllGroups():void{ var _local1:String; for (_local1 in myGroupNodes) { myGroupNodes[_local1].removeNode(); }; myGroupNodes = new Array(); } public function set name(_arg1:String):void{ getNode().attributes.name = _arg1; } public function get pending():Boolean{ if ((((askType == RosterExtension.ASK_TYPE_SUBSCRIBE)) && ((((subscription == RosterExtension.SUBSCRIBE_TYPE_NONE)) || ((subscription == RosterExtension.SUBSCRIBE_TYPE_FROM)))))){ return (true); }; return (false); } public function set subscription(_arg1:String):void{ getNode().attributes.subscription = _arg1; } public function addGroupNamed(_arg1:String):void{ var _local2:XMLNode = addTextNode(getNode(), "group", _arg1); myGroupNodes.push(_local2); } public function removeGroupByName(_arg1:String):Boolean{ var _local2:String; for (_local2 in myGroupNodes) { if (myGroupNodes[_local2].nodeValue == _arg1){ myGroupNodes[_local2].removeNode(); myGroupNodes.splice(Number(_local2), 1); return (true); }; }; return (false); } } }//package org.jivesoftware.xiff.data.im
Section 162
//RosterItemVO (org.jivesoftware.xiff.data.im.RosterItemVO) package org.jivesoftware.xiff.data.im { import org.jivesoftware.xiff.core.*; import flash.events.*; import mx.events.*; public class RosterItemVO extends EventDispatcher implements Contact { private var _priority:Number; private var _status:String; private var _askType:String; private var _subscribeType:String; private var _displayName:String; private var _jid:JID; private var _show:String; private var _online:Boolean;// = false private var _groups:Array; private static var allContacts:Object = {}; public function RosterItemVO(_arg1:JID):void{ _groups = []; super(); jid = _arg1; } public function get show():String{ return (_show); } public function get jid():JID{ return (_jid); } public function set jid(_arg1:JID):void{ var _local2:Object = this.jid; if (_local2 !== _arg1){ this._105221jid = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "jid", _local2, _arg1)); }; } private function set _892481550status(_arg1:String):void{ var _local2:String = status; _status = _arg1; PropertyChangeEvent.createUpdateEvent(this, "status", _local2, status); } public function get pending():Boolean{ return ((((askType == RosterExtension.ASK_TYPE_SUBSCRIBE)) && ((((subscribeType == RosterExtension.SUBSCRIBE_TYPE_NONE)) || ((subscribeType == RosterExtension.SUBSCRIBE_TYPE_FROM)))))); } public function set uid(_arg1:String):void{ } private function set _712664749askType(_arg1:String):void{ var _local2:String = askType; var _local3:Boolean = pending; _askType = _arg1; PropertyChangeEvent.createUpdateEvent(this, "askType", _local2, askType); PropertyChangeEvent.createUpdateEvent(this, "pending", _local3, pending); dispatchEvent(new Event("changeAskType")); } public function set online(_arg1:Boolean):void{ var _local2:Object = this.online; if (_local2 !== _arg1){ this._1012222381online = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "online", _local2, _arg1)); }; } public function get subscribeType():String{ return (_subscribeType); } public function set askType(_arg1:String):void{ var _local2:Object = this.askType; if (_local2 !== _arg1){ this._712664749askType = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "askType", _local2, _arg1)); }; } public function get priority():Number{ return (_priority); } public function set subscribeType(_arg1:String):void{ var _local2:Object = this.subscribeType; if (_local2 !== _arg1){ this._1572088740subscribeType = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "subscribeType", _local2, _arg1)); }; } private function set _1572088740subscribeType(_arg1:String):void{ var _local2:String = subscribeType; _subscribeType = _arg1; PropertyChangeEvent.createUpdateEvent(this, "subscribeType", _local2, subscribeType); dispatchEvent(new Event("changeSubscription")); } public function set priority(_arg1:Number):void{ var _local2:Object = this.priority; if (_local2 !== _arg1){ this._1165461084priority = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "priority", _local2, _arg1)); }; } public function get uid():String{ return (_jid.toString()); } public function get askType():String{ return (_askType); } private function set _105221jid(_arg1:JID):void{ var _local2:JID = _jid; _jid = _arg1; if (!_displayName){ dispatchEvent(new Event("changeDisplayName")); }; PropertyChangeEvent.createUpdateEvent(this, "jid", _local2, _arg1); } private function set _1012222381online(_arg1:Boolean):void{ if (_arg1 == online){ return; }; var _local2:Boolean = online; _online = _arg1; PropertyChangeEvent.createUpdateEvent(this, "online", _local2, online); } public function get online():Boolean{ return (_online); } private function set _3529469show(_arg1:String):void{ var _local2:String = show; _show = _arg1; PropertyChangeEvent.createUpdateEvent(this, "show", _local2, show); } public function set displayName(_arg1:String):void{ var _local2:String = displayName; _displayName = _arg1; PropertyChangeEvent.createUpdateEvent(this, "displayName", _local2, displayName); dispatchEvent(new Event("changeDisplayName")); } public function set status(_arg1:String):void{ var _local2:Object = this.status; if (_local2 !== _arg1){ this._892481550status = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "status", _local2, _arg1)); }; } override public function toString():String{ return (jid.toString()); } public function get displayName():String{ return ((_displayName) ? _displayName : _jid.node); } public function get status():String{ if (!online){ return ("Offline"); }; return ((_status) ? _status : "Available"); } public function set show(_arg1:String):void{ var _local2:Object = this.show; if (_local2 !== _arg1){ this._3529469show = _arg1; this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "show", _local2, _arg1)); }; } private function set _1165461084priority(_arg1:Number):void{ var _local2:Number = priority; _priority = _arg1; PropertyChangeEvent.createUpdateEvent(this, "priority", _local2, priority); } public static function get(_arg1:JID, _arg2:Boolean):RosterItemVO{ var _local3:String = _arg1.toBareJID(); var _local4:RosterItemVO = allContacts[_local3]; if (((!(_local4)) && (_arg2))){ _local4 = new RosterItemVO(_arg1.bareJid); allContacts[_local3] = _local4; }; return (_local4); } } }//package org.jivesoftware.xiff.data.im
Section 163
//MUC (org.jivesoftware.xiff.data.muc.MUC) package org.jivesoftware.xiff.data.muc { import org.jivesoftware.xiff.data.*; public class MUC { public static var ADMIN_AFFILIATION:String = "admin"; public static var OWNER_AFFILIATION:String = "owner"; private static var staticDependencies:Array = [ExtensionClassRegistry, MUCExtension, MUCUserExtension, MUCOwnerExtension, MUCAdminExtension]; public static var PARTICIPANT_ROLE:String = "participant"; public static var VISITOR_ROLE:String = "visitor"; public static var MODERATOR_ROLE:String = "moderator"; public static var NO_AFFILIATION:String = "none"; public static var NO_ROLE:String = "none"; public static var MEMBER_AFFILIATION:String = "member"; public static var OUTCAST_AFFILIATION:String = "outcast"; public static function enable():void{ ExtensionClassRegistry.register(MUCExtension); ExtensionClassRegistry.register(MUCUserExtension); ExtensionClassRegistry.register(MUCOwnerExtension); ExtensionClassRegistry.register(MUCAdminExtension); } } }//package org.jivesoftware.xiff.data.muc
Section 164
//MUCAdminExtension (org.jivesoftware.xiff.data.muc.MUCAdminExtension) package org.jivesoftware.xiff.data.muc { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class MUCAdminExtension extends MUCBaseExtension implements IExtension { private var myItems:Array; public static var ELEMENT:String = "query"; public static var NS:String = "http://jabber.org/protocol/muc#admin"; public function MUCAdminExtension(_arg1:XMLNode=null){ super(_arg1); } public function getElementName():String{ return (MUCAdminExtension.ELEMENT); } public function getNS():String{ return (MUCAdminExtension.NS); } } }//package org.jivesoftware.xiff.data.muc
Section 165
//MUCBaseExtension (org.jivesoftware.xiff.data.muc.MUCBaseExtension) package org.jivesoftware.xiff.data.muc { import flash.xml.*; import org.jivesoftware.xiff.data.*; import org.jivesoftware.xiff.core.*; public class MUCBaseExtension extends Extension implements IExtendable, ISerializable { private var myItems:Array; public function MUCBaseExtension(_arg1:XMLNode=null){ myItems = []; super(_arg1); } public function getAllItems():Array{ return (myItems); } public function serialize(_arg1:XMLNode):Boolean{ var _local3:String; var _local4:Array; var _local5:String; var _local2:XMLNode = getNode(); for (_local3 in myItems) { if (!myItems[_local3].serialize(_local2)){ return (false); }; }; _local4 = getAllExtensions(); for (_local5 in _local4) { if (!_local4[_local5].serialize(_local2)){ return (false); }; }; if (_arg1 != _local2.parentNode){ _arg1.appendChild(_local2.cloneNode(true)); }; return (true); } public function removeAllItems():void{ var _local1:String; for (_local1 in myItems) { myItems[_local1].setNode(null); }; myItems = new Array(); } public function addItem(_arg1:String=null, _arg2:String=null, _arg3:String=null, _arg4:JID=null, _arg5:String=null, _arg6:String=null):MUCItem{ var _local7:MUCItem = new MUCItem(getNode()); if (exists(_arg1)){ _local7.affiliation = _arg1; }; if (exists(_arg2)){ _local7.role = _arg2; }; if (exists(_arg3)){ _local7.nick = _arg3; }; if (exists(_arg4)){ _local7.jid = _arg4; }; if (exists(_arg5)){ _local7.actor = _arg5; }; if (exists(_arg6)){ _local7.reason = _arg6; }; myItems.push(_local7); return (_local7); } public function deserialize(_arg1:XMLNode):Boolean{ var _local2:Array; var _local3:String; var _local4:MUCItem; var _local5:Class; var _local6:IExtension; setNode(_arg1); removeAllItems(); _local2 = _arg1.childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case "item": _local4 = new MUCItem(getNode()); _local4.deserialize(_local2[_local3]); myItems.push(_local4); break; default: _local5 = ExtensionClassRegistry.lookup(_local2[_local3].attributes.xmlns); if (_local5 != null){ _local6 = new (_local5); if (_local6 != null){ if ((_local6 is ISerializable)){ ISerializable(_local6).deserialize(_local2[_local3]); }; addExtension(_local6); }; }; break; }; }; return (true); } } }//package org.jivesoftware.xiff.data.muc
Section 166
//MUCExtension (org.jivesoftware.xiff.data.muc.MUCExtension) package org.jivesoftware.xiff.data.muc { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class MUCExtension extends Extension implements IExtension, ISerializable { private var myPasswordNode:XMLNode; private var myHistoryNode:XMLNode; public static var ELEMENT:String = "x"; public static var NS:String = "http://jabber.org/protocol/muc"; public function MUCExtension(_arg1:XMLNode=null){ super(_arg1); } public function get since():String{ return (myHistoryNode.attributes.since); } public function get seconds():Number{ return (Number(myHistoryNode.attributes.seconds)); } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; setNode(_arg1); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case "history": myHistoryNode = _local2[_local3]; break; case "password": myPasswordNode = _local2[_local3]; break; }; }; return (true); } public function get history():Boolean{ return (exists(myHistoryNode)); } public function addChildNode(_arg1:XMLNode):void{ getNode().appendChild(_arg1); } public function serialize(_arg1:XMLNode):Boolean{ if (exists(getNode().parentNode)){ return (false); }; var _local2:XMLNode = getNode().cloneNode(true); var _local3:Array = getAllExtensions(); var _local4:int; while (_local4 < _local3.length) { if ((_local3[_local4] is ISerializable)){ ISerializable(_local3[_local4]).serialize(_local2); }; _local4++; }; _arg1.appendChild(_local2); return (true); } public function get password():String{ return (myPasswordNode.firstChild.nodeValue); } public function set history(_arg1:Boolean):void{ if (_arg1){ myHistoryNode = ensureNode(myHistoryNode, "history"); } else { myHistoryNode.removeNode(); myHistoryNode = null; }; } public function getElementName():String{ return (MUCExtension.ELEMENT); } public function set maxchars(_arg1:Number):void{ myHistoryNode = ensureNode(myHistoryNode, "history"); myHistoryNode.attributes.maxchars = _arg1.toString(); } public function set maxstanzas(_arg1:Number):void{ myHistoryNode = ensureNode(myHistoryNode, "history"); myHistoryNode.attributes.maxstanzas = _arg1.toString(); } public function set password(_arg1:String):void{ myPasswordNode = replaceTextNode(getNode(), myPasswordNode, "password", _arg1); } public function get maxchars():Number{ return (Number(myHistoryNode.attributes.maxchars)); } public function get maxstanzas():Number{ return (Number(myHistoryNode.attributes.maxstanzas)); } public function set since(_arg1:String):void{ myHistoryNode = ensureNode(myHistoryNode, "history"); myHistoryNode.attributes.since = _arg1; } public function getNS():String{ return (MUCExtension.NS); } public function set seconds(_arg1:Number):void{ myHistoryNode = ensureNode(myHistoryNode, "history"); myHistoryNode.attributes.seconds = _arg1.toString(); } } }//package org.jivesoftware.xiff.data.muc
Section 167
//MUCItem (org.jivesoftware.xiff.data.muc.MUCItem) package org.jivesoftware.xiff.data.muc { import flash.xml.*; import org.jivesoftware.xiff.data.*; import org.jivesoftware.xiff.core.*; public class MUCItem extends XMLStanza implements ISerializable { private var myActorNode:XMLNode; private var myReasonNode:XMLNode; public static var ELEMENT:String = "item"; public function MUCItem(_arg1:XMLNode=null){ getNode().nodeName = ELEMENT; if (exists(_arg1)){ _arg1.appendChild(getNode()); }; } public function serialize(_arg1:XMLNode):Boolean{ if (_arg1 != getNode().parentNode){ _arg1.appendChild(getNode().cloneNode(true)); }; return (true); } public function get nick():String{ return (getNode().attributes.nick); } public function get jid():JID{ if (getNode().attributes.jid == null){ return (null); }; return (new JID(getNode().attributes.jid)); } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; setNode(_arg1); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case "actor": myActorNode = _local2[_local3]; break; case "reason": myReasonNode = _local2[_local3]; break; }; }; return (true); } public function set reason(_arg1:String):void{ myReasonNode = replaceTextNode(getNode(), myReasonNode, "reason", _arg1); } public function set actor(_arg1:String):void{ myActorNode = ensureNode(myActorNode, "actor"); myActorNode.attributes.jid = _arg1; } public function set role(_arg1:String):void{ getNode().attributes.role = _arg1; } public function set nick(_arg1:String):void{ getNode().attributes.nick = _arg1; } public function set affiliation(_arg1:String):void{ getNode().attributes.affiliation = _arg1; } public function get affiliation():String{ return (getNode().attributes.affiliation); } public function set jid(_arg1:JID):void{ getNode().attributes.jid = _arg1.toString(); } public function get actor():String{ return (myActorNode.attributes.jid); } public function get reason():String{ return (myReasonNode.firstChild.nodeValue); } public function get role():String{ return (getNode().attributes.role); } } }//package org.jivesoftware.xiff.data.muc
Section 168
//MUCOwnerExtension (org.jivesoftware.xiff.data.muc.MUCOwnerExtension) package org.jivesoftware.xiff.data.muc { import flash.xml.*; import org.jivesoftware.xiff.data.*; import org.jivesoftware.xiff.core.*; public class MUCOwnerExtension extends MUCBaseExtension implements IExtension { private var myDestroyNode:XMLNode; public static var ELEMENT:String = "query"; public static var NS:String = "http://jabber.org/protocol/muc#owner"; public function MUCOwnerExtension(_arg1:XMLNode=null){ super(_arg1); } public function getElementName():String{ return (MUCOwnerExtension.ELEMENT); } public function destroy(_arg1:String, _arg2:JID):void{ var _local3:String; myDestroyNode = ensureNode(myDestroyNode, "destroy"); for (_local3 in myDestroyNode.childNodes) { myDestroyNode.childNodes[_local3].removeNode(); }; if (exists(_arg1)){ replaceTextNode(myDestroyNode, undefined, "reason", _arg1); }; if (exists(_arg2)){ myDestroyNode.attributes.jid = _arg2.toString(); }; } public function getNS():String{ return (MUCOwnerExtension.NS); } override public function serialize(_arg1:XMLNode):Boolean{ return (super.serialize(_arg1)); } override public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; super.deserialize(_arg1); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case "destroy": myDestroyNode = _local2[_local3]; break; }; }; return (true); } } }//package org.jivesoftware.xiff.data.muc
Section 169
//MUCStatus (org.jivesoftware.xiff.data.muc.MUCStatus) package org.jivesoftware.xiff.data.muc { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class MUCStatus { private var node:XMLNode; private var parent:XMLStanza; public function MUCStatus(_arg1:XMLNode, _arg2:XMLStanza){ node = (_arg1) ? _arg1 : new XMLNode(1, "status"); parent = _arg2; } public function set code(_arg1:Number):void{ node.attributes.code = _arg1.toString(); } public function get message():String{ return (node.firstChild.nodeValue); } public function get code():Number{ return (node.attributes.code); } public function set message(_arg1:String):void{ node = parent.replaceTextNode(parent.getNode(), node, "status", _arg1); } } }//package org.jivesoftware.xiff.data.muc
Section 170
//MUCUserExtension (org.jivesoftware.xiff.data.muc.MUCUserExtension) package org.jivesoftware.xiff.data.muc { import flash.xml.*; import org.jivesoftware.xiff.data.*; import org.jivesoftware.xiff.core.*; public class MUCUserExtension extends MUCBaseExtension implements IExtension { private var myPasswordNode:XMLNode; private var myActionNode:XMLNode; private var myStatuses:Array; public static var DECLINE_TYPE:String = "decline"; public static var NS:String = "http://jabber.org/protocol/muc#user"; public static var OTHER_TYPE:String = "other"; public static var INVITE_TYPE:String = "invite"; public static var ELEMENT:String = "x"; public static var DESTROY_TYPE:String = "destroy"; public function MUCUserExtension(_arg1:XMLNode=null){ myStatuses = []; super(_arg1); } public function set statuses(_arg1:Array):void{ myStatuses = _arg1; } public function get type():String{ if (myActionNode == null){ return (null); }; return (((myActionNode.nodeName == null)) ? OTHER_TYPE : myActionNode.nodeName); } public function get reason():String{ if (myActionNode.firstChild != null){ if (myActionNode.firstChild.firstChild != null){ return (myActionNode.firstChild.firstChild.nodeValue); }; }; return (null); } public function get jid():JID{ return (new JID(myActionNode.attributes.jid)); } override public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; super.deserialize(_arg1); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case DECLINE_TYPE: myActionNode = _local2[_local3]; break; case DESTROY_TYPE: myActionNode = _local2[_local3]; break; case INVITE_TYPE: myActionNode = _local2[_local3]; break; case "status": myStatuses.push(new MUCStatus(_local2[_local3], this)); break; case "password": myPasswordNode = _local2[_local3]; break; }; }; return (true); } public function invite(_arg1:JID, _arg2:JID, _arg3:String):void{ updateActionNode(INVITE_TYPE, {to:_arg1.toString(), from:(_arg2) ? _arg2.toString() : null}, _arg3); } public function get password():String{ if (myPasswordNode == null){ return (null); }; return (myPasswordNode.firstChild.nodeValue); } private function updateActionNode(_arg1:String, _arg2:Object, _arg3:String):void{ var _local4:*; if (myActionNode != null){ myActionNode.removeNode(); }; myActionNode = XMLFactory.createElement(_arg1); for (_local4 in _arg2) { if (exists(_arg2[_local4])){ myActionNode.attributes[_local4] = _arg2[_local4]; }; }; getNode().appendChild(myActionNode); if (_arg3.length > 0){ replaceTextNode(myActionNode, undefined, "reason", _arg3); }; } public function getNS():String{ return (MUCUserExtension.NS); } public function get statuses():Array{ return (myStatuses); } public function get from():JID{ return (new JID(myActionNode.attributes.from)); } public function set password(_arg1:String):void{ myPasswordNode = replaceTextNode(getNode(), myPasswordNode, "password", _arg1); } public function getElementName():String{ return (MUCUserExtension.ELEMENT); } public function hasStatusCode(_arg1:Number):Boolean{ var _local2:MUCStatus; for each (_local2 in statuses) { if (_local2.code == _arg1){ return (true); }; }; return (false); } public function destroy(_arg1:JID, _arg2:String):void{ updateActionNode(DESTROY_TYPE, {jid:_arg1.toString()}, _arg2); } public function get to():JID{ return (new JID(myActionNode.attributes.to)); } public function decline(_arg1:JID, _arg2:JID, _arg3:String):void{ updateActionNode(DECLINE_TYPE, {to:_arg1.toString(), from:(_arg2) ? _arg2.toString() : null}, _arg3); } } }//package org.jivesoftware.xiff.data.muc
Section 171
//RegisterExtension (org.jivesoftware.xiff.data.register.RegisterExtension) package org.jivesoftware.xiff.data.register { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class RegisterExtension extends Extension implements IExtension, ISerializable { private var myFields:Object; private var myInstructionsNode:XMLNode; private var myKeyNode:XMLNode; private var myRemoveNode:XMLNode; public static var NS:String = "jabber:iq:register"; private static var staticDepends:Class = ExtensionClassRegistry; public static var ELEMENT:String = "query"; public function RegisterExtension(_arg1:XMLNode=null){ super(_arg1); myFields = new Object(); } public function getElementName():String{ return (RegisterExtension.ELEMENT); } public function set unregister(_arg1:Boolean):void{ myRemoveNode = replaceTextNode(getNode(), myRemoveNode, "remove", ""); } public function get state():String{ return (getField("state")); } public function get last():String{ return (getField("last")); } public function getNS():String{ return (RegisterExtension.NS); } public function get email():String{ return (getField("email")); } public function get zip():String{ return (getField("zip")); } public function get instructions():String{ return (myInstructionsNode.firstChild.nodeValue); } public function set state(_arg1:String):void{ setField("state", _arg1); } public function get password():String{ return (getField("password")); } public function set last(_arg1:String):void{ setField("last", _arg1); } public function get text():String{ return (getField("text")); } public function get date():String{ return (getField("date")); } public function get first():String{ return (getField("first")); } public function set username(_arg1:String):void{ setField("username", _arg1); } public function set password(_arg1:String):void{ setField("password", _arg1); } public function setField(_arg1:String, _arg2:String):void{ myFields[_arg1] = replaceTextNode(getNode(), myFields[_arg1], _arg1, _arg2); } public function get unregister():Boolean{ return (exists(myRemoveNode)); } public function set key(_arg1:String):void{ myKeyNode = replaceTextNode(getNode(), myKeyNode, "key", _arg1); } public function set email(_arg1:String):void{ setField("email", _arg1); } public function set zip(_arg1:String):void{ setField("zip", _arg1); } public function getField(_arg1:String):String{ return (myFields[_arg1].firstChild.nodeValue); } public function set nick(_arg1:String):void{ setField("nick", _arg1); } public function set instructions(_arg1:String):void{ myInstructionsNode = replaceTextNode(getNode(), myInstructionsNode, "instructions", _arg1); } public function get username():String{ return (getField("username")); } public function set misc(_arg1:String):void{ setField("misc", _arg1); } public function set text(_arg1:String):void{ setField("text", _arg1); } public function set phone(_arg1:String):void{ setField("phone", _arg1); } public function set city(_arg1:String):void{ setField("city", _arg1); } public function set url(_arg1:String):void{ setField("url", _arg1); } public function get key():String{ return (myKeyNode.firstChild.nodeValue); } public function serialize(_arg1:XMLNode):Boolean{ if (!exists(getNode().parentNode)){ _arg1.appendChild(getNode().cloneNode(true)); }; return (true); } public function getRequiredFieldNames():Array{ var _local2:String; var _local1:Array = new Array(); for (_local2 in myFields) { _local1.push(_local2); }; return (_local1); } public function set address(_arg1:String):void{ setField("address", _arg1); } public function get city():String{ return (getField("city")); } public function get misc():String{ return (getField("misc")); } public function get phone():String{ return (getField("phone")); } public function get url():String{ return (getField("url")); } public function get address():String{ return (getField("address")); } public function set first(_arg1:String):void{ setField("first", _arg1); } public function get nick():String{ return (getField("nick")); } public function set date(_arg1:String):void{ setField("date", _arg1); } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; setNode(_arg1); var _local2:Array = getNode().childNodes; for (_local3 in _local2) { switch (_local2[_local3].nodeName){ case "key": myKeyNode = _local2[_local3]; break; case "instructions": myInstructionsNode = _local2[_local3]; break; case "remove": myRemoveNode = _local2[_local3]; break; default: myFields[_local2[_local3].nodeName] = _local2[_local3]; break; }; }; return (true); } public static function enable():void{ ExtensionClassRegistry.register(RegisterExtension); } } }//package org.jivesoftware.xiff.data.register
Section 172
//SessionExtension (org.jivesoftware.xiff.data.session.SessionExtension) package org.jivesoftware.xiff.data.session { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class SessionExtension extends Extension implements IExtension, ISerializable { private var jid:String; public static var NS:String = "urn:ietf:params:xml:ns:xmpp-session"; public static var ELEMENT_NAME:String = "session"; public function SessionExtension(_arg1:XMLNode=null){ super(_arg1); } public function serialize(_arg1:XMLNode):Boolean{ var _local2:XMLNode; if (!exists(getNode().parentNode)){ _local2 = getNode().cloneNode(true); _arg1.appendChild(_local2); }; return (true); } public function getElementName():String{ return (SessionExtension.ELEMENT_NAME); } public function getNS():String{ return (SessionExtension.NS); } public function deserialize(_arg1:XMLNode):Boolean{ setNode(_arg1); return (true); } public function getJID():String{ return (jid); } public static function enable():void{ ExtensionClassRegistry.register(SessionExtension); } } }//package org.jivesoftware.xiff.data.session
Section 173
//XHTMLExtension (org.jivesoftware.xiff.data.xhtml.XHTMLExtension) package org.jivesoftware.xiff.data.xhtml { import flash.xml.*; import org.jivesoftware.xiff.data.*; public class XHTMLExtension extends Extension implements IExtension { public static var NS:String = "http://www.w3.org/1999/xhtml"; private static var staticDepends:Class = ExtensionClassRegistry; public static var ELEMENT:String = "html"; public function XHTMLExtension(_arg1:XMLNode=null){ super(_arg1); } public function get body():String{ var _local3:String; var _local1:Array = new Array(); var _local2:Array = getNode().childNodes; for (_local3 in _local2) { _local1.push(_local2[_local3].toString()); }; _local1.reverse(); return (_local1.join()); } public function set body(_arg1:String):void{ var _local3:String; var _local2:Array = getNode().childNodes; for (_local3 in _local2) { _local2[_local3].removeNode(); }; getNode().appendChild(new XMLDocument(_arg1)); } public function getElementName():String{ return (XHTMLExtension.ELEMENT); } public function getNS():String{ return (XHTMLExtension.NS); } public static function enable():void{ ExtensionClassRegistry.register(XHTMLExtension); } } }//package org.jivesoftware.xiff.data.xhtml
Section 174
//Extension (org.jivesoftware.xiff.data.Extension) package org.jivesoftware.xiff.data { import flash.xml.*; public class Extension extends XMLStanza { public function Extension(_arg1:XMLNode=null){ getNode().nodeName = IExtension(this).getElementName(); getNode().attributes.xmlns = IExtension(this).getNS(); if (exists(_arg1)){ _arg1.appendChild(getNode()); }; } public function remove():void{ getNode().removeNode(); } public function toString():String{ return (getNode().toString()); } } }//package org.jivesoftware.xiff.data
Section 175
//ExtensionClassRegistry (org.jivesoftware.xiff.data.ExtensionClassRegistry) package org.jivesoftware.xiff.data { public class ExtensionClassRegistry { private static var myClasses:Array = new Array(); public static function register(_arg1:Class):Boolean{ var _local2:IExtension = new (_arg1); if ((_local2 is IExtension)){ myClasses[_local2.getNS()] = _arg1; return (true); }; return (false); } public static function lookup(_arg1:String):Class{ return (myClasses[_arg1]); } } }//package org.jivesoftware.xiff.data
Section 176
//ExtensionContainer (org.jivesoftware.xiff.data.ExtensionContainer) package org.jivesoftware.xiff.data { public class ExtensionContainer implements IExtendable { public var _exts:Object; public function ExtensionContainer(){ _exts = new Object(); } public function removeAllExtensions(_arg1:String):void{ var _local2:String; for (_local2 in _exts[_arg1]) { _exts[_arg1][_local2].ns(); }; _exts[_arg1] = new Array(); } public function getAllExtensionsByNS(_arg1:String):Array{ return (_exts[_arg1]); } public function getExtension(_arg1:String):Extension{ var name = _arg1; return (getAllExtensions().filter(function (_arg1:IExtension, _arg2:int, _arg3:Array):Boolean{ return ((_arg1.getElementName() == name)); })[0]); } public function removeExtension(_arg1:IExtension):Boolean{ var _local3:String; var _local2:Object = _exts[_arg1.getNS()]; for (_local3 in _local2) { if (_local2[_local3] === _arg1){ _local2[_local3].remove(); _local2.splice(Number(_local3), 1); return (true); }; }; return (false); } public function addExtension(_arg1:IExtension):IExtension{ if (_exts[_arg1.getNS()] == null){ _exts[_arg1.getNS()] = new Array(); }; _exts[_arg1.getNS()].push(_arg1); return (_arg1); } public function getAllExtensions():Array{ var _local2:String; var _local1:Array = new Array(); for (_local2 in _exts) { _local1 = _local1.concat(_exts[_local2]); }; return (_local1); } } }//package org.jivesoftware.xiff.data
Section 177
//IExtendable (org.jivesoftware.xiff.data.IExtendable) package org.jivesoftware.xiff.data { public interface IExtendable { function removeAllExtensions(_arg1:String):void; function getAllExtensionsByNS(_arg1:String):Array; function removeExtension(_arg1:IExtension):Boolean; function addExtension(_arg1:IExtension):IExtension; function getAllExtensions():Array; } }//package org.jivesoftware.xiff.data
Section 178
//IExtension (org.jivesoftware.xiff.data.IExtension) package org.jivesoftware.xiff.data { public interface IExtension { function getElementName():String; function getNS():String; } }//package org.jivesoftware.xiff.data
Section 179
//INodeProxy (org.jivesoftware.xiff.data.INodeProxy) package org.jivesoftware.xiff.data { import flash.xml.*; public interface INodeProxy { function getNode():XMLNode; function setNode(_arg1:XMLNode):Boolean; } }//package org.jivesoftware.xiff.data
Section 180
//IQ (org.jivesoftware.xiff.data.IQ) package org.jivesoftware.xiff.data { import flash.xml.*; import org.jivesoftware.xiff.core.*; public class IQ extends XMPPStanza implements ISerializable { private var myCallbackScope:Object; private var myQueryName:String; private var myCallback:String; private var myCallbackFunc:Function; private var myQueryFields:Array; public static var ERROR_TYPE:String = "error"; public static var GET_TYPE:String = "get"; public static var SET_TYPE:String = "set"; public static var RESULT_TYPE:String = "result"; public function IQ(_arg1:JID=null, _arg2:String=null, _arg3:String=null, _arg4:String=null, _arg5:Object=null, _arg6:Function=null){ var _local7:String = (exists(_arg3)) ? _arg3 : generateID("iq_"); super(_arg1, null, _arg2, _local7, "iq"); callbackName = _arg4; callbackScope = _arg5; callback = _arg6; } override public function serialize(_arg1:XMLNode):Boolean{ return (super.serialize(_arg1)); } public function get callback():Function{ return (myCallbackFunc); } public function set callback(_arg1:Function):void{ myCallbackFunc = _arg1; } public function get callbackName():String{ return (myCallback); } public function get callbackScope():Object{ return (myCallbackScope); } public function set callbackName(_arg1:String):void{ myCallback = _arg1; } public function set callbackScope(_arg1:Object):void{ myCallbackScope = _arg1; } override public function deserialize(_arg1:XMLNode):Boolean{ return (super.deserialize(_arg1)); } } }//package org.jivesoftware.xiff.data
Section 181
//ISerializable (org.jivesoftware.xiff.data.ISerializable) package org.jivesoftware.xiff.data { import flash.xml.*; public interface ISerializable { function serialize(_arg1:XMLNode):Boolean; function deserialize(_arg1:XMLNode):Boolean; } }//package org.jivesoftware.xiff.data
Section 182
//Message (org.jivesoftware.xiff.data.Message) package org.jivesoftware.xiff.data { import flash.xml.*; import org.jivesoftware.xiff.core.*; import org.jivesoftware.xiff.data.muc.*; import org.jivesoftware.xiff.data.xhtml.*; public class Message extends XMPPStanza implements ISerializable { private var mySubjectNode:XMLNode; private var myTimeStampNode:XMLNode; private var myBodyNode:XMLNode; private var myThreadNode:XMLNode; public static var CHAT_TYPE:String = "chat"; public static var HEADLINE_TYPE:String = "headline"; private static var isMessageStaticCalled:Boolean = MessageStaticConstructor(); public static var ERROR_TYPE:String = "error"; public static var NORMAL_TYPE:String = "normal"; private static var staticConstructorDependency:Array = [XMPPStanza, XHTMLExtension, ExtensionClassRegistry]; public static var GROUPCHAT_TYPE:String = "groupchat"; public function Message(_arg1:JID=null, _arg2:String=null, _arg3:String=null, _arg4:String=null, _arg5:String=null, _arg6:String=null){ var _local7:String = (exists(_arg2)) ? _arg2 : generateID("m_"); super(_arg1, null, _arg5, _local7, "message"); body = _arg3; htmlBody = _arg4; subject = _arg6; } public function set time(_arg1:Date):void{ } public function set thread(_arg1:String):void{ myThreadNode = replaceTextNode(getNode(), myThreadNode, "thread", _arg1); } public function set subject(_arg1:String):void{ mySubjectNode = replaceTextNode(getNode(), mySubjectNode, "subject", _arg1); } public function get body():String{ if (!exists(myBodyNode)){ return (null); }; var value = ""; try { value = myBodyNode.firstChild.nodeValue; } catch(error:Error) { trace(error.getStackTrace()); }; return (value); } public function get thread():String{ if (myThreadNode == null){ return (null); }; return (myThreadNode.firstChild.nodeValue); } public function set body(_arg1:String):void{ myBodyNode = replaceTextNode(getNode(), myBodyNode, "body", _arg1); } override public function serialize(_arg1:XMLNode):Boolean{ return (super.serialize(_arg1)); } public function get htmlBody():String{ var ext:XHTMLExtension; try { ext = getAllExtensionsByNS(XHTMLExtension.NS)[0]; return (ext.body); } catch(e:Error) { trace("Error : null trapped. Resuming."); }; return (null); } public function set htmlBody(_arg1:String):void{ var _local2:XHTMLExtension; removeAllExtensions(XHTMLExtension.NS); if (((exists(_arg1)) && ((_arg1.length > 0)))){ _local2 = new XHTMLExtension(getNode()); _local2.body = _arg1; addExtension(_local2); }; } public function get subject():String{ if (mySubjectNode == null){ return (null); }; return (mySubjectNode.firstChild.nodeValue); } public function get time():Date{ if (myTimeStampNode == null){ return (null); }; var _local1:String = myTimeStampNode.attributes.stamp; var _local2:Date = new Date(); _local2.setUTCFullYear(_local1.slice(0, 4)); _local2.setUTCMonth((Number(_local1.slice(4, 6)) - 1)); _local2.setUTCDate(_local1.slice(6, 8)); _local2.setUTCHours(_local1.slice(9, 11)); _local2.setUTCMinutes(_local1.slice(12, 14)); _local2.setUTCSeconds(_local1.slice(15, 17)); return (_local2); } override public function deserialize(_arg1:XMLNode):Boolean{ var _local3:Array; var _local4:String; var _local5:MUCUserExtension; var _local2:Boolean = super.deserialize(_arg1); if (_local2){ _local3 = _arg1.childNodes; for (_local4 in _local3) { switch (_local3[_local4].nodeName){ case "error": break; case "body": myBodyNode = _local3[_local4]; break; case "subject": mySubjectNode = _local3[_local4]; break; case "thread": myThreadNode = _local3[_local4]; break; case "x": if (_local3[_local4].attributes.xmlns == "jabber:x:delay"){ myTimeStampNode = _local3[_local4]; }; if (_local3[_local4].attributes.xmlns == MUCUserExtension.NS){ _local5 = new MUCUserExtension(getNode()); _local5.deserialize(_local3[_local4]); addExtension(_local5); }; break; }; }; }; return (_local2); } public static function MessageStaticConstructor():Boolean{ XHTMLExtension.enable(); return (true); } } }//package org.jivesoftware.xiff.data
Section 183
//Presence (org.jivesoftware.xiff.data.Presence) package org.jivesoftware.xiff.data { import flash.xml.*; import org.jivesoftware.xiff.core.*; import org.jivesoftware.xiff.data.muc.*; public class Presence extends XMPPStanza implements ISerializable { private var myStatusNode:XMLNode; private var myShowNode:XMLNode; private var myPriorityNode:XMLNode; public static const SHOW_CHAT:String = "chat"; public static const UNSUBSCRIBED_TYPE:String = "unsubscribed"; public static const SHOW_DND:String = "dnd"; public static const UNSUBSCRIBE_TYPE:String = "unsubscribe"; public static const UNAVAILABLE_TYPE:String = "unavailable"; public static const SHOW_XA:String = "xa"; public static const SUBSCRIBE_TYPE:String = "subscribe"; public static const ERROR_TYPE:String = "error"; public static const SHOW_AWAY:String = "away"; public static const PROBE_TYPE:String = "probe"; public static const SUBSCRIBED_TYPE:String = "subscribed"; public function Presence(_arg1:JID=null, _arg2:JID=null, _arg3:String=null, _arg4:String=null, _arg5:String=null, _arg6:Number=0){ super(_arg1, _arg2, _arg3, null, "presence"); show = _arg4; status = _arg5; priority = _arg6; } public function get role():String{ var _local1:Array = getAllExtensionsByNS(MUCUserExtension.NS); var _local2:MUCItem = _local1[0].getAllItems()[0]; return (_local2.role); } override public function deserialize(_arg1:XMLNode):Boolean{ var _local3:Array; var _local4:String; var _local2:Boolean = super.deserialize(_arg1); if (_local2){ _local3 = _arg1.childNodes; for (_local4 in _local3) { switch (_local3[_local4].nodeName){ case "show": myShowNode = _local3[_local4]; break; case "status": myStatusNode = _local3[_local4]; break; case "priority": myPriorityNode = _local3[_local4]; break; }; }; }; return (_local2); } public function set priority(_arg1:Number):void{ myPriorityNode = replaceTextNode(getNode(), myPriorityNode, "priority", _arg1.toString()); } public function get priority():Number{ if (myPriorityNode == null){ return (NaN); }; var _local1:Number = Number(myPriorityNode.firstChild.nodeValue); if (isNaN(_local1)){ return (NaN); }; return (_local1); } override public function serialize(_arg1:XMLNode):Boolean{ return (super.serialize(_arg1)); } public function get status():String{ if ((((myStatusNode == null)) || ((myStatusNode.firstChild == null)))){ return (null); }; return (myStatusNode.firstChild.nodeValue); } public function set show(_arg1:String):void{ if (((((((((((!((_arg1 == SHOW_AWAY))) && (!((_arg1 == SHOW_CHAT))))) && (!((_arg1 == SHOW_DND))))) && (!((_arg1 == SHOW_XA))))) && (!((_arg1 == null))))) && (!((_arg1 == ""))))){ throw (new Error((("Invalid show value: " + _arg1) + " for presence"))); }; if (((myShowNode) && ((((_arg1 == null)) || ((_arg1 == "")))))){ myShowNode.removeNode(); myShowNode = null; }; myShowNode = replaceTextNode(getNode(), myShowNode, "show", _arg1); } public function set status(_arg1:String):void{ myStatusNode = replaceTextNode(getNode(), myStatusNode, "status", _arg1); } public function get show():String{ if (((!(myShowNode)) || (!(exists(myShowNode.firstChild))))){ return (null); }; return (myShowNode.firstChild.nodeValue); } } }//package org.jivesoftware.xiff.data
Section 184
//XMLStanza (org.jivesoftware.xiff.data.XMLStanza) package org.jivesoftware.xiff.data { import flash.xml.*; public class XMLStanza extends ExtensionContainer implements INodeProxy, IExtendable { private var myXML:XMLNode; public static var XMLFactory:XMLDocument = new XMLDocument(); public function XMLStanza(){ myXML = XMLStanza.XMLFactory.createElement(""); } public function addTextNode(_arg1:XMLNode, _arg2:String, _arg3:String):XMLNode{ var _local4:XMLNode = XMLStanza.XMLFactory.createElement(_arg2); _local4.appendChild(XMLFactory.createTextNode(_arg3)); _arg1.appendChild(_local4); return (_local4); } public function setNode(_arg1:XMLNode):Boolean{ var _local2:XMLNode = myXML.parentNode; myXML.removeNode(); myXML = _arg1; if (((exists(myXML)) && (!((_local2 == null))))){ _local2.appendChild(myXML); }; return (true); } public function ensureNode(_arg1:XMLNode, _arg2:String):XMLNode{ if (!exists(_arg1)){ _arg1 = XMLStanza.XMLFactory.createElement(_arg2); getNode().appendChild(_arg1); }; return (_arg1); } public function getNode():XMLNode{ return (myXML); } public function replaceTextNode(_arg1:XMLNode, _arg2:XMLNode, _arg3:String, _arg4:String):XMLNode{ var _local5:XMLNode; if (_arg2 != null){ _arg2.removeNode(); }; if (exists(_arg4)){ _local5 = XMLStanza.XMLFactory.createElement(_arg3); if (_arg4.length > 0){ _local5.appendChild(XMLStanza.XMLFactory.createTextNode(_arg4)); }; _arg1.appendChild(_local5); }; return (_local5); } public static function exists(_arg1):Boolean{ if (((!((_arg1 == null))) && (!((_arg1 === undefined))))){ return (true); }; return (false); } } }//package org.jivesoftware.xiff.data
Section 185
//XMPPStanza (org.jivesoftware.xiff.data.XMPPStanza) package org.jivesoftware.xiff.data { import flash.xml.*; import org.jivesoftware.xiff.data.id.*; import org.jivesoftware.xiff.core.*; public dynamic class XMPPStanza extends XMLStanza implements ISerializable, IExtendable { private var myErrorNode:XMLNode; private var myErrorConditionNode:XMLNode; private static var staticDependencies = [IncrementalGenerator, ExtensionContainer]; public static var CLIENT_NS:String = "jabber:client"; private static var isStaticConstructed = XMPPStanzaStaticConstructor(); public function XMPPStanza(_arg1:JID, _arg2:JID, _arg3:String, _arg4:String, _arg5:String){ getNode().nodeName = _arg5; to = _arg1; from = _arg2; type = _arg3; id = _arg4; } public function get type():String{ return (getNode().attributes.type); } public function set errorType(_arg1:String):void{ myErrorNode = ensureNode(myErrorNode, "error"); delete myErrorNode.attributes.type; if (exists(_arg1)){ myErrorNode.attributes.type = _arg1; }; } public function set from(_arg1:JID):void{ delete getNode().attributes.from; if (exists(_arg1)){ getNode().attributes.from = _arg1.toString(); }; } public function get errorCode():Number{ return (Number(myErrorNode.attributes.code)); } public function get id():String{ return (getNode().attributes.id); } public function get errorMessage():String{ if (exists(errorCondition)){ return (errorCondition.toString()); }; return (myErrorNode.firstChild.nodeValue); } public function serialize(_arg1:XMLNode):Boolean{ var _local4:ISerializable; var _local2:XMLNode = getNode(); var _local3:Array = getAllExtensions(); for each (_local4 in _local3) { _local4.serialize(_local2); }; if (!exists(_local2.parentNode)){ _local2 = _local2.cloneNode(true); _arg1.appendChild(_local2); }; return (true); } public function get errorType():String{ return (myErrorNode.attributes.type); } public function set errorCondition(_arg1:String):void{ myErrorNode = ensureNode(myErrorNode, "error"); var _local2:Object = myErrorNode.attributes; var _local3:String = errorMessage; if (exists(_arg1)){ myErrorNode = replaceTextNode(getNode(), myErrorNode, "error", ""); myErrorConditionNode = addTextNode(myErrorNode, _arg1, _local3); } else { myErrorNode = replaceTextNode(getNode(), myErrorNode, "error", _local3); }; myErrorNode.attributes = _local2; } public function get from():JID{ return (new JID(getNode().attributes.from)); } public function set errorCode(_arg1:Number):void{ myErrorNode = ensureNode(myErrorNode, "error"); delete myErrorNode.attributes.code; if (exists(_arg1)){ myErrorNode.attributes.code = _arg1; }; } public function get errorCondition():String{ if (exists(myErrorConditionNode)){ return (myErrorConditionNode.nodeName); }; return (null); } public function set type(_arg1:String):void{ delete getNode().attributes.type; if (exists(_arg1)){ getNode().attributes.type = _arg1; }; } public function set id(_arg1:String):void{ delete getNode().attributes.id; if (exists(_arg1)){ getNode().attributes.id = _arg1; }; } public function get to():JID{ return (new JID(getNode().attributes.to)); } public function set to(_arg1:JID):void{ delete getNode().attributes.to; if (exists(_arg1)){ getNode().attributes.to = _arg1.toString(); }; } public function set errorMessage(_arg1:String):void{ var _local2:Object; myErrorNode = ensureNode(myErrorNode, "error"); _arg1 = (exists(_arg1)) ? _arg1 : ""; if (exists(errorCondition)){ myErrorConditionNode = replaceTextNode(myErrorNode, myErrorConditionNode, errorCondition, _arg1); } else { _local2 = myErrorNode.attributes; myErrorNode = replaceTextNode(getNode(), myErrorNode, "error", _arg1); myErrorNode.attributes = _local2; }; } public function deserialize(_arg1:XMLNode):Boolean{ var _local3:String; var _local4:String; var _local5:String; var _local6:Class; var _local7:IExtension; setNode(_arg1); var _local2:Array = _arg1.childNodes; for (_local3 in _local2) { _local4 = _local2[_local3].nodeName; _local5 = _local2[_local3].attributes.xmlns; _local5 = (exists(_local5)) ? _local5 : CLIENT_NS; if (_local4 == "error"){ myErrorNode = _local2[_local3]; if (exists(myErrorNode.firstChild.nodeName)){ myErrorConditionNode = myErrorNode.firstChild; }; } else { _local6 = ExtensionClassRegistry.lookup(_local5); if (_local6 != null){ _local7 = new (_local6); ISerializable(_local7).deserialize(_local2[_local3]); addExtension(_local7); }; }; }; return (true); } public static function generateID(_arg1:String):String{ var _local2:String = IncrementalGenerator.getInstance().getID(_arg1); return (_local2); } public static function setIDGenerator(_arg1:IIDGenerator):void{ } private static function XMPPStanzaStaticConstructor():void{ } } }//package org.jivesoftware.xiff.data
Section 186
//ChangePasswordSuccessEvent (org.jivesoftware.xiff.events.ChangePasswordSuccessEvent) package org.jivesoftware.xiff.events { import flash.events.*; public class ChangePasswordSuccessEvent extends Event { public static var PASSWORD_SUCCESS:String = "changePasswordSuccess"; public function ChangePasswordSuccessEvent(){ super(ChangePasswordSuccessEvent.PASSWORD_SUCCESS, false, false); } } }//package org.jivesoftware.xiff.events
Section 187
//ConnectionSuccessEvent (org.jivesoftware.xiff.events.ConnectionSuccessEvent) package org.jivesoftware.xiff.events { import flash.events.*; public class ConnectionSuccessEvent extends Event { public static var CONNECT_SUCCESS:String = "connection"; public function ConnectionSuccessEvent(){ super(_slot1.CONNECT_SUCCESS, false, false); } } }//package org.jivesoftware.xiff.events
Section 188
//DisconnectionEvent (org.jivesoftware.xiff.events.DisconnectionEvent) package org.jivesoftware.xiff.events { import flash.events.*; public class DisconnectionEvent extends Event { public static var DISCONNECT:String = "disconnection"; public function DisconnectionEvent(){ super(_slot1.DISCONNECT, false, false); } } }//package org.jivesoftware.xiff.events
Section 189
//IncomingDataEvent (org.jivesoftware.xiff.events.IncomingDataEvent) package org.jivesoftware.xiff.events { import flash.xml.*; import flash.events.*; public class IncomingDataEvent extends Event { private var _data:XMLDocument; public static var INCOMING_DATA:String = "incomingData"; public function IncomingDataEvent(){ super(IncomingDataEvent.INCOMING_DATA, false, false); } public function get data():XMLDocument{ return (_data); } public function set data(_arg1:XMLDocument):void{ _data = _arg1; } } }//package org.jivesoftware.xiff.events
Section 190
//IQEvent (org.jivesoftware.xiff.events.IQEvent) package org.jivesoftware.xiff.events { import org.jivesoftware.xiff.data.*; import flash.events.*; public class IQEvent extends Event { private var _iq:IQ; private var _data:IExtension; public function IQEvent(_arg1:String){ super(_arg1, false, false); } public function set iq(_arg1:IQ):void{ _iq = _arg1; } public function set data(_arg1:IExtension):void{ _data = _arg1; } public function get iq():IQ{ return (_iq); } public function get data():IExtension{ return (_data); } } }//package org.jivesoftware.xiff.events
Section 191
//LoginEvent (org.jivesoftware.xiff.events.LoginEvent) package org.jivesoftware.xiff.events { import flash.events.*; public class LoginEvent extends Event { public static var LOGIN:String = "login"; public function LoginEvent(){ super(_slot1.LOGIN, false, false); } } }//package org.jivesoftware.xiff.events
Section 192
//MessageEvent (org.jivesoftware.xiff.events.MessageEvent) package org.jivesoftware.xiff.events { import org.jivesoftware.xiff.data.*; import flash.events.*; public class MessageEvent extends Event { private var _data:Message; public static var MESSAGE:String = "message"; public function MessageEvent(){ super(MessageEvent.MESSAGE, false, false); } public function get data():Message{ return (_data); } public function set data(_arg1:Message):void{ _data = _arg1; } } }//package org.jivesoftware.xiff.events
Section 193
//OutgoingDataEvent (org.jivesoftware.xiff.events.OutgoingDataEvent) package org.jivesoftware.xiff.events { import flash.events.*; public class OutgoingDataEvent extends Event { private var _data; public static var OUTGOING_DATA:String = "outgoingData"; public function OutgoingDataEvent(){ super(_slot1.OUTGOING_DATA, false, false); } public function get data(){ return (_data); } public function set data(_arg1):void{ _data = _arg1; } } }//package org.jivesoftware.xiff.events
Section 194
//PresenceEvent (org.jivesoftware.xiff.events.PresenceEvent) package org.jivesoftware.xiff.events { import flash.events.*; public class PresenceEvent extends Event { private var _data:Array; public static var PRESENCE:String = "presence"; public function PresenceEvent(){ super(PresenceEvent.PRESENCE, bubbles, cancelable); } public function get data():Array{ return (_data); } public function set data(_arg1:Array):void{ _data = _arg1; } } }//package org.jivesoftware.xiff.events
Section 195
//RegistrationFieldsEvent (org.jivesoftware.xiff.events.RegistrationFieldsEvent) package org.jivesoftware.xiff.events { import flash.events.*; import org.jivesoftware.xiff.data.register.*; public class RegistrationFieldsEvent extends Event { private var _fields:Array; private var _data:RegisterExtension; public static var REG_FIELDS:String = "registrationFields"; public function RegistrationFieldsEvent(){ super(RegistrationFieldsEvent.REG_FIELDS, false, false); } public function get fields():Array{ return (_fields); } public function set fields(_arg1:Array):void{ _fields = _arg1; } public function set data(_arg1:RegisterExtension):void{ _data = _arg1; } public function get data():RegisterExtension{ return (_data); } } }//package org.jivesoftware.xiff.events
Section 196
//RegistrationSuccessEvent (org.jivesoftware.xiff.events.RegistrationSuccessEvent) package org.jivesoftware.xiff.events { import flash.events.*; public class RegistrationSuccessEvent extends Event { public static var REGISTRATION_SUCCESS:String = "registrationSuccess"; public function RegistrationSuccessEvent(){ super(RegistrationSuccessEvent.REGISTRATION_SUCCESS, false, false); } } }//package org.jivesoftware.xiff.events
Section 197
//RoomEvent (org.jivesoftware.xiff.events.RoomEvent) package org.jivesoftware.xiff.events { import org.jivesoftware.xiff.data.*; import flash.events.*; public class RoomEvent extends Event { private var _message:Message; private var _data; private var _nickname:String; private var _errorCode:Number; private var _from:String; private var _errorCondition:String; private var _errorType:String; private var _reason:String; private var _subject:String; private var _errorMessage:String; public static const AFFILIATIONS:String = "affiliations"; public static const PASSWORD_ERROR:String = "passwordError"; public static const GROUP_MESSAGE:String = "groupMessage"; public static const SUBJECT_CHANGE:String = "subjectChange"; public static const PRIVATE_MESSAGE:String = "privateMessage"; public static const ROOM_JOIN:String = "roomJoin"; public static const USER_BANNED:String = "userBanned"; public static const MAX_USERS_ERROR:String = "maxUsersError"; public static const ADMIN_ERROR:String = "adminError"; public static const USER_KICKED:String = "userKicked"; public static const USER_JOIN:String = "userJoin"; public static const BANNED_ERROR:String = "bannedError"; public static const USER_DEPARTURE:String = "userDeparture"; public static const REGISTRATION_REQ_ERROR:String = "registrationReqError"; public static const USER_CHANGED:String = "userChanged"; public static const NICK_CONFLICT:String = "nickConflict"; public static const ROOM_LEAVE:String = "roomLeave"; public static const CONFIGURE_ROOM:String = "configureForm"; public static const DECLINED:String = "declined"; public static const LOCKED_ERROR:String = "lockedError"; public function RoomEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){ super(_arg1, _arg2, _arg3); } public function get errorCondition():String{ return (_errorCondition); } public function set errorType(_arg1:String):void{ _errorType = _arg1; } public function set errorMessage(_arg1:String):void{ _errorMessage = _arg1; } public function get message():Message{ return (_message); } public function get reason():String{ return (_reason); } public function get from():String{ return (_from); } public function set message(_arg1:Message):void{ _message = _arg1; } public function set reason(_arg1:String):void{ _reason = _arg1; } public function set data(_arg1):void{ _data = _arg1; } public function set from(_arg1:String):void{ _from = _arg1; } public function get errorCode():Number{ return (_errorCode); } public function set subject(_arg1:String):void{ _subject = _arg1; } public function get errorType():String{ return (_errorType); } public function set errorCondition(_arg1:String):void{ _errorCondition = _arg1; } public function set nickname(_arg1:String):void{ _nickname = _arg1; } public function get errorMessage():String{ return (_errorMessage); } public function get data(){ return (_data); } public function get subject():String{ return (_subject); } public function get nickname():String{ return (_nickname); } public function set errorCode(_arg1:Number):void{ _errorCode = _arg1; } } }//package org.jivesoftware.xiff.events
Section 198
//XIFFErrorEvent (org.jivesoftware.xiff.events.XIFFErrorEvent) package org.jivesoftware.xiff.events { import flash.events.*; public class XIFFErrorEvent extends Event { private var _errorType:String; private var _errorMessage:String; private var _errorCondition:String; private var _errorCode:Number; public static var XIFF_ERROR:String = "error"; public function XIFFErrorEvent(){ super(XIFFErrorEvent.XIFF_ERROR, false, false); } public function get errorType():String{ return (_errorType); } public function set errorCondition(_arg1:String):void{ _errorCondition = _arg1; } public function set errorCode(_arg1:Number):void{ _errorCode = _arg1; } public function set errorType(_arg1:String):void{ _errorType = _arg1; } public function get errorCondition():String{ return (_errorCondition); } public function get errorCode():Number{ return (_errorCode); } public function set errorMessage(_arg1:String):void{ _errorMessage = _arg1; } public function get errorMessage():String{ return (_errorMessage); } } }//package org.jivesoftware.xiff.events
Section 199
//SerializationException (org.jivesoftware.xiff.exception.SerializationException) package org.jivesoftware.xiff.exception { public class SerializationException extends Error { private static var MSG:String = "Could not properly serialize/deserialize stanza."; public function SerializationException(){ super(MSG); } } }//package org.jivesoftware.xiff.exception
Section 200
//SocketConn (org.jivesoftware.xiff.util.SocketConn) package org.jivesoftware.xiff.util { import flash.events.*; import com.kongregate.as3.common.util.*; import flash.utils.*; import flash.net.*; import com.wirelust.as3zlib.*; public class SocketConn extends Socket { private var compressed:Boolean; private var totalIncomingUncompressedBytes:uint;// = 0 private var totalIncomingBytes:uint;// = 0 private var deflateStream:ZStream; private var totalOutgoingUncompressedBytes:uint;// = 0 private var remainingBytes:ByteArray; private var flashClient:Boolean;// = false private var inflateStream:ZStream; private var inputBuffer:ByteArray; private var totalOutgoingBytes:uint;// = 0 public function SocketConn(_arg1:String=null, _arg2:int=0){ inflateStream = new ZStream(); deflateStream = new ZStream(); remainingBytes = new ByteArray(); inputBuffer = new ByteArray(); super(_arg1, _arg2); addEventListener(ProgressEvent.SOCKET_DATA, onRead); } public function sendString(_arg1:String):void{ if (compressed){ sendCompressedString(_arg1); } else { writeUTFBytes(_arg1); }; flush(); } public function set compress(_arg1:Boolean):void{ compressed = _arg1; } public function get incomingCompressionRatio():int{ if (compressed){ return (int(((1 - (Number(totalIncomingBytes) / Number(totalIncomingUncompressedBytes))) * 100))); }; return (0); } private function parseNormalInputBuffer():void{ inputBuffer.position = 0; var _local1:String = inputBuffer.readUTFBytes(inputBuffer.bytesAvailable); onSockRead(_local1); } public function get outgoingCompressionRatio():int{ if (compressed){ return (int(((1 - (Number(totalOutgoingBytes) / Number(totalOutgoingUncompressedBytes))) * 100))); }; return (0); } private function readCompressedData():void{ var _local1:ByteArray = new ByteArray(); readBytes(_local1, _local1.position, bytesAvailable); var _local2:ByteArray = inflate(_local1); inputBuffer.writeBytes(_local2); totalIncomingBytes = (totalIncomingBytes + _local1.length); totalIncomingUncompressedBytes = (totalIncomingUncompressedBytes + _local2.length); } private function sendCompressedString(_arg1:String):void{ var _local2:ByteArray = new ByteArray(); _local2.writeUTFBytes(_arg1); var _local3:ByteArray = deflate(_local2); writeBytes(_local3, 0, _local3.length); totalOutgoingBytes = (totalOutgoingBytes + _local3.length); totalOutgoingUncompressedBytes = (totalOutgoingUncompressedBytes + _local2.length); } private function onRead(_arg1:ProgressEvent):void{ var _local2:ByteArray; if (compressed){ readCompressedData(); } else { if (flashClient){ _local2 = new ByteArray(); readBytes(_local2); inputBuffer.writeBytes(_local2); } else { onSockRead(readUTFBytes(bytesAvailable)); return; }; }; parseInputBuffer(); } private function resetCompression():void{ if (deflateStream){ deflateStream.deflateEnd(); }; deflateStream = new ZStream(); deflateStream.deflateInitWithIntInt(JZlib.Z_BEST_COMPRESSION, 12); if (inflateStream){ inflateStream.inflateEnd(); }; inflateStream = new ZStream(); inflateStream.inflateInit(); } public function inflate(_arg1:ByteArray):ByteArray{ var _local2:ByteArray; _local2 = new ByteArray(); inflateStream.next_in = _arg1; inflateStream.next_in_index = 0; inflateStream.avail_in = _arg1.length; inflateStream.next_out = _local2; inflateStream.next_out_index = 0; inflateStream.avail_out = (_arg1.length * 10); var _local3:int; do { _local3 = inflateStream.inflate(JZlib.Z_SYNC_FLUSH); switch (_local3){ case JZlib.Z_OK: break; case JZlib.Z_BUF_ERROR: inflateStream.avail_out = (_arg1.length * 10); break; default: Log.error(("Error during decompression: " + _local3)); return (null); }; } while (inflateStream.avail_in > 0); _local2.position = 0; return (_local2); } public function set flash(_arg1:Boolean):void{ flashClient = _arg1; } private function onSockRead(_arg1:String):void{ var _local2:SocketDataEvent = new SocketDataEvent(); _local2.data = _arg1; dispatchEvent(_local2); } private function deflate(_arg1:ByteArray):ByteArray{ var _local2:int = (Math.round((_arg1.length * 1.135)) + 13); var _local3:ByteArray = new ByteArray(); deflateStream.next_in = _arg1; deflateStream.next_in_index = 0; deflateStream.avail_in = _arg1.length; deflateStream.next_out = _local3; deflateStream.next_out_index = 0; deflateStream.avail_out = _local2; var _local4:int = deflateStream.deflate(JZlib.Z_SYNC_FLUSH); if (_local4 != JZlib.Z_OK){ _local3 = null; }; return (_local3); } private function parseFlashInputBuffer():void{ var _local5:int; inputBuffer.position = 0; var _local1:ByteArray = new ByteArray(); var _local2:int = inputBuffer.bytesAvailable; var _local3 = ""; var _local4:int; while (_local4 < _local2) { _local5 = inputBuffer.readByte(); if ((((_local5 == 0)) && ((_local1.length > 0)))){ _local1.position = 0; _local3 = (_local3 + _local1.readUTFBytes(_local1.bytesAvailable)); _local1 = new ByteArray(); } else { if (_local5 != 0){ _local1.writeByte(_local5); }; }; _local4++; }; inputBuffer = _local1; if (_local3.length > 0){ onSockRead(_local3); }; } override public function connect(_arg1:String, _arg2:int):void{ inputBuffer = new ByteArray(); resetCompression(); super.connect(_arg1, _arg2); } private function parseInputBuffer():void{ if (flashClient){ parseFlashInputBuffer(); } else { parseNormalInputBuffer(); }; } } }//package org.jivesoftware.xiff.util
Section 201
//SocketDataEvent (org.jivesoftware.xiff.util.SocketDataEvent) package org.jivesoftware.xiff.util { import flash.events.*; public class SocketDataEvent extends Event { private var _data:String; public static var SOCKET_DATA_RECEIVED:String = "socketDataReceived"; public function SocketDataEvent(){ super(SOCKET_DATA_RECEIVED, false, false); } public function get data():String{ return (_data); } public function set data(_arg1:String):void{ _data = _arg1; } } }//package org.jivesoftware.xiff.util
Section 202
//_CompiledResourceBundleInfo (_CompiledResourceBundleInfo) package { public class _CompiledResourceBundleInfo { public static function get compiledLocales():Array{ return (["en_US"]); } public static function get compiledResourceBundleNames():Array{ return (["collections"]); } } }//package
Section 203
//en_US$collections_properties (en_US$collections_properties) package { import mx.resources.*; public class en_US$collections_properties extends ResourceBundle { public function en_US$collections_properties(){ super("en_US", "collections"); } override protected function getContent():Object{ var _local1:Object = {findCondition:"Find criteria must contain all sort fields leading up to '{0}'.", noComparatorSortField:"Cannot determine comparator for SortField with name '{0}'.", outOfBounds:"Index '{0}' specified is out of bounds.", nonUnique:"Non-unique values in items.", incorrectAddition:"Attempt to add an item already in the view.", findRestriction:"Find criteria must contain at least one sort field value.", invalidType:"Incorrect type. Must be of type XML or a XMLList that contains one XML object. ", unknownMode:"Unknown find mode.", invalidIndex:"Invalid index: '{0}'.", invalidRemove:"Cannot remove when current is beforeFirst or afterLast.", unknownProperty:"Unknown Property: '{0}'.", invalidInsert:"Cannot insert when current is beforeFirst.", itemNotFound:"Cannot find when view is not sorted.", bookmarkInvalid:"Bookmark no longer valid.", noComparator:"Cannot determine comparator for '{0}'.", invalidCursor:"Cursor no longer valid.", noItems:"No items to search.", bookmarkNotFound:"Bookmark is not from this view."}; return (_local1); } } }//package

Special Tags

FileAttributes (69)Timeline Frame 1Access network only, Metadata present, AS3.
SWFMetaData (77)Timeline Frame 1458 bytes "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'><rdf:Description rdf:about='' xmlns ..."
ScriptLimits (65)Timeline Frame 1MaxRecursionDepth: 1000, ScriptTimeout: 60 seconds
SerialNumber (41)Timeline Frame 1

Labels

"com_kongregate_as3_Konduit"Frame 1




http://swfchan.com/18/87578/info.shtml
Created: 7/10 -2018 14:57:13 Last modified: 7/10 -2018 14:57:13 Server time: 18/11 -2024 21:40:55