Section 1
//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 2
//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 3
//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 4
//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 5
//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 6
//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 7
//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 8
//Room (it.gotoandplay.smartfoxserver.data.Room)
package it.gotoandplay.smartfoxserver.data {
public class Room {
private var maxSpectators:int;
private var maxUsers:int;
private var userList:Array;
private var name:String;
private var userCount:int;
private var specCount:int;
private var temp:Boolean;
private var limbo:Boolean;
private var id:int;
private var myPlayerIndex:int;
private var game:Boolean;
private var variables:Array;
private var priv:Boolean;
public function Room(_arg1:int, _arg2:String, _arg3:int, _arg4:int, _arg5:Boolean, _arg6:Boolean, _arg7:Boolean, _arg8:Boolean, _arg9:int=0, _arg10:int=0){
this.id = _arg1;
this.name = _arg2;
this.maxSpectators = _arg4;
this.maxUsers = _arg3;
this.temp = _arg5;
this.game = _arg6;
this.priv = _arg7;
this.limbo = _arg8;
this.userCount = _arg9;
this.specCount = _arg10;
this.userList = [];
this.variables = [];
}
public function getUser(_arg1):User{
var _local3:String;
var _local4:User;
var _local2:User;
if (typeof(_arg1) == "number"){
_local2 = userList[_arg1];
} else {
if (typeof(_arg1) == "string"){
for (_local3 in userList) {
_local4 = this.userList[_local3];
if (_local4.getName() == _arg1){
_local2 = _local4;
break;
};
};
};
};
return (_local2);
}
public function setUserCount(_arg1:int):void{
this.userCount = _arg1;
}
public function getMyPlayerIndex():int{
return (this.myPlayerIndex);
}
public function removeUser(_arg1:int):void{
var _local2:User = userList[_arg1];
if (((this.game) && (_local2.isSpectator()))){
specCount--;
} else {
userCount--;
};
delete userList[_arg1];
}
public function addUser(_arg1:User, _arg2:int):void{
userList[_arg2] = _arg1;
if (((this.game) && (_arg1.isSpectator()))){
specCount++;
} else {
userCount++;
};
}
public function getUserCount():int{
return (this.userCount);
}
public function getId():int{
return (this.id);
}
public function setIsLimbo(_arg1:Boolean):void{
this.limbo = _arg1;
}
public function getVariables():Array{
return (variables);
}
public function isLimbo():Boolean{
return (this.limbo);
}
public function getMaxUsers():int{
return (this.maxUsers);
}
public function getMaxSpectators():int{
return (this.maxSpectators);
}
public function getName():String{
return (this.name);
}
public function isPrivate():Boolean{
return (this.priv);
}
public function setSpectatorCount(_arg1:int):void{
this.specCount = _arg1;
}
public function clearVariables():void{
this.variables = [];
}
public function isTemp():Boolean{
return (this.temp);
}
public function setVariables(_arg1:Array):void{
this.variables = _arg1;
}
public function getSpectatorCount():int{
return (this.specCount);
}
public function getVariable(_arg1:String){
return (variables[_arg1]);
}
public function setMyPlayerIndex(_arg1:int):void{
this.myPlayerIndex = _arg1;
}
public function isGame():Boolean{
return (this.game);
}
public function clearUserList():void{
this.userList = [];
this.userCount = 0;
this.specCount = 0;
}
public function getUserList():Array{
return (this.userList);
}
}
}//package it.gotoandplay.smartfoxserver.data
Section 9
//User (it.gotoandplay.smartfoxserver.data.User)
package it.gotoandplay.smartfoxserver.data {
public class User {
private var isSpec:Boolean;
private var pId:int;
private var name:String;
private var variables:Array;
private var isMod:Boolean;
private var id:int;
public function User(_arg1:int, _arg2:String){
this.id = _arg1;
this.name = _arg2;
this.variables = [];
this.isSpec = false;
this.isMod = false;
}
public function getName():String{
return (this.name);
}
public function clearVariables():void{
this.variables = [];
}
public function getVariables():Array{
return (this.variables);
}
public function setModerator(_arg1:Boolean):void{
this.isMod = _arg1;
}
public function isSpectator():Boolean{
return (this.isSpec);
}
public function getId():int{
return (this.id);
}
public function isModerator():Boolean{
return (this.isMod);
}
public function setVariables(_arg1:Object):void{
var _local2:String;
var _local3:*;
for (_local2 in _arg1) {
_local3 = _arg1[_local2];
if (_local3 != null){
this.variables[_local2] = _local3;
} else {
delete this.variables[_local2];
};
};
}
public function getVariable(_arg1:String){
return (this.variables[_arg1]);
}
public function setIsSpectator(_arg1:Boolean):void{
this.isSpec = _arg1;
}
public function setPlayerId(_arg1:int):void{
this.pId = _arg1;
}
public function getPlayerId():int{
return (this.pId);
}
}
}//package it.gotoandplay.smartfoxserver.data
Section 10
//ExtHandler (it.gotoandplay.smartfoxserver.handlers.ExtHandler)
package it.gotoandplay.smartfoxserver.handlers {
import it.gotoandplay.smartfoxserver.*;
import it.gotoandplay.smartfoxserver.util.*;
public class ExtHandler implements IMessageHandler {
private var sfs:SmartFoxClient;
public function ExtHandler(_arg1:SmartFoxClient){
this.sfs = _arg1;
}
public function handleMessage(_arg1:Object, _arg2:String):void{
var _local3:Object;
var _local4:SFSEvent;
var _local5:XML;
var _local6:String;
var _local7:int;
var _local8:String;
var _local9:Object;
if (_arg2 == SmartFoxClient.XTMSG_TYPE_XML){
_local5 = (_arg1 as XML);
_local6 = _local5.body.@action;
_local7 = int(_local5.body.@id);
if (_local6 == "xtRes"){
_local8 = _local5.body.toString();
_local9 = ObjectSerializer.getInstance().deserialize(_local8);
_local3 = {};
_local3.dataObj = _local9;
_local3.type = _arg2;
_local4 = new SFSEvent(SFSEvent.onExtensionResponse, _local3);
sfs.dispatchEvent(_local4);
};
} else {
if (_arg2 == SmartFoxClient.XTMSG_TYPE_JSON){
_local3 = {};
_local3.dataObj = _arg1.o;
_local3.type = _arg2;
_local4 = new SFSEvent(SFSEvent.onExtensionResponse, _local3);
sfs.dispatchEvent(_local4);
} else {
if (_arg2 == SmartFoxClient.XTMSG_TYPE_STR){
_local3 = {};
_local3.dataObj = _arg1;
_local3.type = _arg2;
_local4 = new SFSEvent(SFSEvent.onExtensionResponse, _local3);
sfs.dispatchEvent(_local4);
};
};
};
}
}
}//package it.gotoandplay.smartfoxserver.handlers
Section 11
//IMessageHandler (it.gotoandplay.smartfoxserver.handlers.IMessageHandler)
package it.gotoandplay.smartfoxserver.handlers {
public interface IMessageHandler {
function handleMessage(_arg1:Object, _arg2:String):void;
}
}//package it.gotoandplay.smartfoxserver.handlers
Section 12
//SysHandler (it.gotoandplay.smartfoxserver.handlers.SysHandler)
package it.gotoandplay.smartfoxserver.handlers {
import it.gotoandplay.smartfoxserver.*;
import it.gotoandplay.smartfoxserver.data.*;
import it.gotoandplay.smartfoxserver.util.*;
import flash.utils.*;
public class SysHandler implements IMessageHandler {
private var sfs:SmartFoxClient;
private var handlersTable:Array;
public function SysHandler(_arg1:SmartFoxClient){
this.sfs = _arg1;
handlersTable = [];
handlersTable["apiOK"] = this.handleApiOK;
handlersTable["apiKO"] = this.handleApiKO;
handlersTable["logOK"] = this.handleLoginOk;
handlersTable["logKO"] = this.handleLoginKo;
handlersTable["logout"] = this.handleLogout;
handlersTable["rmList"] = this.handleRoomList;
handlersTable["uCount"] = this.handleUserCountChange;
handlersTable["joinOK"] = this.handleJoinOk;
handlersTable["joinKO"] = this.handleJoinKo;
handlersTable["uER"] = this.handleUserEnterRoom;
handlersTable["userGone"] = this.handleUserLeaveRoom;
handlersTable["pubMsg"] = this.handlePublicMessage;
handlersTable["prvMsg"] = this.handlePrivateMessage;
handlersTable["dmnMsg"] = this.handleAdminMessage;
handlersTable["modMsg"] = this.handleModMessage;
handlersTable["dataObj"] = this.handleASObject;
handlersTable["rVarsUpdate"] = this.handleRoomVarsUpdate;
handlersTable["roomAdd"] = this.handleRoomAdded;
handlersTable["roomDel"] = this.handleRoomDeleted;
handlersTable["rndK"] = this.handleRandomKey;
handlersTable["roundTripRes"] = this.handleRoundTripBench;
handlersTable["uVarsUpdate"] = this.handleUserVarsUpdate;
handlersTable["createRmKO"] = this.handleCreateRoomError;
handlersTable["bList"] = this.handleBuddyList;
handlersTable["bUpd"] = this.handleBuddyListUpdate;
handlersTable["bAdd"] = this.handleBuddyAdded;
handlersTable["roomB"] = this.handleBuddyRoom;
handlersTable["leaveRoom"] = this.handleLeaveRoom;
handlersTable["swSpec"] = this.handleSpectatorSwitched;
handlersTable["bPrm"] = this.handleAddBuddyPermission;
handlersTable["remB"] = this.handleRemoveBuddy;
}
private function populateVariables(_arg1:Array, _arg2:Object, _arg3:Array=null):void{
var _local4:XML;
var _local5:String;
var _local6:String;
var _local7:String;
for each (_local4 in _arg2.vars["var"]) {
_local5 = _local4.@n;
_local6 = _local4.@t;
_local7 = _local4;
if (_arg3 != null){
_arg3.push(_local5);
_arg3[_local5] = true;
};
if (_local6 == "b"){
_arg1[_local5] = ((_local7 == "1")) ? true : false;
} else {
if (_local6 == "n"){
_arg1[_local5] = Number(_local7);
} else {
if (_local6 == "s"){
_arg1[_local5] = _local7;
} else {
if (_local6 == "x"){
delete _arg1[_local5];
};
};
};
};
};
}
private function handleRoomDeleted(_arg1:Object):void{
var _local2:int = int(_arg1.body.rm.@id);
var _local3:Array = sfs.getAllRooms();
var _local4:Object = {};
_local4.room = _local3[_local2];
delete _local3[_local2];
var _local5:SFSEvent = new SFSEvent(SFSEvent.onRoomDeleted, _local4);
sfs.dispatchEvent(_local5);
}
public function handleAdminMessage(_arg1:Object):void{
var _local2:int = int(_arg1.body.@r);
var _local3:int = int(_arg1.body.user.@id);
var _local4:String = _arg1.body.txt;
var _local5:Object = {};
_local5.message = Entities.decodeEntities(_local4);
var _local6:SFSEvent = new SFSEvent(SFSEvent.onAdminMessage, _local5);
sfs.dispatchEvent(_local6);
}
public function handleUserVarsUpdate(_arg1:Object):void{
var _local2:int = int(_arg1.body.@r);
var _local3:int = int(_arg1.body.user.@id);
var _local4:User = sfs.getRoom(_local2).getUser(_local3);
var _local5:Array = [];
if (_arg1.body.vars.toString().length > 0){
populateVariables(_local4.getVariables(), _arg1.body, _local5);
};
var _local6:Object = {};
_local6.user = _local4;
_local6.changedVars = _local5;
var _local7:SFSEvent = new SFSEvent(SFSEvent.onUserVariablesUpdate, _local6);
sfs.dispatchEvent(_local7);
}
private function handleCreateRoomError(_arg1:Object):void{
var _local2:String = _arg1.body.room.@e;
var _local3:Object = {};
_local3.error = _local2;
var _local4:SFSEvent = new SFSEvent(SFSEvent.onCreateRoomError, _local3);
sfs.dispatchEvent(_local4);
}
public function handlePrivateMessage(_arg1:Object):void{
var _local2:int = int(_arg1.body.@r);
var _local3:int = int(_arg1.body.user.@id);
var _local4:String = _arg1.body.txt;
var _local5:User = sfs.getRoom(_local2).getUser(_local3);
var _local6:Object = {};
_local6.message = Entities.decodeEntities(_local4);
_local6.sender = _local5;
_local6.roomId = _local2;
_local6.userId = _local3;
var _local7:SFSEvent = new SFSEvent(SFSEvent.onPrivateMessage, _local6);
sfs.dispatchEvent(_local7);
}
private function handleBuddyRoom(_arg1:Object):void{
var _local2:String = _arg1.body.br.@r;
var _local3:Array = _local2.split(",");
var _local4:int;
while (_local4 < _local3.length) {
_local3[_local4] = int(_local3[_local4]);
_local4++;
};
var _local5:Object = {};
_local5.idList = _local3;
var _local6:SFSEvent = new SFSEvent(SFSEvent.onBuddyRoom, _local5);
sfs.dispatchEvent(_local6);
}
public function handleLogout(_arg1:Object):void{
sfs.__logout();
var _local2:SFSEvent = new SFSEvent(SFSEvent.onLogout, {});
sfs.dispatchEvent(_local2);
}
public function handleUserCountChange(_arg1:Object):void{
var _local6:Object;
var _local7:SFSEvent;
var _local2:int = int(_arg1.body.@u);
var _local3:int = int(_arg1.body.@s);
var _local4:int = int(_arg1.body.@r);
var _local5:Room = sfs.getAllRooms()[_local4];
if (_local5 != null){
_local5.setUserCount(_local2);
_local5.setSpectatorCount(_local3);
_local6 = {};
_local6.room = _local5;
_local7 = new SFSEvent(SFSEvent.onUserCountChange, _local6);
sfs.dispatchEvent(_local7);
};
}
private function handleRandomKey(_arg1:Object):void{
var _local2:String = _arg1.body.k.toString();
var _local3:Object = {};
_local3.key = _local2;
var _local4:SFSEvent = new SFSEvent(SFSEvent.onRandomKey, _local3);
sfs.dispatchEvent(_local4);
}
public function handlePublicMessage(_arg1:Object):void{
var _local2:int = int(_arg1.body.@r);
var _local3:int = int(_arg1.body.user.@id);
var _local4:String = _arg1.body.txt;
var _local5:User = sfs.getRoom(_local2).getUser(_local3);
var _local6:Object = {};
_local6.message = Entities.decodeEntities(_local4);
_local6.sender = _local5;
_local6.roomId = _local2;
var _local7:SFSEvent = new SFSEvent(SFSEvent.onPublicMessage, _local6);
sfs.dispatchEvent(_local7);
}
public function handleUserEnterRoom(_arg1:Object):void{
var _local2:int = int(_arg1.body.@r);
var _local3:int = int(_arg1.body.u.@i);
var _local4:String = _arg1.body.u.n;
var _local5 = (_arg1.body.u.@m == "1");
var _local6 = (_arg1.body.u.@s == "1");
var _local7:int = ((_arg1.body.u.@p)!=null) ? int(_arg1.body.u.@p) : -1;
var _local8:XMLList = _arg1.body.u.vars["var"];
var _local9:Room = sfs.getRoom(_local2);
var _local10:User = new User(_local3, _local4);
_local10.setModerator(_local5);
_local10.setIsSpectator(_local6);
_local10.setPlayerId(_local7);
_local9.addUser(_local10, _local3);
if (_arg1.body.u.vars.toString().length > 0){
populateVariables(_local10.getVariables(), _arg1.body.u);
};
var _local11:Object = {};
_local11.roomId = _local2;
_local11.user = _local10;
var _local12:SFSEvent = new SFSEvent(SFSEvent.onUserEnterRoom, _local11);
sfs.dispatchEvent(_local12);
}
public function dispatchDisconnection():void{
var _local1:SFSEvent = new SFSEvent(SFSEvent.onConnectionLost, null);
sfs.dispatchEvent(_local1);
}
private function handleRemoveBuddy(_arg1:Object):void{
var _local4:String;
var _local5:Object;
var _local6:SFSEvent;
var _local2:String = _arg1.body.n.toString();
var _local3:Object;
for (_local4 in sfs.buddyList) {
_local3 = sfs.buddyList[_local4];
if (_local3.name == _local2){
delete sfs.buddyList[_local4];
_local5 = {};
_local5.list = sfs.buddyList;
_local6 = new SFSEvent(SFSEvent.onBuddyList, _local5);
sfs.dispatchEvent(_local6);
break;
};
};
}
private function handleAddBuddyPermission(_arg1:Object):void{
var _local2:Object = {};
_local2.sender = _arg1.body.n.toString();
_local2.message = "";
if (_arg1.body.txt != undefined){
_local2.message = Entities.decodeEntities(_arg1.body.txt);
};
var _local3:SFSEvent = new SFSEvent(SFSEvent.onBuddyPermissionRequest, _local2);
sfs.dispatchEvent(_local3);
}
public function handleLoginOk(_arg1:Object):void{
var _local2:int = int(_arg1.body.login.@id);
var _local3:int = int(_arg1.body.login.@mod);
var _local4:String = _arg1.body.login.@n;
sfs.amIModerator = (_local3 == 1);
sfs.myUserId = _local2;
sfs.myUserName = _local4;
sfs.playerId = -1;
var _local5:Object = {};
_local5.success = true;
_local5.name = _local4;
_local5.error = "";
var _local6:SFSEvent = new SFSEvent(SFSEvent.onLogin, _local5);
sfs.dispatchEvent(_local6);
sfs.getRoomList();
}
private function handleBuddyListUpdate(_arg1:Object):void{
var _local4:Object;
var _local5:XMLList;
var _local6:Object;
var _local7:Boolean;
var _local8:String;
var _local9:XML;
var _local2:Object = {};
var _local3:SFSEvent;
if (_arg1.body.b != null){
_local4 = {};
_local4.isOnline = ((_arg1.body.b.@s == "1")) ? true : false;
_local4.name = _arg1.body.b.n.toString();
_local4.id = _arg1.body.b.@i;
_local4.isBlocked = ((_arg1.body.b.@x == "1")) ? true : false;
_local5 = _arg1.body.b.vs;
_local6 = null;
_local7 = false;
for (_local8 in sfs.buddyList) {
_local6 = sfs.buddyList[_local8];
if (_local6.name == _local4.name){
sfs.buddyList[_local8] = _local4;
_local4.isBlocked = _local6.isBlocked;
_local4.variables = _local6.variables;
if (_local5.toString().length > 0){
for each (_local9 in _local5.v) {
_local4.variables[_local9.@n.toString()] = _local9.toString();
};
};
_local7 = true;
break;
};
};
if (_local7){
_local2.buddy = _local4;
_local3 = new SFSEvent(SFSEvent.onBuddyListUpdate, _local2);
sfs.dispatchEvent(_local3);
};
} else {
_local2.error = _arg1.body.err.toString();
_local3 = new SFSEvent(SFSEvent.onBuddyListError, _local2);
sfs.dispatchEvent(_local3);
};
}
public function handleRoomVarsUpdate(_arg1:Object):void{
var _local2:int = int(_arg1.body.@r);
var _local3:int = int(_arg1.body.user.@id);
var _local4:Room = sfs.getRoom(_local2);
var _local5:Array = [];
if (_arg1.body.vars.toString().length > 0){
populateVariables(_local4.getVariables(), _arg1.body, _local5);
};
var _local6:Object = {};
_local6.room = _local4;
_local6.changedVars = _local5;
var _local7:SFSEvent = new SFSEvent(SFSEvent.onRoomVariablesUpdate, _local6);
sfs.dispatchEvent(_local7);
}
public function handleRoomList(_arg1:Object):void{
var _local3:XML;
var _local4:Object;
var _local5:SFSEvent;
var _local6:int;
var _local7:Room;
sfs.clearRoomList();
var _local2:Array = sfs.getAllRooms();
for each (_local3 in _arg1.body.rmList.rm) {
_local6 = int(_local3.@id);
_local7 = new Room(_local6, _local3.n, int(_local3.@maxu), int(_local3.@maxs), (_local3.@temp == "1"), (_local3.@game == "1"), (_local3.@priv == "1"), (_local3.@lmb == "1"), int(_local3.@ucnt), int(_local3.@scnt));
if (_local3.vars.toString().length > 0){
populateVariables(_local7.getVariables(), _local3);
};
_local2[_local6] = _local7;
};
_local4 = {};
_local4.roomList = _local2;
_local5 = new SFSEvent(SFSEvent.onRoomListUpdate, _local4);
sfs.dispatchEvent(_local5);
}
private function handleBuddyAdded(_arg1:Object):void{
var _local6:XML;
var _local2:Object = {};
_local2.isOnline = ((_arg1.body.b.@s == "1")) ? true : false;
_local2.name = _arg1.body.b.n.toString();
_local2.id = _arg1.body.b.@i;
_local2.isBlocked = ((_arg1.body.b.@x == "1")) ? true : false;
_local2.variables = {};
var _local3:XMLList = _arg1.body.b.vs;
if (_local3.toString().length > 0){
for each (_local6 in _local3.v) {
_local2.variables[_local6.@n.toString()] = _local6.toString();
};
};
sfs.buddyList.push(_local2);
var _local4:Object = {};
_local4.list = sfs.buddyList;
var _local5:SFSEvent = new SFSEvent(SFSEvent.onBuddyList, _local4);
sfs.dispatchEvent(_local5);
}
private function handleRoomAdded(_arg1:Object):void{
var _local2:int = int(_arg1.body.rm.@id);
var _local3:String = _arg1.body.rm.name;
var _local4:int = int(_arg1.body.rm.@max);
var _local5:int = int(_arg1.body.rm.@spec);
var _local6:Boolean = ((_arg1.body.rm.@temp == "1")) ? true : false;
var _local7:Boolean = ((_arg1.body.rm.@game == "1")) ? true : false;
var _local8:Boolean = ((_arg1.body.rm.@priv == "1")) ? true : false;
var _local9:Boolean = ((_arg1.body.rm.@limbo == "1")) ? true : false;
var _local10:Room = new Room(_local2, _local3, _local4, _local5, _local6, _local7, _local8, _local9);
var _local11:Array = sfs.getAllRooms();
_local11[_local2] = _local10;
if (_arg1.body.rm.vars.toString().length > 0){
populateVariables(_local10.getVariables(), _arg1.body.rm);
};
var _local12:Object = {};
_local12.room = _local10;
var _local13:SFSEvent = new SFSEvent(SFSEvent.onRoomAdded, _local12);
sfs.dispatchEvent(_local13);
}
public function handleUserLeaveRoom(_arg1:Object):void{
var _local2:int = int(_arg1.body.user.@id);
var _local3:int = int(_arg1.body.@r);
var _local4:Room = sfs.getRoom(_local3);
var _local5:String = _local4.getUser(_local2).getName();
_local4.removeUser(_local2);
var _local6:Object = {};
_local6.roomId = _local3;
_local6.userId = _local2;
_local6.userName = _local5;
var _local7:SFSEvent = new SFSEvent(SFSEvent.onUserLeaveRoom, _local6);
sfs.dispatchEvent(_local7);
}
private function handleSpectatorSwitched(_arg1:Object):void{
var _local5:int;
var _local6:User;
var _local7:Object;
var _local8:SFSEvent;
var _local2:int = int(_arg1.body.@r);
var _local3:int = int(_arg1.body.pid.@id);
var _local4:Room = sfs.getRoom(_local2);
if (_local3 > 0){
_local4.setUserCount((_local4.getUserCount() + 1));
_local4.setSpectatorCount((_local4.getSpectatorCount() - 1));
};
if (_arg1.body.pid.@u != undefined){
_local5 = int(_arg1.body.pid.@u);
_local6 = _local4.getUser(_local5);
if (_local6 != null){
_local6.setIsSpectator(false);
_local6.setPlayerId(_local3);
};
} else {
sfs.playerId = _local3;
_local7 = {};
_local7.success = (sfs.playerId > 0);
_local7.newId = sfs.playerId;
_local7.room = _local4;
_local8 = new SFSEvent(SFSEvent.onSpectatorSwitched, _local7);
sfs.dispatchEvent(_local8);
};
}
private function handleLeaveRoom(_arg1:Object):void{
var _local2:int = int(_arg1.body.rm.@id);
var _local3:Object = {};
_local3.roomId = _local2;
var _local4:SFSEvent = new SFSEvent(SFSEvent.onRoomLeft, _local3);
sfs.dispatchEvent(_local4);
}
public function handleLoginKo(_arg1:Object):void{
var _local2:Object = {};
_local2.success = false;
_local2.error = _arg1.body.login.@e;
var _local3:SFSEvent = new SFSEvent(SFSEvent.onLogin, _local2);
sfs.dispatchEvent(_local3);
}
public function handleModMessage(_arg1:Object):void{
var _local2:int = int(_arg1.body.@r);
var _local3:int = int(_arg1.body.user.@id);
var _local4:String = _arg1.body.txt;
var _local5:User;
var _local6:Room = sfs.getRoom(_local2);
if (_local6 != null){
_local5 = sfs.getRoom(_local2).getUser(_local3);
};
var _local7:Object = {};
_local7.message = Entities.decodeEntities(_local4);
_local7.sender = _local5;
var _local8:SFSEvent = new SFSEvent(SFSEvent.onModeratorMessage, _local7);
sfs.dispatchEvent(_local8);
}
public function handleApiOK(_arg1:Object):void{
sfs.isConnected = true;
var _local2:SFSEvent = new SFSEvent(SFSEvent.onConnection, {success:true});
sfs.dispatchEvent(_local2);
}
private function handleRoundTripBench(_arg1:Object):void{
var _local2:int = getTimer();
var _local3:int = (_local2 - sfs.getBenchStartTime());
var _local4:Object = {};
_local4.elapsed = _local3;
var _local5:SFSEvent = new SFSEvent(SFSEvent.onRoundTripResponse, _local4);
sfs.dispatchEvent(_local5);
}
public function handleJoinOk(_arg1:Object):void{
var _local7:XML;
var _local8:Object;
var _local9:SFSEvent;
var _local10:String;
var _local11:int;
var _local12:Boolean;
var _local13:Boolean;
var _local14:int;
var _local15:User;
var _local2:int = int(_arg1.body.@r);
var _local3:XMLList = _arg1.body;
var _local4:XMLList = _arg1.body.uLs.u;
var _local5:int = int(_arg1.body.pid.@id);
sfs.activeRoomId = _local2;
var _local6:Room = sfs.getRoom(_local2);
_local6.clearUserList();
sfs.playerId = _local5;
_local6.setMyPlayerIndex(_local5);
if (_local3.vars.toString().length > 0){
_local6.clearVariables();
populateVariables(_local6.getVariables(), _local3);
};
for each (_local7 in _local4) {
_local10 = _local7.n;
_local11 = int(_local7.@i);
_local12 = ((_local7.@m == "1")) ? true : false;
_local13 = ((_local7.@s == "1")) ? true : false;
_local14 = ((_local7.@p == null)) ? -1 : int(_local7.@p);
_local15 = new User(_local11, _local10);
_local15.setModerator(_local12);
_local15.setIsSpectator(_local13);
_local15.setPlayerId(_local14);
if (_local7.vars.toString().length > 0){
populateVariables(_local15.getVariables(), _local7);
};
_local6.addUser(_local15, _local11);
};
sfs.changingRoom = false;
_local8 = {};
_local8.room = _local6;
_local9 = new SFSEvent(SFSEvent.onJoinRoom, _local8);
sfs.dispatchEvent(_local9);
}
public function handleApiKO(_arg1:Object):void{
var _local2:Object = {};
_local2.success = false;
_local2.error = "API are obsolete, please upgrade";
var _local3:SFSEvent = new SFSEvent(SFSEvent.onConnection, _local2);
sfs.dispatchEvent(_local3);
}
public function handleASObject(_arg1:Object):void{
var _local2:int = int(_arg1.body.@r);
var _local3:int = int(_arg1.body.user.@id);
var _local4:String = _arg1.body.dataObj;
var _local5:User = sfs.getRoom(_local2).getUser(_local3);
var _local6:Object = ObjectSerializer.getInstance().deserialize(new XML(_local4));
var _local7:Object = {};
_local7.obj = _local6;
_local7.sender = _local5;
var _local8:SFSEvent = new SFSEvent(SFSEvent.onObjectReceived, _local7);
sfs.dispatchEvent(_local8);
}
private function handleBuddyList(_arg1:Object):void{
var _local4:Object;
var _local7:XML;
var _local8:XML;
var _local9:XMLList;
var _local10:XML;
var _local2:XMLList = _arg1.body.bList;
var _local3:XMLList = _arg1.body.mv;
var _local5:Object = {};
var _local6:SFSEvent;
if (((!((_local2 == null))) && (!((_local2.b.length == null))))){
if (((!((_local3 == null))) && ((_local3.toString().length > 0)))){
for each (_local7 in _local3.v) {
sfs.myBuddyVars[_local7.@n.toString()] = _local7.toString();
};
};
if (_local2.toString().length > 0){
for each (_local8 in _local2.b) {
_local4 = {};
_local4.isOnline = ((_local8.@s == "1")) ? true : false;
_local4.name = _local8.n.toString();
_local4.id = _local8.@i;
_local4.isBlocked = ((_local8.@x == "1")) ? true : false;
_local4.variables = {};
_local9 = _local8.vs;
if (_local9.toString().length > 0){
for each (_local10 in _local9.v) {
_local4.variables[_local10.@n.toString()] = _local10.toString();
};
};
sfs.buddyList.push(_local4);
};
};
_local5.list = sfs.buddyList;
_local6 = new SFSEvent(SFSEvent.onBuddyList, _local5);
sfs.dispatchEvent(_local6);
} else {
_local5.error = _arg1.body.err.toString();
_local6 = new SFSEvent(SFSEvent.onBuddyListError, _local5);
sfs.dispatchEvent(_local6);
};
}
public function handleJoinKo(_arg1:Object):void{
sfs.changingRoom = false;
var _local2:Object = {};
_local2.error = _arg1.body.error.@msg;
var _local3:SFSEvent = new SFSEvent(SFSEvent.onJoinRoomError, _local2);
sfs.dispatchEvent(_local3);
}
public function handleMessage(_arg1:Object, _arg2:String):void{
var _local3:XML = (_arg1 as XML);
var _local4:String = _local3.body.@action;
var _local5:Function = handlersTable[_local4];
if (_local5 != null){
_local5.apply(this, [_arg1]);
} else {
trace(("Unknown sys command: " + _local4));
};
}
}
}//package it.gotoandplay.smartfoxserver.handlers
Section 13
//HttpConnection (it.gotoandplay.smartfoxserver.http.HttpConnection)
package it.gotoandplay.smartfoxserver.http {
import flash.events.*;
import flash.net.*;
public class HttpConnection extends EventDispatcher {
private var urlRequest:URLRequest;
private var port:int;
private var urlLoaderFactory:LoaderFactory;
private var connected:Boolean;// = false
private var sessionId:String;
private var ipAddr:String;
private var webUrl:String;
private var codec:IHttpProtocolCodec;
private static const servletUrl:String = "BlueBox/HttpBox.do";
public static const HANDSHAKE_TOKEN:String = "#";
private static const HANDSHAKE:String = "connect";
private static const DISCONNECT:String = "disconnect";
private static const CONN_LOST:String = "ERR#01";
private static const paramName:String = "sfsHttp";
public function HttpConnection(){
codec = new RawProtocolCodec();
urlLoaderFactory = new LoaderFactory(handleResponse, handleIOError);
}
public function close():void{
send(DISCONNECT);
}
public function getSessionId():String{
return (this.sessionId);
}
private function handleIOError(_arg1:IOErrorEvent):void{
var _local2:Object = {};
_local2.message = _arg1.text;
var _local3:HttpEvent = new HttpEvent(HttpEvent.onHttpError, _local2);
dispatchEvent(_local3);
}
public function send(_arg1:String):void{
var _local2:URLVariables;
var _local3:URLLoader;
if (((((connected) || (((!(connected)) && ((_arg1 == HANDSHAKE)))))) || (((!(connected)) && ((_arg1 == "poll")))))){
_local2 = new URLVariables();
_local2[paramName] = codec.encode(this.sessionId, _arg1);
urlRequest.data = _local2;
if (_arg1 != "poll"){
trace(("[ Send ]: " + urlRequest.data));
};
_local3 = urlLoaderFactory.getLoader();
_local3.data = _local2;
_local3.load(urlRequest);
};
}
public function connect(_arg1:String, _arg2:int=8080):void{
this.ipAddr = _arg1;
this.port = _arg2;
this.webUrl = ((((("http://" + this.ipAddr) + ":") + this.port) + "/") + servletUrl);
this.sessionId = null;
urlRequest = new URLRequest(webUrl);
urlRequest.method = URLRequestMethod.POST;
send(HANDSHAKE);
}
private function handleResponse(_arg1:Event):void{
var _local4:HttpEvent;
var _local2:URLLoader = (_arg1.target as URLLoader);
var _local3:String = (_local2.data as String);
var _local5:Object = {};
if (_local3.charAt(0) == HANDSHAKE_TOKEN){
if (sessionId == null){
sessionId = codec.decode(_local3);
connected = true;
_local5.sessionId = this.sessionId;
_local5.success = true;
_local4 = new HttpEvent(HttpEvent.onHttpConnect, _local5);
dispatchEvent(_local4);
} else {
trace("**ERROR** SessionId is being rewritten");
};
} else {
if (_local3.indexOf(CONN_LOST) == 0){
_local5.data = {};
_local4 = new HttpEvent(HttpEvent.onHttpClose, _local5);
} else {
_local5.data = _local3;
_local4 = new HttpEvent(HttpEvent.onHttpData, _local5);
};
dispatchEvent(_local4);
};
}
public function isConnected():Boolean{
return (this.connected);
}
}
}//package it.gotoandplay.smartfoxserver.http
Section 14
//HttpEvent (it.gotoandplay.smartfoxserver.http.HttpEvent)
package it.gotoandplay.smartfoxserver.http {
import flash.events.*;
public class HttpEvent extends Event {
public var params:Object;
private var evtType:String;
public static const onHttpClose:String = "onHttpClose";
public static const onHttpError:String = "onHttpError";
public static const onHttpConnect:String = "onHttpConnect";
public static const onHttpData:String = "onHttpData";
public function HttpEvent(_arg1:String, _arg2:Object){
super(_arg1);
this.params = _arg2;
this.evtType = _arg1;
}
override public function clone():Event{
return (new HttpEvent(this.evtType, this.params));
}
override public function toString():String{
return (formatToString("HttpEvent", "type", "bubbles", "cancelable", "eventPhase", "params"));
}
}
}//package it.gotoandplay.smartfoxserver.http
Section 15
//IHttpProtocolCodec (it.gotoandplay.smartfoxserver.http.IHttpProtocolCodec)
package it.gotoandplay.smartfoxserver.http {
public interface IHttpProtocolCodec {
function decode(_arg1:String):String;
function encode(_arg1:String, _arg2:String):String;
}
}//package it.gotoandplay.smartfoxserver.http
Section 16
//LoaderFactory (it.gotoandplay.smartfoxserver.http.LoaderFactory)
package it.gotoandplay.smartfoxserver.http {
import flash.events.*;
import flash.net.*;
public class LoaderFactory {
private var currentLoaderIndex:int;
private var loadersPool:Array;
private static const DEFAULT_POOL_SIZE:int = 8;
public function LoaderFactory(_arg1:Function, _arg2:Function, _arg3:int=8){
var _local5:URLLoader;
super();
loadersPool = [];
var _local4:int;
while (_local4 < _arg3) {
_local5 = new URLLoader();
_local5.dataFormat = URLLoaderDataFormat.TEXT;
_local5.addEventListener(Event.COMPLETE, _arg1);
_local5.addEventListener(IOErrorEvent.IO_ERROR, _arg2);
_local5.addEventListener(IOErrorEvent.NETWORK_ERROR, _arg2);
loadersPool.push(_local5);
_local4++;
};
currentLoaderIndex = 0;
}
public function getLoader():URLLoader{
var _local1:URLLoader = loadersPool[currentLoaderIndex];
currentLoaderIndex++;
if (currentLoaderIndex >= loadersPool.length){
currentLoaderIndex = 0;
};
return (_local1);
}
}
}//package it.gotoandplay.smartfoxserver.http
Section 17
//RawProtocolCodec (it.gotoandplay.smartfoxserver.http.RawProtocolCodec)
package it.gotoandplay.smartfoxserver.http {
public class RawProtocolCodec implements IHttpProtocolCodec {
private static const SESSION_ID_LEN:int = 32;
public function decode(_arg1:String):String{
var _local2:String;
if (_arg1.charAt(0) == HttpConnection.HANDSHAKE_TOKEN){
_local2 = _arg1.substr(1, SESSION_ID_LEN);
};
return (_local2);
}
public function encode(_arg1:String, _arg2:String):String{
return ((((_arg1 == null)) ? "" : _arg1 + _arg2));
}
}
}//package it.gotoandplay.smartfoxserver.http
Section 18
//Entities (it.gotoandplay.smartfoxserver.util.Entities)
package it.gotoandplay.smartfoxserver.util {
public class Entities {
private static var hexTable:Array = new Array();
private static var ascTab:Array = [];
private static var ascTabRev:Array = [];
public static function decodeEntities(_arg1:String):String{
var _local2:String;
var _local3:String;
var _local4:String;
var _local5:String;
var _local6:String;
var _local7:int;
_local2 = "";
while (_local7 < _arg1.length) {
_local3 = _arg1.charAt(_local7);
if (_local3 == "&"){
_local4 = _local3;
do {
_local7++;
_local5 = _arg1.charAt(_local7);
_local4 = (_local4 + _local5);
} while (((!((_local5 == ";"))) && ((_local7 < _arg1.length))));
_local6 = ascTabRev[_local4];
if (_local6 != null){
_local2 = (_local2 + _local6);
} else {
_local2 = (_local2 + String.fromCharCode(getCharCode(_local4)));
};
} else {
_local2 = (_local2 + _local3);
};
_local7++;
};
return (_local2);
}
public static function encodeEntities(_arg1:String):String{
var _local4:String;
var _local5:int;
var _local2 = "";
var _local3:int;
while (_local3 < _arg1.length) {
_local4 = _arg1.charAt(_local3);
_local5 = _arg1.charCodeAt(_local3);
if ((((((_local5 == 9)) || ((_local5 == 10)))) || ((_local5 == 13)))){
_local2 = (_local2 + _local4);
} else {
if ((((_local5 >= 32)) && ((_local5 <= 126)))){
if (ascTab[_local4] != null){
_local2 = (_local2 + ascTab[_local4]);
} else {
_local2 = (_local2 + _local4);
};
} else {
_local2 = (_local2 + _local4);
};
};
_local3++;
};
return (_local2);
}
public static function getCharCode(_arg1:String):Number{
var _local2:String = _arg1.substr(3, _arg1.length);
_local2 = _local2.substr(0, (_local2.length - 1));
return (Number(("0x" + _local2)));
}
ascTab[">"] = ">";
ascTab["<"] = "<";
ascTab["&"] = "&";
ascTab["'"] = "'";
ascTab["\""] = """;
ascTabRev[">"] = ">";
ascTabRev["<"] = "<";
ascTabRev["&"] = "&";
ascTabRev["'"] = "'";
ascTabRev["""] = "\"";
hexTable["0"] = 0;
hexTable["1"] = 1;
hexTable["2"] = 2;
hexTable["3"] = 3;
hexTable["4"] = 4;
hexTable["5"] = 5;
hexTable["6"] = 6;
hexTable["7"] = 7;
hexTable["8"] = 8;
hexTable["9"] = 9;
hexTable["A"] = 10;
hexTable["B"] = 11;
hexTable["C"] = 12;
hexTable["D"] = 13;
hexTable["E"] = 14;
hexTable["F"] = 15;
}
}//package it.gotoandplay.smartfoxserver.util
Section 19
//ObjectSerializer (it.gotoandplay.smartfoxserver.util.ObjectSerializer)
package it.gotoandplay.smartfoxserver.util {
public class ObjectSerializer {
private var eof:String;
private var debug:Boolean;
private var tabs:String;
private static var instance:ObjectSerializer;
public function ObjectSerializer(_arg1:Boolean=false){
this.tabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t";
setDebug(_arg1);
}
public function serialize(_arg1:Object):String{
var _local2:Object = {};
obj2xml(_arg1, _local2);
return (_local2.xmlStr);
}
private function xml2obj(_arg1:XML, _arg2:Object):void{
var _local5:String;
var _local6:XML;
var _local7:String;
var _local8:String;
var _local9:String;
var _local10:String;
var _local11:String;
var _local3:int;
var _local4:XMLList = _arg1.children();
for each (_local6 in _local4) {
_local5 = _local6.name().toString();
if (_local5 == "obj"){
_local7 = _local6.@o;
_local8 = _local6.@t;
if (_local8 == "a"){
_arg2[_local7] = [];
} else {
if (_local8 == "o"){
_arg2[_local7] = {};
};
};
xml2obj(_local6, _arg2[_local7]);
} else {
if (_local5 == "var"){
_local9 = _local6.@n;
_local10 = _local6.@t;
_local11 = _local6.toString();
if (_local10 == "b"){
_arg2[_local9] = ((_local11 == "0")) ? false : true;
} else {
if (_local10 == "n"){
_arg2[_local9] = Number(_local11);
} else {
if (_local10 == "s"){
_arg2[_local9] = _local11;
} else {
if (_local10 == "x"){
_arg2[_local9] = null;
};
};
};
};
};
};
};
}
private function setDebug(_arg1:Boolean):void{
this.debug = _arg1;
if (this.debug){
this.eof = "\n";
} else {
this.eof = "";
};
}
private function encodeEntities(_arg1:String):String{
return (_arg1);
}
private function obj2xml(_arg1:Object, _arg2:Object, _arg3:int=0, _arg4:String=""):void{
var _local5:String;
var _local6:String;
var _local7:String;
var _local8:*;
if (_arg3 == 0){
_arg2.xmlStr = ("<dataObj>" + this.eof);
} else {
if (this.debug){
_arg2.xmlStr = (_arg2.xmlStr + this.tabs.substr(0, _arg3));
};
_local6 = ((_arg1 is Array)) ? "a" : "o";
_arg2.xmlStr = (_arg2.xmlStr + ((((("<obj t='" + _local6) + "' o='") + _arg4) + "'>") + this.eof));
};
for (_local5 in _arg1) {
_local7 = typeof(_arg1[_local5]);
_local8 = _arg1[_local5];
if ((((((((_local7 == "boolean")) || ((_local7 == "number")))) || ((_local7 == "string")))) || ((_local7 == "null")))){
if (_local7 == "boolean"){
_local8 = Number(_local8);
} else {
if (_local7 == "null"){
_local7 = "x";
_local8 = "";
} else {
if (_local7 == "string"){
_local8 = Entities.encodeEntities(_local8);
};
};
};
if (this.debug){
_arg2.xmlStr = (_arg2.xmlStr + this.tabs.substr(0, (_arg3 + 1)));
};
_arg2.xmlStr = (_arg2.xmlStr + ((((((("<var n='" + _local5) + "' t='") + _local7.substr(0, 1)) + "'>") + _local8) + "</var>") + this.eof));
} else {
if (_local7 == "object"){
obj2xml(_local8, _arg2, (_arg3 + 1), _local5);
if (this.debug){
_arg2.xmlStr = (_arg2.xmlStr + this.tabs.substr(0, (_arg3 + 1)));
};
_arg2.xmlStr = (_arg2.xmlStr + ("</obj>" + this.eof));
};
};
};
if (_arg3 == 0){
_arg2.xmlStr = (_arg2.xmlStr + ("</dataObj>" + this.eof));
};
}
public function deserialize(_arg1:String):Object{
var _local2:XML = new XML(_arg1);
var _local3:Object = {};
xml2obj(_local2, _local3);
return (_local3);
}
public static function getInstance(_arg1:Boolean=false):ObjectSerializer{
if (instance == null){
instance = new ObjectSerializer(_arg1);
};
return (instance);
}
}
}//package it.gotoandplay.smartfoxserver.util
Section 20
//SFSEvent (it.gotoandplay.smartfoxserver.SFSEvent)
package it.gotoandplay.smartfoxserver {
import flash.events.*;
public class SFSEvent extends Event {
public var params:Object;
public static const onExtensionResponse:String = "onExtensionResponse";
public static const onConfigLoadFailure:String = "onConfigLoadFailure";
public static const onBuddyListUpdate:String = "onBuddyListUpdate";
public static const onUserLeaveRoom:String = "onUserLeaveRoom";
public static const onRoomLeft:String = "onRoomLeft";
public static const onRoundTripResponse:String = "onRoundTripResponse";
public static const onRoomListUpdate:String = "onRoomListUpdate";
public static const onConnection:String = "onConnection";
public static const onBuddyListError:String = "onBuddyListError";
public static const onJoinRoom:String = "onJoinRoom";
public static const onBuddyRoom:String = "onBuddyRoom";
public static const onUserEnterRoom:String = "onUserEnterRoom";
public static const onDebugMessage:String = "onDebugMessage";
public static const onAdminMessage:String = "onAdminMessage";
public static const onPublicMessage:String = "onPublicMessage";
public static const onModeratorMessage:String = "onModMessage";
public static const onPrivateMessage:String = "onPrivateMessage";
public static const onLogout:String = "onLogout";
public static const onJoinRoomError:String = "onJoinRoomError";
public static const onRoomAdded:String = "onRoomAdded";
public static const onLogin:String = "onLogin";
public static const onSpectatorSwitched:String = "onSpectatorSwitched";
public static const onBuddyPermissionRequest:String = "onBuddyPermissionRequest";
public static const onRoomDeleted:String = "onRoomDeleted";
public static const onConnectionLost:String = "onConnectionLost";
public static const onBuddyList:String = "onBuddyList";
public static const onRoomVariablesUpdate:String = "onRoomVariablesUpdate";
public static const onCreateRoomError:String = "onCreateRoomError";
public static const onUserCountChange:String = "onUserCountChange";
public static const onUserVariablesUpdate:String = "onUserVariablesUpdate";
public static const onConfigLoadSuccess:String = "onConfigLoadSuccess";
public static const onRandomKey:String = "onRandomKey";
public static const onObjectReceived:String = "onObjectReceived";
public function SFSEvent(_arg1:String, _arg2:Object){
super(_arg1);
this.params = _arg2;
}
override public function toString():String{
return (formatToString("SFSEvent", "type", "bubbles", "cancelable", "eventPhase", "params"));
}
override public function clone():Event{
return (new SFSEvent(this.type, this.params));
}
}
}//package it.gotoandplay.smartfoxserver
Section 21
//SmartFoxClient (it.gotoandplay.smartfoxserver.SmartFoxClient)
package it.gotoandplay.smartfoxserver {
import flash.events.*;
import it.gotoandplay.smartfoxserver.data.*;
import flash.net.*;
import it.gotoandplay.smartfoxserver.handlers.*;
import it.gotoandplay.smartfoxserver.http.*;
import it.gotoandplay.smartfoxserver.util.*;
import com.adobe.serialization.json.*;
import flash.utils.*;
public class SmartFoxClient extends EventDispatcher {
private var autoConnectOnConfigSuccess:Boolean;// = false
private var connected:Boolean;
private var benchStartTime:int;
public var myUserId:int;
private var _httpPollSpeed:int;
private var minVersion:Number;
private var roomList:Array;
public var httpPort:int;// = 8080
public var blueBoxPort:Number;// = 0
public var debug:Boolean;
private var byteBuffer:ByteArray;
private var subVersion:Number;
public var port:int;// = 9339
public var buddyList:Array;
private var httpConnection:HttpConnection;
public var defaultZone:String;
private var messageHandlers:Array;
private var isHttpMode:Boolean;// = false
private var majVersion:Number;
private var socketConnection:Socket;
public var blueBoxIpAddress:String;
private var sysHandler:SysHandler;
public var myUserName:String;
public var myBuddyVars:Array;
public var ipAddress:String;
public var playerId:int;
public var smartConnect:Boolean;// = true
public var amIModerator:Boolean;
private var extHandler:ExtHandler;
public var changingRoom:Boolean;
public var activeRoomId:int;
public static const CONNECTION_MODE_HTTP:String = "http";
private static const MSG_JSON:String = "{";
public static const MODMSG_TO_USER:String = "u";
public static const XTMSG_TYPE_XML:String = "xml";
private static const MSG_XML:String = "<";
public static const MODMSG_TO_ROOM:String = "r";
private static const EOM:int = 0;
public static const XTMSG_TYPE_STR:String = "str";
public static const CONNECTION_MODE_SOCKET:String = "socket";
public static const MODMSG_TO_ZONE:String = "z";
public static const CONNECTION_MODE_DISCONNECTED:String = "disconnected";
public static const XTMSG_TYPE_JSON:String = "json";
private static var MAX_POLL_SPEED:Number = 10000;
private static var DEFAULT_POLL_SPEED:Number = 750;
private static var MIN_POLL_SPEED:Number = 0;
private static var HTTP_POLL_REQUEST:String = "poll";
private static var MSG_STR:String = "%";
public function SmartFoxClient(_arg1:Boolean=false){
_httpPollSpeed = DEFAULT_POLL_SPEED;
super();
this.majVersion = 1;
this.minVersion = 5;
this.subVersion = 4;
this.activeRoomId = -1;
this.debug = _arg1;
this.messageHandlers = [];
setupMessageHandlers();
socketConnection = new Socket();
socketConnection.addEventListener(Event.CONNECT, handleSocketConnection);
socketConnection.addEventListener(Event.CLOSE, handleSocketDisconnection);
socketConnection.addEventListener(ProgressEvent.SOCKET_DATA, handleSocketData);
socketConnection.addEventListener(IOErrorEvent.IO_ERROR, handleIOError);
socketConnection.addEventListener(IOErrorEvent.NETWORK_ERROR, handleIOError);
socketConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleSecurityError);
httpConnection = new HttpConnection();
httpConnection.addEventListener(HttpEvent.onHttpConnect, handleHttpConnect);
httpConnection.addEventListener(HttpEvent.onHttpClose, handleHttpClose);
httpConnection.addEventListener(HttpEvent.onHttpData, handleHttpData);
httpConnection.addEventListener(HttpEvent.onHttpError, handleHttpError);
byteBuffer = new ByteArray();
}
private function getXmlUserVariable(_arg1:Object):String{
var _local3:*;
var _local4:String;
var _local5:String;
var _local6:String;
var _local2 = "<vars>";
for (_local6 in _arg1) {
_local3 = _arg1[_local6];
_local5 = typeof(_local3);
_local4 = null;
if (_local5 == "boolean"){
_local4 = "b";
_local3 = (_local3) ? "1" : "0";
} else {
if (_local5 == "number"){
_local4 = "n";
} else {
if (_local5 == "string"){
_local4 = "s";
} else {
if ((((((_local3 == null)) && ((_local5 == "object")))) || ((_local5 == "undefined")))){
_local4 = "x";
_local3 = "";
};
};
};
};
if (_local4 != null){
_local2 = (_local2 + (((((("<var n='" + _local6) + "' t='") + _local4) + "'><![CDATA[") + _local3) + "]]></var>"));
};
};
_local2 = (_local2 + "</vars>");
return (_local2);
}
private function jsonReceived(_arg1:String):void{
var _local2:Object = JSON.decode(_arg1);
var _local3:String = _local2["t"];
var _local4:IMessageHandler = messageHandlers[_local3];
if (_local4 != null){
_local4.handleMessage(_local2["b"], XTMSG_TYPE_JSON);
};
}
private function onConfigLoadFailure(_arg1:IOErrorEvent):void{
var _local2:Object = {message:_arg1.text};
var _local3:SFSEvent = new SFSEvent(SFSEvent.onConfigLoadFailure, _local2);
dispatchEvent(_local3);
}
public function getActiveRoom():Room{
return (roomList[activeRoomId]);
}
public function getBuddyRoom(_arg1:Object):void{
if (_arg1.id != -1){
send({t:"sys", bid:_arg1.id}, "roomB", -1, (("<b id='" + _arg1.id) + "' />"));
};
}
private function checkBuddyDuplicates(_arg1:String):Boolean{
var _local3:Object;
var _local2:Boolean;
for each (_local3 in buddyList) {
if (_local3.name == _arg1){
_local2 = true;
break;
};
};
return (_local2);
}
private function handleHttpClose(_arg1:HttpEvent):void{
initialize();
var _local2:SFSEvent = new SFSEvent(SFSEvent.onConnectionLost, {});
dispatchEvent(_local2);
}
private function getXmlRoomVariable(_arg1:Object):String{
var _local2:String = _arg1.name.toString();
var _local3:* = _arg1.val;
var _local4:String = (_arg1.priv) ? "1" : "0";
var _local5:String = (_arg1.persistent) ? "1" : "0";
var _local6:String;
var _local7 = typeof(_local3);
if (_local7 == "boolean"){
_local6 = "b";
_local3 = (_local3) ? "1" : "0";
} else {
if (_local7 == "number"){
_local6 = "n";
} else {
if (_local7 == "string"){
_local6 = "s";
} else {
if ((((((_local3 == null)) && ((_local7 == "object")))) || ((_local7 == "undefined")))){
_local6 = "x";
_local3 = "";
};
};
};
};
if (_local6 != null){
return ((((((((((("<var n='" + _local2) + "' t='") + _local6) + "' pr='") + _local4) + "' pe='") + _local5) + "'><![CDATA[") + _local3) + "]]></var>"));
};
return ("");
}
public function getBuddyById(_arg1:int):Object{
var _local2:Object;
for each (_local2 in buddyList) {
if (_local2.id == _arg1){
return (_local2);
};
};
return (null);
}
private function handleSocketDisconnection(_arg1:Event):void{
initialize();
var _local2:SFSEvent = new SFSEvent(SFSEvent.onConnectionLost, {});
dispatchEvent(_local2);
}
private function handleSocketError(_arg1:SecurityErrorEvent):void{
debugMessage(("Socket Error: " + _arg1.text));
}
private function xmlReceived(_arg1:String):void{
var _local2:XML = new XML(_arg1);
var _local3:String = _local2.@t;
var _local4:String = _local2.body.@action;
var _local5:int = _local2.body.@r;
var _local6:IMessageHandler = messageHandlers[_local3];
if (_local6 != null){
_local6.handleMessage(_local2, XTMSG_TYPE_XML);
};
}
public function switchSpectator(_arg1:int=-1):void{
if (_arg1 == -1){
_arg1 = activeRoomId;
};
send({t:"sys"}, "swSpec", _arg1, "");
}
public function roundTripBench():void{
this.benchStartTime = getTimer();
send({t:"sys"}, "roundTrip", activeRoomId, "");
}
private function handleHttpError(_arg1:HttpEvent):void{
trace("HttpError");
if (!connected){
dispatchConnectionError();
};
}
public function joinRoom(_arg1, _arg2:String="", _arg3:Boolean=false, _arg4:Boolean=false, _arg5:int=-1):void{
var _local8:Room;
var _local9:Object;
var _local10:String;
var _local11:int;
var _local12:String;
var _local6 = -1;
var _local7:int = (_arg3) ? 1 : 0;
if (!this.changingRoom){
if (typeof(_arg1) == "number"){
_local6 = int(_arg1);
} else {
if (typeof(_arg1) == "string"){
for each (_local8 in roomList) {
if (_local8.getName() == _arg1){
_local6 = _local8.getId();
break;
};
};
};
};
if (_local6 != -1){
_local9 = {t:"sys"};
_local10 = (_arg4) ? "0" : "1";
_local11 = ((_arg5 > -1)) ? _arg5 : activeRoomId;
if (activeRoomId == -1){
_local10 = "0";
_local11 = -1;
};
_local12 = (((((((((("<room id='" + _local6) + "' pwd='") + _arg2) + "' spec='") + _local7) + "' leave='") + _local10) + "' old='") + _local11) + "' />");
send(_local9, "joinRoom", activeRoomId, _local12);
changingRoom = true;
} else {
debugMessage("SmartFoxError: requested room to join does not exist!");
};
};
}
public function get httpPollSpeed():int{
return (this._httpPollSpeed);
}
public function uploadFile(_arg1:FileReference, _arg2:int=-1, _arg3:String="", _arg4:int=-1):void{
if (_arg2 == -1){
_arg2 = this.myUserId;
};
if (_arg3 == ""){
_arg3 = this.myUserName;
};
if (_arg4 == -1){
_arg4 = this.httpPort;
};
_arg1.upload(new URLRequest(((((((("http://" + this.ipAddress) + ":") + _arg4) + "/default/Upload.py?id=") + _arg2) + "&nick=") + _arg3)));
debugMessage(((((((("[UPLOAD]: http://" + this.ipAddress) + ":") + _arg4) + "/default/Upload.py?id=") + _arg2) + "&nick=") + _arg3));
}
private function debugMessage(_arg1:String):void{
var _local2:SFSEvent;
if (this.debug){
trace(_arg1);
_local2 = new SFSEvent(SFSEvent.onDebugMessage, {message:_arg1});
dispatchEvent(_local2);
};
}
private function makeXmlHeader(_arg1:Object):String{
var _local3:String;
var _local2 = "<msg";
for (_local3 in _arg1) {
_local2 = (_local2 + ((((" " + _local3) + "='") + _arg1[_local3]) + "'"));
};
_local2 = (_local2 + ">");
return (_local2);
}
public function getRoomByName(_arg1:String):Room{
var _local3:Room;
var _local2:Room;
for each (_local3 in roomList) {
if (_local3.getName() == _arg1){
_local2 = _local3;
break;
};
};
return (_local2);
}
public function loadBuddyList():void{
send({t:"sys"}, "loadB", -1, "");
}
private function handleSocketConnection(_arg1:Event):void{
var _local2:Object = {t:"sys"};
var _local3 = (((("<ver v='" + this.majVersion.toString()) + this.minVersion.toString()) + this.subVersion.toString()) + "' />");
send(_local2, "verChk", 0, _local3);
}
public function set httpPollSpeed(_arg1:int):void{
if ((((_arg1 >= 0)) && ((_arg1 <= 10000)))){
this._httpPollSpeed = _arg1;
};
}
public function leaveRoom(_arg1:int):void{
var _local2:Object = {t:"sys"};
var _local3 = (("<rm id='" + _arg1) + "' />");
send(_local2, "leaveRoom", _arg1, _local3);
}
private function strReceived(_arg1:String):void{
var _local2:Array = _arg1.substr(1, (_arg1.length - 2)).split(MSG_STR);
var _local3:String = _local2[0];
var _local4:IMessageHandler = messageHandlers[_local3];
if (_local4 != null){
_local4.handleMessage(_local2.splice(1, (_local2.length - 1)), XTMSG_TYPE_STR);
};
}
private function addMessageHandler(_arg1:String, _arg2:IMessageHandler):void{
if (this.messageHandlers[_arg1] == null){
this.messageHandlers[_arg1] = _arg2;
} else {
debugMessage((("Warning, message handler called: " + _arg1) + " already exist!"));
};
}
public function getAllRooms():Array{
return (roomList);
}
public function getRoom(_arg1:int):Room{
return (roomList[_arg1]);
}
private function tryBlueBoxConnection(_arg1:ErrorEvent):void{
var _local2:String;
var _local3:int;
if (!connected){
if (smartConnect){
debugMessage("Socket connection failed. Trying BlueBox");
isHttpMode = true;
_local2 = ((blueBoxIpAddress)!=null) ? blueBoxIpAddress : ipAddress;
_local3 = ((blueBoxPort)!=0) ? blueBoxPort : httpPort;
httpConnection.connect(_local2, _local3);
} else {
dispatchConnectionError();
};
} else {
dispatchEvent(_arg1);
debugMessage(("[WARN] Connection error: " + _arg1.text));
};
}
private function handleSocketData(_arg1:Event):void{
var _local3:int;
var _local2:int = socketConnection.bytesAvailable;
while (--_local2 >= 0) {
_local3 = socketConnection.readByte();
if (_local3 != 0){
byteBuffer.writeByte(_local3);
} else {
handleMessage(byteBuffer.toString());
byteBuffer = new ByteArray();
};
};
}
public function setBuddyVariables(_arg1:Array):void{
var _local4:String;
var _local5:String;
var _local2:Object = {t:"sys"};
var _local3 = "<vars>";
for (_local4 in _arg1) {
_local5 = _arg1[_local4];
if (myBuddyVars[_local4] != _local5){
myBuddyVars[_local4] = _local5;
_local3 = (_local3 + (((("<var n='" + _local4) + "'><![CDATA[") + _local5) + "]]></var>"));
};
};
_local3 = (_local3 + "</vars>");
this.send(_local2, "setBvars", -1, _local3);
}
private function handleSecurityError(_arg1:SecurityErrorEvent):void{
tryBlueBoxConnection(_arg1);
}
private function handleIOError(_arg1:IOErrorEvent):void{
tryBlueBoxConnection(_arg1);
}
private function dispatchConnectionError():void{
var _local1:Object = {};
_local1.success = false;
_local1.error = "I/O Error";
var _local2:SFSEvent = new SFSEvent(SFSEvent.onConnection, _local1);
dispatchEvent(_local2);
}
public function login(_arg1:String, _arg2:String, _arg3:String):void{
var _local4:Object = {t:"sys"};
var _local5 = (((((("<login z='" + _arg1) + "'><nick><![CDATA[") + _arg2) + "]]></nick><pword><![CDATA[") + _arg3) + "]]></pword></login>");
send(_local4, "login", 0, _local5);
}
public function __logout():void{
initialize(true);
}
private function setupMessageHandlers():void{
sysHandler = new SysHandler(this);
extHandler = new ExtHandler(this);
addMessageHandler("sys", sysHandler);
addMessageHandler("xt", extHandler);
}
public function autoJoin():void{
var _local1:Object = {t:"sys"};
this.send(_local1, "autoJoin", (this.activeRoomId) ? this.activeRoomId : -1, "");
}
private function onConfigLoadSuccess(_arg1:Event):void{
var _local4:SFSEvent;
var _local2:URLLoader = (_arg1.target as URLLoader);
var _local3:XML = new XML(_local2.data);
this.ipAddress = (this.blueBoxIpAddress = _local3.ip);
this.port = int(_local3.port);
this.defaultZone = _local3.zone;
if (_local3.blueBoxIpAddress != undefined){
this.blueBoxIpAddress = _local3.blueBoxIpAddress;
};
if (_local3.blueBoxPort != undefined){
this.blueBoxPort = _local3.blueBoxPort;
};
if (_local3.debug != undefined){
this.debug = ((_local3.debug.toLowerCase() == "true")) ? true : false;
};
if (_local3.smartConnect != undefined){
this.smartConnect = ((_local3.smartConnect.toLowerCase() == "true")) ? true : false;
};
if (_local3.httpPort != undefined){
this.httpPort = int(_local3.httpPort);
};
if (_local3.httpPollSpeed != undefined){
this.httpPollSpeed = int(_local3.httpPollSpeed);
};
if (_local3.rawProtocolSeparator != undefined){
rawProtocolSeparator = _local3.rawProtocolSeparator;
};
if (autoConnectOnConfigSuccess){
this.connect(ipAddress, port);
} else {
_local4 = new SFSEvent(SFSEvent.onConfigLoadSuccess, {});
dispatchEvent(_local4);
};
}
private function send(_arg1:Object, _arg2:String, _arg3:Number, _arg4:String):void{
var _local5:String = makeXmlHeader(_arg1);
_local5 = (_local5 + ((((((("<body action='" + _arg2) + "' r='") + _arg3) + "'>") + _arg4) + "</body>") + closeHeader()));
debugMessage((("[Sending]: " + _local5) + "\n"));
if (isHttpMode){
httpConnection.send(_local5);
} else {
writeToSocket(_local5);
};
}
public function logout():void{
var _local1:Object = {t:"sys"};
send(_local1, "logout", -1, "");
}
public function getRoomList():void{
var _local1:Object = {t:"sys"};
send(_local1, "getRmList", activeRoomId, "");
}
public function getConnectionMode():String{
var _local1:String = CONNECTION_MODE_DISCONNECTED;
if (this.isConnected){
if (this.isHttpMode){
_local1 = CONNECTION_MODE_HTTP;
} else {
_local1 = CONNECTION_MODE_SOCKET;
};
};
return (_local1);
}
public function disconnect():void{
connected = false;
if (!isHttpMode){
socketConnection.close();
} else {
httpConnection.close();
};
sysHandler.dispatchDisconnection();
}
public function clearRoomList():void{
this.roomList = [];
}
public function sendJson(_arg1:String):void{
debugMessage((("[Sending - JSON]: " + _arg1) + "\n"));
if (isHttpMode){
httpConnection.send(_arg1);
} else {
writeToSocket(_arg1);
};
}
public function setRoomVariables(_arg1:Array, _arg2:int=-1, _arg3:Boolean=true):void{
var _local5:String;
var _local6:Object;
if (_arg2 == -1){
_arg2 = activeRoomId;
};
var _local4:Object = {t:"sys"};
if (_arg3){
_local5 = "<vars>";
} else {
_local5 = "<vars so='0'>";
};
for each (_local6 in _arg1) {
_local5 = (_local5 + getXmlRoomVariable(_local6));
};
_local5 = (_local5 + "</vars>");
send(_local4, "setRvars", _arg2, _local5);
}
public function addBuddy(_arg1:String):void{
var _local2:String;
if (((!((_arg1 == myUserName))) && (!(checkBuddyDuplicates(_arg1))))){
_local2 = (("<n>" + _arg1) + "</n>");
send({t:"sys"}, "addB", -1, _local2);
};
}
private function initialize(_arg1:Boolean=false):void{
this.changingRoom = false;
this.amIModerator = false;
this.playerId = -1;
this.activeRoomId = -1;
this.myUserId = -1;
this.myUserName = "";
this.roomList = [];
this.buddyList = [];
this.myBuddyVars = [];
if (!_arg1){
this.connected = false;
this.isHttpMode = false;
};
}
public function getVersion():String{
return (((((this.majVersion + ".") + this.minVersion) + ".") + this.subVersion));
}
public function setUserVariables(_arg1:Object, _arg2:int=-1):void{
if (_arg2 == -1){
_arg2 = activeRoomId;
};
var _local3:Object = {t:"sys"};
var _local4:Room = getActiveRoom();
var _local5:User = _local4.getUser(myUserId);
_local5.setVariables(_arg1);
var _local6:String = getXmlUserVariable(_arg1);
send(_local3, "setUvars", _arg2, _local6);
}
public function sendPrivateMessage(_arg1:String, _arg2:int, _arg3:int=-1):void{
if (_arg3 == -1){
_arg3 = activeRoomId;
};
var _local4:Object = {t:"sys"};
var _local5 = (((("<txt rcp='" + _arg2) + "'><![CDATA[") + Entities.encodeEntities(_arg1)) + "]]></txt>");
send(_local4, "prvMsg", _arg3, _local5);
}
public function getBuddyByName(_arg1:String):Object{
var _local2:Object;
for each (_local2 in buddyList) {
if (_local2.name == _arg1){
return (_local2);
};
};
return (null);
}
private function closeHeader():String{
return ("</msg>");
}
public function sendPublicMessage(_arg1:String, _arg2:int=-1):void{
if (_arg2 == -1){
_arg2 = activeRoomId;
};
var _local3:Object = {t:"sys"};
var _local4 = (("<txt><![CDATA[" + Entities.encodeEntities(_arg1)) + "]]></txt>");
send(_local3, "pubMsg", _arg2, _local4);
}
public function clearBuddyList():void{
buddyList = [];
send({t:"sys"}, "clearB", -1, "");
var _local1:Object = {};
_local1.list = buddyList;
var _local2:SFSEvent = new SFSEvent(SFSEvent.onBuddyList, _local1);
dispatchEvent(_local2);
}
public function sendString(_arg1:String):void{
debugMessage((("[Sending - STR]: " + _arg1) + "\n"));
if (isHttpMode){
httpConnection.send(_arg1);
} else {
writeToSocket(_arg1);
};
}
public function removeBuddy(_arg1:String):void{
var _local3:Object;
var _local4:String;
var _local5:Object;
var _local6:String;
var _local7:Object;
var _local8:SFSEvent;
var _local2:Boolean;
for (_local4 in buddyList) {
_local3 = buddyList[_local4];
if (_local3.name == _arg1){
delete buddyList[_local4];
_local2 = true;
break;
};
};
if (_local2){
_local5 = {t:"sys"};
_local6 = (("<n>" + _arg1) + "</n>");
send(_local5, "remB", -1, _local6);
_local7 = {};
_local7.list = buddyList;
_local8 = new SFSEvent(SFSEvent.onBuddyList, _local7);
dispatchEvent(_local8);
};
}
public function setBuddyBlockStatus(_arg1:String, _arg2:Boolean):void{
var _local4:String;
var _local5:Object;
var _local6:SFSEvent;
var _local3:Object = getBuddyByName(_arg1);
if (_local3 != null){
if (_local3.blocked != _arg2){
_local3.isBlocked = _arg2;
_local4 = (((("<n x='" + (_arg2) ? "1" : "0") + "'>") + _arg1) + "</n>");
send({t:"sys"}, "setB", -1, _local4);
_local5 = {};
_local5.buddy = _local3;
_local6 = new SFSEvent(SFSEvent.onBuddyListUpdate, _local5);
dispatchEvent(_local6);
};
};
}
private function handleMessage(_arg1:String):void{
if (_arg1 != "ok"){
debugMessage((((("[ RECEIVED ]: " + _arg1) + ", (len: ") + _arg1.length) + ")"));
};
var _local2:String = _arg1.charAt(0);
if (_local2 == MSG_XML){
xmlReceived(_arg1);
} else {
if (_local2 == MSG_STR){
strReceived(_arg1);
} else {
if (_local2 == MSG_JSON){
jsonReceived(_arg1);
};
};
};
}
public function getUploadPath():String{
return ((((("http://" + this.ipAddress) + ":") + this.httpPort) + "/default/uploads/"));
}
private function handleHttpData(_arg1:HttpEvent):void{
var _local4:String;
var _local5:int;
var _local2:String = (_arg1.params.data as String);
var _local3:Array = _local2.split("\n");
if (_local3[0] != ""){
_local5 = 0;
while (_local5 < (_local3.length - 1)) {
_local4 = _local3[_local5];
if (_local4.length > 0){
handleMessage(_local4);
};
_local5++;
};
if (this._httpPollSpeed > 0){
setTimeout(this.handleDelayedPoll, this._httpPollSpeed);
} else {
handleDelayedPoll();
};
};
}
public function loadConfig(_arg1:String="config.xml", _arg2:Boolean=true):void{
this.autoConnectOnConfigSuccess = _arg2;
var _local3:URLLoader = new URLLoader();
_local3.addEventListener(Event.COMPLETE, onConfigLoadSuccess);
_local3.addEventListener(IOErrorEvent.IO_ERROR, onConfigLoadFailure);
_local3.load(new URLRequest(_arg1));
}
public function sendXtMessage(_arg1:String, _arg2:String, _arg3, _arg4:String="xml", _arg5:int=-1):void{
var _local6:Object;
var _local7:Object;
var _local8:String;
var _local9:String;
var _local10:Number;
var _local11:Object;
var _local12:Object;
var _local13:String;
if (_arg5 == -1){
_arg5 = activeRoomId;
};
if (_arg4 == XTMSG_TYPE_XML){
_local6 = {t:"xt"};
_local7 = {name:_arg1, cmd:_arg2, param:_arg3};
_local8 = (("<![CDATA[" + ObjectSerializer.getInstance().serialize(_local7)) + "]]>");
send(_local6, "xtReq", _arg5, _local8);
} else {
if (_arg4 == XTMSG_TYPE_STR){
_local9 = ((((((((MSG_STR + "xt") + MSG_STR) + _arg1) + MSG_STR) + _arg2) + MSG_STR) + _arg5) + MSG_STR);
_local10 = 0;
while (_local10 < _arg3.length) {
_local9 = (_local9 + (_arg3[_local10].toString() + MSG_STR));
_local10++;
};
sendString(_local9);
} else {
if (_arg4 == XTMSG_TYPE_JSON){
_local11 = {};
_local11.x = _arg1;
_local11.c = _arg2;
_local11.r = _arg5;
_local11.p = _arg3;
_local12 = {};
_local12.t = "xt";
_local12.b = _local11;
_local13 = JSON.encode(_local12);
sendJson(_local13);
};
};
};
}
public function set rawProtocolSeparator(_arg1:String):void{
if (((!((_arg1 == "<"))) && (!((_arg1 == "{"))))){
MSG_STR = _arg1;
};
}
private function writeToSocket(_arg1:String):void{
var _local2:ByteArray = new ByteArray();
_local2.writeMultiByte(_arg1, "utf-8");
_local2.writeByte(0);
socketConnection.writeBytes(_local2);
socketConnection.flush();
}
public function sendObjectToGroup(_arg1:Object, _arg2:Array, _arg3:int=-1):void{
var _local5:String;
var _local6:Object;
var _local7:String;
if (_arg3 == -1){
_arg3 = activeRoomId;
};
var _local4 = "";
for (_local5 in _arg2) {
if (!isNaN(_arg2[_local5])){
_local4 = (_local4 + (_arg2[_local5] + ","));
};
};
_local4 = _local4.substr(0, (_local4.length - 1));
_arg1._$$_ = _local4;
_local6 = {t:"sys"};
_local7 = (("<![CDATA[" + ObjectSerializer.getInstance().serialize(_arg1)) + "]]>");
send(_local6, "asObjG", _arg3, _local7);
}
public function get rawProtocolSeparator():String{
return (MSG_STR);
}
public function getRandomKey():void{
send({t:"sys"}, "rndK", -1, "");
}
public function sendObject(_arg1:Object, _arg2:int=-1):void{
if (_arg2 == -1){
_arg2 = activeRoomId;
};
var _local3 = (("<![CDATA[" + ObjectSerializer.getInstance().serialize(_arg1)) + "]]>");
var _local4:Object = {t:"sys"};
send(_local4, "asObj", _arg2, _local3);
}
public function connect(_arg1:String, _arg2:int=9339):void{
if (!connected){
initialize();
this.ipAddress = _arg1;
this.port = _arg2;
socketConnection.connect(_arg1, _arg2);
} else {
debugMessage("*** ALREADY CONNECTED ***");
};
}
public function sendBuddyPermissionResponse(_arg1:Boolean, _arg2:String):void{
var _local3:Object = {t:"sys"};
var _local4 = (((("<n res='" + (_arg1) ? "g" : "r") + "'>") + _arg2) + "</n>");
send(_local3, "bPrm", -1, _local4);
}
public function sendModeratorMessage(_arg1:String, _arg2:String, _arg3:int=-1):void{
var _local4:Object = {t:"sys"};
var _local5 = (((((("<txt t='" + _arg2) + "' id='") + _arg3) + "'><![CDATA[") + Entities.encodeEntities(_arg1)) + "]]></txt>");
send(_local4, "modMsg", activeRoomId, _local5);
}
public function getBenchStartTime():int{
return (this.benchStartTime);
}
public function createRoom(_arg1:Object, _arg2:int=-1):void{
var _local9:String;
if (_arg2 == -1){
_arg2 = activeRoomId;
};
var _local3:Object = {t:"sys"};
var _local4:String = (_arg1.isGame) ? "1" : "0";
var _local5 = "1";
var _local6:String = ((_arg1.maxUsers == null)) ? "0" : String(_arg1.maxUsers);
var _local7:String = ((_arg1.maxSpectators == null)) ? "0" : String(_arg1.maxSpectators);
if (((_arg1.isGame) && (!((_arg1.exitCurrent == null))))){
_local5 = (_arg1.exitCurrent) ? "1" : "0";
};
var _local8 = (((((("<room tmp='1' gam='" + _local4) + "' spec='") + _local7) + "' exit='") + _local5) + "'>");
_local8 = (_local8 + (("<name><![CDATA[" + ((_arg1.name == null)) ? "" : _arg1.name) + "]]></name>"));
_local8 = (_local8 + (("<pwd><![CDATA[" + ((_arg1.password == null)) ? "" : _arg1.password) + "]]></pwd>"));
_local8 = (_local8 + (("<max>" + _local6) + "</max>"));
if (_arg1.uCount != null){
_local8 = (_local8 + (("<uCnt>" + (_arg1.uCount) ? "1" : "0") + "</uCnt>"));
};
if (_arg1.extension != null){
_local8 = (_local8 + ("<xt n='" + _arg1.extension.name));
_local8 = (_local8 + (("' s='" + _arg1.extension.script) + "' />"));
};
if (_arg1.vars == null){
_local8 = (_local8 + "<vars></vars>");
} else {
_local8 = (_local8 + "<vars>");
for (_local9 in _arg1.vars) {
_local8 = (_local8 + getXmlRoomVariable(_arg1.vars[_local9]));
};
_local8 = (_local8 + "</vars>");
};
_local8 = (_local8 + "</room>");
send(_local3, "createRoom", _arg2, _local8);
}
private function handleDelayedPoll():void{
httpConnection.send(HTTP_POLL_REQUEST);
}
private function handleHttpConnect(_arg1:HttpEvent):void{
this.handleSocketConnection(null);
connected = true;
httpConnection.send(HTTP_POLL_REQUEST);
}
public function set isConnected(_arg1:Boolean):void{
this.connected = _arg1;
}
public function get isConnected():Boolean{
return (this.connected);
}
}
}//package it.gotoandplay.smartfoxserver
Section 22
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.0.0.0";
public function BitmapAsset(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
}
}//package mx.core
Section 23
//EdgeMetrics (mx.core.EdgeMetrics)
package mx.core {
public class EdgeMetrics {
public var top:Number;
public var left:Number;
public var bottom:Number;
public var right:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public static const EMPTY:EdgeMetrics = new EdgeMetrics(0, 0, 0, 0);
;
public function EdgeMetrics(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0){
this.left = _arg1;
this.top = _arg2;
this.right = _arg3;
this.bottom = _arg4;
}
public function clone():EdgeMetrics{
return (new EdgeMetrics(left, top, right, bottom));
}
}
}//package mx.core
Section 24
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexBitmap(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
var bitmapData = _arg1;
var pixelSnapping = _arg2;
var smoothing = _arg3;
super(bitmapData, pixelSnapping, smoothing);
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 25
//FlexSprite (mx.core.FlexSprite)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexSprite extends Sprite {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexSprite(){
super();
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 26
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
}
}//package mx.core
Section 27
//IBorder (mx.core.IBorder)
package mx.core {
public interface IBorder {
function get borderMetrics():EdgeMetrics;
}
}//package mx.core
Section 28
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 29
//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 30
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 31
//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 32
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
}
}//package mx.core
Section 33
//SpriteAsset (mx.core.SpriteAsset)
package mx.core {
public class SpriteAsset extends FlexSprite implements IFlexAsset, IFlexDisplayObject, IBorder {
private var _measuredHeight:Number;
private var _measuredWidth:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public function SpriteAsset(){
_measuredWidth = width;
_measuredHeight = height;
}
public function get measuredWidth():Number{
return (_measuredWidth);
}
public function get measuredHeight():Number{
return (_measuredHeight);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
public function get borderMetrics():EdgeMetrics{
if (scale9Grid == null){
return (EdgeMetrics.EMPTY);
};
return (new EdgeMetrics(scale9Grid.left, scale9Grid.top, Math.ceil((measuredWidth - scale9Grid.right)), Math.ceil((measuredHeight - scale9Grid.bottom))));
}
}
}//package mx.core
Section 34
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import mx.core.*;
import flash.display.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var _local2:String;
var _local4:String;
var _local5:Array;
var _local3:DisplayObject = _arg1;
while (_local3 != null) {
if (((((_local3.parent) && (_local3.stage))) && ((_local3.parent == _local3.stage)))){
break;
};
_local4 = _local3.name;
if ((_local3 is IRepeaterClient)){
_local5 = IRepeaterClient(_local3).instanceIndices;
if (_local5){
_local4 = (_local4 + (("[" + _local5.join("][")) + "]"));
};
};
_local2 = ((_local2 == null)) ? _local4 : ((_local4 + ".") + _local2);
_local3 = _local3.parent;
};
return (_local2);
}
public static function createUniqueName(_arg1:Object):String{
if (!_arg1){
return (null);
};
var _local2:String = getQualifiedClassName(_arg1);
var _local3:int = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
var _local4:int = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 35
//Advertisment (Advertisment)
package {
import flash.display.*;
public dynamic class Advertisment extends Sprite {
}
}//package
Section 36
//Button3D (Button3D)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.geom.*;
public class Button3D extends Sprite {
private var posX:Number;
private var posY:Number;
public var hitShape:Sprite;
private var isMouseOver:Boolean;// = false
private var offset:Number;// = 0
public var ID:String;
public function Button3D(_arg1:String, _arg2:Number, _arg3:Number, _arg4:String){
ID = _arg4;
posX = _arg2;
posY = _arg3;
x = posX;
y = posY;
var _local5:Bitmap = new Resources.imgMenuButton();
_local5.smoothing = true;
addChild(_local5);
var _local6:TextFormat = new TextFormat();
_local6.color = 0xFFFFFF;
_local6.font = "MyBerlinSans";
_local6.size = 13;
_local6.align = TextFormatAlign.CENTER;
var _local7:TextField = new TextField();
_local7.text = _arg1;
_local7.embedFonts = true;
_local7.width = 104;
_local7.setTextFormat(_local6);
var _local8:Bitmap = new Bitmap(new BitmapData(_local7.width, _local7.height, true, 0xFFFFFF));
_local8.smoothing = true;
_local8.bitmapData.draw(_local7);
_local7.textColor = 2573669;
_local8.bitmapData.draw(_local7, new Matrix(1, 0, 0, 1, -1, 1), null, null, null, true);
var _local9:Bitmap = new Bitmap(new BitmapData(_local7.width, 50, true, 0xFFFFFF));
_local9.smoothing = true;
_local9.bitmapData.draw(_local8, new Matrix(1, 0.085), null, null, null, true);
_local9.y = 16;
addChild(_local9);
hitShape = new Sprite();
hitShape.graphics.beginFill(0, 0);
hitShape.graphics.lineTo(13, 0);
hitShape.graphics.lineTo(0, 14);
hitShape.graphics.lineTo(0, 41);
hitShape.graphics.lineTo(106, 50);
hitShape.graphics.lineTo(104, 37);
hitShape.graphics.lineTo(116, 10);
hitShape.graphics.lineTo(13, 0);
hitShape.graphics.endFill();
hitShape.addEventListener(MouseEvent.MOUSE_OVER, buttonMouseOver);
hitShape.addEventListener(MouseEvent.MOUSE_OUT, buttonMouseOut);
addChild(hitShape);
hitArea = hitShape;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function buttonMouseOut(_arg1:MouseEvent):void{
isMouseOver = false;
}
private function buttonMouseOver(_arg1:MouseEvent):void{
isMouseOver = true;
}
private function onEnterFrame(_arg1:Event):void{
if (((((isMouseOver) && ((offset < 5)))) && (!(MadNumbsFlash.gameApp.paused)))){
offset = (offset + ((6 - offset) / 4));
if (offset > 4.5){
offset = 5;
};
x = (posX - offset);
y = (posY + offset);
} else {
if (((((!(isMouseOver)) || (MadNumbsFlash.gameApp.paused))) && ((offset > 0)))){
offset = (offset - ((6 - offset) / 4));
if (offset < 0.5){
offset = 0;
};
x = (posX - offset);
y = (posY + offset);
};
};
}
}
}//package
Section 37
//InfoCloud (InfoCloud)
package {
import flash.events.*;
import it.gotoandplay.smartfoxserver.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.geom.*;
public class InfoCloud extends Sprite {
private var destSize:Point;
public var stageHeight:Number;
private var infoType:String;// = "none"
private var loaded:Boolean;// = false
private var soundControl:SoundControl;
private var currSize:Point;
private var timer:Number;// = 0
private var textImg:Bitmap;
private var sponsorLogo:SpnsrLogo;
public var stageWidth:Number;
private var background:Array;
public var ads:Advertisment;
private var checkboxes:Array;
private var okButton:SimpleButton;
public function InfoCloud(){
stageWidth = Preloader.stageWidth;
stageHeight = Preloader.stageHeight;
background = new Array(9);
checkboxes = new Array();
destSize = new Point(0, 0);
currSize = new Point(0, 0);
soundControl = MadNumbsFlash.gameApp.soundControl;
super();
background[0] = new Bitmap(new BitmapData(9, 9));
background[1] = new Bitmap(new BitmapData(9, 9));
background[2] = new Bitmap(new BitmapData(9, 9));
background[3] = new Bitmap(new BitmapData(9, 9));
background[4] = new Bitmap(new BitmapData(1, 9));
background[5] = new Bitmap(new BitmapData(1, 9));
background[6] = new Bitmap(new BitmapData(9, 1));
background[7] = new Bitmap(new BitmapData(9, 1));
background[8] = new Bitmap(new BitmapData(1, 1));
background[0].bitmapData.copyPixels(new Resources.imgInfoCloud().bitmapData, new Rectangle(0, 0, 9, 9), new Point(0, 0));
background[1].bitmapData.copyPixels(new Resources.imgInfoCloud().bitmapData, new Rectangle(10, 0, 9, 9), new Point(0, 0));
background[2].bitmapData.copyPixels(new Resources.imgInfoCloud().bitmapData, new Rectangle(0, 10, 9, 9), new Point(0, 0));
background[3].bitmapData.copyPixels(new Resources.imgInfoCloud().bitmapData, new Rectangle(10, 10, 9, 9), new Point(0, 0));
background[4].bitmapData.copyPixels(new Resources.imgInfoCloud().bitmapData, new Rectangle(9, 0, 1, 9), new Point(0, 0));
background[5].bitmapData.copyPixels(new Resources.imgInfoCloud().bitmapData, new Rectangle(9, 10, 1, 9), new Point(0, 0));
background[6].bitmapData.copyPixels(new Resources.imgInfoCloud().bitmapData, new Rectangle(0, 9, 9, 1), new Point(0, 0));
background[7].bitmapData.copyPixels(new Resources.imgInfoCloud().bitmapData, new Rectangle(10, 9, 9, 1), new Point(0, 0));
background[8].bitmapData.copyPixels(new Resources.imgInfoCloud().bitmapData, new Rectangle(9, 9, 1, 1), new Point(0, 0));
var _local1:int;
while (_local1 < 9) {
addChild(background[_local1]);
_local1++;
};
var _local2:Bitmap = new Bitmap(new BitmapData(55, 24));
var _local3:Bitmap = new Bitmap(new BitmapData(55, 24));
_local2.bitmapData.copyPixels(new Resources.imgButton().bitmapData, new Rectangle(0, 24, 55, 24), new Point(0, 0));
_local3.bitmapData.copyPixels(new Resources.imgButton().bitmapData, new Rectangle(0, 0, 55, 24), new Point(0, 0));
_local2.smoothing = true;
_local3.smoothing = true;
okButton = new SimpleButton(_local2, _local3, _local2, _local2);
addChild(okButton);
okButton.addEventListener(MouseEvent.CLICK, onOkClick);
sponsorLogo = new SpnsrLogo();
sponsorLogo.x = 129;
sponsorLogo.y = 287;
sponsorLogo.logoSprite.mask.x = sponsorLogo.x;
sponsorLogo.logoSprite.mask.y = sponsorLogo.y;
ads = new Advertisment();
ads.x = 116;
ads.y = 72;
MadNumbsFlash.gameApp.layers[9].addChild(ads);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function ShowAds():void{
var app:MadNumbsFlash = MadNumbsFlash.gameApp;
app.paused = true;
timer = getTimer();
infoType = "ads";
var adv_id:String = ((Math.random())>0.5) ? "6faacf024cebca46" : "455306bf9f04caf6";
var myOptions:Object = {id:adv_id, clip:ads, ad_failed:function ():void{
MadNumbsFlash.gameApp.AdvCloud.loaded = true;
}, ad_skipped:function ():void{
MadNumbsFlash.gameApp.AdvCloud.loaded = true;
}, ad_loaded:function ():void{
MadNumbsFlash.gameApp.AdvCloud.loaded = true;
}};
MochiAd.showClickAwayAd(myOptions);
var textFld:TextField = new TextField();
textFld.text = "Game Advertisment";
var textFormat:TextFormat = new TextFormat();
textFormat.color = 0xFFFFFF;
textFormat.font = "MyBerlinSans";
textFormat.align = TextFormatAlign.CENTER;
textFormat.size = 20;
textFld.setTextFormat(textFormat);
textFld.width;
textFld.embedFonts = true;
textFld.width = 320;
textImg = new Bitmap(new BitmapData(textFld.width, textFld.height, true, 0xFFFFFF));
textImg.bitmapData.draw(textFld);
textImg.smoothing = true;
addChild(textImg);
destSize.x = (300 + 15);
destSize.y = (250 + 60);
currSize.x = destSize.x;
currSize.y = destSize.y;
x = Math.round((((stageWidth / 2) - (destSize.x / 2)) - 9));
y = Math.round((((stageHeight / 2) - (destSize.y / 2)) - 9));
Grow();
}
public function ShowEnd(_arg1:Boolean=false):void{
var playerscore:String;
var o:Object;
var boardID:String;
var fobj:Object;
var aobj:Object;
var new_score:Number;
var UserLost = _arg1;
var app:MadNumbsFlash = MadNumbsFlash.gameApp;
app.paused = true;
infoType = "gameEnd";
var game_result:Number = 0;
if (app.game_mode == "multiplayer"){
app.sfs.removeEventListener(SFSEvent.onExtensionResponse, app.onExtensionResponse);
app.sfs.removeEventListener(SFSEvent.onSpectatorSwitched, app.onSpectatorSwitched);
};
soundControl.Play(3, 1);
MadNumbsFlash.gameApp.layers[8].addChild(sponsorLogo);
var textFld:TextField = new TextField();
if (((!((app.game_mode == "multiplayer"))) || ((UserLost == false)))){
if (app.game_mode != "multiplayer"){
if (app.score[0] > app.score[1]){
textFld.text = Localization.endGame1[app.currentLang];
game_result = 1;
} else {
if (app.score[1] > app.score[0]){
textFld.text = Localization.endGame2[app.currentLang];
} else {
textFld.text = Localization.endGame3[app.currentLang];
game_result = 1;
};
};
playerscore = app.score[0];
} else {
if ((((((app.score[0] > app.score[1])) && ((app.liquid_left == true)))) || ((((app.score[1] > app.score[0])) && ((app.liquid_left == false)))))){
textFld.text = Localization.endGame1[app.currentLang];
game_result = 1;
playerscore = String((app.wins + 1));
fobj = {};
fobj.game_id = app.game_id;
app.sfs.sendXtMessage(app.xtName, "finish", fobj);
} else {
if ((((((app.score[1] > app.score[0])) && ((app.liquid_left == true)))) || ((((app.score[0] > app.score[1])) && ((app.liquid_left == false)))))){
textFld.text = Localization.endGame2[app.currentLang];
} else {
if (app.score[1] == app.score[0]){
textFld.text = Localization.endGame3[app.currentLang];
};
};
};
};
} else {
if ((((app.game_mode == "multiplayer")) && ((UserLost == true)))){
if ((((((app.score[0] > app.score[1])) && ((app.liquid_left == true)))) || ((((app.score[1] > app.score[0])) && ((app.liquid_left == false)))))){
textFld.text = Localization.endGame4[app.currentLang];
game_result = 1;
playerscore = String((app.wins + 1));
aobj = {};
aobj.game_id = app.game_id;
app.sfs.sendXtMessage(app.xtName, "finish", aobj);
} else {
if ((((((app.score[1] > app.score[0])) && ((app.liquid_left == true)))) || ((((app.score[0] > app.score[1])) && ((app.liquid_left == false)))))){
textFld.text = Localization.endGame5[app.currentLang];
} else {
if (app.score[1] == app.score[0]){
textFld.text = Localization.endGame6[app.currentLang];
};
};
};
};
};
var textFormat:TextFormat = new TextFormat();
textFormat.color = 0xFFFFFF;
textFormat.font = "MyBerlinSans";
textFormat.size = 20;
textFld.setTextFormat(textFormat);
textFld.embedFonts = true;
textFld.autoSize = TextFieldAutoSize.LEFT;
textImg = new Bitmap(new BitmapData(textFld.width, textFld.height, true, 0xFFFFFF));
textImg.bitmapData.draw(textFld);
textImg.smoothing = true;
addChild(textImg);
currSize.x = 0;
currSize.y = 0;
destSize.x = (textImg.width + 5);
destSize.y = (textImg.height + 50);
x = Math.round((((stageWidth / 2) - (destSize.x / 2)) - 9));
y = Math.round((((stageHeight / 2) - (destSize.y / 2)) - 9));
Grow();
if (app.game_mode == "multiplayer"){
if ((((app.egPlayer == true)) && ((game_result == 1)))){
app.layers[8].addChild(app.infoCloud);
o = {n:[1, 0, 15, 0, 0, 6, 15, 1, 12, 13, 4, 2, 0, 14, 15, 12], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, name:app.your_name});
};
} else {
if (game_result == 1){
app.debugTrace("As winer you get X2 Scores!");
};
if (app.dificulty == 0){
o = {n:[7, 13, 12, 13, 3, 15, 2, 2, 3, 8, 0, 1, 2, 15, 4, 14], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
} else {
if (app.dificulty == 1){
o = {n:[9, 0, 8, 14, 15, 10, 3, 3, 3, 8, 11, 8, 13, 8, 13, 2], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
} else {
if (app.dificulty == 2){
o = {n:[3, 7, 13, 0, 2, 11, 3, 14, 10, 1, 3, 9, 3, 0, 2, 2], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
};
};
};
boardID = o.f(0, "");
new_score = (Math.abs(Number(playerscore)) * ((game_result)==1) ? 2 : 1);
MochiScores.showLeaderboard({boardID:boardID, score:new_score.toString()});
};
}
public function ShowLanguage():void{
var _local4:Bitmap;
var _local5:Bitmap;
MadNumbsFlash.gameApp.paused = true;
infoType = "language";
soundControl.Play(3, 1);
var _local1:TextField = new TextField();
_local1.text = Localization.langName[0];
var _local2:int;
while (_local2 < Localization.numLang) {
_local4 = new Bitmap(new BitmapData(24, 24));
_local5 = new Bitmap(new BitmapData(24, 24));
_local4.bitmapData.copyPixels(new Resources.imgCheckbox().bitmapData, new Rectangle(0, 24, 24, 24), new Point(0, 0));
_local5.bitmapData.copyPixels(new Resources.imgCheckbox().bitmapData, new Rectangle(0, 0, 24, 24), new Point(0, 0));
_local4.smoothing = true;
_local5.smoothing = true;
checkboxes[_local2] = new SimpleButton(_local4, _local4, _local5, _local5);
checkboxes[_local2].addEventListener(MouseEvent.MOUSE_UP, onCheckboxClick);
addChild(checkboxes[_local2]);
if (_local2 == 0){
} else {
_local1.appendText(("\n" + Localization.langName[_local2]));
};
_local2++;
};
checkboxes[0].enabled = false;
checkboxes[0].downState = checkboxes[0].upState;
checkboxes[0].upState = checkboxes[0].hitTestState;
checkboxes[0].overState = checkboxes[0].hitTestState;
var _local3:TextFormat = new TextFormat();
_local3.color = 0xFFFFFF;
_local3.font = "Arial Black";
_local3.size = 17;
_local3.leading = 6;
_local1.setTextFormat(_local3);
_local1.autoSize = TextFieldAutoSize.LEFT;
textImg = new Bitmap(new BitmapData(_local1.width, _local1.height, true, 0xFFFFFF));
textImg.bitmapData.draw(_local1);
textImg.smoothing = true;
addChild(textImg);
currSize.x = 0;
currSize.y = 0;
destSize.x = (_local1.width + 35);
destSize.y = (_local1.height + 50);
x = Math.round((((stageWidth / 2) - (destSize.x / 2)) - 9));
y = Math.round((((stageHeight / 2) - (destSize.y / 2)) - 9));
Grow();
}
public function ShowDificulty():void{
var _local4:Bitmap;
var _local5:Bitmap;
MadNumbsFlash.gameApp.paused = true;
MadNumbsFlash.gameApp.dificulty = 0;
infoType = "dificulty";
soundControl.Play(3, 1);
var _local1:TextField = new TextField();
_local1.text = Localization.dificulty[MadNumbsFlash.gameApp.currentLang];
var _local2:int;
while (_local2 < 3) {
_local4 = new Bitmap(new BitmapData(24, 24));
_local5 = new Bitmap(new BitmapData(24, 24));
_local4.bitmapData.copyPixels(new Resources.imgCheckbox().bitmapData, new Rectangle(0, 24, 24, 24), new Point(0, 0));
_local5.bitmapData.copyPixels(new Resources.imgCheckbox().bitmapData, new Rectangle(0, 0, 24, 24), new Point(0, 0));
_local4.smoothing = true;
_local5.smoothing = true;
checkboxes[_local2] = new SimpleButton(_local4, _local4, _local5, _local5);
checkboxes[_local2].addEventListener(MouseEvent.MOUSE_UP, onCheckboxClick);
addChild(checkboxes[_local2]);
_local2++;
};
checkboxes[0].enabled = false;
checkboxes[0].downState = checkboxes[0].upState;
checkboxes[0].upState = checkboxes[0].hitTestState;
checkboxes[0].overState = checkboxes[0].hitTestState;
var _local3:TextFormat = new TextFormat();
_local3.color = 0xFFFFFF;
_local3.font = "MyBerlinSans";
_local3.size = 20;
_local3.leading = 8;
_local1.setTextFormat(_local3);
_local1.embedFonts = true;
_local1.autoSize = TextFieldAutoSize.LEFT;
textImg = new Bitmap(new BitmapData(_local1.width, _local1.height, true, 0xFFFFFF));
textImg.bitmapData.draw(_local1);
textImg.smoothing = true;
addChild(textImg);
currSize.x = 0;
currSize.y = 0;
destSize.x = (_local1.width + 35);
destSize.y = (_local1.height + 50);
x = Math.round((((stageWidth / 2) - (destSize.x / 2)) - 9));
y = Math.round((((stageHeight / 2) - (destSize.y / 2)) - 9));
Grow();
}
public function ShowRules():void{
MadNumbsFlash.gameApp.paused = true;
infoType = "rules";
soundControl.Play(3, 1);
var _local1:TextField = new TextField();
_local1.text = Localization.rules[MadNumbsFlash.gameApp.currentLang];
var _local2:TextFormat = new TextFormat();
_local2.color = 0xFFFFFF;
_local2.font = "MyBerlinSans";
_local2.size = 16;
_local1.setTextFormat(_local2);
_local1.wordWrap = true;
_local1.embedFonts = true;
_local1.width = 250;
_local1.autoSize = TextFieldAutoSize.LEFT;
textImg = new Bitmap(new BitmapData(_local1.width, _local1.height, true, 0xFFFFFF));
textImg.bitmapData.draw(_local1);
textImg.smoothing = true;
addChild(textImg);
currSize.x = 0;
currSize.y = 0;
destSize.x = (_local1.width + 35);
destSize.y = (_local1.height + 50);
x = Math.round((((stageWidth / 2) - (destSize.x / 2)) - 9));
y = Math.round((((stageHeight / 2) - (destSize.y / 2)) - 9));
Grow();
}
public function Hide():void{
var _local1:int;
if (checkboxes.length > 0){
_local1 = 0;
while (_local1 < checkboxes.length) {
removeChild(checkboxes[_local1]);
delete checkboxes[_local1];
_local1++;
};
};
checkboxes.length = 0;
removeChild(textImg);
if (ads.parent != null){
ads.parent.removeChild(ads);
};
MadNumbsFlash.gameApp.paused = false;
if (infoType == "language"){
MadNumbsFlash.gameApp.CreateEnviroment();
} else {
if (infoType == "dificulty"){
MadNumbsFlash.gameApp.CreateGameField();
} else {
if (infoType == "gameEnd"){
MadNumbsFlash.gameApp.EndGame();
};
};
};
infoType = "none";
if (sponsorLogo.parent != null){
sponsorLogo.parent.removeChild(sponsorLogo);
};
parent.removeChild(this);
}
public function ShowMessage(_arg1:String, _arg2:Boolean=false):void{
MadNumbsFlash.gameApp.paused = true;
infoType = "rules";
if (_arg2 == true){
okButton.visible = false;
};
soundControl.Play(3, 1);
var _local3:TextField = new TextField();
_local3.text = _arg1;
var _local4:TextFormat = new TextFormat();
_local4.color = 0xFFFFFF;
_local4.font = "MyBerlinSans";
_local4.size = 16;
_local3.setTextFormat(_local4);
_local3.wordWrap = true;
_local3.embedFonts = true;
_local3.width = 250;
_local3.autoSize = TextFieldAutoSize.LEFT;
textImg = new Bitmap(new BitmapData(_local3.width, _local3.height, true, 0xFFFFFF));
textImg.bitmapData.draw(_local3);
textImg.smoothing = true;
addChild(textImg);
currSize.x = 0;
currSize.y = 0;
destSize.x = (_local3.width + 35);
destSize.y = (_local3.height + 50);
x = Math.round((((stageWidth / 2) - (destSize.x / 2)) - 9));
y = Math.round((((stageHeight / 2) - (destSize.y / 2)) - 9));
Grow();
}
private function onOkClick(_arg1:MouseEvent):void{
soundControl.Play(0, 1);
if (infoType == "ads"){
if ((((loaded == true)) && (((getTimer() - timer) >= 3000)))){
Hide();
};
} else {
Hide();
};
}
private function onEnterFrame(_arg1:Event):void{
if ((((destSize.x > currSize.x)) || ((destSize.y > currSize.y)))){
Grow();
};
}
private function Grow():void{
var _local5:int;
var _local1:Number = 20;
if (currSize.y == 0){
_local1 = (destSize.x / destSize.y);
if (_local1 < 1){
_local1 = (1 / _local1);
};
} else {
_local1 = (_local1 - (((currSize.y / destSize.y) * _local1) * 0.9));
};
var _local2:Point = new Point();
if (destSize.y > destSize.x){
_local2.y = (currSize.y + _local1);
_local2.x = (currSize.x + (_local1 * (destSize.x / destSize.y)));
} else {
_local2.x = (currSize.x + _local1);
_local2.y = (currSize.y + (_local1 * (destSize.y / destSize.x)));
};
if (_local2.x > destSize.x){
_local2.x = destSize.x;
};
if (_local2.y > destSize.y){
_local2.y = destSize.y;
};
currSize = _local2;
_local2.x = Math.round(_local2.x);
_local2.y = Math.round(_local2.y);
background[4].scaleX = _local2.x;
background[5].scaleX = _local2.x;
background[6].scaleY = _local2.y;
background[7].scaleY = _local2.y;
background[8].scaleX = _local2.x;
background[8].scaleY = _local2.y;
var _local3:Point = new Point();
_local3.x = Math.round(((destSize.x - currSize.x) / 2));
_local3.y = Math.round(((destSize.y - currSize.y) / 2));
background[0].x = (0 + _local3.x);
background[0].y = (0 + _local3.y);
background[1].x = ((9 + _local2.x) + _local3.x);
background[1].y = (0 + _local3.y);
background[2].x = (0 + _local3.x);
background[2].y = ((9 + _local2.y) + _local3.y);
background[3].x = ((9 + _local2.x) + _local3.x);
background[3].y = ((9 + _local2.y) + _local3.y);
background[4].x = (9 + _local3.x);
background[4].y = (0 + _local3.y);
background[5].x = (9 + _local3.x);
background[5].y = ((9 + _local2.y) + _local3.y);
background[6].x = (0 + _local3.x);
background[6].y = (9 + _local3.y);
background[7].x = ((9 + _local2.x) + _local3.x);
background[7].y = (9 + _local3.y);
background[8].x = (9 + _local3.x);
background[8].y = (9 + _local3.y);
var _local4:Number = (currSize.y / destSize.y);
okButton.scaleX = _local4;
okButton.scaleY = _local4;
okButton.x = (((destSize.x / 2) - (okButton.width / 2)) + 9);
okButton.y = (((destSize.y + 12) - _local3.y) - (30 * _local4));
textImg.scaleX = _local4;
textImg.scaleY = _local4;
if (checkboxes.length > 0){
_local5 = 0;
while (_local5 < checkboxes.length) {
checkboxes[_local5].scaleX = _local4;
checkboxes[_local5].scaleY = _local4;
checkboxes[_local5].x = ((6 + (9 * _local4)) + _local3.x);
checkboxes[_local5].y = (((6 + (9 * _local4)) + _local3.y) + ((30 * _local5) * _local4));
_local5++;
};
textImg.x = ((6 + (37 * _local4)) + _local3.x);
textImg.y = ((6 + (5 * _local4)) + _local3.y);
} else {
textImg.x = ((6 + (4 * _local4)) + _local3.x);
textImg.y = (6 + _local3.y);
};
}
private function onCheckboxClick(_arg1:MouseEvent):void{
soundControl.Play(0, 1);
var _local2:int;
while (_local2 < checkboxes.length) {
if (!checkboxes[_local2].enabled){
checkboxes[_local2].enabled = true;
checkboxes[_local2].upState = checkboxes[_local2].downState;
checkboxes[_local2].overState = checkboxes[_local2].downState;
checkboxes[_local2].downState = checkboxes[_local2].hitTestState;
};
_local2++;
};
_arg1.currentTarget.enabled = false;
_arg1.currentTarget.downState = _arg1.currentTarget.upState;
_arg1.currentTarget.upState = _arg1.currentTarget.hitTestState;
_arg1.currentTarget.overState = _arg1.currentTarget.hitTestState;
_local2 = 0;
while (_local2 < checkboxes.length) {
if (!checkboxes[_local2].enabled){
if (infoType == "language"){
MadNumbsFlash.gameApp.currentLang = _local2;
} else {
if (infoType == "dificulty"){
MadNumbsFlash.gameApp.dificulty = _local2;
};
};
};
_local2++;
};
}
}
}//package
Section 38
//Liquid (Liquid)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.geom.*;
public class Liquid extends Sprite {
private var currScore:Number;// = 0
private var redLiq:Bitmap;
public var predel:int;// = 10
private var currLiq:String;// = "green"
public var text:TextField;
private var setScore:Number;// = 0
private var greenLiq:Bitmap;
public function Liquid(){
text = new TextField();
super();
redLiq = new Bitmap(new BitmapData(32, 144));
redLiq.bitmapData.copyPixels(new Resources.imgProbirksLiquid().bitmapData, new Rectangle(0, 9, 32, 9), new Point());
redLiq.bitmapData.fillRect(new Rectangle(0, 9, 32, 135), 4285993984);
redLiq.y = (78 - ((62 / predel) * 0));
addChild(redLiq);
greenLiq = new Bitmap(new BitmapData(32, 144));
greenLiq.bitmapData.copyPixels(new Resources.imgProbirksLiquid().bitmapData, new Rectangle(0, 0, 32, 9), new Point());
greenLiq.bitmapData.fillRect(new Rectangle(0, 9, 32, 135), 4278220544);
greenLiq.y = (78 - ((62 / predel) * 0));
addChild(greenLiq);
var _local1:TextFormat = new TextFormat();
_local1.font = "MyBerlinSans";
_local1.size = 12;
_local1.align = TextFormatAlign.CENTER;
text.antiAliasType = AntiAliasType.NORMAL;
text.embedFonts = true;
text.defaultTextFormat = _local1;
text.text = "0";
text.width = 50;
text.textColor = 0xFFFFFF;
text.selectable = false;
MadNumbsFlash.gameApp.layers[8].addChild(text);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
var _local2:Number;
if ((((currLiq == "green")) && ((greenLiq.alpha < 1)))){
greenLiq.alpha = (greenLiq.alpha + 0.1);
} else {
if ((((currLiq == "red")) && ((greenLiq.alpha > 0)))){
greenLiq.alpha = (greenLiq.alpha - 0.1);
};
};
if (setScore != currScore){
if (setScore > currScore){
_local2 = (((setScore - currScore) + (predel / 50)) / 10);
if ((_local2 + currScore) > setScore){
_local2 = (setScore - currScore);
};
} else {
_local2 = (((setScore - currScore) - (predel / 50)) / 10);
if ((_local2 + currScore) < setScore){
_local2 = (setScore - currScore);
};
};
currScore = (currScore + _local2);
greenLiq.y = (78 - ((62 / predel) * currScore));
redLiq.y = (78 - ((62 / predel) * currScore));
};
}
public function SetScore(_arg1:int, _arg2:Boolean):void{
text.text = String(_arg1);
setScore = _arg1;
if (setScore > predel){
setScore = predel;
} else {
if (setScore < -(predel)){
setScore = -(predel);
};
};
if ((((currLiq == "green")) && (!(_arg2)))){
currLiq = "red";
} else {
if ((((currLiq == "red")) && (_arg2))){
currLiq = "green";
};
};
}
}
}//package
Section 39
//Localization (Localization)
package {
public class Localization {
public static var endGame5:Array = new Array(numLang);
public static var buttonText1:Array = new Array(numLang);
public static var buttonText2:Array = new Array(numLang);
public static var numLang:int = 2;
public static var langName:Array = new Array(numLang);
public static var buttonText3:Array = new Array(numLang);
public static var endGame2:Array = new Array(numLang);
public static var endGame4:Array = new Array(numLang);
public static var endGame6:Array = new Array(numLang);
public static var endGame1:Array = new Array(numLang);
public static var endGame3:Array = new Array(numLang);
public static var rules:Array = new Array(numLang);
public static var dificulty:Array = new Array(numLang);
langName[0] = "English";
langName[1] = "Russian";
rules[0] = " The player and a computer go by turns, the player goes only on a horizontal line from the previous choice, and a computer only on a vertical.\n Light blocks add points, and dark are take them away.\n The choice needs to be chosen so that you received as much as possible a maximum quantity of points, and thus the computer in next turn has received a minimum quantity of points";
rules[1] = " Игрок и компьютер ходят по очереди, игрок ходит только по горизонтали от предыдущего выбора, а компьютер только по вертикали.\n Светлые блоки прибавляют очки, а темные отнимают.\n Свой ход нужно выбирать таким образом, чтобы тебе досталось максимально большое количество очков, и при этом компьютер в следующем ходу получил минимальное количество очков";
buttonText1[0] = "SINGLE GAME";
buttonText1[1] = "НОВАЯ ИГРА";
buttonText2[0] = "RULES";
buttonText2[1] = "ПРАВИЛА";
buttonText3[0] = "MULTIPLAYER";
buttonText3[1] = "ИГРАТЬ ОНЛАЙН";
dificulty[0] = "SHORT\nMEDIUM\nLONG";
dificulty[1] = "ЛЕГКО\nСРЕДНЕ\nСЛОЖНО";
endGame1[0] = "YOU WIN THE GAME!";
endGame1[1] = "ВЫ ПОБЕДИЛИ!";
endGame2[0] = "SORRY - YOU LOSE :(";
endGame2[1] = "ВЫ ПРОИГРАЛИ :(";
endGame3[0] = "DRAW GAME";
endGame3[1] = "НИЧЬЯ";
endGame4[0] = "YOUR OPPONENT ARE DISCONNECTED!\nYOU WIN THE GAME!";
endGame4[1] = "СОПЕРНИК ОТКЛЮЧИЛСЯ!\nВЫ ПОБЕДИЛИ!";
endGame5[0] = "YOUR OPPONENT ARE DISCONNECTED!\nSORRY - YOU LOSE :(";
endGame5[1] = "СОПЕРНИК ОТКЛЮЧИЛСЯ!\nВЫ ПРОИГРАЛИ :(";
endGame6[0] = "YOUR OPPONENT ARE DISCONNECTED!\nDRAW GAME";
endGame6[1] = "СОПЕРНИК ОТКЛЮЧИЛСЯ!\nНИЧЬЯ";
}
}//package
Section 40
//MadNumbsFlash (MadNumbsFlash)
package {
import flash.events.*;
import it.gotoandplay.smartfoxserver.*;
import flash.display.*;
import it.gotoandplay.smartfoxserver.data.*;
import flash.net.*;
import flash.text.*;
import flash.geom.*;
public dynamic class MadNumbsFlash extends MovieClip {
private var field:Bitmap;
public var currentLang:int;// = 0
private var roomListEvent:SFSEvent;
private var iAmSpectator:Boolean;
private var memScore1:int;
private var memScore2:int;
public var your_name:String;
private var player1Name:String;
public var egPlayer:Boolean;// = false
public var wins:Number;// = 0
public var infoCloud:InfoCloud;
private var myOpponent:User;
public var liquid_left:Boolean;// = true
public var opponent_name:String;
public var paused:Boolean;// = false
private var gameStarted:Boolean;
private var whoseTurn:int;
public var dificulty:int;// = 0
public var liquid:Array;
public var ta_info:TextField;
public var layers:Array;
private var blackScreen:Sprite;
public var soundControl:SoundControl;
public var numbs:Array;
public var menu:Bitmap;
public var AdvCloud:InfoCloud;
private var serverPort:int;// = 9339
public var stageWidth:Number;
private var player2Id:int;
public var guestLogin:String;// = "guest"
public var connection_status:String;// = "none"
public var leaderboard:Sprite;
public var kongregate_flashVarsName:String;// = "kongregate_username"
public var sfs:SmartFoxClient;
public var currEvent:String;// = "none"
private var selection:Selection;
public var game_id:int;
public var score:Array;
public var turn:int;
private var myPlayerID:int;
private var tick:int;// = 0
private var serverZone:String;// = "MadNumbs"
private var pmUserId:int;
public var xtName:String;// = "MadNumbs"
private var player1Id:int;
public var menu2:Bitmap;
private var player2Name:String;
public var maxDepth:int;
public var canMove:Boolean;// = false
public var stageHeight:Number;
public var welcomScr:WelcomScreen;
public var maxGrid:int;
private var serverIp:String;// = "208.78.96.244"
public var game_mode:String;// = "single"
public var ng_flashVarsName:String;// = "ng_username"
public var flashVarsName:String;// = "user_name"
private var board:Array;
public var line:int;
public static var gameApp:MadNumbsFlash;
public function MadNumbsFlash(){
stageWidth = Preloader.stageWidth;
stageHeight = Preloader.stageHeight;
layers = new Array(11);
liquid = new Array(2);
numbs = new Array();
score = new Array(2);
super();
}
private function Button3DClick(_arg1:MouseEvent):void{
if (paused){
return;
};
if (_arg1.currentTarget.hitShape.hitTestPoint(_arg1.stageX, _arg1.stageY, true)){
soundControl.Play(0, 1);
if (_arg1.currentTarget.ID == "game"){
if (connection_status != "none"){
sfs.disconnect();
};
game_mode = "single";
debugTrace("");
soundControl.Stop(1);
currEvent = "showWelcome";
liquid[0].SetScore(0, true);
liquid[1].SetScore(0, true);
layers[8].addChild(infoCloud);
infoCloud.ShowDificulty();
menu2.visible = false;
menu.visible = true;
} else {
if (_arg1.currentTarget.ID == "rules"){
layers[8].addChild(infoCloud);
infoCloud.ShowRules();
} else {
if (_arg1.currentTarget.ID == "multiplayer"){
if (connection_status == "none"){
soundControl.Stop(1);
currEvent = "showWelcome";
liquid[0].SetScore(0, true);
liquid[1].SetScore(0, true);
menu.visible = false;
menu2.visible = true;
debugTrace("Waiting for Connection...");
pmUserId = -1;
sfs = new SmartFoxClient(true);
sfs.addEventListener(SFSEvent.onConnection, onConnection);
sfs.addEventListener(SFSEvent.onLogin, onLogin);
sfs.addEventListener(SFSEvent.onConnectionLost, onConnectionLost);
sfs.addEventListener(SFSEvent.onRoomListUpdate, onRoomListUpdate);
sfs.addEventListener(SFSEvent.onJoinRoom, onJoinRoom);
sfs.addEventListener(SFSEvent.onJoinRoomError, onJoinRoomError);
sfs.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
sfs.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
sfs.addEventListener(SFSEvent.onExtensionResponse, onExtensionResponse);
sfs.addEventListener(SFSEvent.onSpectatorSwitched, onSpectatorSwitched);
sfs.connect(serverIp, serverPort);
};
} else {
if (_arg1.currentTarget.ID == "sound"){
soundControl.TouchSound();
} else {
if (_arg1.currentTarget.ID == "more"){
navigateToURL(new URLRequest("http://www.elite-games.net/in.php?id=37"));
};
};
};
};
};
};
}
public function onRoomListUpdate(_arg1:SFSEvent):void{
connection_status = "Room list received";
debugTrace(connection_status);
sfs.autoJoin();
}
public function onConnection(_arg1:SFSEvent):void{
var _local3:String;
var _local2:Boolean = _arg1.params.success;
if (_local2){
connection_status = ((("Connected to " + serverIp) + ":") + serverPort);
debugTrace(connection_status);
_local3 = ((guestLogin + "_") + Math.floor((Math.random() * 10000)));
if (Preloader.App.loaderInfo.parameters[flashVarsName] != undefined){
_local3 = String(Preloader.App.loaderInfo.parameters[flashVarsName]);
egPlayer = true;
} else {
if (Preloader.App.loaderInfo.parameters[kongregate_flashVarsName] != undefined){
_local3 = String(Preloader.App.loaderInfo.parameters[kongregate_flashVarsName]);
egPlayer = true;
} else {
if (Preloader.App.loaderInfo.parameters[ng_flashVarsName] != undefined){
_local3 = String(Preloader.App.loaderInfo.parameters[ng_flashVarsName]);
egPlayer = true;
};
};
};
sfs.login(serverZone, _local3, "");
} else {
connection_status = ((("Failed connecting to " + serverIp) + ":") + serverPort);
debugTrace(connection_status);
};
}
public function onSecurityError(_arg1:SecurityErrorEvent):void{
layers[8].addChild(infoCloud);
infoCloud.ShowMessage(("Security error: " + _arg1.text), true);
}
public function SplashScr():void{
MochiBot.track(this, "85fa70ec");
gameApp = this;
stage.showDefaultContextMenu = false;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
Init();
}
public function onJoinRoom(_arg1:SFSEvent):void{
connection_status = ("Successfully joined room: " + _arg1.params.room.getName());
debugTrace(connection_status);
sfs.playerId = sfs.myUserId;
dificulty = 0;
game_mode = "multiplayer";
}
private function Init():void{
soundControl = new SoundControl();
var _local1:int;
while (_local1 < layers.length) {
layers[_local1] = new Sprite();
addChild(layers[_local1]);
_local1++;
};
leaderboard = new Advertisment();
layers[(layers.length - 1)].addChild(leaderboard);
MochiServices.connect("455306bf9f04caf6", leaderboard);
blackScreen = new Sprite();
blackScreen.graphics.beginFill(0);
blackScreen.graphics.drawRect(0, 0, stageWidth, stageHeight);
blackScreen.graphics.endFill();
layers[8].addChild(blackScreen);
infoCloud = new InfoCloud();
CreateEnviroment();
}
public function Choose(_arg1:Numb):void{
var _local3:int;
_arg1.Destroy();
score[turn] = (score[turn] + _arg1.number);
_arg1.number = 99;
liquid[0].SetScore(score[0], (score[0] >= score[1]));
liquid[1].SetScore(score[1], (score[1] >= score[0]));
var _local2:int;
if (turn == 0){
_local3 = 0;
while (_local3 < maxGrid) {
numbs[_local3][line].SetUnselectable();
_local3++;
};
line = _arg1.posX;
turn = 1;
_local3 = 0;
while (_local3 < maxGrid) {
if (numbs[line][_local3].destroyed){
_local2++;
};
numbs[line][_local3].SetSelectable();
_local3++;
};
} else {
_local3 = 0;
while (_local3 < maxGrid) {
numbs[line][_local3].SetUnselectable();
_local3++;
};
line = _arg1.posY;
turn = 0;
_local3 = 0;
while (_local3 < maxGrid) {
if (numbs[_local3][line].destroyed){
_local2++;
};
numbs[_local3][line].SetSelectable();
_local3++;
};
};
if (_local2 == maxGrid){
layers[8].addChild(infoCloud);
infoCloud.ShowEnd();
} else {
if (game_mode != "multiplayer"){
tick = 0;
currEvent = "aiTurn";
} else {
currEvent = "none";
};
};
}
public function onJoinRoomError(_arg1:SFSEvent):void{
connection_status = ("Problems joining default room. Reason: " + _arg1.params.error);
debugTrace(_arg1.params.error);
}
private function onNumbClick(_arg1:MouseEvent):void{
var _local3:Object;
var _local2:Numb = (_arg1.currentTarget as Numb);
if (game_mode == "multiplayer"){
if ((((((((canMove == true)) && (_local2.selectable))) && (!(paused)))) && ((whoseTurn == sfs.myUserId)))){
canMove = false;
Choose(_local2);
_local3 = {};
_local3.index = (_local2.posX + (maxGrid * _local2.posY));
_local3.game_id = game_id;
sfs.sendXtMessage(xtName, "move", _local3);
debugTrace("Send Move...");
};
} else {
if (((((_local2.selectable) && (!(paused)))) && ((turn == 0)))){
Choose(_local2);
};
};
}
public function EndGame():void{
if (game_mode == "multiplayer"){
if (connection_status != "none"){
sfs.removeEventListener(SFSEvent.onExtensionResponse, onExtensionResponse);
sfs.removeEventListener(SFSEvent.onSpectatorSwitched, onSpectatorSwitched);
sfs.disconnect();
};
gameStarted = false;
};
currEvent = "showWelcome";
soundControl.Stop(1);
}
public function startGame(_arg1:Object):void{
whoseTurn = _arg1.t;
player1Id = _arg1.p1i;
player2Id = _arg1.p2i;
player1Name = _arg1.p1n;
player2Name = _arg1.p2n;
board = _arg1.board;
if (player1Id == sfs.myUserId){
your_name = player1Name;
opponent_name = player2Name;
} else {
if (player2Id == sfs.myUserId){
your_name = player2Name;
opponent_name = player1Name;
};
};
if (whoseTurn == sfs.myUserId){
debugTrace("Your turn!");
canMove = true;
} else {
debugTrace((("Turn of " + opponent_name) + "!"));
canMove = false;
};
gameStarted = true;
CreateGameField();
}
public function CreateEnviroment():void{
var _local2:Button3D;
welcomScr = new WelcomScreen();
welcomScr.x = 6;
welcomScr.y = 6;
layers[7].addChild(welcomScr);
var _local1:Bitmap = new Resources.imgMenuRightLine();
_local1.x = 520;
_local1.y = 30;
_local1.scaleY = 358;
layers[7].addChild(_local1);
_local2 = new Button3D("MORE GAMES", 408, 334, "more");
layers[6].addChild(_local2);
_local2.addEventListener(MouseEvent.CLICK, Button3DClick);
_local2 = new Button3D(Localization.buttonText2[currentLang], 408, 299, "rules");
layers[6].addChild(_local2);
_local2.addEventListener(MouseEvent.CLICK, Button3DClick);
_local2 = new Button3D(Localization.buttonText3[currentLang], 408, 264, "multiplayer");
layers[6].addChild(_local2);
_local2.addEventListener(MouseEvent.CLICK, Button3DClick);
_local2 = new Button3D(Localization.buttonText1[currentLang], 408, 229, "game");
layers[6].addChild(_local2);
_local2.addEventListener(MouseEvent.CLICK, Button3DClick);
menu2 = new Resources.imgMenu2();
menu2.x = 400;
menu2.y = 7;
layers[5].addChild(menu2);
menu2.visible = false;
menu = new Resources.imgMenu();
menu.x = 400;
menu.y = 7;
layers[5].addChild(menu);
var _local3:Bitmap = new Bitmap(new BitmapData(88, 140));
_local3.bitmapData.copyPixels(new Resources.imgProbirksBack().bitmapData, new Rectangle(0, 0, 32, 135), new Point(0, 0));
_local3.bitmapData.copyPixels(new Resources.imgProbirksBack().bitmapData, new Rectangle(32, 0, 32, 135), new Point(56, 5));
_local3.x = 423;
_local3.y = 30;
layers[3].addChild(_local3);
liquid[0] = new Liquid();
liquid[0].x = 423;
liquid[0].y = 21;
liquid[0].text.x = 415;
liquid[0].text.y = 15;
layers[4].addChild(liquid[0]);
liquid[1] = new Liquid();
liquid[1].x = 479;
liquid[1].y = 26;
liquid[1].text.x = 471;
liquid[1].text.y = 20;
layers[4].addChild(liquid[1]);
var _local4:Bitmap = new Bitmap(new BitmapData(394, 394));
_local4.bitmapData.copyPixels(new Resources.imgGridBorder().bitmapData, new Rectangle(0, 0, 5, 5), new Point(6, 6));
var _local5:int;
while (_local5 < 381) {
_local4.bitmapData.copyPixels(new Resources.imgGridBorder().bitmapData, new Rectangle(5, 0, 1, 5), new Point((11 + _local5), 6));
_local4.bitmapData.copyPixels(new Resources.imgGridBorder().bitmapData, new Rectangle(0, 5, 5, 1), new Point(6, (11 + _local5)));
_local5++;
};
_local4.bitmapData.fillRect(new Rectangle(0, 0, 6, 394), 4291155171);
_local4.bitmapData.fillRect(new Rectangle(0, 0, 394, 6), 4291155171);
layers[0].addChild(_local4);
_local4 = new Bitmap(new BitmapData(stageWidth, (stageHeight - 392), true, 0xFFFFFF));
_local4.bitmapData.copyPixels(new Resources.imgGridBorder().bitmapData, new Rectangle(0, 6, 5, 2), new Point(6, 0));
_local4.bitmapData.copyPixels(new Resources.imgGridBorder().bitmapData, new Rectangle(6, 6, 2, 2), new Point(392, 0));
_local5 = 0;
while (_local5 < 381) {
_local4.bitmapData.copyPixels(new Resources.imgGridBorder().bitmapData, new Rectangle(5, 6, 1, 2), new Point((11 + _local5), 0));
_local5++;
};
_local4.bitmapData.fillRect(new Rectangle(0, 2, stageWidth, (stageHeight - 394)), 4291155171);
_local4.y = 392;
layers[2].addChild(_local4);
_local4 = new Bitmap(new BitmapData(141, 394, true, 0xFFFFFF));
_local4.bitmapData.copyPixels(new Resources.imgGridBorder().bitmapData, new Rectangle(6, 0, 2, 5), new Point(0, 6));
_local5 = 0;
while (_local5 < 381) {
_local4.bitmapData.copyPixels(new Resources.imgGridBorder().bitmapData, new Rectangle(6, 5, 2, 1), new Point(0, (11 + _local5)));
_local5++;
};
_local4.bitmapData.fillRect(new Rectangle(2, 0, 139, 394), 4291155171);
_local4.x = 392;
layers[2].addChild(_local4);
selection = new Selection();
layers[6].addChild(selection);
field = new Bitmap(new BitmapData(384, 384));
field.x = 11;
field.y = 11;
layers[0].addChild(field);
ta_info = new TextField();
ta_info.text = "";
var _local6:TextFormat = new TextFormat();
_local6.color = 204;
_local6.font = "MyBerlinSans";
_local6.size = 12;
ta_info.setTextFormat(_local6);
ta_info.wordWrap = true;
ta_info.embedFonts = true;
ta_info.selectable = false;
ta_info.width = 350;
ta_info.autoSize = TextFieldAutoSize.LEFT;
layers[9].addChild(ta_info);
ta_info.x = 0;
ta_info.y = -3;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function CreateGameField():void{
var _local4:int;
soundControl.Play(1, 999, true);
currEvent = "hideWelcome";
maxGrid = (8 + (4 * dificulty));
maxDepth = (2 * 2);
score[0] = 0;
score[1] = 0;
turn = 0;
line = (maxGrid / 2);
var _local1:Bitmap = new (Resources.imgGrid[dificulty]);
var _local2:int;
while (_local2 < (384 / _local1.width)) {
_local4 = 0;
while (_local4 < (384 / _local1.height)) {
field.bitmapData.copyPixels(_local1.bitmapData, new Rectangle(0, 0, _local1.width, _local1.height), new Point((_local2 * _local1.width), (_local4 * _local1.height)));
_local4++;
};
_local2++;
};
_local2 = 0;
while (_local2 < numbs.length) {
_local4 = 0;
while (_local4 < numbs[_local2].length) {
if (numbs[_local2][_local4].parent){
layers[1].removeChild(numbs[_local2][_local4]);
};
delete numbs[_local2][_local4];
_local4++;
};
delete numbs[_local2];
_local2++;
};
numbs.length = 0;
var _local3:int;
_local2 = 0;
while (_local2 < maxGrid) {
numbs[_local2] = new Array(maxGrid);
_local4 = 0;
while (_local4 < maxGrid) {
if (game_mode == "multiplayer"){
numbs[_local2][_local4] = new Numb(_local2, _local4, board[(_local2 + (_local4 * maxGrid))], false);
} else {
numbs[_local2][_local4] = new Numb(_local2, _local4);
};
_local3 = (_local3 + Math.abs(numbs[_local2][_local4].number));
numbs[_local2][_local4].addEventListener(MouseEvent.CLICK, onNumbClick);
layers[1].addChild(numbs[_local2][_local4]);
if (_local4 == line){
numbs[_local2][_local4].SetSelectable();
};
_local4++;
};
_local2++;
};
liquid[0].predel = (_local3 / 4);
liquid[1].predel = (_local3 / 4);
liquid[0].SetScore(score[0], (score[0] >= score[1]));
liquid[1].SetScore(score[1], (score[1] >= score[0]));
}
public function onExtensionResponse(_arg1:SFSEvent):void{
var _local2:Object = _arg1.params.dataObj;
var _local3:String = _local2._cmd;
switch (_local3){
case "join":
game_id = _local2.game_id;
liquid_left = ((_local2.whoseTurn)==sfs.myUserId) ? true : false;
wins = _local2.uwins;
getReady();
break;
case "start":
startGame(_local2);
break;
case "stop":
layers[8].addChild(infoCloud);
infoCloud.ShowEnd(true);
break;
case "move":
moveReceived(_local2);
break;
case "specStatus":
break;
case "win":
case "tie":
break;
};
}
public function debugTrace(_arg1:String):void{
layers[9].removeChild(ta_info);
ta_info = new TextField();
ta_info.text = _arg1;
var _local2:TextFormat = new TextFormat();
_local2.color = 204;
_local2.font = "MyBerlinSans";
_local2.size = 12;
ta_info.setTextFormat(_local2);
ta_info.wordWrap = true;
ta_info.embedFonts = true;
ta_info.width = 350;
ta_info.selectable = false;
ta_info.autoSize = TextFieldAutoSize.LEFT;
layers[9].addChild(ta_info);
ta_info.x = 0;
ta_info.y = -3;
}
private function onEnterFrame(_arg1:Event):void{
if (blackScreen.alpha > 0){
blackScreen.alpha = (blackScreen.alpha - 0.1);
if (blackScreen.alpha <= 0){
layers[8].removeChild(blackScreen);
if (loaderInfo.url.toLocaleLowerCase().indexOf("kongregate", 0) == -1){
layers[8].addChild(infoCloud);
AdvCloud = infoCloud;
infoCloud.ShowAds();
};
};
};
if (currEvent == "hideWelcome"){
if (welcomScr.alpha > 0){
welcomScr.alpha = (welcomScr.alpha - 0.1);
} else {
if (welcomScr.parent){
welcomScr.parent.removeChild(welcomScr);
};
currEvent = "none";
};
} else {
if (currEvent == "showWelcome"){
if (!welcomScr.parent){
layers[7].addChild(welcomScr);
};
if (welcomScr.alpha < 1){
welcomScr.alpha = (welcomScr.alpha + 0.1);
} else {
currEvent = "none";
};
} else {
if ((((currEvent == "aiTurn")) && (!((game_mode == "multiplayer"))))){
tick++;
if (tick == 20){
memScore1 = 0;
memScore2 = 0;
selection.SetPosition(line, AIchoice(turn, line, 0));
} else {
if (tick == 30){
Choose(numbs[selection.posX][selection.posY]);
currEvent = "none";
};
};
};
};
};
}
public function onSpectatorSwitched(_arg1:SFSEvent):void{
var _local2:String;
if (_arg1.params.success){
myPlayerID = sfs.playerId;
iAmSpectator = false;
_local2 = "Waiting for another player";
debugTrace(_local2);
};
}
public function AIchoice(_arg1:int, _arg2:int, _arg3:int):int{
var _local9:int;
var _local10:int;
_arg3++;
var _local4 = -9999;
var _local5 = -9999;
var _local6 = -1;
var _local7:int = memScore1;
var _local8:int = memScore2;
var _local11:int;
for (;_local11 < maxGrid;_local11++) {
if (_arg1 == 0){
if (numbs[_local11][_arg2].number == 99){
continue;
};
memScore1 = _local7;
memScore2 = (_local8 + numbs[_local11][_arg2].number);
_local10 = numbs[_local11][_arg2].number;
numbs[_local11][_arg2].number = 99;
if (_arg3 < maxDepth){
_local9 = AIchoice(1, _local11, _arg3);
};
if (((((((memScore1 - memScore2) < (_local4 - _local5))) && (((!((_local9 == -1))) || ((((_local9 == -1)) && (((score[1] + memScore1) < (score[0] + memScore2))))))))) || ((_local4 == -9999)))){
_local4 = memScore1;
_local5 = memScore2;
_local6 = _local11;
if (_local9 == -1){
_local5 = (_local5 + (maxGrid * 5));
};
};
numbs[_local11][_arg2].number = _local10;
} else {
if (numbs[_arg2][_local11].number == 99){
} else {
memScore1 = (_local7 + numbs[_arg2][_local11].number);
memScore2 = _local8;
_local10 = numbs[_arg2][_local11].number;
numbs[_arg2][_local11].number = 99;
if (_arg3 < maxDepth){
_local9 = AIchoice(0, _local11, _arg3);
};
if (((((((memScore1 - memScore2) > (_local4 - _local5))) && (((!((_local9 == -1))) || ((((_local9 == -1)) && (((score[1] + memScore1) > (score[0] + memScore2))))))))) || ((_local4 == -9999)))){
_local4 = memScore1;
_local5 = memScore2;
_local6 = _local11;
if (_local9 == -1){
_local4 = (_local4 + (maxGrid * 5));
};
};
numbs[_arg2][_local11].number = _local10;
};
};
};
if (_local4 != -9999){
memScore1 = _local4;
memScore2 = _local5;
};
return (_local6);
}
public function moveReceived(_arg1:Object):void{
var _local2:int;
var _local3:Numb;
var _local4:int;
var _local5:int;
if (game_mode == "multiplayer"){
whoseTurn = _arg1.t;
_local2 = _arg1.index;
_local4 = 0;
while (_local4 < maxGrid) {
_local5 = 0;
while (_local5 < maxGrid) {
if ((_local4 + (_local5 * maxGrid)) == _local2){
_local3 = numbs[_local4][_local5];
};
_local5++;
};
_local4++;
};
if (((((_local3.selectable) && (!(paused)))) && ((whoseTurn == sfs.myUserId)))){
Choose(_local3);
};
if (whoseTurn == sfs.myUserId){
debugTrace("Your turn!");
canMove = true;
} else {
debugTrace((("Turn of " + opponent_name) + "!"));
canMove = false;
};
};
}
public function onLogin(_arg1:SFSEvent):void{
var _local2:Boolean = _arg1.params.success;
if (!_local2){
connection_status = _arg1.params.error;
if (_arg1.params.error == "This user name is already taken."){
sfs.login(serverZone, ((guestLogin + "_") + Math.floor((Math.random() * 10000))), "");
} else {
debugTrace(_arg1.params.error);
};
} else {
connection_status = ("Login as " + sfs.myUserName);
debugTrace(connection_status);
};
}
public function onIOError(_arg1:IOErrorEvent):void{
layers[8].addChild(infoCloud);
infoCloud.ShowMessage(("I/O Error: " + _arg1.text), true);
}
public function onConnectionLost(_arg1:SFSEvent):void{
connection_status = "none";
debugTrace("Connection Lost");
soundControl.Stop(1);
currEvent = "showWelcome";
}
public function getReady():void{
var _local1:String;
var _local2:Object;
if (game_mode == "multiplayer"){
myPlayerID = sfs.playerId;
iAmSpectator = (myPlayerID == -1);
_local1 = "Waiting for another player";
if (!iAmSpectator){
debugTrace(_local1);
};
_local2 = {};
_local2.game_id = game_id;
sfs.sendXtMessage(xtName, "ready", _local2);
};
}
}
}//package
Section 41
//MochiAd (MochiAd)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return ("2.7");
}
public static function showClickAwayAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
var sendHostProgress:Boolean;
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
_local3 = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.root == null){
_local3 = true;
};
if (_local3){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(_arg1:String):String{
var _local2:String = _arg1.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (_arg1.origFrameRate != undefined){
_arg1.stage.frameRate = _arg1.origFrameRate;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad._containerLCName != undefined){
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "notify", {id:"unload"});
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var clip:Object;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_msec:Number = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (_local2 > chk.ad_msec){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _cleanup(_arg1:Object):void{
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
var idx:Number = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(_arg1:Object):MovieClip{
var clip:Object;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
var depth:Number = options.depth;
delete options.depth;
var mc:MovieClip = createEmptyMovieClip(clip, "_mochiad", depth);
var wh:Array = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
};
var lv:URLVariables = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest(((server + ".swf?cacheBust=") + new Date().getTime()));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(_arg1:Object, _arg2:String, _arg3:Array):Object{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
if (typeof(_arg1[_local4[_local5]]) == "function"){
return (_arg1[_local4[_local5]].apply(_arg1, _arg3));
};
return (undefined);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local6:Array;
var _local3:Object = _arg2.getBounds(_arg2.root);
var _local4:Number = 0;
var _local5:Number = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function adShowing(_arg1:Object):void{
_arg1.origFrameRate = _arg1.stage.frameRate;
_arg1.stage.frameRate = 30;
}
public static function getValue(_arg1:Object, _arg2:String):Object{
var _local3:Array = _arg2.split(".");
var _local4:Number = 0;
while (_local4 < (_local3.length - 1)) {
if ((((_arg1[_local3[_local4]] == undefined)) || ((_arg1[_local3[_local4]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local3[_local4]];
_local4++;
};
return (_arg1[_local3[_local4]]);
}
public static function rpc(_arg1:Object, _arg2:Number, _arg3:Object):void{
var _local4:Object;
var _local5:Object;
switch (_arg3.id){
case "setValue":
MochiAd.setValue(_arg1, _arg3.objectName, _arg3.value);
break;
case "getValue":
_local4 = MochiAd.getValue(_arg1, _arg3.objectName);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(_arg1, _arg3.method, _arg3.args);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + _arg3.id));
};
}
public static function setValue(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return;
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
_arg1[_local4[_local5]] = _arg3;
}
public static function showPreGameAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var complete:Boolean;
var unloaded:Boolean;
var sendHostProgress:Boolean;
var fn:Function;
var r:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (_arg1:Number):void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
return;
};
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
var fn:Function = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = 10;
bar.y = (h - 20);
};
var bar_color:Number = options.color;
delete options.color;
var bar_background:Number = options.background;
delete options.background;
var bar_outline:Number = options.outline;
delete options.outline;
var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1);
var backing:Object = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2);
var inside:Object = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3);
var outline:Object = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
var f:Function = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
mc.rpcTestFn = function (_arg1:String):Object{
trace(("[MOCHIAD rpcTestFn] " + _arg1));
return (_arg1);
};
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (_arg1:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var _local11:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
var _local1:Object = this.parent.parent.root;
var _local2:Object = this.parent._mochiad_ctr;
var _local3:Number = (getTimer() - this.started);
var _local4:Boolean;
var _local5:Number = _local1.loaderInfo.bytesTotal;
var _local6:Number = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
var _local7:Number = ((100 * _local6) / _local5);
var _local8:Number = ((100 * _local3) / chk.ad_msec);
var _local9:Object = this._mochiad_bar._inside;
var _local10:Number = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
options.ad_progress(_local10);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local7});
if (_local7 == 100){
sendHostProgress = false;
};
};
if (!chk.showing){
_local11 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local11 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((_local3 > chk.ad_timeout)) && ((_local7 == 100)))){
options.ad_failed();
_local4 = true;
};
};
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(_arg1);
}
public static function showTimedAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(_arg1);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var mc = _arg1;
var f:Function = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package
Section 42
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
if (Security.sandboxType == "localWithFile"){
return (null);
};
var _local3:MochiBot = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
var _local4 = "http://core.mochibot.com/my/core.swf";
var _local5:URLVariables = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
var _local6:String = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
var _local7:URLRequest = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
var _local8:Loader = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 43
//MochiDigits (MochiDigits)
package {
public final class MochiDigits {
private var Sibling:MochiDigits;
private var Fragment:Number;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function reencode():void{
var _local1:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function toString():String{
var _local1:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String = _arg1.toString();
var _temp1 = _arg2;
_arg2 = (_arg2 + 1);
Fragment = (_local3.charCodeAt(_temp1) ^ Encoder);
if (_arg2 < _local3.length){
Sibling = new MochiDigits(_arg1, _arg2);
} else {
Sibling = null;
};
reencode();
}
public function get value():Number{
return (Number(this.toString()));
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
}
}//package
Section 44
//MochiScores (MochiScores)
package {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var n:Number;
var options = _arg1;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
var _local2:Object = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
_arg1 = Number(_arg1);
if (isNaN(_arg1)){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((_arg1 == Number.NEGATIVE_INFINITY)) || ((_arg1 == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(_arg1) != _arg1){
trace((("WARNING: Submitted score '" + String(_arg1)) + "' will be truncated"));
};
_arg1 = Number(_arg1);
};
};
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (_arg1 != null){
if (_arg1.error != null){
if (_arg1.error == true){
if (onErrorHandler != null){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package
Section 45
//MochiServices (MochiServices)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
import flash.geom.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__ms_";
private static var _servicesURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
public static var netup:Boolean = true;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (_clip != null){
if (_clip._queue != null){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
};
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function get childClip():Object{
return (_clip);
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local4:int;
var _local14:Loader;
var _local3:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
var _local5:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var _local6:Array = [0, 64, 0, 0, 0];
var _local7:MovieClip = new MovieClip();
var _local8:LocalConnection = new LocalConnection();
var _local9:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().getTime()));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
var _local10:ByteArray = new ByteArray();
var _local11:ByteArray = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
var _local12:uint = ((_local3.length + _local11.length) + 4);
var _local13:uint = (_local12 + 35);
_local10.endian = Endian.LITTLE_ENDIAN;
_local10.writeUTFBytes("FWS");
_local10.writeByte(8);
_local10.writeUnsignedInt(_local13);
for each (_local4 in _local5) {
_local10.writeByte(_local4);
};
_local10.writeUnsignedInt(_local12);
_local10.writeByte(136);
_local10.writeShort(_local11.length);
_local10.writeBytes(_local11);
for each (_local4 in _local3) {
_local10.writeByte(_local4);
};
for each (_local4 in _local6) {
_local10.writeByte(_local4);
};
_local14 = new Loader();
_local14.loadBytes(_local10);
_local7.addChild(_local14);
return (_local7);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function addLinkEvent(_arg1:String, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Function=null):void{
var avm1Click:DisplayObject;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = _arg1;
var burl = _arg2;
var btn = _arg3;
var onClick = _arg4;
var vars:Object = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
var s = "?";
var i:Number = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://x.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (_arg1:String):void{
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
var _local2:Rectangle = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = _local2.x;
avm1Click.y = _local2.y;
avm1Click.scaleX = (0.01 * _local2.width);
avm1Click.scaleY = (0.01 * _local2.height);
};
err = function (_arg1:Object):void{
netup = false;
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
setURL(burl);
};
complete = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_listenChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
};
return (_local2);
}
public static function getVersion():String{
return ("3.0");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
private static function onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
public static function get id():String{
return (_id);
}
private static function urlOptions(_arg1:Object):Object{
var _local4:Array;
var _local5:Number;
var _local6:Array;
var _local2:Object = {};
var _local3:String = _arg1.loaderInfo.parameters.mochiad_options;
if (_local3){
_local4 = _local3.split("&");
_local5 = 0;
while (_local5 < _local4.length) {
_local6 = _local4[_local5].split("=");
_local2[unescape(_local6[0])] = unescape(_local6[1]);
_local5++;
};
};
return (_local2);
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
private static function initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_listenChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var methodName:String;
var pkg = _arg1;
var cb:String = pkg.callbackID;
var cblst:Object = this.client._callbacks[cb];
if (!cblst){
return;
};
var method:* = cblst.callbackMethod;
methodName = "";
var obj:Object = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
trace("connected!");
_connecting = false;
_connected = true;
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var id = _arg1;
var clip = _arg2;
var clipname:String = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(clip).servicesURL != undefined){
_servicesURL = urlOptions(clip).servicesURL;
};
MochiServices.allowDomains(_servicesURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
var f:Function = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().getTime()) + "_") + Math.floor((Math.random() * 99999))));
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
var req:URLRequest = new URLRequest(_servicesURL);
var vars:URLVariables = new URLVariables();
vars.listenLC = _listenChannelName;
vars.mochiad_options = clip.loaderInfo.parameters.mochiad_options;
if (widget){
vars.widget = true;
};
req.data = vars;
listen();
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_clip._nextcallbackID = 0;
_clip._callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
public static function get clip():Object{
return (_container);
}
public static function bringToTop(_arg1:Event):void{
var e = _arg1;
if (MochiServices.clip != null){
if (MochiServices.childClip != null){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
if ((clip is DisplayObject)){
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
var mc:MovieClip = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function connectWait(_arg1:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
}
}
}//package
Section 46
//Numb (Numb)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class Numb extends Sprite {
public var posX:int;
public var posY:int;
public var number:int;
private var selNumb:Bitmap;
private var currEvent:String;// = "none"
private var soundControl:SoundControl;
public var selectable:Boolean;// = false
public var destroyed:Boolean;// = false
private var unselNumb:Bitmap;
private var numbField:TextField;
public function Numb(_arg1:int, _arg2:int, _arg3:int=0, _arg4:Boolean=true){
soundControl = MadNumbsFlash.gameApp.soundControl;
super();
posX = _arg1;
posY = _arg2;
if (_arg4 == false){
number = _arg3;
} else {
number = (Math.floor((Math.random() * 22)) - 11);
};
if ((((number >= 0)) && (!((MadNumbsFlash.gameApp.game_mode == "multiplayer"))))){
number++;
};
var _local5:MadNumbsFlash = MadNumbsFlash.gameApp;
unselNumb = new (Resources.imgNumb[_local5.dificulty][((number)>0) ? 0 : 1]);
selNumb = new (Resources.imgNumb[_local5.dificulty][((number)>0) ? 2 : 3]);
var _local6:TextFormat = new TextFormat();
_local6.font = "MyBerlinSans";
switch (_local5.dificulty){
case 0:
_local6.size = 35;
break;
case 1:
_local6.size = 23;
break;
case 2:
_local6.size = 17;
break;
};
_local6.align = TextFormatAlign.CENTER;
numbField = new TextField();
numbField.antiAliasType = AntiAliasType.NORMAL;
numbField.embedFonts = true;
numbField.width = ((384 / _local5.maxGrid) - (2 - _local5.dificulty));
numbField.defaultTextFormat = _local6;
numbField.text = String(Math.abs(number));
numbField.selectable = false;
selNumb.alpha = 0;
addChild(unselNumb);
addChild(selNumb);
addChild(numbField);
x = (9 + ((384 / _local5.maxGrid) * posX));
y = (9 + ((384 / _local5.maxGrid) * posY));
if (_local5.dificulty == 2){
numbField.x--;
numbField.y--;
if (numbField.text == "10"){
numbField.scaleX = 0.8;
numbField.x = (numbField.x + 3);
};
} else {
if ((((_local5.dificulty == 1)) && ((numbField.text == "10")))){
numbField.scaleX = 0.9;
numbField.x = (numbField.x + 2);
};
};
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function Destroy():void{
currEvent = "destroy";
destroyed = true;
selectable = false;
}
public function SetUnselectable():void{
if (destroyed){
return;
};
currEvent = "hideSelection";
selectable = false;
}
private function onEnterFrame(_arg1:Event):void{
var _local2:int;
if (currEvent == "showSelection"){
if (selNumb.alpha < 1){
selNumb.alpha = (selNumb.alpha + 0.1);
} else {
currEvent = "none";
};
} else {
if (currEvent == "hideSelection"){
if (selNumb.alpha > 0){
selNumb.alpha = (selNumb.alpha - 0.1);
} else {
currEvent = "none";
};
} else {
if (currEvent == "destroy"){
_local2 = (parseInt(numbField.text) - 1);
if ((((_local2 == -1)) && ((unselNumb.alpha == 1)))){
soundControl.Play(5, 1);
};
if (_local2 >= 0){
soundControl.Play(4, 1);
numbField.text = String(_local2);
} else {
if (unselNumb.alpha > 0){
numbField.alpha = (numbField.alpha - 0.2);
selNumb.alpha = (selNumb.alpha - 0.2);
unselNumb.alpha = (unselNumb.alpha - 0.05);
} else {
currEvent = "none";
};
};
};
};
};
}
public function SetSelectable():void{
if (destroyed){
return;
};
currEvent = "showSelection";
selectable = true;
}
}
}//package
Section 47
//Preloader (Preloader)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
public dynamic class Preloader extends MovieClip {
private var blackScreen:Sprite;
private var textLoading:TextField;
private var iY:Number;// = 30
private var iZ:Number;
private var hosts:Array;
private var firstDraw:Boolean;// = false
private var iX:Number;// = 250
private var ofX:Number;
private var progressBar:Sprite;
private var ofY:Number;
private var progress:Number;// = 0
public static var App:Preloader;
public static var stageHeight:Number = 400;
public static var stageWidth:Number = 533;
public static var swfLogo:Class = Preloader_swfLogo;
public function Preloader(){
var _local3:SpnsrLogo;
textLoading = new TextField();
progressBar = new Sprite();
iZ = (23 / Math.sqrt(2));
ofX = ((stageWidth / 2) - ((iX + iZ) / 2));
ofY = ((stageHeight / 2) - ((iY + iZ) / 2));
hosts = new Array("ungrounded.net", "kongregate.com", "dustunited.com", "elite-games.net", "localhost", "debug", "file://");
super();
App = this;
stage.showDefaultContextMenu = false;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var _local1:TextFormat = new TextFormat();
_local1.font = "Arial Black";
_local1.color = 0xFFFFFF;
_local1.size = 25;
_local1.align = TextFormatAlign.CENTER;
textLoading.defaultTextFormat = _local1;
textLoading.text = "LOADING";
textLoading.width = iX;
textLoading.height = iY;
textLoading.x = (ofX + iZ);
textLoading.y = (ofY - 6);
textLoading.autoSize = TextFieldAutoSize.CENTER;
addChild(textLoading);
if (!isUrl(hosts)){
textLoading.text = "BAD URL";
return;
};
graphics.beginFill(0x424242);
graphics.lineTo((ofX + 0), (ofY + iZ));
graphics.lineTo((ofX + iZ), (ofY + 0));
graphics.lineTo((ofX + iZ), (ofY + iY));
graphics.lineTo((ofX + 0), ((ofY + iY) + iZ));
graphics.lineTo((ofX + 0), (ofY + iZ));
graphics.endFill();
graphics.beginFill(0x8A8A8A);
graphics.drawRect((ofX + iZ), ofY, iX, iY);
graphics.endFill();
graphics.beginFill(0x646464);
graphics.lineTo((ofX + iZ), (ofY + iY));
graphics.lineTo(((ofX + iZ) + iX), (ofY + iY));
graphics.lineTo((ofX + iX), ((ofY + iY) + iZ));
graphics.lineTo((ofX + 0), ((ofY + iY) + iZ));
graphics.lineTo((ofX + iZ), (ofY + iY));
graphics.endFill();
progressBar.x = (ofX + 2);
progressBar.y = ofY;
addChild(progressBar);
var _local2:Sprite = new Sprite();
_local2.graphics.beginFill(0);
_local2.graphics.lineTo(iX, iZ);
_local2.graphics.lineTo(((iX + iZ) + 2), -2);
_local2.graphics.lineTo(((iX + iZ) + 2), iY);
_local2.graphics.lineTo(iX, (iY + iZ));
_local2.graphics.lineTo(iX, iZ);
_local2.graphics.endFill();
_local2.graphics.lineStyle(1, 0xC5C5C5);
_local2.graphics.lineTo((iX + iZ), 0);
_local2.graphics.lineTo(iX, iZ);
_local2.graphics.lineTo(iX, (iY + iZ));
_local2.graphics.lineStyle(2, 0xC5C5C5);
_local2.graphics.moveTo((iZ + iX), 0);
_local2.graphics.lineTo(iZ, 0);
_local2.graphics.lineTo(0, iZ);
_local2.graphics.lineTo(0, (iY + iZ));
_local2.graphics.lineTo(iX, (iY + iZ));
_local2.x = ofX;
_local2.y = ofY;
addChild(_local2);
_local3 = new SpnsrLogo();
_local3.x = 270;
_local3.y = 295;
_local3.logoSprite.mask.x = _local3.x;
_local3.logoSprite.mask.y = _local3.y;
addChild(_local3);
blackScreen = new Sprite();
blackScreen.graphics.beginFill(0);
blackScreen.graphics.drawRect(0, 0, stageWidth, stageHeight);
blackScreen.graphics.endFill();
blackScreen.alpha = 0;
stop();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function init():void{
var _local1:Class = Class(getDefinitionByName("MadNumbsFlash"));
var _local2:Object = new (_local1);
parent.addChild((_local2 as DisplayObject));
_local2.SplashScr();
parent.removeChild(this);
}
public function isUrl(_arg1:Array):Boolean{
var _local2:String = loaderInfo.url.toLocaleLowerCase();
var _local3:String = loaderInfo.loaderURL.toLocaleLowerCase();
var _local4:int;
while (_local4 < _arg1.length) {
if (_local2.indexOf(_arg1[_local4]) != -1){
return (true);
};
if (_local3.indexOf(_arg1[_local4]) != -1){
return (true);
};
_local4++;
};
return (false);
}
public function onEnterFrame(_arg1:Event):void{
var _local2:Number = (root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal);
if ((((framesLoaded == totalFrames)) && (firstDraw))){
if (blackScreen.parent == null){
addChild(blackScreen);
};
blackScreen.alpha = (blackScreen.alpha + 0.1);
if (blackScreen.alpha >= 1){
nextFrame();
init();
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
};
} else {
firstDraw = true;
progressBar.graphics.clear();
progressBar.graphics.beginFill(1264923, 0.7);
progressBar.graphics.lineTo(0, iZ);
progressBar.graphics.lineTo(iZ, 0);
progressBar.graphics.lineTo(iZ, 0);
progressBar.graphics.lineTo((iZ + (iX * _local2)), 0);
progressBar.graphics.lineTo((iZ + (iX * _local2)), iY);
progressBar.graphics.lineTo((iX * _local2), (iY + iZ));
progressBar.graphics.lineTo(0, (iY + iZ));
progressBar.graphics.lineTo(0, iZ);
progressBar.graphics.endFill();
progressBar.graphics.lineStyle(1, 2921274, 0.3);
progressBar.graphics.moveTo(0, iZ);
progressBar.graphics.lineTo((iX * _local2), iZ);
progressBar.graphics.moveTo((iZ + (iX * _local2)), 0);
progressBar.graphics.lineTo((iX * _local2), iZ);
progressBar.graphics.lineTo((iX * _local2), (iZ + iY));
};
}
}
}//package
Section 48
//Preloader_swfLogo (Preloader_swfLogo)
package {
import mx.core.*;
public class Preloader_swfLogo extends SpriteAsset {
}
}//package
Section 49
//Resources (Resources)
package {
public class Resources {
private var Font1:Class;
private static var imgNumb23:Class = Resources_imgNumb23;
private static var imgNumb24:Class = Resources_imgNumb24;
public static var imgNumb:Array = new Array(3);
public static var imgLogo:Class = Resources_imgLogo;
public static var imgProbirksBack:Class = Resources_imgProbirksBack;
public static var imgWelcomScreen:Class = Resources_imgWelcomScreen;
public static var imgMenuButton:Class = Resources_imgMenuButton;
public static var imgMenuRightLine:Class = Resources_imgMenuRightLine;
private static var imgNumb31:Class = Resources_imgNumb31;
private static var imgNumb32:Class = Resources_imgNumb32;
private static var imgNumb33:Class = Resources_imgNumb33;
public static var imgInfoCloud:Class = Resources_imgInfoCloud;
public static var imgProbirksLiquid:Class = Resources_imgProbirksLiquid;
public static var imgCheckbox:Class = Resources_imgCheckbox;
private static var imgNumb34:Class = Resources_imgNumb34;
private static var imgGrid2:Class = Resources_imgGrid2;
public static var sndSqrew:Class = Resources_sndSqrew;
public static var sndCount:Class = Resources_sndCount;
private static var imgGrid1:Class = Resources_imgGrid1;
public static var imgMenu2:Class = Resources_imgMenu2;
private static var imgGrid3:Class = Resources_imgGrid3;
public static var imgGridBorder:Class = Resources_imgGridBorder;
public static var sndInfo:Class = Resources_sndInfo;
public static var imgGrid:Array = new Array(3);
public static var imgMenu:Class = Resources_imgMenu;
public static var swfLogo:Class = Preloader.swfLogo;
public static var imgButton:Class = Resources_imgButton;
private static var imgNumb11:Class = Resources_imgNumb11;
private static var imgNumb12:Class = Resources_imgNumb12;
private static var imgNumb13:Class = Resources_imgNumb13;
private static var imgNumb14:Class = Resources_imgNumb14;
public static var sndTheme:Class = Resources_sndTheme;
public static var sndHidden:Class = Resources_sndHidden;
public static var sndButton:Class = Resources_sndButton;
private static var imgNumb21:Class = Resources_imgNumb21;
private static var imgNumb22:Class = Resources_imgNumb22;
public function Resources(){
Font1 = Resources_Font1;
super();
}
imgGrid[0] = imgGrid1;
imgGrid[1] = imgGrid2;
imgGrid[2] = imgGrid3;
imgNumb[0] = [imgNumb11, imgNumb12, imgNumb13, imgNumb14];
imgNumb[1] = [imgNumb21, imgNumb22, imgNumb23, imgNumb24];
imgNumb[2] = [imgNumb31, imgNumb32, imgNumb33, imgNumb34];
}
}//package
Section 50
//Resources_Font1 (Resources_Font1)
package {
import mx.core.*;
public class Resources_Font1 extends FontAsset {
}
}//package
Section 51
//Resources_imgButton (Resources_imgButton)
package {
import mx.core.*;
public class Resources_imgButton extends BitmapAsset {
}
}//package
Section 52
//Resources_imgCheckbox (Resources_imgCheckbox)
package {
import mx.core.*;
public class Resources_imgCheckbox extends BitmapAsset {
}
}//package
Section 53
//Resources_imgGrid1 (Resources_imgGrid1)
package {
import mx.core.*;
public class Resources_imgGrid1 extends BitmapAsset {
}
}//package
Section 54
//Resources_imgGrid2 (Resources_imgGrid2)
package {
import mx.core.*;
public class Resources_imgGrid2 extends BitmapAsset {
}
}//package
Section 55
//Resources_imgGrid3 (Resources_imgGrid3)
package {
import mx.core.*;
public class Resources_imgGrid3 extends BitmapAsset {
}
}//package
Section 56
//Resources_imgGridBorder (Resources_imgGridBorder)
package {
import mx.core.*;
public class Resources_imgGridBorder extends BitmapAsset {
}
}//package
Section 57
//Resources_imgInfoCloud (Resources_imgInfoCloud)
package {
import mx.core.*;
public class Resources_imgInfoCloud extends BitmapAsset {
}
}//package
Section 58
//Resources_imgLogo (Resources_imgLogo)
package {
import mx.core.*;
public class Resources_imgLogo extends BitmapAsset {
}
}//package
Section 59
//Resources_imgMenu (Resources_imgMenu)
package {
import mx.core.*;
public class Resources_imgMenu extends BitmapAsset {
}
}//package
Section 60
//Resources_imgMenu2 (Resources_imgMenu2)
package {
import mx.core.*;
public class Resources_imgMenu2 extends BitmapAsset {
}
}//package
Section 61
//Resources_imgMenuButton (Resources_imgMenuButton)
package {
import mx.core.*;
public class Resources_imgMenuButton extends BitmapAsset {
}
}//package
Section 62
//Resources_imgMenuRightLine (Resources_imgMenuRightLine)
package {
import mx.core.*;
public class Resources_imgMenuRightLine extends BitmapAsset {
}
}//package
Section 63
//Resources_imgNumb11 (Resources_imgNumb11)
package {
import mx.core.*;
public class Resources_imgNumb11 extends BitmapAsset {
}
}//package
Section 64
//Resources_imgNumb12 (Resources_imgNumb12)
package {
import mx.core.*;
public class Resources_imgNumb12 extends BitmapAsset {
}
}//package
Section 65
//Resources_imgNumb13 (Resources_imgNumb13)
package {
import mx.core.*;
public class Resources_imgNumb13 extends BitmapAsset {
}
}//package
Section 66
//Resources_imgNumb14 (Resources_imgNumb14)
package {
import mx.core.*;
public class Resources_imgNumb14 extends BitmapAsset {
}
}//package
Section 67
//Resources_imgNumb21 (Resources_imgNumb21)
package {
import mx.core.*;
public class Resources_imgNumb21 extends BitmapAsset {
}
}//package
Section 68
//Resources_imgNumb22 (Resources_imgNumb22)
package {
import mx.core.*;
public class Resources_imgNumb22 extends BitmapAsset {
}
}//package
Section 69
//Resources_imgNumb23 (Resources_imgNumb23)
package {
import mx.core.*;
public class Resources_imgNumb23 extends BitmapAsset {
}
}//package
Section 70
//Resources_imgNumb24 (Resources_imgNumb24)
package {
import mx.core.*;
public class Resources_imgNumb24 extends BitmapAsset {
}
}//package
Section 71
//Resources_imgNumb31 (Resources_imgNumb31)
package {
import mx.core.*;
public class Resources_imgNumb31 extends BitmapAsset {
}
}//package
Section 72
//Resources_imgNumb32 (Resources_imgNumb32)
package {
import mx.core.*;
public class Resources_imgNumb32 extends BitmapAsset {
}
}//package
Section 73
//Resources_imgNumb33 (Resources_imgNumb33)
package {
import mx.core.*;
public class Resources_imgNumb33 extends BitmapAsset {
}
}//package
Section 74
//Resources_imgNumb34 (Resources_imgNumb34)
package {
import mx.core.*;
public class Resources_imgNumb34 extends BitmapAsset {
}
}//package
Section 75
//Resources_imgProbirksBack (Resources_imgProbirksBack)
package {
import mx.core.*;
public class Resources_imgProbirksBack extends BitmapAsset {
}
}//package
Section 76
//Resources_imgProbirksLiquid (Resources_imgProbirksLiquid)
package {
import mx.core.*;
public class Resources_imgProbirksLiquid extends BitmapAsset {
}
}//package
Section 77
//Resources_imgWelcomScreen (Resources_imgWelcomScreen)
package {
import mx.core.*;
public class Resources_imgWelcomScreen extends BitmapAsset {
}
}//package
Section 78
//Resources_sndButton (Resources_sndButton)
package {
import mx.core.*;
public class Resources_sndButton extends SoundAsset {
}
}//package
Section 79
//Resources_sndCount (Resources_sndCount)
package {
import mx.core.*;
public class Resources_sndCount extends SoundAsset {
}
}//package
Section 80
//Resources_sndHidden (Resources_sndHidden)
package {
import mx.core.*;
public class Resources_sndHidden extends SoundAsset {
}
}//package
Section 81
//Resources_sndInfo (Resources_sndInfo)
package {
import mx.core.*;
public class Resources_sndInfo extends SoundAsset {
}
}//package
Section 82
//Resources_sndSqrew (Resources_sndSqrew)
package {
import mx.core.*;
public class Resources_sndSqrew extends SoundAsset {
}
}//package
Section 83
//Resources_sndTheme (Resources_sndTheme)
package {
import mx.core.*;
public class Resources_sndTheme extends SoundAsset {
}
}//package
Section 84
//Selection (Selection)
package {
import flash.events.*;
import flash.display.*;
public class Selection extends Sprite {
private var app:MadNumbsFlash;
public var posY:int;// = 0
private var currEvent:String;// = "none"
public var posX:int;// = 0
private var radius:Number;
public function Selection(){
app = MadNumbsFlash.gameApp;
super();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
var _local2:Number;
if (currEvent == "showSel"){
graphics.clear();
_local2 = ((((384 / app.maxGrid) + 15) - radius) / 15);
if (_local2 <= 0){
currEvent = "none";
return;
};
graphics.lineStyle(1, 0xFFFFFF, _local2);
graphics.drawRoundRect((-(radius) / 2), (-(radius) / 2), radius, radius, (5 + ((1 - _local2) * 15)));
graphics.lineStyle(3, 0xFFFFFF, _local2);
graphics.drawRoundRect((-((radius + 8)) / 2), (-((radius + 8)) / 2), (radius + 8), (radius + 8), (10 + ((1 - _local2) * 30)));
radius = (radius + 1);
};
}
public function SetPosition(_arg1:int, _arg2:int):void{
posX = _arg1;
posY = _arg2;
x = ((9 + ((384 / app.maxGrid) * _arg1)) + ((384 / app.maxGrid) / 2));
y = ((9 + ((384 / app.maxGrid) * _arg2)) + ((384 / app.maxGrid) / 2));
radius = (384 / app.maxGrid);
currEvent = "showSel";
}
}
}//package
Section 85
//SoundControl (SoundControl)
package {
import flash.events.*;
import flash.display.*;
import flash.media.*;
public class SoundControl extends Sprite {
private var sndTransform:Array;
private var sndNum:int;// = 6
private var channel:Array;
private var sound:Array;
private var globalSwitch:Boolean;// = true
private var loopPlay:Array;
private var sndSwitch:Array;
public function SoundControl(){
sound = new Array(sndNum);
channel = new Array(sndNum);
sndTransform = new Array(sndNum);
sndSwitch = new Array(sndNum);
loopPlay = new Array(sndNum);
super();
sound[0] = new Resources.sndButton();
sound[1] = new Resources.sndTheme();
sound[2] = new Resources.sndSqrew();
sound[3] = new Resources.sndInfo();
sound[4] = new Resources.sndCount();
sound[5] = new Resources.sndHidden();
var _local1:int;
while (_local1 < sndNum) {
channel[_local1] = new SoundChannel();
sndTransform[_local1] = new SoundTransform();
sndSwitch[_local1] = true;
loopPlay[_local1] = false;
_local1++;
};
channel[1].soundTransform = new SoundTransform();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function Stop(_arg1:int):void{
sndSwitch[_arg1] = false;
}
public function Play(_arg1:int, _arg2:int, _arg3:Boolean=false):void{
sndSwitch[_arg1] = true;
if (!loopPlay[_arg1]){
if (_arg2 >= 100){
loopPlay[_arg1] = true;
};
if (((!(globalSwitch)) || (_arg3))){
sndTransform[_arg1].volume = 0;
};
channel[_arg1] = sound[_arg1].play(0, _arg2, sndTransform[_arg1]);
};
}
private function onEnterFrame(_arg1:Event):void{
var _local2:int;
while (_local2 < sndNum) {
if (((((!(globalSwitch)) || (!(sndSwitch[_local2])))) && ((sndTransform[_local2].volume > 0)))){
sndTransform[_local2].volume = (sndTransform[_local2].volume - 0.05);
channel[_local2].soundTransform = sndTransform[_local2];
if (sndTransform[_local2].volume <= 0.07){
sndTransform[_local2].volume = 0;
channel[_local2].soundTransform = sndTransform[_local2];
};
} else {
if (((((globalSwitch) && (sndSwitch[_local2]))) && ((sndTransform[_local2].volume < 1)))){
sndTransform[_local2].volume = (sndTransform[_local2].volume + 0.05);
channel[_local2].soundTransform = sndTransform[_local2];
if (sndTransform[_local2].volume >= 0.93){
sndTransform[_local2].volume = 1;
channel[_local2].soundTransform = sndTransform[_local2];
};
};
};
_local2++;
};
}
public function TouchSound():void{
globalSwitch = !(globalSwitch);
if (globalSwitch){
sndTransform[0].volume = 1;
channel[0].soundTransform = sndTransform[0];
};
}
}
}//package
Section 86
//SpnsrLogo (SpnsrLogo)
package {
import flash.events.*;
import flash.display.*;
import flash.filters.*;
import flash.net.*;
public class SpnsrLogo extends Sprite {
public var logoSprite:Sprite;
private var ttl:Number;// = 0
public function SpnsrLogo(){
logoSprite = new Preloader.swfLogo();
var _local1:Shape = new Shape();
_local1.graphics.beginFill(0);
_local1.graphics.drawRect(0, 0, 263, 105);
logoSprite.mask = _local1;
addChild(logoSprite);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
addEventListener(MouseEvent.MOUSE_OVER, onOver);
addEventListener(MouseEvent.CLICK, onClick);
}
private function onEnterFrame(_arg1:Event):void{
if (ttl > 0){
logoSprite.filters = [new GlowFilter(11145489, 0.5, (ttl * 2), (ttl * 2), 3, 1, false, false)];
ttl = (ttl - 0.8);
if (ttl <= 0){
logoSprite.filters = [new GlowFilter(11145489, 0, (ttl * 2), (ttl * 2), 3, 1, false, false)];
};
};
}
private function onClick(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.elite-games.net/in.php?id=37"));
}
private function onOver(_arg1:MouseEvent):void{
ttl = 10;
logoSprite.filters = [new GlowFilter(11145489, 0.5, (ttl * 2), (ttl * 2), 3, 1, false, false)];
}
}
}//package
Section 87
//WelcomScreen (WelcomScreen)
package {
import flash.events.*;
import flash.display.*;
public class WelcomScreen extends Sprite {
private var logo:Bitmap;
private var phase:Number;// = 90
private var soundControl:SoundControl;
public function WelcomScreen(){
soundControl = MadNumbsFlash.gameApp.soundControl;
super();
var _local1:Bitmap = new Resources.imgWelcomScreen();
addChild(_local1);
var _local2:SpnsrLogo = new SpnsrLogo();
_local2.x = 129;
_local2.y = 287;
_local2.logoSprite.mask.x = _local2.x;
_local2.logoSprite.mask.y = _local2.y;
addChild(_local2);
logo = new Resources.imgLogo();
logo.x = 76;
logo.y = 6;
logo.smoothing = true;
addChild(logo);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
if (parent == null){
return;
};
phase = (phase + 3);
if (phase == 360){
phase = 0;
};
var _local2:Number = (Math.floor(((new Resources.sndSqrew().length - 100) / (1000 / 30))) * 3);
if ((((phase == (180 - _local2))) || ((phase == (360 - _local2))))){
soundControl.Play(2, 1);
};
var _local3:Number = Math.sin((phase / (180 / Math.PI)));
logo.rotation = (logo.rotation + (_local3 / 2));
var _local4:Number = Math.sqrt(13973);
var _local5:Number = (Math.asin((7 / _local4)) + (logo.rotation / (180 / Math.PI)));
var _local6:Number = ((_local4 * Math.sin(_local5)) - 7);
var _local7:Number = (118 - (_local4 * Math.cos(_local5)));
logo.x = (76 + _local7);
logo.y = (6 - _local6);
}
}
}//package