Section 1
//1P_Panel_30 (assets_fla.1P_Panel_30)
package assets_fla {
import flash.text.*;
import flash.display.*;
public dynamic class 1P_Panel_30 extends MovieClip {
public var label_txt:TextField;
}
}//package assets_fla
Section 2
//2P_Panel_32 (assets_fla.2P_Panel_32)
package assets_fla {
import flash.text.*;
import flash.display.*;
public dynamic class 2P_Panel_32 extends MovieClip {
public var label_txt:TextField;
}
}//package assets_fla
Section 3
//AimArrow_125 (assets_fla.AimArrow_125)
package assets_fla {
import flash.display.*;
public dynamic class AimArrow_125 extends MovieClip {
public function AimArrow_125(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package assets_fla
Section 4
//Ball_Ball_122 (assets_fla.Ball_Ball_122)
package assets_fla {
import flash.display.*;
public dynamic class Ball_Ball_122 extends MovieClip {
public function Ball_Ball_122(){
addFrameScript(0, frame1, 11, frame12, 32, frame33, 43, frame44, 64, frame65);
}
function frame65(){
gotoAndPlay("backward_slow");
}
function frame12(){
gotoAndPlay("forward");
}
function frame1(){
stop();
}
function frame44(){
gotoAndPlay("backward");
}
function frame33(){
gotoAndPlay("forward_slow");
}
}
}//package assets_fla
Section 5
//Button_GameOver_PlayAgain_48 (assets_fla.Button_GameOver_PlayAgain_48)
package assets_fla {
import flash.display.*;
public dynamic class Button_GameOver_PlayAgain_48 extends MovieClip {
public var playagain_but:MovieClip;
}
}//package assets_fla
Section 6
//ButtonJoinLobby_70 (assets_fla.ButtonJoinLobby_70)
package assets_fla {
import flash.text.*;
import flash.display.*;
public dynamic class ButtonJoinLobby_70 extends MovieClip {
public var label_txt:TextField;
}
}//package assets_fla
Section 7
//ButtonMainMenu_25 (assets_fla.ButtonMainMenu_25)
package assets_fla {
import flash.text.*;
import flash.display.*;
public dynamic class ButtonMainMenu_25 extends MovieClip {
public var label_txt:TextField;
}
}//package assets_fla
Section 8
//Checkbox_35 (assets_fla.Checkbox_35)
package assets_fla {
import flash.display.*;
public dynamic class Checkbox_35 extends MovieClip {
public function Checkbox_35(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package assets_fla
Section 9
//CustomCheckBox_109 (assets_fla.CustomCheckBox_109)
package assets_fla {
import flash.display.*;
public dynamic class CustomCheckBox_109 extends MovieClip {
public function CustomCheckBox_109(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package assets_fla
Section 10
//fsb_upArrow_face_79 (assets_fla.fsb_upArrow_face_79)
package assets_fla {
import flash.display.*;
public dynamic class fsb_upArrow_face_79 extends MovieClip {
public function fsb_upArrow_face_79(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package assets_fla
Section 11
//GameOver_49 (assets_fla.GameOver_49)
package assets_fla {
import flash.display.*;
public dynamic class GameOver_49 extends MovieClip {
public function GameOver_49(){
addFrameScript(1, frame2);
}
function frame2(){
stop();
}
}
}//package assets_fla
Section 12
//Lobby_138 (assets_fla.Lobby_138)
package assets_fla {
import flash.display.*;
public dynamic class Lobby_138 extends MovieClip {
public var level_mc:MovieClip;
public function Lobby_138(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package assets_fla
Section 13
//Lobby_139 (assets_fla.Lobby_139)
package assets_fla {
import flash.display.*;
public dynamic class Lobby_139 extends MovieClip {
public function Lobby_139(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame2(){
stop();
}
}
}//package assets_fla
Section 14
//MultiGameHolder_68 (assets_fla.MultiGameHolder_68)
package assets_fla {
import flash.display.*;
public dynamic class MultiGameHolder_68 extends MovieClip {
public var p1_ball4:MovieClip;
public var p1_ball1:MovieClip;
public var p1_ball2:MovieClip;
public var p1_ball3:MovieClip;
public var p1_ball5:MovieClip;
public var p2_ball3:MovieClip;
public var p2_ball2:MovieClip;
public var p2_ball4:MovieClip;
public var p2_ball1:MovieClip;
public var p2_ball5:MovieClip;
}
}//package assets_fla
Section 15
//MultiGameHolder_69 (assets_fla.MultiGameHolder_69)
package assets_fla {
import flash.text.*;
import flash.display.*;
public dynamic class MultiGameHolder_69 extends MovieClip {
public var p2_ball:MovieClip;
public var label_txt:TextField;
public var p1_ball:MovieClip;
}
}//package assets_fla
Section 16
//MultiScorePanel_19 (assets_fla.MultiScorePanel_19)
package assets_fla {
import flash.text.*;
import flash.display.*;
public dynamic class MultiScorePanel_19 extends MovieClip {
public var message_txt:TextField;
public var register_but:ButtonLobby2_Graphic;
}
}//package assets_fla
Section 17
//Player_173 (assets_fla.Player_173)
package assets_fla {
import flash.display.*;
public dynamic class Player_173 extends MovieClip {
public var body_mc:MovieClip;
public function Player_173(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package assets_fla
Section 18
//Player_174 (assets_fla.Player_174)
package assets_fla {
import flash.display.*;
public dynamic class Player_174 extends MovieClip {
public function Player_174(){
addFrameScript(1, frame2);
}
function frame2(){
stop();
}
}
}//package assets_fla
Section 19
//Player_Default_Icon_177 (assets_fla.Player_Default_Icon_177)
package assets_fla {
import flash.display.*;
public dynamic class Player_Default_Icon_177 extends MovieClip {
public function Player_Default_Icon_177(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package assets_fla
Section 20
//Room_Create_BG_134 (assets_fla.Room_Create_BG_134)
package assets_fla {
import flash.display.*;
public dynamic class Room_Create_BG_134 extends MovieClip {
public function Room_Create_BG_134(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package assets_fla
Section 21
//Scoreboard_55 (assets_fla.Scoreboard_55)
package assets_fla {
import flash.display.*;
public dynamic class Scoreboard_55 extends MovieClip {
public function Scoreboard_55(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame2(){
stop();
}
}
}//package assets_fla
Section 22
//Scoreboard_58 (assets_fla.Scoreboard_58)
package assets_fla {
import flash.display.*;
public dynamic class Scoreboard_58 extends MovieClip {
public var bar_mc:MovieClip;
public var label1:MovieClip;
public var label2:MovieClip;
public var label5:MovieClip;
public var mask_mc:MovieClip;
public var label3:MovieClip;
public var label4:MovieClip;
}
}//package assets_fla
Section 23
//Scoreboard_61 (assets_fla.Scoreboard_61)
package assets_fla {
import flash.text.*;
import flash.display.*;
public dynamic class Scoreboard_61 extends MovieClip {
public var label_s_txt:TextField;
public var label_txt:TextField;
}
}//package assets_fla
Section 24
//SuperSave_183 (assets_fla.SuperSave_183)
package assets_fla {
import flash.display.*;
public dynamic class SuperSave_183 extends MovieClip {
public function SuperSave_183(){
addFrameScript(1, frame2, 2, frame3);
}
function frame3(){
stop();
}
function frame2(){
stop();
}
}
}//package assets_fla
Section 25
//Window_40 (assets_fla.Window_40)
package assets_fla {
import flash.text.*;
import flash.display.*;
public dynamic class Window_40 extends MovieClip {
public var label_txt:TextField;
}
}//package assets_fla
Section 26
//MD5 (com.adobe.crypto.MD5)
package com.adobe.crypto {
import flash.utils.*;
import com.adobe.utils.*;
public class MD5 {
public static var digest:ByteArray;
public function MD5(){
super();
}
private static function ff(a:int, b:int, c:int, d:int, x:int, s:int, t:int):int{
return (transform(f, a, b, c, d, x, s, t));
}
private static function f(x:int, y:int, z:int):int{
return (((x & y) | (~(x) & z)));
}
private static function g(x:int, y:int, z:int):int{
return (((x & z) | (y & ~(z))));
}
private static function h(x:int, y:int, z:int):int{
return (((x ^ y) ^ z));
}
private static function i(x:int, y:int, z:int):int{
return ((y ^ (x | ~(z))));
}
private static function transform(func:Function, a:int, b:int, c:int, d:int, x:int, s:int, t:int):int{
var tmp:int = (((a + int(func(b, c, d))) + x) + t);
return ((IntUtil.rol(tmp, s) + b));
}
private static function hh(a:int, b:int, c:int, d:int, x:int, s:int, t:int):int{
return (transform(h, a, b, c, d, x, s, t));
}
public static function hash(s:String):String{
var ba:ByteArray = new ByteArray();
ba.writeUTFBytes(s);
return (hashBinary(ba));
}
private static function createBlocks(s:ByteArray):Array{
var blocks:Array = new Array();
var len:int = (s.length * 8);
var mask = 0xFF;
var i:int;
while (i < len) {
blocks[int((i >> 5))] = (blocks[int((i >> 5))] | ((s[(i / 8)] & mask) << (i % 32)));
i = (i + 8);
};
blocks[int((len >> 5))] = (blocks[int((len >> 5))] | (128 << (len % 32)));
blocks[int(((((len + 64) >>> 9) << 4) + 14))] = len;
return (blocks);
}
public static function hashBinary(s:ByteArray):String{
var aa:int;
var bb:int;
var cc:int;
var dd:int;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
var x:Array = createBlocks(s);
var len:int = x.length;
var i:int;
while (i < len) {
aa = a;
bb = b;
cc = c;
dd = d;
a = ff(a, b, c, d, x[int((i + 0))], 7, -680876936);
d = ff(d, a, b, c, x[int((i + 1))], 12, -389564586);
c = ff(c, d, a, b, x[int((i + 2))], 17, 606105819);
b = ff(b, c, d, a, x[int((i + 3))], 22, -1044525330);
a = ff(a, b, c, d, x[int((i + 4))], 7, -176418897);
d = ff(d, a, b, c, x[int((i + 5))], 12, 1200080426);
c = ff(c, d, a, b, x[int((i + 6))], 17, -1473231341);
b = ff(b, c, d, a, x[int((i + 7))], 22, -45705983);
a = ff(a, b, c, d, x[int((i + 8))], 7, 1770035416);
d = ff(d, a, b, c, x[int((i + 9))], 12, -1958414417);
c = ff(c, d, a, b, x[int((i + 10))], 17, -42063);
b = ff(b, c, d, a, x[int((i + 11))], 22, -1990404162);
a = ff(a, b, c, d, x[int((i + 12))], 7, 1804603682);
d = ff(d, a, b, c, x[int((i + 13))], 12, -40341101);
c = ff(c, d, a, b, x[int((i + 14))], 17, -1502002290);
b = ff(b, c, d, a, x[int((i + 15))], 22, 1236535329);
a = gg(a, b, c, d, x[int((i + 1))], 5, -165796510);
d = gg(d, a, b, c, x[int((i + 6))], 9, -1069501632);
c = gg(c, d, a, b, x[int((i + 11))], 14, 643717713);
b = gg(b, c, d, a, x[int((i + 0))], 20, -373897302);
a = gg(a, b, c, d, x[int((i + 5))], 5, -701558691);
d = gg(d, a, b, c, x[int((i + 10))], 9, 38016083);
c = gg(c, d, a, b, x[int((i + 15))], 14, -660478335);
b = gg(b, c, d, a, x[int((i + 4))], 20, -405537848);
a = gg(a, b, c, d, x[int((i + 9))], 5, 568446438);
d = gg(d, a, b, c, x[int((i + 14))], 9, -1019803690);
c = gg(c, d, a, b, x[int((i + 3))], 14, -187363961);
b = gg(b, c, d, a, x[int((i + 8))], 20, 1163531501);
a = gg(a, b, c, d, x[int((i + 13))], 5, -1444681467);
d = gg(d, a, b, c, x[int((i + 2))], 9, -51403784);
c = gg(c, d, a, b, x[int((i + 7))], 14, 1735328473);
b = gg(b, c, d, a, x[int((i + 12))], 20, -1926607734);
a = hh(a, b, c, d, x[int((i + 5))], 4, -378558);
d = hh(d, a, b, c, x[int((i + 8))], 11, -2022574463);
c = hh(c, d, a, b, x[int((i + 11))], 16, 1839030562);
b = hh(b, c, d, a, x[int((i + 14))], 23, -35309556);
a = hh(a, b, c, d, x[int((i + 1))], 4, -1530992060);
d = hh(d, a, b, c, x[int((i + 4))], 11, 1272893353);
c = hh(c, d, a, b, x[int((i + 7))], 16, -155497632);
b = hh(b, c, d, a, x[int((i + 10))], 23, -1094730640);
a = hh(a, b, c, d, x[int((i + 13))], 4, 681279174);
d = hh(d, a, b, c, x[int((i + 0))], 11, -358537222);
c = hh(c, d, a, b, x[int((i + 3))], 16, -722521979);
b = hh(b, c, d, a, x[int((i + 6))], 23, 76029189);
a = hh(a, b, c, d, x[int((i + 9))], 4, -640364487);
d = hh(d, a, b, c, x[int((i + 12))], 11, -421815835);
c = hh(c, d, a, b, x[int((i + 15))], 16, 530742520);
b = hh(b, c, d, a, x[int((i + 2))], 23, -995338651);
a = ii(a, b, c, d, x[int((i + 0))], 6, -198630844);
d = ii(d, a, b, c, x[int((i + 7))], 10, 1126891415);
c = ii(c, d, a, b, x[int((i + 14))], 15, -1416354905);
b = ii(b, c, d, a, x[int((i + 5))], 21, -57434055);
a = ii(a, b, c, d, x[int((i + 12))], 6, 1700485571);
d = ii(d, a, b, c, x[int((i + 3))], 10, -1894986606);
c = ii(c, d, a, b, x[int((i + 10))], 15, -1051523);
b = ii(b, c, d, a, x[int((i + 1))], 21, -2054922799);
a = ii(a, b, c, d, x[int((i + 8))], 6, 1873313359);
d = ii(d, a, b, c, x[int((i + 15))], 10, -30611744);
c = ii(c, d, a, b, x[int((i + 6))], 15, -1560198380);
b = ii(b, c, d, a, x[int((i + 13))], 21, 1309151649);
a = ii(a, b, c, d, x[int((i + 4))], 6, -145523070);
d = ii(d, a, b, c, x[int((i + 11))], 10, -1120210379);
c = ii(c, d, a, b, x[int((i + 2))], 15, 718787259);
b = ii(b, c, d, a, x[int((i + 9))], 21, -343485551);
a = (a + aa);
b = (b + bb);
c = (c + cc);
d = (d + dd);
i = (i + 16);
};
digest = new ByteArray();
digest.writeInt(a);
digest.writeInt(b);
digest.writeInt(c);
digest.writeInt(d);
digest.position = 0;
return ((((IntUtil.toHex(a) + IntUtil.toHex(b)) + IntUtil.toHex(c)) + IntUtil.toHex(d)));
}
private static function gg(a:int, b:int, c:int, d:int, x:int, s:int, t:int):int{
return (transform(g, a, b, c, d, x, s, t));
}
private static function ii(a:int, b:int, c:int, d:int, x:int, s:int, t:int):int{
return (transform(i, a, b, c, d, x, s, t));
}
public static function hashBytes(s:ByteArray):String{
return (hashBinary(s));
}
}
}//package com.adobe.crypto
Section 27
//JSON (com.adobe.serialization.json.JSON)
package com.adobe.serialization.json {
public class JSON {
public function JSON(){
super();
}
public static function decode(s:String, strict:Boolean=true){
return (new JSONDecoder(s, strict).getValue());
}
public static function encode(o:Object):String{
return (new JSONEncoder(o).getString());
}
}
}//package com.adobe.serialization.json
Section 28
//JSONDecoder (com.adobe.serialization.json.JSONDecoder)
package com.adobe.serialization.json {
public class JSONDecoder {
private var strict:Boolean;
private var value;
private var tokenizer:JSONTokenizer;
private var token:JSONToken;
public function JSONDecoder(s:String, strict:Boolean){
super();
this.strict = strict;
tokenizer = new JSONTokenizer(s, strict);
nextToken();
value = parseValue();
if (((strict) && (!((nextToken() == null))))){
tokenizer.parseError("Unexpected characters left in input stream");
};
}
private function nextToken():JSONToken{
return ((token = tokenizer.getNextToken()));
}
private function parseObject():Object{
var key:String;
var o:Object = new Object();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (o);
};
if (((!(strict)) && ((token.type == JSONTokenType.COMMA)))){
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (o);
};
tokenizer.parseError(("Leading commas are not supported. Expecting '}' but found " + token.value));
};
while (true) {
if (token.type == JSONTokenType.STRING){
key = String(token.value);
nextToken();
if (token.type == JSONTokenType.COLON){
nextToken();
o[key] = parseValue();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (o);
};
if (token.type == JSONTokenType.COMMA){
nextToken();
if (!strict){
if (token.type == JSONTokenType.RIGHT_BRACE){
return (o);
};
};
} 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 parseArray():Array{
var a:Array = new Array();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (a);
};
if (((!(strict)) && ((token.type == JSONTokenType.COMMA)))){
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (a);
};
tokenizer.parseError(("Leading commas are not supported. Expecting ']' but found " + token.value));
};
while (true) {
a.push(parseValue());
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (a);
};
if (token.type == JSONTokenType.COMMA){
nextToken();
if (!strict){
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (a);
};
};
} else {
tokenizer.parseError(("Expecting ] or , but found " + token.value));
};
};
return (null);
}
public function getValue(){
return (value);
}
private function parseValue():Object{
if (token == null){
tokenizer.parseError("Unexpected end of input");
};
switch (token.type){
case JSONTokenType.LEFT_BRACE:
return (parseObject());
case JSONTokenType.LEFT_BRACKET:
return (parseArray());
case JSONTokenType.STRING:
case JSONTokenType.NUMBER:
case JSONTokenType.TRUE:
case JSONTokenType.FALSE:
case JSONTokenType.NULL:
return (token.value);
case JSONTokenType.NAN:
if (!strict){
return (token.value);
};
tokenizer.parseError(("Unexpected " + token.value));
default:
tokenizer.parseError(("Unexpected " + token.value));
};
return (null);
}
}
}//package com.adobe.serialization.json
Section 29
//JSONEncoder (com.adobe.serialization.json.JSONEncoder)
package com.adobe.serialization.json {
import flash.utils.*;
public class JSONEncoder {
private var jsonString:String;
public function JSONEncoder(value){
super();
jsonString = convertToString(value);
}
private function escapeString(str:String):String{
var ch:String;
var hexCode:String;
var zeroPad:String;
var s:String = "";
var len:Number = str.length;
var i:int;
while (i < len) {
ch = str.charAt(i);
switch (ch){
case "\"":
s = (s + "\\\"");
break;
case "\\":
s = (s + "\\\\");
break;
case "\b":
s = (s + "\\b");
break;
case "\f":
s = (s + "\\f");
break;
case "\n":
s = (s + "\\n");
break;
case "\r":
s = (s + "\\r");
break;
case "\t":
s = (s + "\\t");
break;
default:
if (ch < " "){
hexCode = ch.charCodeAt(0).toString(16);
zeroPad = ((hexCode.length == 2)) ? "00" : "000";
s = (s + (("\\u" + zeroPad) + hexCode));
} else {
s = (s + ch);
};
};
i++;
};
return ((("\"" + s) + "\""));
}
private function arrayToString(a:Array):String{
var s:String = "";
var i:int;
while (i < a.length) {
if (s.length > 0){
s = (s + ",");
};
s = (s + convertToString(a[i]));
i++;
};
return ((("[" + s) + "]"));
}
public function getString():String{
return (jsonString);
}
private function objectToString(o:Object):String{
var value:Object;
var key:String;
var v:XML;
var o = o;
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 {
var _local3:int;
var _local6:int;
var _local7:* = classInfo..*;
var _local5 = new XMLList("");
for each (var _local8 in classInfo..*) {
var _local9 = _local8;
with (_local9) {
if ((((name() == "variable")) || ((((name() == "accessor")) && ((attribute("access").charAt(0) == "r")))))){
_local5[_local6] = _local8;
};
};
};
var _local4:* = _local5;
for each (v in _local5) {
if (((v.metadata) && ((v.metadata.(@name == "Transient").length() > 0)))){
} else {
if (s.length > 0){
s = (s + ",");
};
s = (s + ((escapeString(v.@name.toString()) + ":") + convertToString(o[v.@name])));
};
};
};
return ((("{" + s) + "}"));
}
private function convertToString(value):String{
if ((value is String)){
return (escapeString((value as String)));
};
if ((value is Number)){
return ((isFinite((value as Number))) ? value.toString() : "null");
} else {
if ((value is Boolean)){
return ((value) ? "true" : "false");
} else {
if ((value is Array)){
return (arrayToString((value as Array)));
};
if ((((value is Object)) && (!((value == null))))){
return (objectToString(value));
};
};
};
return ("null");
}
}
}//package com.adobe.serialization.json
Section 30
//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(message:String="", location:int=0, text:String=""){
super(message);
name = "JSONParseError";
_location = location;
_text = text;
}
public function get location():int{
return (_location);
}
public function get text():String{
return (_text);
}
}
}//package com.adobe.serialization.json
Section 31
//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(type:int=-1, value:Object=null){
super();
_type = type;
_value = value;
}
public function get value():Object{
return (_value);
}
public function get type():int{
return (_type);
}
public function set type(value:int):void{
_type = value;
}
public function set value(v:Object):void{
_value = v;
}
}
}//package com.adobe.serialization.json
Section 32
//JSONTokenizer (com.adobe.serialization.json.JSONTokenizer)
package com.adobe.serialization.json {
public class JSONTokenizer {
private var ch:String;
private var loc:int;
private var jsonString:String;
private var strict:Boolean;
private var controlCharsRegExp:RegExp;
private var obj:Object;
public function JSONTokenizer(s:String, strict:Boolean){
controlCharsRegExp = /[\x00-\x1F]/;
super();
jsonString = s;
this.strict = strict;
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(ch:String):Boolean{
return ((((ch >= "0")) && ((ch <= "9"))));
}
private function readNumber():JSONToken{
var token:JSONToken;
var input:String = "";
if (ch == "-"){
input = (input + "-");
nextChar();
};
if (!isDigit(ch)){
parseError("Expecting a digit");
};
if (ch == "0"){
input = (input + ch);
nextChar();
if (isDigit(ch)){
parseError("A digit cannot immediately follow 0");
} else {
if (((!(strict)) && ((ch == "x")))){
input = (input + ch);
nextChar();
if (isHexDigit(ch)){
input = (input + ch);
nextChar();
} else {
parseError("Number in hex format require at least one hex digit after \"0x\"");
};
while (isHexDigit(ch)) {
input = (input + ch);
nextChar();
};
};
};
} else {
while (isDigit(ch)) {
input = (input + ch);
nextChar();
};
};
if (ch == "."){
input = (input + ".");
nextChar();
if (!isDigit(ch)){
parseError("Expecting a digit");
};
while (isDigit(ch)) {
input = (input + ch);
nextChar();
};
};
if ((((ch == "e")) || ((ch == "E")))){
input = (input + "e");
nextChar();
if ((((ch == "+")) || ((ch == "-")))){
input = (input + ch);
nextChar();
};
if (!isDigit(ch)){
parseError("Scientific notation number needs exponent value");
};
while (isDigit(ch)) {
input = (input + ch);
nextChar();
};
};
var num:Number = Number(input);
if (((isFinite(num)) && (!(isNaN(num))))){
token = new JSONToken();
token.type = JSONTokenType.NUMBER;
token.value = num;
return (token);
};
parseError((("Number " + num) + " is not valid!"));
return (null);
}
public function unescapeString(input:String):String{
var afterBackslashIndex:*;
var escapedChar:*;
var _local10:*;
var i:*;
var possibleHexChar:*;
if (((strict) && (controlCharsRegExp.test(input)))){
parseError("String contains unescaped control character (0x00-0x1F)");
};
var result:String = "";
var backslashIndex:int;
var nextSubstringStartPosition:int;
var len:int = input.length;
do {
backslashIndex = input.indexOf("\\", nextSubstringStartPosition);
if (backslashIndex >= 0){
result = (result + input.substr(nextSubstringStartPosition, (backslashIndex - nextSubstringStartPosition)));
nextSubstringStartPosition = (backslashIndex + 2);
afterBackslashIndex = (backslashIndex + 1);
escapedChar = input.charAt(afterBackslashIndex);
switch (escapedChar){
case "\"":
result = (result + "\"");
break;
case "\\":
result = (result + "\\");
break;
case "n":
result = (result + "\n");
break;
case "r":
result = (result + "\r");
break;
case "t":
result = (result + "\t");
break;
case "u":
_local10 = "";
if ((nextSubstringStartPosition + 4) > len){
parseError("Unexpected end of input. Expecting 4 hex digits after \\u.");
};
i = nextSubstringStartPosition;
while (i < (nextSubstringStartPosition + 4)) {
possibleHexChar = input.charAt(i);
if (!isHexDigit(possibleHexChar)){
parseError(("Excepted a hex digit, but found: " + possibleHexChar));
};
_local10 = (_local10 + possibleHexChar);
i++;
};
result = (result + String.fromCharCode(parseInt(_local10, 16)));
nextSubstringStartPosition = (nextSubstringStartPosition + 4);
break;
case "f":
result = (result + "\f");
break;
case "/":
result = (result + "/");
break;
case "b":
result = (result + "\b");
break;
default:
result = (result + ("\\" + escapedChar));
};
} else {
result = (result + input.substr(nextSubstringStartPosition));
break;
};
} while (nextSubstringStartPosition < len);
return (result);
}
private function skipWhite():void{
while (isWhiteSpace(ch)) {
nextChar();
};
}
private function isWhiteSpace(ch:String):Boolean{
if ((((((((ch == " ")) || ((ch == "\t")))) || ((ch == "\n")))) || ((ch == "\r")))){
return (true);
};
if (((!(strict)) && ((ch.charCodeAt(0) == 160)))){
return (true);
};
return (false);
}
public function parseError(message:String):void{
throw (new JSONParseError(message, loc, jsonString));
}
private function readString():JSONToken{
var backspaceCount:*;
var backspaceIndex:*;
var quoteIndex:int = loc;
do {
quoteIndex = jsonString.indexOf("\"", quoteIndex);
if (quoteIndex >= 0){
backspaceCount = 0;
backspaceIndex = (quoteIndex - 1);
while (jsonString.charAt(backspaceIndex) == "\\") {
backspaceCount++;
backspaceIndex--;
};
if ((backspaceCount % 2) == 0){
break;
};
quoteIndex++;
} else {
parseError("Unterminated string literal");
};
} while (true);
var token:JSONToken = new JSONToken();
token.type = JSONTokenType.STRING;
token.value = unescapeString(jsonString.substr(loc, (quoteIndex - loc)));
loc = (quoteIndex + 1);
nextChar();
return (token);
}
private function nextChar():String{
return ((ch = jsonString.charAt(loc++)));
}
private function skipIgnored():void{
var originalLoc:int;
do {
originalLoc = loc;
skipWhite();
skipComments();
} while (originalLoc != loc);
}
private function isHexDigit(ch:String):Boolean{
return (((((isDigit(ch)) || ((((ch >= "A")) && ((ch <= "F")))))) || ((((ch >= "a")) && ((ch <= "f"))))));
}
public function getNextToken():JSONToken{
var _local2:String;
var _local3:String;
var _local4:String;
var _local5:String;
var token:JSONToken = new JSONToken();
skipIgnored();
switch (ch){
case "{":
token.type = JSONTokenType.LEFT_BRACE;
token.value = "{";
nextChar();
break;
case "}":
token.type = JSONTokenType.RIGHT_BRACE;
token.value = "}";
nextChar();
break;
case "[":
token.type = JSONTokenType.LEFT_BRACKET;
token.value = "[";
nextChar();
break;
case "]":
token.type = JSONTokenType.RIGHT_BRACKET;
token.value = "]";
nextChar();
break;
case ",":
token.type = JSONTokenType.COMMA;
token.value = ",";
nextChar();
break;
case ":":
token.type = JSONTokenType.COLON;
token.value = ":";
nextChar();
break;
case "t":
_local2 = ((("t" + nextChar()) + nextChar()) + nextChar());
if (_local2 == "true"){
token.type = JSONTokenType.TRUE;
token.value = true;
nextChar();
} else {
parseError(("Expecting 'true' but found " + _local2));
};
break;
case "f":
_local3 = (((("f" + nextChar()) + nextChar()) + nextChar()) + nextChar());
if (_local3 == "false"){
token.type = JSONTokenType.FALSE;
token.value = false;
nextChar();
} else {
parseError(("Expecting 'false' but found " + _local3));
};
break;
case "n":
_local4 = ((("n" + nextChar()) + nextChar()) + nextChar());
if (_local4 == "null"){
token.type = JSONTokenType.NULL;
token.value = null;
nextChar();
} else {
parseError(("Expecting 'null' but found " + _local4));
};
break;
case "N":
_local5 = (("N" + nextChar()) + nextChar());
if (_local5 == "NaN"){
token.type = JSONTokenType.NAN;
token.value = NaN;
nextChar();
} else {
parseError(("Expecting 'NaN' but found " + _local5));
};
break;
case "\"":
token = readString();
break;
default:
if (((isDigit(ch)) || ((ch == "-")))){
token = readNumber();
} else {
if (ch == ""){
return (null);
};
parseError((("Unexpected " + ch) + " encountered"));
};
};
return (token);
}
}
}//package com.adobe.serialization.json
Section 33
//JSONTokenType (com.adobe.serialization.json.JSONTokenType)
package com.adobe.serialization.json {
public class JSONTokenType {
public static const FALSE:int = 8;
public static const RIGHT_BRACKET:int = 4;
public static const NULL:int = 9;
public static const NUMBER:int = 11;
public static const TRUE:int = 7;
public static const RIGHT_BRACE:int = 2;
public static const STRING:int = 10;
public static const LEFT_BRACKET:int = 3;
public static const LEFT_BRACE:int = 1;
public static const UNKNOWN:int = -1;
public static const COMMA:int = 0;
public static const NAN:int = 12;
public static const COLON:int = 6;
public function JSONTokenType(){
super();
}
}
}//package com.adobe.serialization.json
Section 34
//IntUtil (com.adobe.utils.IntUtil)
package com.adobe.utils {
public class IntUtil {
private static var hexChars:String = "0123456789abcdef";
public function IntUtil(){
super();
}
public static function toHex(n:int, bigEndian:Boolean=false):String{
var i:int;
var x:int;
var s:String = "";
if (bigEndian){
i = 0;
while (i < 4) {
s = (s + (hexChars.charAt(((n >> (((3 - i) * 8) + 4)) & 15)) + hexChars.charAt(((n >> ((3 - i) * 8)) & 15))));
i++;
};
} else {
x = 0;
while (x < 4) {
s = (s + (hexChars.charAt(((n >> ((x * 8) + 4)) & 15)) + hexChars.charAt(((n >> (x * 8)) & 15))));
x++;
};
};
return (s);
}
public static function ror(x:int, n:int):uint{
var nn:int = (32 - n);
return (((x << nn) | (x >>> (32 - nn))));
}
public static function rol(x:int, n:int):int{
return (((x << n) | (x >>> (32 - n))));
}
}
}//package com.adobe.utils
Section 35
//FreeKickLevel (com.freekickfusion.game.levels.FreeKickLevel)
package com.freekickfusion.game.levels {
import uk.co.inbox.game.levels.*;
public class FreeKickLevel extends Level {
private var _goalkeeperLevel:GoalkeeperLevel;
private var _playersInWall:int;
private var _variancePosition:int;
public function FreeKickLevel($goalkeeperLevel:GoalkeeperLevel, $variancePosition:int, $playersInWall:int){
super();
_goalkeeperLevel = $goalkeeperLevel;
_variancePosition = $variancePosition;
_playersInWall = $playersInWall;
}
public function get playersInWall():int{
return (_playersInWall);
}
public function get variancePosition():int{
return (_variancePosition);
}
public function get goalkeeperLevel():GoalkeeperLevel{
return (_goalkeeperLevel);
}
}
}//package com.freekickfusion.game.levels
Section 36
//FreeKickMultiLevel (com.freekickfusion.game.levels.FreeKickMultiLevel)
package com.freekickfusion.game.levels {
import uk.co.inbox.game.levels.*;
public class FreeKickMultiLevel extends Level {
private var _goalkeeperLevel:GoalkeeperLevel;
private var _playersInWall:int;
private var _name:String;
public function FreeKickMultiLevel($name:String, $goalkeeperLevel:GoalkeeperLevel, $playersInWall:int){
super();
_name = $name;
_goalkeeperLevel = $goalkeeperLevel;
_playersInWall = $playersInWall;
}
public function get playersInWall():int{
return (_playersInWall);
}
public function get name():String{
return (_name);
}
public function get goalkeeperLevel():GoalkeeperLevel{
return (_goalkeeperLevel);
}
}
}//package com.freekickfusion.game.levels
Section 37
//GoalkeeperLevel (com.freekickfusion.game.levels.GoalkeeperLevel)
package com.freekickfusion.game.levels {
import uk.co.inbox.game.levels.*;
public class GoalkeeperLevel extends Level {
private var _maxHighDiveDist:Number;
private var _speed:Number;
private var _name:String;
private var _xSpeedDeficit:Number;
public function GoalkeeperLevel($name:String, $speed:Number, $maxHighDiveDist:Number, $xSpeedDeficit:Number){
super();
_name = $name;
_speed = $speed;
_maxHighDiveDist = $maxHighDiveDist;
_xSpeedDeficit = $xSpeedDeficit;
}
public function get maxHighDiveDist():Number{
return (_maxHighDiveDist);
}
public function get speed():Number{
return (_speed);
}
public function get name():String{
return (_name);
}
public function get xSpeedDeficit():Number{
return (_xSpeedDeficit);
}
}
}//package com.freekickfusion.game.levels
Section 38
//FireBallEvent (com.freekickfusion.game.render.events.FireBallEvent)
package com.freekickfusion.game.render.events {
import flash.events.*;
public class FireBallEvent extends Event {
public var angle:Number;
public var power:Number;
public var curl:Number;
public var elevation:Number;
public static const FIRE:String = "fire";
public function FireBallEvent(type:String, power:Number, angle:Number, curl:Number, elevation:Number, bubbles:Boolean=false, cancelable:Boolean=false){
this.power = power;
this.angle = angle;
this.curl = curl;
this.elevation = elevation;
super(type, bubbles, cancelable);
}
override public function clone():Event{
return (new FireBallEvent(type, power, angle, curl, elevation, bubbles, cancelable));
}
override public function toString():String{
return (formatToString("FireBallEvent", "type", "power", "angle", "curl", "elevation", "bubbles", "cancelable", "eventPhase"));
}
}
}//package com.freekickfusion.game.render.events
Section 39
//GameMessageEvent (com.freekickfusion.game.render.events.GameMessageEvent)
package com.freekickfusion.game.render.events {
import flash.events.*;
public class GameMessageEvent extends Event {
public var messageId:int;
public static const MESSAGE_WIDE:int = 5;
public static const MESSAGE_HIT_POST:int = 3;
public static const MESSAGE_OVER_CROSSBAR:int = 6;
public static const MESSAGE_SUPER_SAVED:int = 2;
public static const SHOW:String = "show";
public static const MESSAGE_SAVED:int = 1;
public static const SHOW_SCORE:String = "showScore";
public static const MESSAGE_GOAL:int = 0;
public static const MESSAGE_HIT_WALL:int = 7;
public static const MESSAGE_HIT_CROSSBAR:int = 4;
public function GameMessageEvent(type:String, $messageId:int, bubbles:Boolean=false, cancelable:Boolean=false){
messageId = $messageId;
super(type, bubbles, cancelable);
}
override public function clone():Event{
return (new GameMessageEvent(type, messageId, bubbles, cancelable));
}
override public function toString():String{
return (formatToString("GameMessageEvent", "type", "messageId", "bubbles", "cancelable", "eventPhase"));
}
}
}//package com.freekickfusion.game.render.events
Section 40
//AimArrow (com.freekickfusion.game.render.AimArrow)
package com.freekickfusion.game.render {
import flash.events.*;
import flash.utils.*;
import com.freekickfusion.game.render.events.*;
public class AimArrow extends PitchItem {
private const ANGLE_LEFT:String = "left";
private const ANGLE_RIGHT:String = "right";
private var MAX_ELEVATION:Number;// = 10
private var ELEVATION_MULTIPLIER:Number;// = 2.5
private var posX:Number;// = 250
private var posY:Number;// = 50
private var isPoweringUp:Boolean;// = false
private var power:Number;// = 0
private var tempCounter:Number;
private var ELEVATION_FACTOR:Number;// = 10
private var MIN_POWER:Number;// = 0
private var MIN_CURL:Number;// = -3
private var POWER_DIVIDER:Number;// = 0.7
private var isStartedShot:Boolean;// = false
private var POSX_INC:Number;// = 4
private var POSY_INC:Number;// = 30
private var MAX_POWER:Number;// = 100
private var CURL_INC:Number;// = 5
private var curl:Number;// = 0
private var startXmouse:Number;
private var state:int;// = 0
private var CURL_MULTIPLIER:Number;// = 1.7
private var ballList:Array;
private var angleDir:String;// = "right"
private var CURL_FACTOR:Number;// = 30
private var isStopped:Boolean;// = false
private var MAX_CURL:Number;// = 3
private var ANGLE_MULTIPLIER:Number;// = 0.9
private var startYmouse:Number;
private var isPoweringDown:Boolean;// = false
private var SHOT_PAUSE:Number;// = 2000
private var angle:Number;// = 0
private var BALLS_NUM:Number;// = 8
private var MAX_POWER_DIV:Number;
private var elevation:Number;// = 4
private var POWER_INC:Number;// = 1.4
private var MIN_ANGLE:Number;// = -60
private var pauseTimer:Timer;
private var startTime:Number;// = 0
private var MAX_ANGLE:Number;// = 60
private var MIN_ELEVATION:Number;// = 0
private static const STATE_FIRING:int = 2;
private static const STATE_IDLE:int = 0;
private static const STATE_POWERING:int = 1;
private static const STATE_STOPPED:int = 3;
public function AimArrow(){
MAX_POWER_DIV = (2000 / MAX_POWER);
ballList = [];
super();
pauseTimer = new Timer(SHOT_PAUSE, 1);
pauseTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onPauseComplete, false, 0, true);
myPos._z = 10.5;
drawBalls();
}
public function reappear():void{
var ball:AimArrow_Ball_Graphic;
pauseTimer.stop();
state = STATE_IDLE;
var i:int;
while (i < ballList.length) {
ball = ballList[i];
ball.visible = true;
i++;
};
}
private function drawBalls():void{
var ball:AimArrow_Ball_Graphic;
var i:int;
while (i < BALLS_NUM) {
ball = new AimArrow_Ball_Graphic();
ball.alpha = ((1 - (BALLS_NUM / 10)) + (i / 10));
addChild(ball);
ballList.push(ball);
i++;
};
}
public function get isShooting():Boolean{
return ((state == STATE_POWERING));
}
private function onPauseComplete(e:TimerEvent):void{
trace("AimArrow.onPauseComplete");
reappear();
}
public function fireBall($isDoReset:Boolean):void{
state = STATE_FIRING;
if (power > MAX_POWER){
power = MAX_POWER;
};
var s:KickSound = new KickSound();
s.play();
dispatchEvent(new FireBallEvent(FireBallEvent.FIRE, (power / POWER_DIVIDER), (angle * ANGLE_MULTIPLIER), ((elevation * ELEVATION_MULTIPLIER) * (power / MAX_POWER)), (curl * CURL_MULTIPLIER)));
reset($isDoReset);
}
public function drawGuideBall():void{
var ball:AimArrow_Ball_Graphic;
state = STATE_STOPPED;
var i:int;
while (i < ballList.length) {
ball = ballList[i];
ball.visible = false;
i++;
};
var ref:AimArrow_Ball_Graphic = ballList[(ballList.length - 1)];
ref.visible = true;
}
override public function update():void{
var diff:Number;
if (state == STATE_IDLE){
if (angleDir == ANGLE_RIGHT){
angle++;
if (angle >= MAX_ANGLE){
angleDir = ANGLE_LEFT;
};
};
if (angleDir == ANGLE_LEFT){
angle--;
if (angle <= MIN_ANGLE){
angleDir = ANGLE_RIGHT;
};
};
};
if (isStartedShot){
diff = (getTimer() - startTime);
if (isPoweringUp){
power = ((diff % 2000) / MAX_POWER_DIV);
if (diff >= 2000){
startTime = getTimer();
power = MAX_POWER;
isPoweringUp = false;
isPoweringDown = true;
};
} else {
if (isPoweringDown){
power = (MAX_POWER - ((diff % 2000) / MAX_POWER_DIV));
if (diff >= 2000){
startTime = getTimer();
power = MIN_POWER;
isPoweringUp = true;
isPoweringDown = false;
};
};
};
elevation = ((mouseY - startYmouse) / ELEVATION_FACTOR);
if (elevation < MIN_ELEVATION){
elevation = MIN_ELEVATION;
} else {
if (elevation > MAX_ELEVATION){
elevation = MAX_ELEVATION;
};
};
curl = ((mouseX - startXmouse) / CURL_FACTOR);
if (curl < MIN_CURL){
curl = MIN_CURL;
} else {
if (curl > MAX_CURL){
curl = MAX_CURL;
};
};
};
redrawMe();
super.update();
scaleX = (scaleX * 0.37);
scaleY = (scaleY * 0.37);
}
public function startShoot():void{
state = STATE_POWERING;
startXmouse = mouseX;
startYmouse = (mouseY - 45);
isStartedShot = true;
isPoweringUp = true;
isStopped = true;
startTime = getTimer();
}
public function reset($isDoReset:Boolean):void{
var ball:AimArrow_Ball_Graphic;
trace(("AimArrow.reset - $isDoReset:" + $isDoReset));
elevation = 4.5;
power = 0;
curl = 0;
isPoweringUp = true;
isStopped = false;
isStartedShot = false;
state = STATE_IDLE;
var i:int;
while (i < ballList.length) {
ball = ballList[i];
ball.visible = false;
ball.ball_mc.gotoAndStop("blank");
i++;
};
if ($isDoReset){
trace(" yeah");
pauseTimer.start();
};
}
private function redrawMe():void{
var ref:AimArrow_Ball_Graphic;
var i:int;
var posY:Number = 0;
var posX:Number = 0;
var len:int = ballList.length;
i = 0;
while (i < len) {
ref = ballList[((len - i) - 1)];
if (i > 0){
posX = (posX + ((angle / POSX_INC) + (i * (curl / (CURL_INC - (i / 3))))));
posY = (posY - ((6 - ((angle / POSY_INC) * (angle / POSY_INC))) - (elevation / 5)));
};
ref.x = posX;
ref.y = posY;
ref.ball_mc.y = (-7 - ((i + 1) * elevation));
ref.shadow_mc.scaleX = (ref.shadow_mc.scaleY = (1 - ((i * elevation) / 400)));
if (power > (i * (MAX_POWER / BALLS_NUM))){
if (ref.ball_mc.currentFrame == 1){
ref.ball_mc.gotoAndStop("powered");
};
} else {
if (ref.ball_mc.currentFrame == 2){
ref.ball_mc.gotoAndStop("blank");
};
};
i++;
};
}
}
}//package com.freekickfusion.game.render
Section 41
//Ball (com.freekickfusion.game.render.Ball)
package com.freekickfusion.game.render {
import gs.*;
import com.freekickfusion.game.render.events.*;
import uk.co.inbox.game.render.vector.*;
public class Ball extends PitchItem {
public const RIGHTPOST_MID:Number = 63;
public const LEFTPOST_MID:Number = -64;
public const LEFTPOST_LEFT:Number = -66;
public const CROSSBAR_BOTTOM:Number = -43;
public const RIGHTPOST_RIGHT:Number = 65;
public const CROSSBAR_TOP:Number = -47;
public const RIGHTPOST_LEFT:Number = 61;
public const LEFTPOST_RIGHT:Number = -62;
private var isFading:Boolean;// = false
private var BALL_START_HEIGHT:Number;// = -10
private var ballWidth:Number;// = 14
private var ballHeight:Number;// = 0
private var checkLawnmowerZDist:Number;// = 2
private var dampSideNetCollision:Number;// = 0.3
public var power:Number;
private var dampNetCollision:Number;// = 0.15
private var yMin:Number;// = -188
public var isOverBar:Boolean;// = false
private var checkLawnmowerXDist:Number;// = 15
private var yMax:Number;// = 0
private var dampCurl:Number;// = 0.95
public var curl:Number;
public var isGoalieDived:Boolean;// = false
private var dampCollision:Number;// = 0.6
private var _shadow:BallShadow;
private var xEnd:Number;// = -246
private var minX:Number;// = -10
private var checkStaticXDist:Number;// = 10
private var checkStaticZDist:Number;// = 2
private var playerList:Array;
private var yzS:Number;
public var isGoal:Boolean;// = false
public var mydir:GVector;
private var dampCurlCollision:Number;// = 0.9
public var isHitWoodwork:Boolean;// = false
private var playerInfoList:Array;
private var goalie:Goalie;
public var isPastLine:Boolean;// = false
private var dampPostCollision:Number;// = 0.7
private var maxX:Number;// = 510
private var maxY:Number;// = 310
private var bounceCount:int;// = 0
private var xyS:Number;
private var myWidth:Number;// = 1
private var dampAdBoard:Number;// = 0.6
private var posX:Number;
private var posY:Number;
private var dampWallCollision:Number;// = 0.7
private var dampGoalieCollision:Number;// = 0.6
public var dir:Number;
public var isPastGoalNet:Boolean;// = false
public var isTesting:Boolean;// = false
public var frCount:Number;// = 0
private var xzS:Number;
public var isDead:Boolean;// = false
public var floorloc:GVector;
private var _isGoalScored:Boolean;// = false
private var main:Ball_Graphic;
private var xMin:Number;// = 0
public var vx:Number;
public var vy:Number;
public var vz:Number;
private var startVy:Number;// = -9
public var isThisARealVariableIDontThinkSo:Boolean;// = true
private var floorY:Number;// = 0
public var isCheckedGoal:Boolean;// = false
private var checkPersonDist:Number;// = 10
private var xMax:Number;// = 416
public var isCheckedGoalie:Boolean;// = false
public var isHitGround:Boolean;// = false
private var myHeight:Number;// = 1
private var checkTargetDist:Number;// = 10
public function Ball($playerList:Array, $xyS:Number, $xzS:Number, $yzS:Number){
playerList = [];
playerInfoList = [];
super();
main = new Ball_Graphic();
addChild(main);
isHitWoodwork = false;
isOverBar = false;
ballHeight = BALL_START_HEIGHT;
frCount = 0;
myPos = new GVector(0, 0, 10.4);
mydir = new GVector(0, 0, 0);
floorloc = new GVector(0, 0, 0);
xyS = $xyS;
xzS = $xzS;
yzS = $yzS;
playerInfoList = [];
var i:int;
while (i < $playerList.length) {
playerInfoList[i] = [false, false, false];
i++;
};
playerList = $playerList.slice();
}
public function get shadow():BallShadow{
return (_shadow);
}
public function setShadow($shadow:BallShadow):void{
_shadow = $shadow;
}
public function fadeOut():void{
_shadow.fadeOut();
if (!isFading){
isFading = true;
TweenLite.to(this, 0.5, {alpha:0, onComplete:onFadeOutComplete});
};
}
public function setGoalie($goalie:Goalie):void{
goalie = $goalie;
}
public function moveBall():void{
var xD:Number;
var zD:Number;
var rotVal:Number;
var xDist:Number;
var radians:Number;
var nxP:Number;
var nzP:Number;
var nD:Number;
var yD:Number;
var dist:Number;
var s:GoalSound;
processFlight();
if (!isDead){
checkPlayers();
};
if (((((power / (30 - myPos._z)) > 20)) && (!(isGoalieDived)))){
isGoalieDived = true;
goalie.dive();
};
if ((((myPos._z > 30)) && (!(isCheckedGoalie)))){
isCheckedGoalie = true;
goalie.xSpeed = 0;
if (goalie.newHitTest(x, y, true)){
myPos._z = 30;
dir = (180 - dir);
check180();
power = (power * dampGoalieCollision);
if (goalie.isSuperSave){
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_SUPER_SAVED));
} else {
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_SAVED));
};
isHitGround = false;
};
};
if ((((myPos._z > 31)) && (!(isPastLine)))){
if (((((((myPos._x + myWidth) > RIGHTPOST_LEFT)) && (((myPos._x - myWidth) < RIGHTPOST_RIGHT)))) && ((myPos._y > CROSSBAR_BOTTOM)))){
myPos._z = 31;
xD = (RIGHTPOST_MID - myPos._x);
zD = ((myPos._z - 30.9) * xzS);
rotVal = (90 + (Math.atan((xD / zD)) / (Math.PI / 180)));
xDist = (1.5 + (myWidth * 1.5));
radians = (rotVal * (Math.PI / 180));
nxP = (xDist * Math.cos(radians));
nzP = ((xDist * Math.sin(radians)) / xzS);
nD = (dir + ((rotVal - dir) * 2));
dir = nD;
check180();
power = (power * dampPostCollision);
isHitWoodwork = true;
isHitGround = false;
doBallSpin();
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_HIT_POST));
} else {
if (((((((myPos._x + myWidth) > LEFTPOST_LEFT)) && (((myPos._x - myWidth) < LEFTPOST_RIGHT)))) && ((myPos._y > CROSSBAR_BOTTOM)))){
myPos._z = 31;
xD = (LEFTPOST_MID - myPos._x);
zD = ((myPos._z - 30.9) * xzS);
rotVal = (90 + (Math.atan((xD / zD)) / (Math.PI / 180)));
xDist = (1.5 + (myWidth * 1.5));
radians = (rotVal * (Math.PI / 180));
nxP = (xDist * Math.cos(radians));
nzP = ((xDist * Math.sin(radians)) / xzS);
nD = (dir + ((rotVal - dir) * 2));
dir = nD;
check180();
power = (power * dampPostCollision);
isHitWoodwork = true;
isHitGround = false;
doBallSpin();
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_HIT_POST));
};
};
if (((((((((myPos._y + myHeight) > CROSSBAR_TOP)) && (((myPos._y - myHeight) < CROSSBAR_BOTTOM)))) && ((myPos._x > LEFTPOST_LEFT)))) && ((myPos._x < RIGHTPOST_RIGHT)))){
dir = (180 - dir);
power = (power * 0.7);
check180();
isHitWoodwork = true;
isHitGround = false;
doBallSpin();
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_HIT_CROSSBAR));
};
if ((myPos._y + myHeight) < CROSSBAR_TOP){
isOverBar = true;
};
if ((((dir > -90)) && ((dir < 90)))){
isPastLine = true;
};
};
if ((((myPos._z > 31.3)) && (!(isCheckedGoal)))){
isCheckedGoal = true;
if (((!(isGoal)) && ((((dir > -90)) && ((dir < 90)))))){
if ((((((((myPos._x < RIGHTPOST_RIGHT)) && ((myPos._x > LEFTPOST_LEFT)))) && ((myPos._y > CROSSBAR_TOP)))) && (!(isOverBar)))){
isGoal = true;
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_GOAL));
if (myPos._x > 0){
xD = ((RIGHTPOST_LEFT - 3) - myPos._x);
} else {
xD = (myPos._x - (LEFTPOST_RIGHT + 3));
};
yD = (-((CROSSBAR_BOTTOM + 2)) + myPos._y);
if (xD < 0){
xD = 0;
};
if (yD < 0){
yD = 0;
};
dist = (10 - (Math.round(Math.sqrt(((xD * xD) + (yD * yD)))) / 10));
if (dist < 1){
dist = 1;
} else {
if (dist > 10){
dist = 10;
};
};
dist = (dist * 10);
_isGoalScored = true;
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW_SCORE, dist));
s = new GoalSound();
s.play();
} else {
if (!isHitWoodwork){
if ((((myPos._x >= RIGHTPOST_RIGHT)) || ((myPos._x <= LEFTPOST_LEFT)))){
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_WIDE));
} else {
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_OVER_CROSSBAR));
};
};
};
} else {
if (!isHitWoodwork){
if ((((myPos._x >= RIGHTPOST_RIGHT)) || ((myPos._x <= LEFTPOST_LEFT)))){
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_WIDE));
} else {
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_OVER_CROSSBAR));
};
};
};
};
if (isGoal){
if (myPos._z > 34){
myPos._z = 34;
if ((((myPos._x > LEFTPOST_LEFT)) && ((myPos._x < RIGHTPOST_RIGHT)))){
if (myPos._y > -45){
power = (power * dampNetCollision);
if (dir > 0){
dir = 90;
} else {
dir = -90;
};
isHitGround = false;
doBallSpin();
};
};
};
if (myPos._x < LEFTPOST_LEFT){
myPos._x = LEFTPOST_LEFT;
dir = -(dir);
power = (power * dampSideNetCollision);
} else {
if (myPos._x > RIGHTPOST_RIGHT){
myPos._x = RIGHTPOST_RIGHT;
dir = -(dir);
power = (power * dampSideNetCollision);
};
};
} else {
if ((((((((myPos._z < 34.5)) && ((myPos._z > 34)))) && (isPastLine))) && ((((dir < -90)) || ((dir > 90)))))){
if ((((myPos._x < RIGHTPOST_RIGHT)) && ((myPos._x > LEFTPOST_LEFT)))){
myPos._z = 34.5;
dir = (180 - dir);
check180();
isHitGround = false;
doBallSpin();
};
};
};
if (myPos._z > 41){
myPos._z = 41;
dir = (180 - dir);
power = (power * dampAdBoard);
isHitGround = false;
doBallSpin();
};
if ((((x > maxX)) || ((x < minX)))){
fadeOut();
};
floorloc._x = myPos._x;
floorloc._y = floorY;
floorloc._z = myPos._z;
shadow.setPos(floorloc);
}
public function doBallSpin():void{
if ((((dir < -90)) || ((dir > 90)))){
main.ball_mc.gotoAndPlay("backward");
} else {
main.ball_mc.gotoAndPlay("forward");
};
}
private function checkPlayers():void{
var player:Player;
var checkXZ:Boolean;
var checkY:Boolean;
var xzC:Boolean;
var yC:Boolean;
var diff:Number;
var xD:Number;
var zD:Number;
var dist:Number;
var rotVal:Number;
var xDist:Number;
var radians:Number;
var nxP:Number;
var nzP:Number;
var nD:Number;
var trotVal:Number;
var tx:Number;
var ty:Number;
var tz:Number;
var tpower:Number;
var tvx:Number;
var tvy:Number;
var tvz:Number;
var tdir:Number;
var tcurl:Number;
var tfrCount:Number;
var j:Number;
var found:Boolean;
var startDir:Number = dir;
floorY = 0;
var i:int;
while (i < playerList.length) {
player = playerList[i];
checkXZ = false;
checkY = false;
xzC = playerInfoList[i][0];
yC = playerInfoList[i][1];
diff = 0;
if (myPos._y >= (player.myPos._y - player.h)){
if ((myPos._y - myHeight) <= player.myPos._y){
playerInfoList[i][1] = true;
} else {
playerInfoList[i][1] = false;
};
} else {
playerInfoList[i][1] = false;
};
xD = (myPos._x - player.myPos._x);
zD = ((myPos._z - player.myPos._z) * xzS);
dist = Math.sqrt(((xD * xD) + (zD * zD)));
if (dist < (player.rad + (myWidth * 1.5))){
playerInfoList[i][0] = true;
} else {
playerInfoList[i][0] = false;
};
if (playerInfoList[i][0]){
if (playerInfoList[i][1]){
bounceCount++;
if (!xzC){
checkXZ = true;
};
if (!yC){
if (playerList[i].ref != "bin"){
if (vy > 0){
myPos._y = (player.myPos._y - player.h);
} else {
myPos._y = (player.myPos._y + myHeight);
};
};
diff = (dist - player.rad);
checkY = true;
};
};
if (myPos._y <= (player.myPos._y - player.h)){
if ((player.myPos._y - player.h) < floorY){
floorY = (player.myPos._y - player.h);
};
};
};
if (checkXZ){
rotVal = (90 + (Math.atan((xD / zD)) / (Math.PI / 180)));
xDist = (player.rad + (myWidth * 1.5));
radians = (rotVal * (Math.PI / 180));
nxP = (xDist * Math.cos(radians));
nzP = ((xDist * Math.sin(radians)) / xzS);
myPos._x = (player.myPos._x + nxP);
if ((((dir > -90)) && ((dir < 90)))){
myPos._z = (player.myPos._z - nzP);
} else {
myPos._z = (player.myPos._z + nzP);
};
trace((((" rotVal=" + rotVal) + " dir=") + dir));
nD = (startDir + ((rotVal - startDir) * 2));
dir = nD;
if (dir > 180){
dir = (-180 + (dir - 180));
};
trotVal = rotVal;
if (trotVal > -90){
trotVal = (90 - (rotVal - 90));
};
power = (power * dampWallCollision);
trace((" dir=" + dir));
isHitGround = false;
doBallSpin();
tx = myPos._x;
ty = myPos._y;
tz = myPos._z;
tpower = power;
tvx = vx;
tvy = vy;
tvz = vz;
tdir = dir;
tcurl = curl;
tfrCount = frCount;
j = 0;
found = false;
while ((((j < 1000)) && (!(found)))) {
processFlight();
if (power < 0.4){
if ((((vy < 0.3)) && ((vy > -0.3)))){
if (myPos._y > -3){
found = true;
};
};
};
if (myPos._z > 30){
goalie.setFinalPos(myPos._x, myPos._y, myPos._z);
found = true;
};
j++;
};
myPos._x = tx;
myPos._y = ty;
myPos._z = tz;
power = tpower;
vx = tvx;
vy = tvy;
vz = tvz;
dir = tdir;
curl = tcurl;
frCount = tfrCount;
dispatchEvent(new GameMessageEvent(GameMessageEvent.SHOW, GameMessageEvent.MESSAGE_HIT_WALL));
};
if (checkY){
trace(("CYL - checkY ref=" + playerList[i].ref));
power = (power * dampK);
vy = (-(vy) * dampCollision);
if (vy > -(gravK)){
vy = (-(gravK) - 0.01);
};
isHitGround = false;
doBallSpin();
};
i++;
};
}
private function onFadeOutComplete():void{
destroy();
}
public function processFlight():void{
frCount++;
var framediff:Number = 1;
var radians:Number = (dir * (Math.PI / 180));
power = (power * slowK);
dir = (dir + curl);
curl = (curl * dampCurl);
vz = (((power * Math.cos(radians)) / 2) / 75);
vx = (((power * Math.sin(radians)) / 2) / 6);
vy = (vy + (gravK * framediff));
if (power < 0.3){
if ((((vy < 0.3)) && ((vy > -0.3)))){
if (myPos._y > -3){
main.ball_mc.stop();
fadeOut();
};
};
};
vx = (vx + ((frCount / 35) * curl));
mydir._x = (vx * framediff);
mydir._y = (vy * framediff);
mydir._z = (vz * framediff);
myPos.addV(mydir);
if (myPos._y > 0){
power = (power * dampK);
vy = (-(vy) * dampCollision);
myPos._y = 0;
curl = (curl * dampCurlCollision);
if (!isHitGround){
isHitGround = true;
doBallSpin();
};
};
}
public function get isGoalScored():Boolean{
return (_isGoalScored);
}
public function bounceOffBar():void{
vy = (-(vy) * 0.5);
vz = (-(vz) * 0.5);
}
override public function update():void{
moveBall();
super.update();
scaleX = (scaleX * 0.58);
scaleY = (scaleY * 0.58);
}
public function check180():void{
if (dir > 180){
dir = (-180 + (dir - 180));
};
}
}
}//package com.freekickfusion.game.render
Section 42
//BallShadow (com.freekickfusion.game.render.BallShadow)
package com.freekickfusion.game.render {
import gs.*;
import uk.co.inbox.game.render.vector.*;
public class BallShadow extends PitchItem {
private var isFading:Boolean;// = false
private var main:Ball_Shadow_Graphic;
public function BallShadow(){
super();
main = new Ball_Shadow_Graphic();
addChild(main);
}
override public function update():void{
super.update();
scaleX = (scaleX * 0.6);
scaleY = (scaleY * 0.6);
}
public function setPos($newPos:GVector):void{
myPos = $newPos;
}
public function fadeOut():void{
if (!isFading){
isFading = true;
TweenLite.to(this, 0.5, {alpha:0, onComplete:onFadeOutComplete});
};
}
override public function destroy():void{
super.destroy();
}
private function onFadeOutComplete():void{
destroy();
}
}
}//package com.freekickfusion.game.render
Section 43
//GameMessage (com.freekickfusion.game.render.GameMessage)
package com.freekickfusion.game.render {
import flash.text.*;
import gs.*;
public class GameMessage extends PitchItem {
private var main:GameMessage_Graphic;
private var isMoveY:Boolean;
public function GameMessage($text:String, $isMoveY:Boolean=false){
super();
isMoveY = $isMoveY;
main = new GameMessage_Graphic();
main.label_txt.autoSize = TextFieldAutoSize.CENTER;
main.label_txt.text = $text;
addChild(main);
}
override public function update():void{
}
private function onFinish():void{
destroy();
}
public function show():void{
TweenLite.to(this, 1.5, {y:(isMoveY) ? (y - 20) : y, scaleX:(isMoveY) ? 1 : 1.3, scaleY:(isMoveY) ? 1 : 1.3, onComplete:onFinish});
}
}
}//package com.freekickfusion.game.render
Section 44
//Goalie (com.freekickfusion.game.render.Goalie)
package com.freekickfusion.game.render {
import flash.display.*;
import uk.co.inbox.events.*;
public class Goalie extends PitchItem {
private var maxHighDiveDist:Number;// = 25
private var isDraggable:Boolean;// = false
private var startPosX:Number;// = 0
public var isSuperSave:Boolean;// = false
private var mainDiveLowRight:Goalie_DiveLow_Graphic;
private var yPos:Number;// = 0
public var finalX:Number;
public var finalY:Number;
public var finalZ:Number;
private var mainIdle:Goalie_Idle_Graphic;
private var xSpeedInc:Number;// = 0.05
private var mainDiveJump:Goalie_DiveJump_Graphic;
private var xSpeedMax:Number;// = 1
private var myLevel:Number;// = 0
private var xPos:Number;
private var mainDiveHighLeft:Goalie_DiveHigh_Graphic;
public var xSpeed:Number;// = 0
private var mainDiveHighRight:Goalie_DiveHigh_Graphic;
private var ySpeed:Number;// = 0
private var currentMain:MovieClip;
private var xSpeedDeficit:Number;
private var isDived:Boolean;
private var mainDiveCrouch:Goalie_DiveCrouch_Graphic;
private var mainDiveLowLeft:Goalie_DiveLow_Graphic;
private var zPos:Number;
private var isDiving:Boolean;// = false
private var ball:Ball;
public function Goalie(){
super();
mainDiveJump = new Goalie_DiveJump_Graphic();
mainDiveJump.addEventListener(TimelineEvent.END, onDiveEnd, false, 0, true);
mainDiveCrouch = new Goalie_DiveCrouch_Graphic();
mainDiveCrouch.addEventListener(TimelineEvent.END, onDiveEnd, false, 0, true);
mainDiveHighRight = new Goalie_DiveHigh_Graphic();
mainDiveHighRight.addEventListener(TimelineEvent.END, onDiveEnd, false, 0, true);
mainDiveHighLeft = new Goalie_DiveHigh_Graphic();
mainDiveHighLeft.addEventListener(TimelineEvent.END, onDiveEnd, false, 0, true);
mainDiveHighLeft.scaleX = -1;
mainDiveLowRight = new Goalie_DiveLow_Graphic();
mainDiveLowRight.addEventListener(TimelineEvent.END, onDiveEnd, false, 0, true);
mainDiveLowLeft = new Goalie_DiveLow_Graphic();
mainDiveLowLeft.addEventListener(TimelineEvent.END, onDiveEnd, false, 0, true);
mainDiveLowLeft.scaleX = -1;
mainIdle = new Goalie_Idle_Graphic();
animateDive(mainIdle);
myPos._z = 30;
mouseEnabled = false;
mouseChildren = false;
}
public function setBall($ball:Ball):void{
ball = $ball;
}
public function newHitTest($x:Number, $y:Number, $isSomething:Boolean):Boolean{
if (currentMain != null){
return (currentMain.hitTestPoint($x, $y, $isSomething));
};
return (false);
}
public function setFinalPos($x:Number, $y:Number, $z:Number):void{
finalX = $x;
finalY = $y;
finalZ = $z;
}
public function init($xPos:Number, $xSpeedMax:Number, $maxHighDiveDist:Number, $xSpeedDeficit:Number):void{
myPos._x = (startPosX = $xPos);
xSpeedMax = $xSpeedMax;
maxHighDiveDist = $maxHighDiveDist;
xSpeedDeficit = $xSpeedDeficit;
}
public function dive():void{
var diveType:String;
var nxD:Number;
var diff:Number = (myPos._x - finalX);
var xD:Number = diff;
var yD:Number = (-39 - finalY);
if (isSuperSave){
maxHighDiveDist = 100;
};
currentMain.ySpeed = 0;
if (finalY < -16){
diveType = "high";
isDiving = true;
if ((((xD < maxHighDiveDist)) && ((xD > -(maxHighDiveDist))))){
xD = Math.abs(xD);
xSpeed = ((xD - 25) / 10);
if (diff > 3){
xSpeed = -(xSpeed);
};
} else {
if (xD > 0){
xSpeed = (xSpeedDeficit / 2);
} else {
xSpeed = (-(xSpeedDeficit) / 2);
};
};
currentMain.ySpeed = -((yD / 5));
} else {
diveType = "low";
isDiving = true;
if ((((xD < (maxHighDiveDist * 2.4))) && ((xD > -((maxHighDiveDist * 2.4)))))){
nxD = Math.abs(xD);
xSpeed = ((nxD - 35) / 10);
if (diff > 3){
xSpeed = -(xSpeed);
};
} else {
if (xD > 0){
xSpeed = xSpeedDeficit;
} else {
xSpeed = -(xSpeedDeficit);
};
};
};
if ((((diff < -3)) && ((finalY > (ball.CROSSBAR_TOP - 16))))){
isDived = true;
if (diveType == "low"){
animateDive(mainDiveLowRight);
} else {
if (diveType == "high"){
animateDive(mainDiveHighRight);
};
};
} else {
if ((((diff > 3)) && ((finalY > (ball.CROSSBAR_TOP - 16))))){
isDived = true;
if (diveType == "low"){
animateDive(mainDiveLowLeft);
} else {
if (diveType == "high"){
animateDive(mainDiveHighLeft);
};
};
} else {
if (finalY > -15){
animateDive(mainDiveCrouch);
} else {
if (finalY < -27){
animateDive(mainDiveJump);
};
};
};
};
}
override public function update():void{
var diff:Number = (finalX - myPos._x);
if (!isNaN(diff)){
if (((!(isDived)) && ((ball.myPos._z < 30)))){
if (diff < -(xSpeedMax)){
xSpeed = (xSpeed - xSpeedInc);
} else {
if (diff > xSpeedMax){
xSpeed = (xSpeed + xSpeedInc);
} else {
xSpeed = diff;
};
};
if (xSpeed > xSpeedMax){
xSpeed = xSpeedMax;
} else {
if (xSpeed < -(xSpeedMax)){
xSpeed = -(xSpeedMax);
};
};
if (currentMain.currentFrame == 10){
currentMain.ySpeed = -(ySpeed);
} else {
if (currentMain.currentFrame == 20){
currentMain.ySpeed = 0;
};
};
myPos._x = (myPos._x + xSpeed);
} else {
if (((isDiving) && ((ball.myPos._z < 30)))){
myPos._x = (myPos._x + xSpeed);
};
};
};
super.update();
scaleX = (scaleX * 0.98);
scaleY = (scaleY * 0.98);
}
public function reset():void{
finalX = 0;
finalY = 0;
finalZ = 0;
xSpeed = 0;
myPos._x = startPosX;
animateDive(mainIdle);
isDived = false;
isDiving = false;
super.update();
}
private function onDiveEnd(e:TimelineEvent):void{
reset();
}
private function animateDive($diveGraphic:MovieClip):void{
if (currentMain != null){
if (contains(currentMain)){
removeChild(currentMain);
};
};
currentMain = $diveGraphic;
currentMain.gotoAndPlay(2);
addChild(currentMain);
}
}
}//package com.freekickfusion.game.render
Section 45
//MultiPitchRenderer (com.freekickfusion.game.render.MultiPitchRenderer)
package com.freekickfusion.game.render {
import flash.events.*;
import com.freekickfusion.game.*;
import com.freekickfusion.multiplayer.server.*;
import uk.co.inbox.game.render.objects.*;
import com.freekickfusion.game.levels.*;
import com.freekickfusion.game.render.events.*;
import flash.geom.*;
import com.freekickfusion.multiplayer.lobby.player.*;
public class MultiPitchRenderer extends PitchRenderer {
protected var superSaveXMax:Number;// = 312
protected var currentGoalkeeperLevel:GoalkeeperLevel;
protected var superSaveYMin:Number;// = 73
private var superSave:SuperSave;
private var playersInWall:int;
protected var superSaveYMax:Number;// = 39
private var turnManager:TurnManager;
protected var superSaveXMin:Number;// = 182
public function MultiPitchRenderer(){
super();
superSave = new SuperSave(new Rectangle(193, 124, 127, 33));
superSave.addEventListener(SuperSave.POSITION_UPDATED, onSuperSavePositionUpdated, false, 0, true);
addContent(superSave);
}
public function disableSuperSave():void{
trace("MultiPitchRenderer.disableSuperSave");
superSave.visible = false;
}
override protected function onFireBall(e:FireBallEvent):void{
gameServer.sendShot(e.power, e.angle, e.curl, e.elevation);
}
public function enableSuperSave():void{
trace("MultiPitchRenderer.enableSuperSave");
superSave.visible = true;
superSave.enable();
}
override public function createShot(power:Number, dir:Number, elevation:Number, curl:Number, superSaveX:Number, superSaveY:Number):Ball{
superSave.stopDrag();
superSave.disable();
superSave.x = superSaveX;
superSave.y = superSaveY;
var ball:Ball = super.createShot(power, dir, elevation, curl, superSaveX, superSaveY);
ball.addEventListener(GameSpriteRender.DESTROY, onBallDestroyed, false, 0, true);
return (ball);
}
public function setGameServer($gameServer:FreeKickGameServer):void{
gameServer = $gameServer;
}
private function onSuperSavePositionUpdated(e:Event):void{
gameServer.updateSuperSave(superSave.x, superSave.y);
}
public function setInitX($val:Number):void{
initX = $val;
}
public function setPlayersInWall($players:int):void{
playersInWall = $players;
}
public function setSuperSavePos($x:Number, $y:Number):void{
}
public function hideAimArrow():void{
aimArrow.visible = true;
aimArrow.drawGuideBall();
}
public function showAimArrow():void{
aimArrow.visible = true;
aimArrow.reappear();
}
override protected function onMessageDestroyed(e:Event):void{
gameMessage.removeEventListener(GameSpriteRender.DESTROY, onMessageDestroyed);
gameMessage = null;
}
override protected function onAddMessage(e:GameMessageEvent):void{
var msg:String = "";
switch (e.messageId){
case GameMessageEvent.MESSAGE_GOAL:
msg = "GOAL!!";
break;
case GameMessageEvent.MESSAGE_HIT_CROSSBAR:
msg = "OFF THE BAR!!";
break;
case GameMessageEvent.MESSAGE_HIT_POST:
msg = "OFF THE POST!!";
break;
case GameMessageEvent.MESSAGE_HIT_WALL:
msg = "HIT THE WALL!!";
break;
case GameMessageEvent.MESSAGE_OVER_CROSSBAR:
msg = "OVER THE BAR!!";
break;
case GameMessageEvent.MESSAGE_SAVED:
msg = "SAVED!!";
break;
case GameMessageEvent.MESSAGE_SUPER_SAVED:
msg = "SUPER SAVED!!";
break;
case GameMessageEvent.MESSAGE_WIDE:
msg = "WIDE!!";
break;
};
if (gameMessage != null){
gameMessage.destroy();
};
gameMessage = new GameMessage(msg);
gameMessage.addEventListener(GameSpriteRender.DESTROY, onMessageDestroyed, false, 0, true);
gameMessage.x = 0xFF;
gameMessage.y = 110;
gameMessage.show();
addContent(gameMessage);
}
public function setTurnManager($turnManager:TurnManager):void{
turnManager = $turnManager;
}
override public function initPositions():void{
aimArrow.myPos._x = initX;
goalie.init((-(initX) / 2.5), currentGoalkeeperLevel.speed, currentGoalkeeperLevel.maxHighDiveDist, currentGoalkeeperLevel.xSpeedDeficit);
createPlayers(playersInWall);
}
private function onBallDestroyed(e:Event):void{
(e.target as Ball).removeEventListener(GameSpriteRender.DESTROY, onBallDestroyed);
if (!(e.target as Ball).isGoalScored){
(turnManager.currentPlayer as FreeKickGamePlayer).goalScore.addAttempt(false);
};
gameServer.shotComplete((e.target as Ball).isGoalScored);
}
public function setGoalkeeperLevel($level:GoalkeeperLevel):void{
currentGoalkeeperLevel = $level;
}
override protected function onAddScoreMessage(e:GameMessageEvent):void{
(turnManager.currentPlayer as FreeKickGamePlayer).goalScore.addAttempt(true);
}
}
}//package com.freekickfusion.game.render
Section 46
//PitchItem (com.freekickfusion.game.render.PitchItem)
package com.freekickfusion.game.render {
import uk.co.inbox.game.render.objects.*;
import uk.co.inbox.game.render.vector.*;
public class PitchItem extends GameSpriteRender {
private const SCALE_FACTOR:Number = 50;
public var oldMyPos:GVector;
protected var bounceK:Number;// = 0.4
public var myPos:GVector;
protected var slowK:Number;// = 0.99
protected var gravK:Number;// = 0.18
public var gWorld:GWorld;
protected var isPaused:Boolean;// = false
protected var dampK:Number;// = 0.97
public function PitchItem(){
super();
myPos = new GVector(0, 0, 0);
oldMyPos = new GVector(0, 0, 0);
}
override public function update():void{
var displaypos:Object = gWorld.getPosition(myPos);
scaleX = (displaypos._scale / SCALE_FACTOR);
scaleY = (displaypos._scale / SCALE_FACTOR);
x = displaypos._x;
y = displaypos._y;
}
}
}//package com.freekickfusion.game.render
Section 47
//PitchRenderer (com.freekickfusion.game.render.PitchRenderer)
package com.freekickfusion.game.render {
import flash.events.*;
import flash.display.*;
import uk.co.inbox.game.score.*;
import com.freekickfusion.multiplayer.server.*;
import uk.co.inbox.game.render.objects.*;
import com.freekickfusion.game.levels.*;
import com.freekickfusion.game.render.events.*;
import uk.co.inbox.game.render.vector.*;
import uk.co.inbox.game.render.*;
import uk.co.inbox.utils.*;
public class PitchRenderer extends GameRenderer {
protected var initX:Number;// = 0
protected var currentLevel:FreeKickLevel;
protected var gameServer:FreeKickGameServer;
protected var playerList:Array;
protected var _aimArrow:AimArrow;
protected var gWorld:GWorld;
protected var goalie:Goalie;
protected var gameMessage:GameMessage;
protected var isEnabled:Boolean;
protected var ballList:Array;
protected var goalScore:TargetGameScore;
public function PitchRenderer(){
ballList = [];
playerList = [];
super();
setupGame();
}
public function playersJump($isRandom:Boolean=true):void{
var player:Player;
var i:int;
while (i < playerList.length) {
player = playerList[i];
player.jump(i, $isRandom);
i++;
};
}
protected function onMouseUp(e:MouseEvent):void{
if (isEnabled){
if (aimArrow.isShooting){
aimArrow.fireBall(!((this is MultiPitchRenderer)));
};
};
}
public function enable():void{
isEnabled = true;
aimArrow.visible = true;
}
public function setGoalScore($goalScore:TargetGameScore):void{
goalScore = $goalScore;
}
public function initPositions():void{
initX = (currentLevel.variancePosition - Math.floor((Math.random() * (currentLevel.variancePosition * 2))));
aimArrow.myPos._x = initX;
goalie.init((-(initX) / 2.5), currentLevel.goalkeeperLevel.speed, currentLevel.goalkeeperLevel.maxHighDiveDist, currentLevel.goalkeeperLevel.xSpeedDeficit);
createPlayers(currentLevel.playersInWall);
}
public function setCurrentLevel($currentLevel:FreeKickLevel):void{
currentLevel = $currentLevel;
}
public function sortDepths():void{
var i:int;
spriteList.sort(sortDepthsOn);
var numObjects:int = spriteList.length;
i = 0;
for (;i < numObjects;(i = (i + 1))) {
spriteHolder.setChildIndex(spriteList[i], 0);
continue;
var _slot1 = e;
trace((" bad index - i:" + i));
};
}
protected function setupGame():void{
gWorld = new GWorld(0.7, 60, 258, (83 - 5.5));
aimArrow = new AimArrow();
aimArrow.addEventListener(FireBallEvent.FIRE, onFireBall, false, 0, true);
addContent(aimArrow);
goalie = new Goalie();
addContent(goalie);
addEventListener(Event.ADDED_TO_STAGE, onAdded, false, 0, true);
}
protected function onMessageDestroyed(e:Event):void{
gameMessage.removeEventListener(GameSpriteRender.DESTROY, onMessageDestroyed);
gameMessage = null;
}
public function sortDepthsOn(a:PitchItem, b:PitchItem):Number{
if (a.myPos._z < b.myPos._z){
return (-1);
};
if (a.myPos._z > b.myPos._z){
return (1);
};
if (a.myPos._y < b.myPos._y){
return (-1);
};
if (a.myPos._y > b.myPos._y){
return (1);
};
return (0);
}
protected function onFireBall(e:FireBallEvent):void{
createShot(e.power, e.angle, e.curl, e.elevation, -999, -999);
playersJump();
}
protected function onMouseDown(e:MouseEvent):void{
if (isEnabled){
if (e.stageX < 510){
if (e.stageY > 80){
if (e.stageY < 380){
aimArrow.startShoot();
};
};
};
};
}
override public function addContent($newContent:GameSpriteRender):void{
super.addContent($newContent);
if (($newContent is PitchItem)){
($newContent as PitchItem).gWorld = gWorld;
};
}
protected function onAddScoreMessage(e:GameMessageEvent):void{
var gameMessage:GameMessage;
if (isEnabled){
goalScore.incrementScore(e.messageId);
initPositions();
_aimArrow.reappear();
gameMessage = new GameMessage(String(e.messageId), true);
gameMessage.x = (ballList[0] as Ball).x;
gameMessage.y = ((ballList[0] as Ball).y - 17);
if (gameMessage.y < 110){
gameMessage.y = 110;
};
gameMessage.show();
addContent(gameMessage);
};
}
public function createShot(power:Number, dir:Number, elevation:Number, curl:Number, superSaveX:Number, superSaveY:Number):Ball{
var displaypos:Object;
var ballX:Number;
var ballY:Number;
removeBalls();
trace(((((((((((("createShot() power=" + power) + " dir=") + dir) + " elevation=") + elevation) + " curl=") + curl) + ", superSaveX:") + superSaveX) + ", superSaveY:") + superSaveY));
dir = (dir + (initX / 2));
var ballShadow:BallShadow = new BallShadow();
addContent(ballShadow);
var newBall:Ball = new Ball(playerList, gWorld.xyS, gWorld.xzS, gWorld.yzS);
newBall.addEventListener(GameMessageEvent.SHOW, onAddMessage, false, 0, true);
newBall.addEventListener(GameMessageEvent.SHOW_SCORE, onAddScoreMessage, false, 0, true);
newBall.setShadow(ballShadow);
newBall.setGoalie(goalie);
ballList.push(newBall);
addContent(newBall);
var radians:Number = (dir * (Math.PI / 180));
newBall.vz = (((power * Math.cos(radians)) / 2) / 75);
newBall.vx = (((power * Math.sin(radians)) / 2) / 3);
newBall.vy = (-(elevation) / 3);
newBall.power = power;
newBall.dir = dir;
newBall.curl = (curl / 2.5);
newBall.myPos = new GVector(initX, 0, 10.4);
newBall.mydir = new GVector(0, 0, 0);
newBall.floorloc = new GVector(0, 0, 0);
goalie.reset();
goalie.setBall(newBall);
var i:int;
newBall.isTesting = true;
var found:Boolean;
while ((((i < 1000)) && (!(found)))) {
newBall.processFlight();
if (newBall.power < 0.4){
if ((((newBall.vy < 0.3)) && ((newBall.vy > -0.3)))){
if (newBall.myPos._y > -3){
found = true;
};
};
};
if (newBall.myPos._z > 30){
if (superSaveX != -999){
displaypos = gWorld.getPosition(newBall.myPos);
ballX = displaypos._x;
ballY = displaypos._y;
if (((((ballX - superSaveX) > -64)) && (((ballX - superSaveX) < 64)))){
if (((((ballY - superSaveY) > -17)) && (((ballY - superSaveY) < 17)))){
goalie.isSuperSave = true;
} else {
goalie.isSuperSave = false;
};
} else {
goalie.isSuperSave = false;
};
} else {
goalie.isSuperSave = false;
};
goalie.finalX = newBall.myPos._x;
goalie.finalY = newBall.myPos._y;
goalie.finalZ = newBall.myPos._z;
found = true;
};
i++;
};
trace(("i=" + i));
newBall.isTesting = false;
newBall.myPos = new GVector(initX, 0, 10.4);
newBall.mydir = new GVector(0, 0, 0);
newBall.floorloc = new GVector(0, 0, 0);
newBall.frCount = 0;
newBall.vz = (((power * Math.cos(radians)) / 2) / 75);
newBall.vx = (((power * Math.sin(radians)) / 2) / 3);
newBall.vy = (-(elevation) / 3);
newBall.power = power;
newBall.dir = dir;
newBall.curl = (curl / 2.5);
newBall.isHitGround = false;
newBall.update();
return (newBall);
}
public function set aimArrow(value:AimArrow):void{
_aimArrow = value;
}
protected function onAdded(e:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAdded);
(Settings.get("stage") as DisplayObject).addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true);
(Settings.get("stage") as DisplayObject).addEventListener(MouseEvent.MOUSE_UP, onMouseUp, false, 0, true);
}
protected function clearPlayers():void{
var player:Player;
var i:int;
while (i < playerList.length) {
player = playerList[i];
player.destroy();
i++;
};
playerList = [];
}
public function get aimArrow():AimArrow{
return (_aimArrow);
}
public function disable():void{
isEnabled = false;
aimArrow.visible = false;
}
protected function onAddMessage(e:GameMessageEvent):void{
var msg:String;
if (isEnabled){
msg = "";
switch (e.messageId){
case GameMessageEvent.MESSAGE_GOAL:
msg = "GOAL!!";
break;
case GameMessageEvent.MESSAGE_HIT_CROSSBAR:
msg = "OFF THE BAR!!";
break;
case GameMessageEvent.MESSAGE_HIT_POST:
msg = "OFF THE POST!!";
break;
case GameMessageEvent.MESSAGE_HIT_WALL:
msg = "HIT THE WALL!!";
break;
case GameMessageEvent.MESSAGE_OVER_CROSSBAR:
msg = "OVER THE BAR!!";
break;
case GameMessageEvent.MESSAGE_SAVED:
msg = "SAVED!!";
break;
case GameMessageEvent.MESSAGE_SUPER_SAVED:
msg = "SUPER SAVED!!";
break;
case GameMessageEvent.MESSAGE_WIDE:
msg = "WIDE!!";
break;
};
if (gameMessage != null){
gameMessage.destroy();
};
gameMessage = new GameMessage(msg);
gameMessage.addEventListener(GameSpriteRender.DESTROY, onMessageDestroyed, false, 0, true);
gameMessage.x = 0xFF;
gameMessage.y = 110;
gameMessage.show();
addContent(gameMessage);
};
}
protected function removeBalls():void{
var ball:Ball;
var i:int;
while (i < ballList.length) {
ball = ballList[i];
ball.shadow.destroy();
ball.destroy();
i++;
};
ballList = [];
}
override public function update():void{
sortDepths();
super.update();
}
public function createPlayers($numPlayers:int):void{
var player:Player;
clearPlayers();
var i:int;
while (i < $numPlayers) {
player = new Player(i);
player.h = 32;
player.rad = 3;
if (initX > 0){
if ((i % 2) == 0){
player.xPos = ((10 + (initX / 1.5)) + (i * 4.5));
} else {
player.xPos = (((10 + ((i - 1) * 4.5)) + (initX / 1.5)) - (i * 9));
};
} else {
if ((i % 2) == 0){
player.xPos = ((-10 + (initX / 1.5)) - (i * 4.5));
} else {
player.xPos = (((-10 - ((i - 1) * 4.5)) + (initX / 1.5)) + (i * 9));
};
};
player.zPos = 16.4;
player.startMe();
addContent(player);
playerList.push(player);
i++;
};
}
}
}//package com.freekickfusion.game.render
Section 48
//Player (com.freekickfusion.game.render.Player)
package com.freekickfusion.game.render {
import uk.co.inbox.game.render.vector.*;
public class Player extends PitchItem {
private var id:int;
private var vy:Number;
public var h:Number;
protected var jumpList:Array;
public var rad:Number;
private var startY:Number;
private var main:Player_Graphic;
public var zPos:Number;// = 0
public var yPos:Number;// = 0
public var xPos:Number;// = 0
public function Player($id:int){
jumpList = [2, 1, 3, 2, 3, 1, 2, 3];
super();
id = $id;
main = new Player_Graphic();
addChild(main);
gravK = 0.18;
mouseEnabled = false;
mouseChildren = false;
}
public function startMe():void{
myPos = new GVector(xPos, yPos, zPos);
}
public function jump($playerIndex:Number, $isRandom:Boolean=true):void{
var temp:Number;
if ($isRandom){
temp = Math.ceil((Math.random() * 3));
main.body.body_mc.gotoAndPlay(("jump" + temp));
main.body.body_mc.extra = (2 + (Math.random() * 2));
} else {
temp = jumpList[$playerIndex];
main.body.body_mc.gotoAndPlay(("jump" + temp));
main.body.body_mc.extra = (2 + temp);
};
if ((id % 2) == 0){
vy = (-1.9 - (id / 20));
} else {
vy = (-1.9 + (id / 20));
};
}
override public function update():void{
super.update();
scaleX = (scaleX * 0.62);
scaleY = (scaleY * 0.62);
}
}
}//package com.freekickfusion.game.render
Section 49
//SuperSave (com.freekickfusion.game.render.SuperSave)
package com.freekickfusion.game.render {
import flash.events.*;
import flash.geom.*;
import uk.co.inbox.utils.*;
public class SuperSave extends PitchItem {
private var main:SuperSave_Graphic;
private var bounds:Rectangle;
private var isEnabled:Boolean;
private var isDragging:Boolean;
public static const POSITION_UPDATED:String = "positionUpdated";
public function SuperSave($bounds:Rectangle){
bounds = $bounds;
main = new SuperSave_Graphic();
addChild(main);
x = bounds.x;
y = bounds.y;
main.buttonMode = true;
main.mouseChildren = false;
main.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true);
Settings.get("stage").addEventListener(MouseEvent.MOUSE_UP, onMouseUp, false, 0, true);
super();
myPos._z = 30.5;
}
public function enable():void{
isEnabled = true;
}
public function disable():void{
isEnabled = false;
}
override public function update():void{
}
private function onMouseDown(e:MouseEvent):void{
if (isEnabled){
isDragging = true;
startDrag(false, bounds);
};
}
private function onMouseUp(e:MouseEvent):void{
if (isDragging){
dispatchEvent(new Event(POSITION_UPDATED));
};
isDragging = false;
stopDrag();
}
}
}//package com.freekickfusion.game.render
Section 50
//FreeKickGameScoreEvent (com.freekickfusion.game.score.events.FreeKickGameScoreEvent)
package com.freekickfusion.game.score.events {
import flash.events.*;
public class FreeKickGameScoreEvent extends Event {
public var multiplier:Number;
public var score:Number;
public static const UPDATE:String = "freekickGameUpdate";
public function FreeKickGameScoreEvent(type:String, $score:Number, $multiplier:Number, bubbles:Boolean=false, cancelable:Boolean=false){
score = $score;
multiplier = $multiplier;
super(type, bubbles, cancelable);
}
override public function toString():String{
return (formatToString("FreeKickGameScoreEvent", "type", "score", "multiplier", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new FreeKickGameScoreEvent(type, score, multiplier, bubbles, cancelable));
}
}
}//package com.freekickfusion.game.score.events
Section 51
//FreeKickGameScore (com.freekickfusion.game.score.FreeKickGameScore)
package com.freekickfusion.game.score {
import uk.co.inbox.game.score.*;
import com.freekickfusion.game.score.events.*;
public class FreeKickGameScore extends GameScore {
public function FreeKickGameScore(){
super();
}
public function addLevelScore($score:Number, $multiplier:Number):void{
incrementScore(($score * $multiplier));
dispatchEvent(new FreeKickGameScoreEvent(FreeKickGameScoreEvent.UPDATE, $score, $multiplier));
}
}
}//package com.freekickfusion.game.score
Section 52
//GoalTargetScore (com.freekickfusion.game.score.GoalTargetScore)
package com.freekickfusion.game.score {
import uk.co.inbox.game.score.*;
public class GoalTargetScore extends TargetGameScore {
private var _scoreList:Array;
public function GoalTargetScore(){
_scoreList = [];
super();
}
public function get scoreList():Array{
return (_scoreList);
}
override public function resetScore():void{
_scoreList = [];
super.resetScore();
}
public function get totalScores():Number{
var total:Number = 0;
var i:int;
while (i < _scoreList.length) {
total = (total + _scoreList[i]);
i++;
};
return (total);
}
override public function incrementScore($goalScore:Number):void{
scoreList.push($goalScore);
super.incrementScore(1);
}
}
}//package com.freekickfusion.game.score
Section 53
//MultiGoalScore (com.freekickfusion.game.score.MultiGoalScore)
package com.freekickfusion.game.score {
import uk.co.inbox.game.score.*;
public class MultiGoalScore extends TargetGameScore {
private var _scoreList:Array;
public function MultiGoalScore(){
_scoreList = [];
super();
}
public function get scoreList():Array{
return (_scoreList);
}
override public function resetScore():void{
_scoreList = [];
}
public function addAttempt($isSuccess:Boolean):void{
scoreList.push($isSuccess);
super.incrementScore(($isSuccess) ? 1 : 0);
}
}
}//package com.freekickfusion.game.score
Section 54
//FreeKickGameEngine (com.freekickfusion.game.FreeKickGameEngine)
package com.freekickfusion.game {
import uk.co.inbox.game.levels.*;
import uk.co.inbox.game.*;
import com.freekickfusion.game.levels.*;
import uk.co.inbox.language.*;
import uk.co.inbox.game.render.*;
public class FreeKickGameEngine extends GameEngine {
protected var goalkeeperLevelManager:LevelManager;
protected var sceneRenderer:GameRenderer;
public function FreeKickGameEngine(){
super();
initStates();
}
protected function createGoalkeeperLevels():void{
goalkeeperLevelManager = new LevelManager();
goalkeeperLevelManager.addLevel(new GoalkeeperLevel(LangStrings.singleGoalkeeperLevel1, 0.1, 15, 2));
goalkeeperLevelManager.addLevel(new GoalkeeperLevel(LangStrings.singleGoalkeeperLevel2, 0.3, 20, 1));
goalkeeperLevelManager.addLevel(new GoalkeeperLevel(LangStrings.singleGoalkeeperLevel3, 0.5, 23, 0));
goalkeeperLevelManager.addLevel(new GoalkeeperLevel(LangStrings.singleGoalkeeperLevel4, 0.7, 25, 0));
goalkeeperLevelManager.addLevel(new GoalkeeperLevel(LangStrings.singleGoalkeeperLevel5, 1, 25, 0));
}
protected function createSceneRenderer():void{
sceneRenderer = new GameRenderer();
}
override public function update():void{
sceneRenderer.update();
}
}
}//package com.freekickfusion.game
Section 55
//FreeKickGameMultiEngine (com.freekickfusion.game.FreeKickGameMultiEngine)
package com.freekickfusion.game {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.game.levels.*;
import uk.co.inbox.game.timer.*;
import uk.co.inbox.game.timer.events.*;
import com.freekickfusion.multiplayer.server.*;
import com.freekickfusion.game.levels.*;
import com.freekickfusion.game.render.*;
import uk.co.inbox.language.*;
import com.freekickfusion.multiplayer.lobby.player.*;
public class FreeKickGameMultiEngine extends FreeKickGameEngine {
private var _levelManager:LevelManager;
private var _gameTimer:GameCountdown;
private var gameServer:FreeKickGameServer;
private var turnManager:TurnManager;
private var _playerList:Array;
public function FreeKickGameMultiEngine(){
super();
createGoalkeeperLevels();
_levelManager = new LevelManager();
_levelManager.addLevel(new FreeKickMultiLevel(LangStrings.multiLevel1, goalkeeperLevelManager.levelList[0], 1));
_levelManager.addLevel(new FreeKickMultiLevel(LangStrings.multiLevel2, goalkeeperLevelManager.levelList[1], 3));
_levelManager.addLevel(new FreeKickMultiLevel(LangStrings.multiLevel3, goalkeeperLevelManager.levelList[3], 4));
_levelManager.addLevel(new FreeKickMultiLevel(LangStrings.multiLevel4, goalkeeperLevelManager.levelList[4], 6));
_gameTimer = new GameCountdown();
_gameTimer.addEventListener(GameCountdownEvent.TIME_UP, onGameTimerUp, false, 0, true);
_gameTimer.setTimeLimit((15 * 1000));
turnManager = new TurnManager();
createSceneRenderer();
}
public function get gameTimer():GameCountdown{
return (_gameTimer);
}
private function onStartGame(e:GameServerEvent):void{
var gamePlayer:FreeKickGamePlayer;
trace(("FreeKickGameMultiEngine.onStartGame - e.params.difficulty:" + e.params.difficulty));
var i:int;
while (i < _playerList.length) {
gamePlayer = _playerList[i];
gamePlayer.resetScore();
i++;
};
var turnIndex:int = e.params.turnIndex;
trace((" turnIndex:" + turnIndex));
turnManager.setTurnIndex(turnIndex);
_levelManager.setLevel((Number(e.params.difficulty) - 1));
}
private function onReceiveShot(e:FreeKickGameServerEvent):void{
(sceneRenderer as PitchRenderer).createShot(e.params.power, e.params.angle, e.params.elevation, e.params.curl, e.params.superSaveX, e.params.superSaveY);
(sceneRenderer as PitchRenderer).playersJump(false);
(sceneRenderer as PitchRenderer).disable();
_gameTimer.stop();
}
public function setGameServer($gameServer:FreeKickGameServer):void{
gameServer = $gameServer;
(sceneRenderer as MultiPitchRenderer).setGameServer(gameServer);
(sceneRenderer as MultiPitchRenderer).setTurnManager(turnManager);
gameServer.addEventListener(GameServerEvent.INIT_GAME, onInitGame, false, 0, true);
gameServer.addEventListener(GameServerEvent.START_GAME, onStartGame, false, 0, true);
gameServer.addEventListener(FreeKickGameServerEvent.START_TURN, onStartTurn, false, 0, true);
gameServer.addEventListener(FreeKickGameServerEvent.RECEIVE_SHOT, onReceiveShot, false, 0, true);
}
private function onStartTurn(e:FreeKickGameServerEvent):void{
trace("FreeKickGameMultiEngine.onStartTurn");
var turnIndex:int = e.params.turnIndex;
trace((" turnIndex:" + turnIndex));
turnManager.setTurnIndex(turnIndex);
trace((" turnManager.currentPlayer:" + turnManager.currentPlayer));
if (turnManager.currentPlayer.isUser){
(sceneRenderer as MultiPitchRenderer).enable();
(sceneRenderer as MultiPitchRenderer).showAimArrow();
(sceneRenderer as MultiPitchRenderer).disableSuperSave();
} else {
(sceneRenderer as MultiPitchRenderer).disable();
(sceneRenderer as MultiPitchRenderer).hideAimArrow();
(sceneRenderer as MultiPitchRenderer).enableSuperSave();
};
(sceneRenderer as MultiPitchRenderer).setInitX(e.params.xPos);
(sceneRenderer as MultiPitchRenderer).setPlayersInWall(e.params.playersInWall);
(sceneRenderer as MultiPitchRenderer).setGoalkeeperLevel(goalkeeperLevelManager.levelList[e.params.goalkeeperLevel]);
(sceneRenderer as MultiPitchRenderer).initPositions();
_gameTimer.setTimeLimit(e.params.timeLimit);
_gameTimer.start();
}
public function get levelManager():LevelManager{
return (_levelManager);
}
private function onGameTimerUp(e:GameCountdownEvent):void{
if (turnManager.currentPlayer.isUser){
gameServer.skipShot();
};
}
override public function actionStop():void{
(sceneRenderer as PitchRenderer).disable();
_gameTimer.stop();
}
private function onInitGame(e:GameServerEvent):void{
trace("FreeKickGameMultiEngine.onStartTurn");
_playerList = e.params.playerList;
trace((" _playerList:" + _playerList));
turnManager.setPlayerList(_playerList);
}
override protected function createSceneRenderer():void{
sceneRenderer = new MultiPitchRenderer();
addChild(sceneRenderer);
}
public function get playerList():Array{
return (_playerList);
}
}
}//package com.freekickfusion.game
Section 56
//FreeKickGameSingleEngine (com.freekickfusion.game.FreeKickGameSingleEngine)
package com.freekickfusion.game {
import uk.co.inbox.game.score.events.*;
import uk.co.inbox.game.levels.*;
import uk.co.inbox.game.score.*;
import uk.co.inbox.game.timer.*;
import uk.co.inbox.score.*;
import com.freekickfusion.game.score.*;
import com.freekickfusion.game.levels.*;
import com.freekickfusion.game.render.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.tracking.*;
public class FreeKickGameSingleEngine extends FreeKickGameEngine {
protected var _gameScore:FreeKickGameScore;
protected var _goalScore:GoalTargetScore;
protected var _mainScore:ScoreItem;
protected var _levelManager:LevelManager;
protected var _gameTimer:GameCountdown;
public function FreeKickGameSingleEngine(){
super();
setupGame();
}
public function get levelManager():LevelManager{
return (_levelManager);
}
override public function actionStart():void{
initLevel();
_gameTimer.start();
(sceneRenderer as PitchRenderer).enable();
}
public function get gameScore():GameScore{
return (_gameScore);
}
public function nextLevel():void{
_levelManager.increment();
}
override protected function createSceneRenderer():void{
sceneRenderer = new PitchRenderer();
addChild(sceneRenderer);
}
protected function initLevel():void{
_goalScore.resetScore();
(sceneRenderer as PitchRenderer).enable();
(sceneRenderer as PitchRenderer).setCurrentLevel((levelManager.currentLevel as FreeKickLevel));
(sceneRenderer as PitchRenderer).initPositions();
var s:WhistleSound = new WhistleSound();
s.play();
}
public function setupGame():void{
createGoalkeeperLevels();
_levelManager = new LevelManager();
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[0], 30, 1));
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[0], 32, 2));
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[1], 34, 2));
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[1], 36, 3));
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[2], 38, 3));
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[2], 40, 4));
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[3], 45, 4));
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[3], 45, 5));
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[4], 45, 5));
_levelManager.addLevel(new FreeKickLevel(goalkeeperLevelManager.levelList[4], 45, 6));
_gameTimer = new GameCountdown();
_gameTimer.setTimeLimit((55 * 1000));
_goalScore = new GoalTargetScore();
_goalScore.addEventListener(TargetGameScoreEvent.TARGET_HIT, onGoalsTargetHit, false, 0, true);
_goalScore.setTargetScore(3);
_gameScore = new FreeKickGameScore();
_mainScore = new ScoreItem();
_mainScore.setGlobalRanking(Settings.get("gameName"), InboxTagData.SUBMIT_SCORE);
createSceneRenderer();
(sceneRenderer as PitchRenderer).setGoalScore(_goalScore);
}
override public function actionStop():void{
_gameTimer.stop();
(sceneRenderer as PitchRenderer).disable();
}
public function calculateBonus($timeLeft:Number, $timeLimit:Number):Number{
return ((6 - Math.floor((5 * (($timeLimit - $timeLeft) / $timeLimit)))));
}
public function restart():void{
_levelManager.reset();
_gameScore.resetScore();
}
override public function actionPause():void{
_gameTimer.pause();
}
protected function onGoalsTargetHit(e:TargetGameScoreEvent):void{
_gameScore.addLevelScore(_goalScore.totalScores, calculateBonus(_gameTimer.timeLeft, _gameTimer.timeLimit));
_gameTimer.stop();
(sceneRenderer as PitchRenderer).disable();
}
public function get mainScore():ScoreItem{
return (_mainScore);
}
public function get gameTimer():GameCountdown{
return (_gameTimer);
}
public function get goalScore():TargetGameScore{
return (_goalScore);
}
}
}//package com.freekickfusion.game
Section 57
//TurnManager (com.freekickfusion.game.TurnManager)
package com.freekickfusion.game {
import uk.co.inbox.multiplayer.player.*;
public class TurnManager {
private var turnIndex:int;// = 0
private var playerList:Array;
public function TurnManager(){
playerList = [];
super();
}
public function setPlayerList($playerList:Array):void{
trace(("TurnManager.setPlayerList - $playerList:" + $playerList));
playerList = $playerList.slice();
}
public function setTurnIndex($turnIndex:int):void{
turnIndex = $turnIndex;
}
public function get currentPlayer():GamePlayer{
return (playerList[turnIndex]);
}
public function incrementTurn():void{
turnIndex++;
if (turnIndex >= playerList.length){
turnIndex = 0;
};
}
}
}//package com.freekickfusion.game
Section 58
//FreeKickChallengeList (com.freekickfusion.multiplayer.lobby.challenge.FreeKickChallengeList)
package com.freekickfusion.multiplayer.lobby.challenge {
import uk.co.inbox.multiplayer.lobby.render.*;
public class FreeKickChallengeList extends ChallengeList {
protected var main:ChallengeList_Graphic;
public function FreeKickChallengeList(){
main = new ChallengeList_Graphic();
addChild(main);
setScrollBar(main.list_scr);
super();
itemClass = FreeKickChallengeListItem;
visibleItems = 3;
scrollBarGapX = 0;
}
}
}//package com.freekickfusion.multiplayer.lobby.challenge
Section 59
//FreeKickChallengeListItem (com.freekickfusion.multiplayer.lobby.challenge.FreeKickChallengeListItem)
package com.freekickfusion.multiplayer.lobby.challenge {
import uk.co.inbox.multiplayer.lobby.render.challenge.*;
public class FreeKickChallengeListItem extends ChallengeListItem {
public function FreeKickChallengeListItem(){
super();
}
override protected function createDefaultItem():ChallengeListItem_Base{
return (new FreeKickChallengeListItem_Default());
}
}
}//package com.freekickfusion.multiplayer.lobby.challenge
Section 60
//FreeKickChallengeListItem_Default (com.freekickfusion.multiplayer.lobby.challenge.FreeKickChallengeListItem_Default)
package com.freekickfusion.multiplayer.lobby.challenge {
import flash.events.*;
import uk.co.inbox.multiplayer.lobby.render.challenge.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class FreeKickChallengeListItem_Default extends ChallengeListItem_Base {
private var noBut:ButtonLobbySmall;
private var main:FreeKickChallenge_Default_Graphic;
private var yesBut:ButtonLobbySmall;
public function FreeKickChallengeListItem_Default(){
super();
main = new FreeKickChallenge_Default_Graphic();
yesBut = new ButtonLobbySmall(main.yes_but, "Y");
yesBut.addEventListener(Button2.CLICK, onClickYes, false, 0, true);
noBut = new ButtonLobbySmall(main.no_but, "N");
noBut.addEventListener(Button2.CLICK, onClickNo, false, 0, true);
addChild(main);
}
private function onClickNo(e:Event):void{
gameServer.rejectGameChallenge(challenge.creatorPlayer.serverId);
challenge.destroy();
}
override public function update():void{
main.name_txt.text = challenge.creatorPlayer.name;
}
private function onClickYes(e:Event):void{
gameServer.acceptGameChallenge(challenge.creatorPlayer.serverId);
}
}
}//package com.freekickfusion.multiplayer.lobby.challenge
Section 61
//FreeKickGamePlayer (com.freekickfusion.multiplayer.lobby.player.FreeKickGamePlayer)
package com.freekickfusion.multiplayer.lobby.player {
import uk.co.inbox.multiplayer.player.*;
import com.freekickfusion.game.score.*;
public class FreeKickGamePlayer extends GamePlayer {
private var _goalScore:MultiGoalScore;
private var _oldRating:int;
private var _rating:int;
public function FreeKickGamePlayer(){
super();
_goalScore = new MultiGoalScore();
}
public function resetScore():void{
_goalScore.resetScore();
}
public function get oldRating():int{
return (_oldRating);
}
public function set oldRating(value:int):void{
_oldRating = value;
}
public function addAttempt($isSuccess:Boolean):void{
_goalScore.addAttempt($isSuccess);
}
public function get ratingLabel():String{
return (((_rating == -1)) ? "-" : String(_rating));
}
public function set rating(value:int):void{
_rating = value;
}
public function get rating():int{
return (_rating);
}
public function get goalScore():MultiGoalScore{
return (_goalScore);
}
}
}//package com.freekickfusion.multiplayer.lobby.player
Section 62
//FreeKickLobbyPlayerInfo (com.freekickfusion.multiplayer.lobby.player.FreeKickLobbyPlayerInfo)
package com.freekickfusion.multiplayer.lobby.player {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.player.*;
import flash.display.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class FreeKickLobbyPlayerInfo extends Sprite {
private var player:FreeKickPlayer;
protected var gameServer:GameServer;
private var main:FreeKickLobbyPlayerInfo_Graphic;
private var inviteButton:ButtonLobby2;
public function FreeKickLobbyPlayerInfo(){
super();
main = new FreeKickLobbyPlayerInfo_Graphic();
addChild(main);
inviteButton = new ButtonLobby2(main.invite_but, "Invite");
inviteButton.refreshLang();
inviteButton.addEventListener(Button2.CLICK, onClickInvite, false, 0, true);
main.close_but.addEventListener(MouseEvent.CLICK, onClickClose, false, 0, true);
}
private function onClickClose(e:MouseEvent):void{
visible = false;
}
private function onClickInvite(e:Event):void{
gameServer.sendGameChallenge(player.serverId);
inviteButton.disable();
inviteButton.alpha = 0.4;
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
gameServer.addEventListener(GameServerEvent.RECEIVE_PLAYER_DATA, onReceivePlayerData, false, 0, true);
}
public function show($player:Player):void{
visible = true;
main.preloader.visible = true;
if ($player.isUser){
inviteButton.disable();
inviteButton.alpha = 0;
} else {
if (Player.me.state != Player.STATE_WAITING){
inviteButton.disable();
inviteButton.alpha = 0.4;
} else {
inviteButton.enable();
inviteButton.alpha = 1;
};
};
gameServer.getPlayerData($player.serverId);
}
private function onReceivePlayerData(e:GameServerEvent):void{
main.preloader.visible = false;
player = (e.params.player as FreeKickPlayer);
main.name_txt.text = (e.params.player as FreeKickPlayer).name;
if (player.isGuest){
main.rating_txt.text = "-";
main.played_txt.text = "-";
main.won_txt.text = "-";
main.lost_txt.text = "-";
} else {
main.rating_txt.text = String((e.params.player as FreeKickPlayer).rating);
main.played_txt.text = String((e.params.player as FreeKickPlayer).played);
main.won_txt.text = String((e.params.player as FreeKickPlayer).won);
main.lost_txt.text = String((e.params.player as FreeKickPlayer).lost);
};
}
}
}//package com.freekickfusion.multiplayer.lobby.player
Section 63
//FreeKickPlayer (com.freekickfusion.multiplayer.lobby.player.FreeKickPlayer)
package com.freekickfusion.multiplayer.lobby.player {
import uk.co.inbox.multiplayer.player.*;
public class FreeKickPlayer extends Player {
protected var _played:Number;// = 0
protected var _won:Number;// = 0
protected var _rating:Number;// = 0
public function FreeKickPlayer(){
super();
}
public function get played():Number{
return (_played);
}
public function set played(value:Number):void{
_played = value;
updated();
}
public function get lost():Number{
return ((_played - _won));
}
public function set won(value:Number):void{
_won = value;
updated();
}
public function get won():Number{
return (_won);
}
public function set rating(value:Number):void{
_rating = value;
updated();
}
public function get rating():Number{
return (_rating);
}
}
}//package com.freekickfusion.multiplayer.lobby.player
Section 64
//FreeKickPlayerList (com.freekickfusion.multiplayer.lobby.player.FreeKickPlayerList)
package com.freekickfusion.multiplayer.lobby.player {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.lobby.render.*;
public class FreeKickPlayerList extends PlayerList {
protected var main:PlayerList_Graphic;
private var playerInfo:FreeKickLobbyPlayerInfo;
public function FreeKickPlayerList(){
main = new PlayerList_Graphic();
addChild(main);
setScrollBar(main.list_scr);
super();
itemClass = FreeKickPlayerListItem;
visibleItems = 8;
scrollBarGapX = 0;
playerInfo = new FreeKickLobbyPlayerInfo();
playerInfo.x = -(playerInfo.width);
playerInfo.visible = false;
addChild(playerInfo);
}
override protected function sortItems():void{
dataList.sort(sortDepthsOn);
}
override public function setGameServer($gameServer:GameServer):void{
super.setGameServer($gameServer);
playerInfo.setGameServer(gameServer);
}
override public function drawItems():void{
var entry:FreeKickPlayerListItem;
super.drawItems();
var i:int;
while (i < entryList.length) {
entry = (entryList[i] as FreeKickPlayerListItem);
entry.setPlayerInfo(playerInfo);
i++;
};
}
private function sortDepthsOn(a:FreeKickPlayer, b:FreeKickPlayer):Number{
if (a.rating > b.rating){
return (-1);
};
if (a.rating < b.rating){
return (1);
};
if (a.name < b.name){
return (-1);
};
if (a.name > b.name){
return (1);
};
return (0);
}
}
}//package com.freekickfusion.multiplayer.lobby.player
Section 65
//FreeKickPlayerListItem (com.freekickfusion.multiplayer.lobby.player.FreeKickPlayerListItem)
package com.freekickfusion.multiplayer.lobby.player {
import uk.co.inbox.multiplayer.lobby.render.player.*;
public class FreeKickPlayerListItem extends PlayerListItem {
public function FreeKickPlayerListItem(){
super();
}
override protected function initSubItems():void{
stateGraphicList = [createDefaultItem(), createGuestItem()];
main = stateGraphicList[0];
addChild(main);
}
public function setPlayerInfo($playerInfo:FreeKickLobbyPlayerInfo):void{
var item:FreeKickPlayerListItem_Base;
var i:int;
while (i < stateGraphicList.length) {
item = (stateGraphicList[i] as FreeKickPlayerListItem_Base);
item.setPlayerInfo($playerInfo);
i++;
};
}
override protected function selectGraphic():void{
if (player.isGuest){
main = stateGraphicList[1];
} else {
main = stateGraphicList[0];
};
}
protected function createGuestItem():PlayerListItem_Base{
return (new FreeKickPlayerListItem_Guest());
}
override protected function createDefaultItem():PlayerListItem_Base{
return (new FreeKickPlayerListItem_Default());
}
}
}//package com.freekickfusion.multiplayer.lobby.player
Section 66
//FreeKickPlayerListItem_Base (com.freekickfusion.multiplayer.lobby.player.FreeKickPlayerListItem_Base)
package com.freekickfusion.multiplayer.lobby.player {
import uk.co.inbox.multiplayer.lobby.render.player.*;
public class FreeKickPlayerListItem_Base extends PlayerListItem_Base {
protected var playerInfo:FreeKickLobbyPlayerInfo;
public function FreeKickPlayerListItem_Base(){
super();
}
public function setPlayerInfo($playerInfo:FreeKickLobbyPlayerInfo):void{
playerInfo = $playerInfo;
}
}
}//package com.freekickfusion.multiplayer.lobby.player
Section 67
//FreeKickPlayerListItem_Default (com.freekickfusion.multiplayer.lobby.player.FreeKickPlayerListItem_Default)
package com.freekickfusion.multiplayer.lobby.player {
import flash.events.*;
public class FreeKickPlayerListItem_Default extends FreeKickPlayerListItem_Base {
private var main:FreeKickPlayer_Default_Graphic;
public function FreeKickPlayerListItem_Default(){
super();
main = new FreeKickPlayer_Default_Graphic();
addChild(main);
main.buttonMode = true;
main.mouseChildren = false;
main.addEventListener(MouseEvent.CLICK, onClickPlayer, false, 0, true);
}
override public function update():void{
var freeKickPlayer:FreeKickPlayer = (player as FreeKickPlayer);
main.name_txt.text = freeKickPlayer.name;
main.rating_txt.text = String(freeKickPlayer.rating);
if (freeKickPlayer.rating > 1900){
main.star.gotoAndStop(4);
} else {
if (freeKickPlayer.rating > 1600){
main.star.gotoAndStop(3);
} else {
if (freeKickPlayer.rating >= 1200){
main.star.gotoAndStop(2);
} else {
main.star.gotoAndStop(1);
};
};
};
}
private function onClickPlayer(e:MouseEvent):void{
playerInfo.show(player);
}
}
}//package com.freekickfusion.multiplayer.lobby.player
Section 68
//FreeKickPlayerListItem_Guest (com.freekickfusion.multiplayer.lobby.player.FreeKickPlayerListItem_Guest)
package com.freekickfusion.multiplayer.lobby.player {
import flash.events.*;
public class FreeKickPlayerListItem_Guest extends FreeKickPlayerListItem_Base {
private var main:FreeKickPlayer_Guest_Graphic;
public function FreeKickPlayerListItem_Guest(){
super();
main = new FreeKickPlayer_Guest_Graphic();
addChild(main);
main.buttonMode = true;
main.mouseChildren = false;
main.addEventListener(MouseEvent.CLICK, onClickPlayer, false, 0, true);
}
override public function update():void{
main.name_txt.text = player.name;
main.rating_txt.text = "";
}
private function onClickPlayer(e:MouseEvent):void{
playerInfo.show(player);
}
}
}//package com.freekickfusion.multiplayer.lobby.player
Section 69
//FreeKickRoom_Setup (com.freekickfusion.multiplayer.lobby.room.FreeKickRoom_Setup)
package com.freekickfusion.multiplayer.lobby.room {
import flash.events.*;
import com.freekickfusion.game.*;
import uk.co.inbox.users.*;
import flash.display.*;
import com.freekickfusion.multiplayer.server.*;
import uk.co.inbox.form.*;
import com.freekickfusion.game.levels.*;
import uk.co.inbox.language.*;
import uk.co.inbox.multiplayer.lobby.render.room.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class FreeKickRoom_Setup extends Room_Setup {
private var levelList:Array;
private var privateCheck:FormCustomCheckBox;
private var createButton:ButtonLobby2;
private var cancelButton:ButtonLobby2;
private var memberCheck:FormCustomCheckBox;
private var difficultyId:int;// = 1
private var main:FreeKickRoom_Setup_Graphic;
private var userHandle:UserHandle;
public function FreeKickRoom_Setup(){
super();
main = new FreeKickRoom_Setup_Graphic();
addChild(main);
createButton = new ButtonLobby2(main.create_but, LangStrings.roomSetupCreate);
createButton.addEventListener(Button2.CLICK, onCreateGame, false, 0, true);
createButton.refreshLang();
cancelButton = new ButtonLobby2(main.cancel_but, LangStrings.roomSetupCancel);
cancelButton.addEventListener(Button2.CLICK, onCancel, false, 0, true);
cancelButton.refreshLang();
privateCheck = new FormCustomCheckBox(main.private_chk, null, false, false);
memberCheck = new FormCustomCheckBox(main.member_chk, null, false, false);
var i = 1;
while (i <= 4) {
main[("ball" + i)].buttonMode = true;
main[("ball" + i)].mouseChildren = false;
main[("ball" + i)].addEventListener(MouseEvent.CLICK, onChangeDifficulty, false, 0, true);
i++;
};
}
private function onCancel(e:Event):void{
gameServer.leaveGameRoom();
hide();
}
public function setUserHandle($userHandle:UserHandle):void{
userHandle = $userHandle;
}
public function setGameEngine($gameEngine:FreeKickGameMultiEngine):void{
levelList = $gameEngine.levelManager.levelList;
setDifficulty(2);
}
private function onChangeDifficulty(e:MouseEvent):void{
var targ:Sprite = (e.target as Sprite);
difficultyId = int(targ.name.slice(-1));
setDifficulty(difficultyId);
}
private function onCreateGame(e:Event):void{
(gameServer as FreeKickGameServer).createFreeKickGameRoom(roomId, privateCheck.value, memberCheck.value, false, difficultyId);
hide();
}
private function setDifficulty($difficulty:int):void{
var i = 1;
while (i <= 4) {
main[("ball" + i)].alpha = ((i)<=difficultyId) ? 1 : 0.4;
i++;
};
main.level_txt.text = getText((levelList[(difficultyId - 1)] as FreeKickMultiLevel).name).toUpperCase();
}
override public function show($roomId:int):void{
super.show($roomId);
main.membersBlocker.visible = userHandle.userDetails.isGuest;
}
}
}//package com.freekickfusion.multiplayer.lobby.room
Section 70
//FreeKickRoomList (com.freekickfusion.multiplayer.lobby.room.FreeKickRoomList)
package com.freekickfusion.multiplayer.lobby.room {
import uk.co.inbox.multiplayer.lobby.render.*;
public class FreeKickRoomList extends RoomList {
protected var main:RoomList_Graphic;
public function FreeKickRoomList(){
main = new RoomList_Graphic();
addChild(main);
setScrollBar(main.list_scr);
super();
visibleItems = 8;
scrollBarGapX = 0;
itemClass = FreeKickRoomListItem;
}
}
}//package com.freekickfusion.multiplayer.lobby.room
Section 71
//FreeKickRoomListItem (com.freekickfusion.multiplayer.lobby.room.FreeKickRoomListItem)
package com.freekickfusion.multiplayer.lobby.room {
import uk.co.inbox.multiplayer.lobby.render.room.*;
public class FreeKickRoomListItem extends RoomListItem {
public function FreeKickRoomListItem(){
super();
}
override protected function createCreatingItem():RoomListItem_Base{
return (new FreeKickRoomListItem_Creating());
}
override protected function createJoinItem():RoomListItem_Base{
return (new FreeKickRoomListItem_Join());
}
override protected function createCreateItem():RoomListItem_Base{
return (new FreeKickRoomListItem_Create());
}
override protected function createFullItem():RoomListItem_Base{
return (new FreeKickRoomListItem_Full());
}
}
}//package com.freekickfusion.multiplayer.lobby.room
Section 72
//FreeKickRoomListItem_Create (com.freekickfusion.multiplayer.lobby.room.FreeKickRoomListItem_Create)
package com.freekickfusion.multiplayer.lobby.room {
import flash.events.*;
import uk.co.inbox.multiplayer.lobby.render.room.*;
public class FreeKickRoomListItem_Create extends RoomListItem_Base {
private var main:FreeKickRoom_Create_Graphic;
public function FreeKickRoomListItem_Create(){
super();
main = new FreeKickRoom_Create_Graphic();
addChild(main);
main.buttonMode = true;
main.mouseChildren = false;
main.addEventListener(MouseEvent.MOUSE_OVER, onCreateOver, false, 0, true);
main.addEventListener(MouseEvent.MOUSE_OUT, onCreateOut, false, 0, true);
main.addEventListener(MouseEvent.CLICK, onClickCreate, false, 0, true);
}
override public function update():void{
main.num_txt.text = gameRoom.idLabel;
}
protected function onClickCreate(e:Event):void{
gameServer.creatingGameRoom(gameRoom.serverId);
}
private function onCreateOut(e:MouseEvent):void{
(e.target as FreeKickRoom_Create_Graphic).bg.gotoAndStop(1);
}
private function onCreateOver(e:MouseEvent):void{
(e.target as FreeKickRoom_Create_Graphic).bg.gotoAndStop(2);
}
}
}//package com.freekickfusion.multiplayer.lobby.room
Section 73
//FreeKickRoomListItem_Creating (com.freekickfusion.multiplayer.lobby.room.FreeKickRoomListItem_Creating)
package com.freekickfusion.multiplayer.lobby.room {
import uk.co.inbox.multiplayer.lobby.render.room.*;
public class FreeKickRoomListItem_Creating extends RoomListItem_Base {
private var main:FreeKickRoom_Creating_Graphic;
public function FreeKickRoomListItem_Creating(){
super();
main = new FreeKickRoom_Creating_Graphic();
addChild(main);
}
override public function update():void{
main.num_txt.text = gameRoom.idLabel;
}
}
}//package com.freekickfusion.multiplayer.lobby.room
Section 74
//FreeKickRoomListItem_Full (com.freekickfusion.multiplayer.lobby.room.FreeKickRoomListItem_Full)
package com.freekickfusion.multiplayer.lobby.room {
import uk.co.inbox.multiplayer.lobby.render.room.*;
import com.freekickfusion.multiplayer.lobby.player.*;
import com.freekickfusion.ui.buttons.*;
import com.freekickfusion.multiplayer.lobby.*;
public class FreeKickRoomListItem_Full extends RoomListItem_Base {
private var watchButton:ButtonLobby;
private var main:FreeKickRoom_Full_Graphic;
public function FreeKickRoomListItem_Full(){
super();
main = new FreeKickRoom_Full_Graphic();
addChild(main);
}
override public function update():void{
main.num_txt.text = gameRoom.idLabel;
main.score_mc.level_mc.gotoAndStop(((gameRoom as FreeKickGameRoom).difficulty + 1));
var player1:FreeKickGamePlayer = ((gameRoom as FreeKickGameRoom).playerList[0] as FreeKickGamePlayer);
var player2:FreeKickGamePlayer = ((gameRoom as FreeKickGameRoom).playerList[1] as FreeKickGamePlayer);
if (player1 != null){
main.player1_rating_txt.text = ((player1.rating == -1)) ? "" : (("(" + player1.rating) + ")");
main.player1_txt.text = player1.name;
if (player1.rating == -1){
main.player1_txt.x = 65;
main.player1_txt.textColor = 0x999999;
} else {
main.player1_txt.x = 34;
main.player1_txt.textColor = 0x666666;
};
};
if (player2 != null){
main.player2_txt.text = (player2.name + ((player2.rating == -1)) ? "" : ((" (" + player2.rating) + ")"));
if (player2.rating == -1){
main.player2_txt.textColor = 0x999999;
} else {
main.player2_txt.textColor = 0x666666;
};
};
}
}
}//package com.freekickfusion.multiplayer.lobby.room
Section 75
//FreeKickRoomListItem_Join (com.freekickfusion.multiplayer.lobby.room.FreeKickRoomListItem_Join)
package com.freekickfusion.multiplayer.lobby.room {
import flash.events.*;
import uk.co.inbox.multiplayer.player.*;
import uk.co.inbox.multiplayer.lobby.render.room.*;
import com.freekickfusion.multiplayer.lobby.player.*;
import com.freekickfusion.ui.buttons.*;
import com.freekickfusion.multiplayer.lobby.*;
import uk.co.inbox.buttons.*;
public class FreeKickRoomListItem_Join extends RoomListItem_Base {
private var main:FreeKickRoom_Join_Graphic;
private var joinButton:ButtonLobby;
public function FreeKickRoomListItem_Join(){
super();
main = new FreeKickRoom_Join_Graphic();
addChild(main);
joinButton = new ButtonLobby(main.join_but, "Join");
joinButton.addEventListener(Button2.CLICK, onClickJoin, false, 0, true);
joinButton.refreshLang();
main.private_txt.text = "PRIVATE";
}
override public function update():void{
main.num_txt.text = gameRoom.idLabel;
main.score_mc.level_mc.gotoAndStop(((gameRoom as FreeKickGameRoom).difficulty + 1));
var player1:FreeKickGamePlayer = ((gameRoom as FreeKickGameRoom).playerList[0] as FreeKickGamePlayer);
if (player1 != null){
main.player1_rating_txt.text = ((player1.rating == -1)) ? "" : (("(" + player1.rating) + ")");
main.player1_txt.text = player1.name;
if (player1.rating == -1){
main.player1_txt.x = 65;
main.player1_txt.textColor = 0x999999;
} else {
main.player1_txt.x = 34;
main.player1_txt.textColor = 0x666666;
};
if (player1.isUser){
main.private_txt.visible = false;
main.members_txt.visible = false;
joinButton.visible = true;
joinButton.textId = "Leave";
joinButton.refreshLang();
} else {
if (gameRoom.isPrivate){
main.private_txt.visible = true;
main.members_txt.visible = false;
joinButton.visible = false;
} else {
if (((gameRoom.isMembersOnly) && (Player.me.isGuest))){
main.private_txt.visible = false;
main.members_txt.visible = true;
joinButton.visible = false;
} else {
main.private_txt.visible = false;
main.members_txt.visible = false;
joinButton.visible = true;
joinButton.textId = "Join";
joinButton.refreshLang();
};
};
};
};
}
protected function onClickJoin(e:Event):void{
if (joinButton.textId == "Join"){
gameServer.joinGameRoom(gameRoom.serverId);
} else {
if (joinButton.textId == "Leave"){
gameServer.leaveGameRoom();
};
};
}
}
}//package com.freekickfusion.multiplayer.lobby.room
Section 76
//FreeKickGameRoom (com.freekickfusion.multiplayer.lobby.FreeKickGameRoom)
package com.freekickfusion.multiplayer.lobby {
import uk.co.inbox.multiplayer.lobby.*;
public class FreeKickGameRoom extends GameRoom {
protected var _difficulty:int;// = 0
public function FreeKickGameRoom(){
super();
}
public function get difficulty():int{
return (_difficulty);
}
public function set difficulty(value:int):void{
_difficulty = value;
}
}
}//package com.freekickfusion.multiplayer.lobby
Section 77
//FreeKickLobby (com.freekickfusion.multiplayer.lobby.FreeKickLobby)
package com.freekickfusion.multiplayer.lobby {
import uk.co.inbox.multiplayer.server.*;
import com.freekickfusion.game.*;
import uk.co.inbox.users.*;
import uk.co.inbox.multiplayer.lobby.*;
import uk.co.inbox.multiplayer.lobby.render.room.*;
import uk.co.inbox.multiplayer.lobby.render.*;
import com.freekickfusion.multiplayer.lobby.player.*;
import com.freekickfusion.multiplayer.lobby.challenge.*;
import com.freekickfusion.multiplayer.lobby.room.*;
public class FreeKickLobby extends Lobby {
private var multiEngine:FreeKickGameMultiEngine;
private var userHandle:UserHandle;
public function FreeKickLobby($gameServer:GameServer, $userHandle:UserHandle, $multiEngine:FreeKickGameMultiEngine){
userHandle = $userHandle;
multiEngine = $multiEngine;
super($gameServer);
createAllElements();
}
override protected function initLobbySelector():LobbySelector{
return (new FreeKickLobbySelector());
}
override protected function createRoomSetup():void{
super.createRoomSetup();
(roomSetup as FreeKickRoom_Setup).setGameEngine(multiEngine);
(roomSetup as FreeKickRoom_Setup).setUserHandle(userHandle);
roomSetup.x = 10;
roomSetup.y = 111;
roomSetup.visible = false;
}
override protected function initRoomList():RoomList{
return (new FreeKickRoomList());
}
override protected function createChallengeList():void{
super.createChallengeList();
challengeList.x = 360;
challengeList.y = 290;
}
override protected function initPlayerList():PlayerList{
return (new FreeKickPlayerList());
}
override protected function initChallengeList():ChallengeList{
return (new FreeKickChallengeList());
}
override protected function initRoomSetup():Room_Setup{
return (new FreeKickRoom_Setup());
}
override protected function createRoomList():void{
super.createRoomList();
roomList.x = 10;
roomList.y = 111;
}
override protected function createLobbySelector():void{
super.createLobbySelector();
lobbySelector.x = 16;
lobbySelector.y = 88;
}
override protected function createPlayerList():void{
super.createPlayerList();
playerList.x = 360;
playerList.y = 111;
}
}
}//package com.freekickfusion.multiplayer.lobby
Section 78
//FreeKickLobbySelector (com.freekickfusion.multiplayer.lobby.FreeKickLobbySelector)
package com.freekickfusion.multiplayer.lobby {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import it.gotoandplay.smartfoxserver.data.*;
import flash.text.*;
import fl.controls.*;
import uk.co.inbox.multiplayer.lobby.render.*;
import fl.data.*;
public class FreeKickLobbySelector extends LobbySelector {
private var main:FreeKickLobbySelector_Graphic;
private var comboBox:ComboBox;
public function FreeKickLobbySelector(){
super();
main = new FreeKickLobbySelector_Graphic();
addChild(main);
var cmbFormat:TextFormat = new TextFormat();
cmbFormat.color = 0x666666;
cmbFormat.size = 13;
cmbFormat.font = new _HandelGothic().fontName;
cmbFormat.align = "left";
cmbFormat.indent = 3;
main.lobbies_cmb.textField.setStyle("textFormat", cmbFormat);
main.lobbies_cmb.textField.setStyle("embedFonts", true);
main.lobbies_cmb.textField.setStyle("textPadding", -1);
main.lobbies_cmb.dropdown.setStyle("cellRenderer", MyRenderer);
main.lobbies_cmb.dropdown.rowHeight = 20;
main.lobbies_cmb.rowCount = 10;
comboBox = main.lobbies_cmb;
comboBox.addEventListener(Event.CHANGE, onChangeLobby, false, 0, true);
}
override protected function onJoinLobby(e:GameServerEvent):void{
var lobbyRoomId:int;
var dP:DataProvider;
var i:int;
var check:Object;
var lobbyRoom:Room = e.params.lobbyRoom;
if (lobbyRoom != null){
lobbyRoomId = lobbyRoom.getId();
dP = comboBox.dataProvider;
i = 0;
while (i < dP.length) {
check = dP.getItemAt(i);
if (check.data == lobbyRoomId){
comboBox.selectedIndex = i;
break;
};
i++;
};
};
}
private function onChangeLobby(e:Event):void{
gameServer.changeLobby(comboBox.selectedItem.data);
}
override protected function onLobbyListUpdate(e:GameServerEvent):void{
var checkRoom:Room;
var roomList:Array = e.params.roomList;
var dataList:Array = [];
var i:int;
while (i < roomList.length) {
checkRoom = roomList[i];
dataList.push({data:checkRoom.getId(), label:checkRoom.getName()});
i++;
};
dataList.sortOn("data", Array.NUMERIC);
comboBox.dataProvider = new DataProvider(dataList);
}
}
}//package com.freekickfusion.multiplayer.lobby
Section 79
//MyRenderer (com.freekickfusion.multiplayer.lobby.MyRenderer)
package com.freekickfusion.multiplayer.lobby {
import flash.text.*;
import fl.controls.listClasses.*;
public class MyRenderer extends CellRenderer {
public function MyRenderer(){
super();
var originalStyles:Object = CellRenderer.getStyleDefinition();
var cmbFormat:TextFormat = new TextFormat();
cmbFormat.color = 0x666666;
cmbFormat.size = 13;
cmbFormat.font = new _HandelGothic().fontName;
setStyle("textFormat", cmbFormat);
setStyle("embedFonts", true);
}
override protected function draw():void{
super.draw();
textField.y = 2;
}
}
}//package com.freekickfusion.multiplayer.lobby
Section 80
//FreeKickGameServer (com.freekickfusion.multiplayer.server.FreeKickGameServer)
package com.freekickfusion.multiplayer.server {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.player.*;
import uk.co.inbox.multiplayer.lobby.*;
import com.freekickfusion.multiplayer.lobby.player.*;
import com.freekickfusion.multiplayer.lobby.*;
import uk.co.inbox.hub.*;
public class FreeKickGameServer extends GameServer {
private const CMD_UPDATE_SUPER_SAVE:String = "uSS";
private const CMD_SKIP_SHOT:String = "skS";
private const CMD_ACTIVATE_DEBUG_MODE:String = "aDM";
private const CMD_SHOT_COMPLETE:String = "sC";
private const CMD_SEND_SHOT:String = "sS";
private var isDebugMode:Boolean;// = false
public function FreeKickGameServer($defaultZone:String, $extName:String, $sfsDebug:Boolean=false){
super($defaultZone, $extName, $sfsDebug);
}
override protected function processExtensionString($allParamList:Array):void{
super.processExtensionString($allParamList);
var method:String = $allParamList[0];
var remParams:Array = $allParamList.slice(2);
switch (method){
case "sT":
dispatchEvent(new FreeKickGameServerEvent(FreeKickGameServerEvent.START_TURN, {turnIndex:Number(remParams[0]), xPos:Number(remParams[1]), goalkeeperLevel:Number(remParams[2]), playersInWall:Number(remParams[3]), timeLimit:Number(remParams[4])}));
break;
case "rS":
dispatchEvent(new FreeKickGameServerEvent(FreeKickGameServerEvent.RECEIVE_SHOT, {power:Number(remParams[0]), angle:Number(remParams[1]), elevation:Number(remParams[2]), curl:Number(remParams[3]), superSaveX:Number(remParams[4]), superSaveY:Number(remParams[5])}));
break;
case "rDM":
HubLink.showAlert("Freekick Fusion", "Multiplayer Debug Mode successfully activated", 2);
break;
};
}
public function createFreeKickGameRoom($roomId:int, $isPrivate:Boolean, $isMemberOnly:Boolean, $isAllowSpectators:Boolean, $difficulty:Number):void{
sendLobbyExtensionMessage(CMD_CREATE_GAME_ROOM, [$roomId, ($isPrivate) ? 1 : 0, ($isMemberOnly) ? 1 : 0, ($isAllowSpectators) ? 1 : 0, $difficulty]);
}
public function activateDebugMode():void{
isDebugMode = true;
sendGameExtensionMessage(CMD_ACTIVATE_DEBUG_MODE);
}
override protected function onCompleteGame($paramList:Array):void{
var player:GamePlayer;
var playerDataList:Array = $paramList[3].split("|");
var playerList:Array = [];
var i:int;
while (i < playerDataList.length) {
player = populateGamePlayer(playerDataList[i].split("^"));
playerList.push(player);
i++;
};
dispatchEvent(new GameServerEvent(GameServerEvent.COMPLETE_GAME, {isValidGame:($paramList[0] == "true"), winnerId:Number($paramList[1]), isGuestGame:($paramList[2] == "1"), playerList:playerList}));
}
public function updateSuperSave($x:Number, $y:Number):void{
sendGameExtensionMessage(CMD_UPDATE_SUPER_SAVE, [$x, $y]);
}
override protected function initPlayer():Player{
return (new FreeKickPlayer());
}
public function shotComplete($isGoalScored:Boolean):void{
sendGameExtensionMessage(CMD_SHOT_COMPLETE, [($isGoalScored) ? 1 : 0]);
}
override protected function onLoginSuccess($paramList:Array):Player{
var player:Player = super.onLoginSuccess($paramList);
dispatchEvent(new GameServerEvent(GameServerEvent.RECEIVE_PLAYER_DATA, {player:player}));
return (player);
}
override protected function populatePlayerFull($paramList:Array):Player{
var player:FreeKickPlayer = (super.populatePlayerFull($paramList) as FreeKickPlayer);
player.played = Number($paramList[5]);
player.won = Number($paramList[6]);
return (player);
}
override protected function onStartGame($paramList:Array):void{
var player:GamePlayer;
var playerDataList:Array = $paramList[0].split("|");
var playerList:Array = [];
var i:int;
while (i < playerDataList.length) {
player = populateGamePlayer(playerDataList[i].split("^"));
playerList.push(player);
i++;
};
dispatchEvent(new GameServerEvent(GameServerEvent.START_GAME, {playerList:playerList, turnIndex:Number($paramList[1]), difficulty:Number($paramList[2])}));
}
override protected function initGameRoom():GameRoom{
return (new FreeKickGameRoom());
}
public function skipShot():void{
sendGameExtensionMessage(CMD_SEND_SHOT, [0.1, 0, 1, 0]);
}
public function sendShot($power:Number, $angle:Number, $elevation:Number, $curl:Number):void{
sendGameExtensionMessage(CMD_SEND_SHOT, [$power, $angle, $elevation, $curl]);
}
override protected function initGamePlayer():GamePlayer{
return (new FreeKickGamePlayer());
}
override protected function populatePlayer($paramList:Array):Player{
var player:FreeKickPlayer = (super.populatePlayer($paramList) as FreeKickPlayer);
player.rating = Number($paramList[4]);
return (player);
}
override protected function populateGameRoomGameParams($gameRoom:GameRoom, $paramList:Array):void{
super.populateGameRoomGameParams($gameRoom, $paramList);
($gameRoom as FreeKickGameRoom).difficulty = (Number($paramList[0]) - 1);
}
override protected function onJoinGameRoom($paramList:Array):void{
if (isDebugMode){
activateDebugMode();
};
super.onJoinGameRoom($paramList);
}
override protected function populateGameRoom($paramList:Array):GameRoom{
var room:FreeKickGameRoom = (super.populateGameRoom($paramList) as FreeKickGameRoom);
room.difficulty = $paramList[7];
return (room);
}
override protected function populateGamePlayer($paramList:Array):GamePlayer{
var gamePlayer:FreeKickGamePlayer = (super.populateGamePlayer($paramList) as FreeKickGamePlayer);
gamePlayer.rating = Number($paramList[3]);
gamePlayer.oldRating = Number($paramList[4]);
return (gamePlayer);
}
}
}//package com.freekickfusion.multiplayer.server
Section 81
//FreeKickGameServerEvent (com.freekickfusion.multiplayer.server.FreeKickGameServerEvent)
package com.freekickfusion.multiplayer.server {
import flash.events.*;
public class FreeKickGameServerEvent extends Event {
public var params:Object;
public static const START_TURN:String = "startTurn";
public static const RECEIVE_SHOT:String = "receiveShot";
public function FreeKickGameServerEvent(type:String, params:Object, bubbles:Boolean=false, cancelable:Boolean=false){
this.params = params;
super(type, bubbles, cancelable);
}
override public function toString():String{
return (formatToString("FreeKickGameServerEvent", "type", "params", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new FreeKickGameServerEvent(type, params, bubbles, cancelable));
}
}
}//package com.freekickfusion.multiplayer.server
Section 82
//ButtonLobby (com.freekickfusion.ui.buttons.ButtonLobby)
package com.freekickfusion.ui.buttons {
import flash.text.*;
import uk.co.inbox.buttons.*;
public class ButtonLobby extends Button2 {
public function ButtonLobby($button:ButtonLobby_Graphic, $textId:String){
super($button, $textId);
refreshLang();
}
override public function refreshLang():void{
(contentSprite as ButtonLobby_Graphic).label_txt.autoSize = TextFieldAutoSize.CENTER;
(contentSprite as ButtonLobby_Graphic).label_txt.text = _textId.toUpperCase();
}
}
}//package com.freekickfusion.ui.buttons
Section 83
//ButtonLobby2 (com.freekickfusion.ui.buttons.ButtonLobby2)
package com.freekickfusion.ui.buttons {
import flash.text.*;
import flash.display.*;
import uk.co.inbox.language.*;
import uk.co.inbox.buttons.*;
public class ButtonLobby2 extends Button2 {
public function ButtonLobby2($contentSprite:MovieClip, $textId:String="", $align:String="left"){
super($contentSprite, $textId, $align);
}
override public function refreshLang():void{
(contentSprite as MovieClip).label_txt.autoSize = TextFieldAutoSize.LEFT;
(contentSprite as MovieClip).label_txt.text = getText(_textId).toUpperCase();
(contentSprite as MovieClip).icon.x = (((contentSprite as MovieClip).label_txt.x + (contentSprite as MovieClip).label_txt.textWidth) + 14);
(contentSprite as MovieClip).hit.width = ((contentSprite as MovieClip).label_txt.textWidth + 30);
}
}
}//package com.freekickfusion.ui.buttons
Section 84
//ButtonLobbySmall (com.freekickfusion.ui.buttons.ButtonLobbySmall)
package com.freekickfusion.ui.buttons {
import flash.text.*;
import uk.co.inbox.buttons.*;
public class ButtonLobbySmall extends Button2 {
public function ButtonLobbySmall($button:ButtonLobbySmall_Graphic, $textId:String){
super($button, $textId);
refreshLang();
}
override public function refreshLang():void{
(contentSprite as ButtonLobbySmall_Graphic).label_txt.autoSize = TextFieldAutoSize.CENTER;
(contentSprite as ButtonLobbySmall_Graphic).label_txt.text = _textId.toUpperCase();
}
}
}//package com.freekickfusion.ui.buttons
Section 85
//ButtonMain (com.freekickfusion.ui.buttons.ButtonMain)
package com.freekickfusion.ui.buttons {
import flash.text.*;
import uk.co.inbox.language.*;
import uk.co.inbox.buttons.*;
public class ButtonMain extends Button2 {
public function ButtonMain($contentSprite:Button_Main_Graphic, $textId:String="", $align:String="left"){
super($contentSprite, $textId, $align);
}
override public function refreshLang():void{
(contentSprite as Button_Main_Graphic).label_txt.autoSize = TextFieldAutoSize.LEFT;
(contentSprite as Button_Main_Graphic).label_txt.text = getText(_textId).toUpperCase();
(contentSprite as Button_Main_Graphic).icon.x = (((contentSprite as Button_Main_Graphic).label_txt.x + (contentSprite as Button_Main_Graphic).label_txt.textWidth) + 14);
(contentSprite as Button_Main_Graphic).hit.width = ((contentSprite as Button_Main_Graphic).label_txt.textWidth + 30);
}
}
}//package com.freekickfusion.ui.buttons
Section 86
//LeagueList (com.freekickfusion.ui.league.LeagueList)
package com.freekickfusion.ui.league {
import uk.co.inbox.multiplayer.lobby.render.list.*;
public class LeagueList extends ScrollerListViewer {
private var main:LeagueList_Graphic;
public function LeagueList(){
main = new LeagueList_Graphic();
addChild(main);
setScrollBar(main.list_scr);
startX = main.x;
startY = (main.y + 21);
gapY = 1;
super();
if (itemClass == null){
itemClass = LeagueListItem;
};
visibleItems = 9;
}
public function setScores($list:Array):void{
dataList = $list.slice();
drawItems();
refreshItems();
}
}
}//package com.freekickfusion.ui.league
Section 87
//LeagueListItem (com.freekickfusion.ui.league.LeagueListItem)
package com.freekickfusion.ui.league {
import uk.co.inbox.users.items.*;
import uk.co.inbox.multiplayer.lobby.render.list.*;
public class LeagueListItem extends ListItem {
private var main:LeagueListItem_Graphic;
public function LeagueListItem(){
super();
main = new LeagueListItem_Graphic();
addChild(main);
}
override public function update($data:Object):void{
var scoreInfo:ScoreInfo = ($data as ScoreInfo);
trace(("W:" + scoreInfo));
main.name_txt.text = scoreInfo.name;
main.rating_txt.text = scoreInfo.score;
main.star.visible = false;
main.num_txt.text = (scoreInfo.rank + ".");
}
}
}//package com.freekickfusion.ui.league
Section 88
//AdPanel (com.freekickfusion.ui.uiframe.AdPanel)
package com.freekickfusion.ui.uiframe {
import flash.events.*;
import uk.co.inbox.ads.*;
public class AdPanel {
private var adViewer:SequentialAdViewer;
private var main:AdPanel_Graphic;
public function AdPanel($main:AdPanel_Graphic, $filePath:String){
super();
main = $main;
adViewer = new SequentialAdViewer();
adViewer.x = 2;
adViewer.y = 3;
adViewer.mask = main.adMask;
adViewer.loadFromXML($filePath);
main.addChild(adViewer);
}
private function onAddedToStage(e:Event):void{
main.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
main.stage.addEventListener(MouseEvent.CLICK, onClickStage, false, 0, true);
}
private function onClickStage(e:MouseEvent):void{
adViewer.showNext();
}
}
}//package com.freekickfusion.ui.uiframe
Section 89
//Chat (com.freekickfusion.ui.uiframe.Chat)
package com.freekickfusion.ui.uiframe {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.form.events.*;
import uk.co.inbox.multiplayer.player.*;
import flash.text.*;
import uk.co.inbox.form.*;
import flash.utils.*;
import uk.co.inbox.language.*;
import com.freekickfusion.multiplayer.lobby.player.*;
public class Chat {
private var input:ChatFormTextField;
private var buttonTimer:Timer;
private var gameServer:GameServer;
private var main:ChatWindow_Graphic;
public function Chat($main:ChatWindow_Graphic){
super();
main = $main;
input = new ChatFormTextField(main.input_txt, FormTextField.VALIDATION_TEXT, LangStrings.chatWritePrompt);
var form:Form = new Form([input]);
form.addEventListener(FormEvent.FORM_SUBMIT_SUCCESS, onFormSuccess, false, 0, true);
main.send_but.addEventListener(MouseEvent.CLICK, form.submit, false, 0, true);
buttonTimer = new Timer(2000, 1);
buttonTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onShowButton, false, 0, true);
}
private function onFormSuccess(e:FormEvent):void{
gameServer.sendGameChat(input.text);
(input.content as TextField).textColor = 0xFF6600;
input.setDefaultTextId(input.text);
main.send_but.visible = false;
buttonTimer.reset();
buttonTimer.start();
}
private function onInitGame(e:GameServerEvent):void{
var player1:FreeKickGamePlayer = (e.params.playerList[0] as FreeKickGamePlayer);
var player2:FreeKickGamePlayer = (e.params.playerList[1] as FreeKickGamePlayer);
if (player1.isUser){
main.player1_txt.text = player1.name;
main.player2_txt.text = player2.name;
} else {
if (player2.isUser){
main.player1_txt.text = player2.name;
main.player2_txt.text = player1.name;
};
};
}
public function set visible(value:Boolean):void{
main.visible = value;
}
private function onShowButton(e:TimerEvent):void{
main.send_but.visible = true;
}
public function reset():void{
input.reset();
main.player2_chat_txt.text = "";
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
gameServer.addEventListener(GameServerEvent.INIT_GAME, onInitGame, false, 0, true);
gameServer.addEventListener(GameServerEvent.RECEIVE_GAME_CHAT, onReceiveChat, false, 0, true);
}
private function onReceiveChat(e:GameServerEvent):void{
if (e.params.from != GamePlayer.me.name){
main.player2_chat_txt.text = e.params.message;
};
}
public function get visible():Boolean{
return (main.visible);
}
}
}//package com.freekickfusion.ui.uiframe
Section 90
//ChatFormTextField (com.freekickfusion.ui.uiframe.ChatFormTextField)
package com.freekickfusion.ui.uiframe {
import flash.text.*;
import uk.co.inbox.form.*;
public class ChatFormTextField extends FormTextField {
public function ChatFormTextField($textField:TextField, $validationType:String, $defaultTextId:String="", $defaultInvalidTextId:String="", $fieldId:String="", $isRequired:Boolean=true, $minimumLength:int=0, $maximumLength:int=0, $invalidColour:uint=0xFF0000, $isKeyboardEnabled:Boolean=true, $isShowErrorInField:Boolean=true){
super($textField, $validationType, $defaultTextId, $defaultInvalidTextId, $fieldId, $isRequired, $minimumLength, $maximumLength, $invalidColour, $isKeyboardEnabled, $isShowErrorInField);
}
public function setDefaultTextId($value:String):void{
defaultTextId = $value;
}
}
}//package com.freekickfusion.ui.uiframe
Section 91
//Header (com.freekickfusion.ui.uiframe.Header)
package com.freekickfusion.ui.uiframe {
import flash.events.*;
import flash.net.*;
import uk.co.inbox.utils.*;
public class Header {
private var main:Header_Graphic;
public function Header($main:Header_Graphic){
super();
main = $main;
main.logo_but.addEventListener(MouseEvent.CLICK, onClickLogo, false, 0, true);
}
private function onClickLogo(e:MouseEvent):void{
navigateToURL(new URLRequest(Settings.get("inboxURL")));
}
}
}//package com.freekickfusion.ui.uiframe
Section 92
//MultiScorePanel (com.freekickfusion.ui.uiframe.MultiScorePanel)
package com.freekickfusion.ui.uiframe {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.windows.*;
import uk.co.inbox.users.*;
import uk.co.inbox.multiplayer.player.*;
import uk.co.inbox.users.items.*;
import uk.co.inbox.language.*;
import com.freekickfusion.multiplayer.lobby.player.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.utils.*;
public class MultiScorePanel {
private var userInfo:UserInfo;
private var userHandle:UserHandle;
private var main:MultiScorePanel_Graphic;
private var gameServer:GameServer;
public function MultiScorePanel($main:MultiScorePanel_Graphic){
super();
main = $main;
var registerButton:ButtonLobby2 = new ButtonLobby2(main.registerPrompt.register_but, LangStrings.panelRegisterPrompt);
registerButton.refreshLang();
main.registerPrompt.buttonMode = true;
main.registerPrompt.mouseChildren = false;
main.registerPrompt.addEventListener(MouseEvent.CLICK, onClickRegister, false, 0, true);
main.logout_but.visible = false;
main.logout_but.buttonMode = true;
main.logout_but.mouseChildren = false;
main.logout_but.addEventListener(MouseEvent.CLICK, onClickLogout, false, 0, true);
}
private function onPlayerUpdated(e:Event):void{
updateFields((Player.me as FreeKickPlayer));
}
public function setPlayer($player:Player):void{
}
private function updateFields($player:FreeKickPlayer):void{
main.title_txt.text = $player.name;
if ($player.isGuest){
main.registerPrompt.visible = true;
main.logout_but.visible = false;
} else {
main.registerPrompt.visible = false;
main.logout_but.visible = true;
main.rating_txt.text = String($player.rating);
main.played_txt.text = String($player.played);
main.won_txt.text = String($player.won);
main.lost_txt.text = String($player.lost);
};
}
private function onClickLogout(e:MouseEvent):void{
Settings.set({isUserDisconnect:true});
gameServer.addEventListener(GameServerEvent.DISCONNECTED, onServerDisconnection, false, 0, true);
userHandle.logout();
gameServer.disconnect();
}
private function onClickRegister(e:MouseEvent):void{
WindowManager.openWindow("Register", true);
}
private function onReceivePlayerData(e:GameServerEvent):void{
var player:FreeKickPlayer = e.params.player;
if (player.isUser){
updateFields(player);
};
}
private function onServerDisconnection(e:GameServerEvent):void{
Settings.set({isUserDisconnect:false});
WindowManager.openWindow("GameSelection");
}
public function setUserHandle($userHandle:UserHandle):void{
userHandle = $userHandle;
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
gameServer.addEventListener(GameServerEvent.RECEIVE_PLAYER_DATA, onReceivePlayerData, false, 0, true);
}
public function setUserInfo($userInfo:UserInfo):void{
userInfo = $userInfo;
}
}
}//package com.freekickfusion.ui.uiframe
Section 93
//RightPanel (com.freekickfusion.ui.uiframe.RightPanel)
package com.freekickfusion.ui.uiframe {
import uk.co.inbox.multiplayer.server.*;
import com.freekickfusion.game.*;
import uk.co.inbox.users.*;
import uk.co.inbox.multiplayer.player.*;
import uk.co.inbox.utils.*;
public class RightPanel {
private var multiScorePanel:MultiScorePanel;
private var singleScoreCompetitionPanel:SingleScoreCompetitionPanel;
private var adPanel1:AdPanel;
private var adPanel2:AdPanel;
private var userHandle:GuestUserHandle;
private var singleScorePanel2:SingleScorePanel2;
private var main:RightPanel_Graphic;
private var singleScorePanel:SingleScorePanel;
private var singleScoreCompetitionLoginPanel:SingleScoreCompetitionLoginPanel;
public function RightPanel($main:RightPanel_Graphic){
super();
main = $main;
var adPath1:String = (Settings.get("isCompetition")) ? "competition_ad1.xml" : "ads1.xml";
var adPath2:String = (Settings.get("isCompetition")) ? "competition_ad2.xml" : "ads2.xml";
adPanel1 = new AdPanel(main.adPanel1, ((Settings.get("isLocal")) ? "" : Settings.get("gamePath") + adPath1));
adPanel2 = new AdPanel(main.adPanel2, ((Settings.get("isLocal")) ? "" : Settings.get("gamePath") + adPath2));
singleScorePanel = new SingleScorePanel(main.singleScore);
singleScorePanel2 = new SingleScorePanel2(main.singleScore2);
singleScoreCompetitionPanel = new SingleScoreCompetitionPanel(main.singleScoreCompetition);
singleScoreCompetitionLoginPanel = new SingleScoreCompetitionLoginPanel(main.singleScoreCompetitionLogin);
multiScorePanel = new MultiScorePanel(main.multiScore);
}
public function setPlayer($player:Player):void{
multiScorePanel.setPlayer($player);
}
public function setUserHandle($userHandle:GuestUserHandle):void{
userHandle = $userHandle;
multiScorePanel.setUserHandle(userHandle);
singleScorePanel2.setUserHandle(userHandle);
}
public function showSingleScorePanel():void{
main.singleScore.visible = false;
main.singleScore2.visible = true;
main.singleScoreCompetition.visible = false;
main.singleScoreCompetitionLogin.visible = false;
main.multiScore.visible = false;
}
public function showMultiScorePanel():void{
main.singleScore.visible = false;
main.singleScore2.visible = false;
main.singleScoreCompetition.visible = false;
main.singleScoreCompetitionLogin.visible = false;
main.multiScore.visible = true;
}
public function setSingleGame($singleGame:FreeKickGameSingleEngine):void{
singleScorePanel.setSingleGame($singleGame);
singleScorePanel2.setSingleGame($singleGame);
singleScoreCompetitionPanel.setSingleGame($singleGame);
}
public function setGameServer($gameServer:GameServer):void{
multiScorePanel.setGameServer($gameServer);
}
}
}//package com.freekickfusion.ui.uiframe
Section 94
//SingleScoreCompetitionLoginPanel (com.freekickfusion.ui.uiframe.SingleScoreCompetitionLoginPanel)
package com.freekickfusion.ui.uiframe {
import flash.events.*;
import uk.co.inbox.windows.*;
import com.freekickfusion.game.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class SingleScoreCompetitionLoginPanel {
private var main:SingleScoreCompetitionLoginPanel_Graphic;
private var singleGame:FreeKickGameSingleEngine;
private var loginButton:ButtonLobby2;
public function SingleScoreCompetitionLoginPanel($main:SingleScoreCompetitionLoginPanel_Graphic){
super();
main = $main;
loginButton = new ButtonLobby2(main.login_but, LangStrings.multiLoginLogin);
loginButton.addEventListener(Button2.CLICK, onClickLogin, false, 0, true);
loginButton.refreshLang();
}
private function onClickLogin(e:Event):void{
WindowManager.openWindow("LoginCompetition");
}
}
}//package com.freekickfusion.ui.uiframe
Section 95
//SingleScoreCompetitionPanel (com.freekickfusion.ui.uiframe.SingleScoreCompetitionPanel)
package com.freekickfusion.ui.uiframe {
import flash.events.*;
import uk.co.inbox.windows.*;
import com.freekickfusion.game.*;
import uk.co.inbox.score.events.*;
import flash.utils.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class SingleScoreCompetitionPanel {
private var main:SingleScoreCompetitionPanel_Graphic;
private var singleGame:FreeKickGameSingleEngine;
private var viewStandingsBut:ButtonLobby2;
public function SingleScoreCompetitionPanel($main:SingleScoreCompetitionPanel_Graphic){
super();
main = $main;
viewStandingsBut = new ButtonLobby2(main.viewstandings_but, "View Standings");
viewStandingsBut.refreshLang();
viewStandingsBut.addEventListener(Button2.CLICK, onClickViewStandings, false, 0, true);
}
private function onClickViewStandings(e:Event):void{
WindowManager.openWindow("SingleViewStandingsCompetition", getQualifiedClassName(WindowManager.currentWindow).split("::")[1]);
}
private function onGlobalRankingUpdated(e:ScoreEvent=null):void{
main.ranking_txt.text = String(((singleGame.mainScore.ranking == -1)) ? "-" : singleGame.mainScore.ranking);
}
private function onBestScoreUpdated(e:ScoreEvent=null):void{
main.bestscore_txt.text = String(singleGame.mainScore.bestScore);
onGlobalRankingUpdated();
}
public function setSingleGame($singleGame:FreeKickGameSingleEngine):void{
singleGame = $singleGame;
singleGame.mainScore.addEventListener(ScoreEvent.BEST_SCORE_UPDATED, onBestScoreUpdated, false, 0, true);
singleGame.mainScore.globalRanking.addEventListener(ScoreEvent.GLOBAL_RANKING_LOADED, onGlobalRankingUpdated, false, 0, true);
onBestScoreUpdated();
}
}
}//package com.freekickfusion.ui.uiframe
Section 96
//SingleScorePanel (com.freekickfusion.ui.uiframe.SingleScorePanel)
package com.freekickfusion.ui.uiframe {
import com.freekickfusion.game.*;
import uk.co.inbox.score.events.*;
public class SingleScorePanel {
private var main:SingleScorePanel_Graphic;
private var singleGame:FreeKickGameSingleEngine;
public function SingleScorePanel($main:SingleScorePanel_Graphic){
super();
main = $main;
}
private function onGlobalRankingUpdated(e:ScoreEvent=null):void{
main.ranking_txt.text = String(((singleGame.mainScore.ranking == -1)) ? "-" : singleGame.mainScore.ranking);
}
private function onBestScoreUpdated(e:ScoreEvent=null):void{
main.bestscore_txt.text = String(singleGame.mainScore.bestScore);
onGlobalRankingUpdated();
}
public function setSingleGame($singleGame:FreeKickGameSingleEngine):void{
singleGame = $singleGame;
singleGame.mainScore.addEventListener(ScoreEvent.BEST_SCORE_UPDATED, onBestScoreUpdated, false, 0, true);
singleGame.mainScore.globalRanking.addEventListener(ScoreEvent.GLOBAL_RANKING_LOADED, onGlobalRankingUpdated, false, 0, true);
onBestScoreUpdated();
}
}
}//package com.freekickfusion.ui.uiframe
Section 97
//SingleScorePanel2 (com.freekickfusion.ui.uiframe.SingleScorePanel2)
package com.freekickfusion.ui.uiframe {
import flash.events.*;
import uk.co.inbox.windows.*;
import com.freekickfusion.game.*;
import uk.co.inbox.users.*;
import uk.co.inbox.users.items.*;
import uk.co.inbox.score.events.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
public class SingleScorePanel2 {
private var userHandle:GuestUserHandle;
private var main:SingleScorePanel2_Graphic;
private var singleGame:FreeKickGameSingleEngine;
public function SingleScorePanel2($main:SingleScorePanel2_Graphic){
super();
main = $main;
var registerButton:ButtonLobby2 = new ButtonLobby2(main.registerPrompt.register_but, LangStrings.panelRegisterPrompt);
registerButton.refreshLang();
main.registerPrompt.buttonMode = true;
main.registerPrompt.mouseChildren = false;
main.registerPrompt.addEventListener(MouseEvent.CLICK, onClickRegister, false, 0, true);
}
private function updateFields():void{
if (!userHandle.loggedIn){
main.registerPrompt.visible = true;
main.logout_but.visible = false;
main.title_txt.text = "YOUR STATS";
} else {
main.registerPrompt.visible = false;
main.logout_but.visible = true;
main.title_txt.text = userHandle.userDetails.username;
main.bestscore_txt.text = (userHandle.userDetails.scores[0] as ScoreInfo).score;
};
}
private function onGlobalRankingUpdated(e:ScoreEvent=null):void{
main.ranking_txt.text = String(((singleGame.mainScore.ranking == -1)) ? "-" : singleGame.mainScore.ranking);
}
private function onBestScoreUpdated(e:ScoreEvent=null):void{
main.bestscore_txt.text = String(singleGame.mainScore.bestScore);
onGlobalRankingUpdated();
}
public function setUserHandle($userHandle:GuestUserHandle):void{
userHandle = $userHandle;
updateFields();
}
private function onClickRegister(e:MouseEvent):void{
WindowManager.openWindow("Register", true);
}
public function setSingleGame($singleGame:FreeKickGameSingleEngine):void{
singleGame = $singleGame;
singleGame.mainScore.addEventListener(ScoreEvent.BEST_SCORE_UPDATED, onBestScoreUpdated, false, 0, true);
singleGame.mainScore.globalRanking.addEventListener(ScoreEvent.GLOBAL_RANKING_LOADED, onGlobalRankingUpdated, false, 0, true);
onBestScoreUpdated();
}
}
}//package com.freekickfusion.ui.uiframe
Section 98
//UIFrame (com.freekickfusion.ui.uiframe.UIFrame)
package com.freekickfusion.ui.uiframe {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.windows.*;
import com.freekickfusion.game.*;
import uk.co.inbox.users.*;
import uk.co.inbox.multiplayer.player.*;
import flash.net.*;
import flash.display.*;
import uk.co.inbox.utils.*;
import flash.media.*;
public class UIFrame extends Sprite {
private var rightPanel:RightPanel;
private var multiGame:FreeKickGameMultiEngine;
private var header:Header;
private var chat:Chat;
private var singleGame:FreeKickGameSingleEngine;
private var main:UIFrame_Graphic;
public function UIFrame(){
super();
main = new UIFrame_Graphic();
addChild(main);
main.mainmenu_but.buttonMode = true;
main.mainmenu_but.mouseChildren = false;
main.mainmenu_but.addEventListener(MouseEvent.CLICK, onClickMainMenu, false, 0, true);
header = new Header(main.header);
rightPanel = new RightPanel(main.rightPanel);
chat = new Chat(main.chat);
chat.visible = false;
setVolume(CustomSharedObject.get("isSoundOn", true));
main.sound_but.addEventListener(MouseEvent.CLICK, onToggleSound, false, 0, true);
main.feedback_but.addEventListener(MouseEvent.CLICK, onFeedback, false, 0, true);
}
private function onClickMainMenu(e:MouseEvent):void{
WindowManager.openWindow("GameSelection");
}
private function onFeedback(e:MouseEvent):void{
navigateToURL(new URLRequest("mailto:rwallis@inbox.co.uk?subject=Freekick Fusion"));
}
public function resetChat():void{
chat.reset();
}
public function setMultiGame($multiGame:FreeKickGameMultiEngine):void{
multiGame = $multiGame;
}
public function setUserHandle($userHandle:GuestUserHandle):void{
rightPanel.setUserHandle($userHandle);
}
public function setGameServer($gameServer:GameServer):void{
chat.setGameServer($gameServer);
rightPanel.setGameServer($gameServer);
}
private function setVolume($isOn:Boolean):void{
var sT:SoundTransform = SoundMixer.soundTransform;
sT.volume = ($isOn) ? 1 : 0;
SoundMixer.soundTransform = sT;
CustomSharedObject.set({isSoundOn:$isOn});
main.sound_txt.text = ((sT.volume == 1)) ? "SOUND: ON" : "SOUND: OFF";
}
public function setVersion($version:String):void{
main.version_txt.text = ("v " + $version);
}
public function showSingleScorePanel():void{
rightPanel.showSingleScorePanel();
}
public function setPlayer($player:Player):void{
rightPanel.setPlayer($player);
}
public function showMainMenuButton():void{
main.mainmenu_but.visible = true;
}
public function setSingleGame($singleGame:FreeKickGameSingleEngine):void{
singleGame = $singleGame;
rightPanel.setSingleGame(singleGame);
}
public function hideMainMenuButton():void{
main.mainmenu_but.visible = false;
}
public function showMultiScorePanel():void{
rightPanel.showMultiScorePanel();
}
public function showChat():void{
chat.visible = true;
}
public function hideChat():void{
chat.visible = false;
}
private function onToggleSound(e:MouseEvent):void{
var sT:SoundTransform = SoundMixer.soundTransform;
setVolume(((sT.volume == 1)) ? false : true);
}
private function onClickAwards(e:MouseEvent):void{
WindowManager.openWindow("SingleAwards");
}
}
}//package com.freekickfusion.ui.uiframe
Section 99
//FreeKickWindowManager (com.freekickfusion.ui.windows.FreeKickWindowManager)
package com.freekickfusion.ui.windows {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.windows.*;
import com.freekickfusion.game.*;
import com.freekickfusion.ui.uiframe.*;
import uk.co.inbox.users.*;
import flash.display.*;
public class FreeKickWindowManager extends WindowManager {
private var singleGame:FreeKickGameSingleEngine;
private var userHandle:UserHandle;
private var gameServer:GameServer;
private var uiFrame:UIFrame;
private var multiGame:FreeKickGameMultiEngine;
public function FreeKickWindowManager($windowHolder:Sprite, $initWindowList:Array, $uiFrame:UIFrame, $gameServer:GameServer, $userHandle:UserHandle, $singleGame:FreeKickGameSingleEngine, $multiGame:FreeKickGameMultiEngine){
uiFrame = $uiFrame;
gameServer = $gameServer;
userHandle = $userHandle;
singleGame = $singleGame;
multiGame = $multiGame;
super($windowHolder, $initWindowList);
isDebugMode = true;
}
override protected function initWindows():void{
var win:GameWindow;
for each (win in windowList) {
win.setUIFrame(uiFrame);
win.setGameServer(gameServer);
win.setUserHandle(userHandle);
win.setSingleGame(singleGame);
win.setMultiGame(multiGame);
};
super.initWindows();
}
}
}//package com.freekickfusion.ui.windows
Section 100
//GameSelection (com.freekickfusion.ui.windows.GameSelection)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.language.*;
import uk.co.inbox.tracking.*;
public class GameSelection extends GameWindow {
private var main:Window_GameSelection;
public function GameSelection(){
super();
}
override public function init():void{
main = new Window_GameSelection();
addChild(main);
main.single_but.buttonMode = true;
main.single_but.mouseChildren = false;
main.single_but.addEventListener(MouseEvent.CLICK, onClickSingle, false, 0, true);
main.multiplayer_but.buttonMode = true;
main.multiplayer_but.mouseChildren = false;
main.multiplayer_but.addEventListener(MouseEvent.CLICK, onClickMulti, false, 0, true);
}
private function onClickSingle(e:MouseEvent):void{
InboxTag.callTag(InboxTagData.SINGLE_PLAYER);
windowManager.openWindow("SingleHowToPlay");
}
private function onClickMulti(e:MouseEvent):void{
var loginCmd:LoginCommand = userHandle.init(false);
InboxTag.callTag(InboxTagData.MULTIPLAYER);
if (loginCmd == null){
windowManager.openWindow("MultiLogin");
} else {
windowManager.openWindow("MultiConnecting");
};
}
override public function refreshLang():void{
main.title_txt.htmlText = (("<b>" + getText(LangStrings.gameSelectionIntro)) + "</b>");
trace((" getText(LangStrings.gameSelectionIntro):" + getText(LangStrings.gameSelectionIntro)));
main.single_but.label_txt.text = getText(LangStrings.singlePlayer).toUpperCase();
main.multiplayer_but.label_txt.text = getText(LangStrings.multiplayer).toUpperCase();
}
public function openDisplay():void{
super.open();
uiFrame.hideMainMenuButton();
uiFrame.showSingleScorePanel();
}
}
}//package com.freekickfusion.ui.windows
Section 101
//GameWindow (com.freekickfusion.ui.windows.GameWindow)
package com.freekickfusion.ui.windows {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.windows.*;
import com.freekickfusion.game.*;
import com.freekickfusion.ui.uiframe.*;
import uk.co.inbox.users.*;
import gs.*;
import gs.easing.*;
public class GameWindow extends AnimWindow {
protected var multiGame:FreeKickGameMultiEngine;
protected var userHandle:UserHandle;
protected var gameServer:GameServer;
protected var uiFrame:UIFrame;
protected var singleGame:FreeKickGameSingleEngine;
public function GameWindow(){
super();
}
public function setUserHandle($userHandle:UserHandle):void{
userHandle = $userHandle;
}
public function setMultiGame($multiGame:FreeKickGameMultiEngine):void{
multiGame = $multiGame;
}
override protected function startOpen():void{
filters = [];
alpha = 1;
TweenMax.from(this, 0.2, {alpha:0, blurFilter:{blurX:80, blurY:10}, ease:Quad.easeOut, onComplete:completeOpen});
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
}
public function setSingleGame($singleGame:FreeKickGameSingleEngine):void{
singleGame = $singleGame;
}
override protected function startClose():void{
TweenMax.to(this, 0.2, {alpha:1, blurFilter:{blurX:80, blurY:10}, ease:Quad.easeIn, onComplete:completeClose});
}
public function setUIFrame($uiFrame:UIFrame):void{
uiFrame = $uiFrame;
}
}
}//package com.freekickfusion.ui.windows
Section 102
//LoggingIn (com.freekickfusion.ui.windows.LoggingIn)
package com.freekickfusion.ui.windows {
import uk.co.inbox.users.commands.events.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.language.*;
public class LoggingIn extends GameWindow {
private var loginCommand:LoginCommand;
private var main:Window_LoggingIn;
public function LoggingIn(){
super();
}
override public function init():void{
main = new Window_LoggingIn();
addChild(main);
}
private function onLogInSuccess(e:CommandEvent):void{
trace("onLogInSuccess");
loginCommand.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onLogInSuccess);
loginCommand.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onLogInFailure);
windowManager.openWindow("SingleHowToPlay");
uiFrame.showSingleScorePanel();
}
private function onLogInFailure(e:CommandEvent):void{
trace("onLogInFailure");
loginCommand.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onLogInSuccess);
loginCommand.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onLogInFailure);
windowManager.openWindow("Login", e.message);
}
public function openDisplay($loginCommand:LoginCommand):void{
loginCommand = $loginCommand;
loginCommand.addEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onLogInSuccess, false, 0, true);
loginCommand.addEventListener(CommandEvent.EVENT_COMMAND_FAIL, onLogInFailure, false, 0, true);
super.open();
}
override protected function completeOpen():void{
super.completeOpen();
userHandle.runCommand(loginCommand);
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.loggingInTitle).toUpperCase();
}
}
}//package com.freekickfusion.ui.windows
Section 103
//LoginCompetition (com.freekickfusion.ui.windows.LoginCompetition)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.form.events.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.form.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class LoginCompetition extends GameWindow {
private var guestLoginButton:ButtonLobby2;
private var isGuestSubmit:Boolean;// = false
private var main:Window_LoginCompetition;
private var inputGuestName:FormTextField;
private var inputGuestPass:FormPasswordField;
private var inputUserName:FormTextField;
private var inputUserPass:FormPasswordField;
private var userForm:Form;
private var userLoginButton:ButtonLobby2;
private var registerButton:ButtonLobby2;
private var rememberElement:FormCustomCheckBox;
private var guestForm:Form;
public function LoginCompetition(){
super();
}
override public function init():void{
main = new Window_LoginCompetition();
addChild(main);
inputUserName = new FormTextField(main.user_name_txt, FormTextField.VALIDATION_TEXT, LangStrings.username, "Enter your name");
inputUserPass = new FormPasswordField(main.user_password_txt, FormTextField.VALIDATION_PASSWORD, LangStrings.password, "Enter your password");
rememberElement = new FormCustomCheckBox(main.rem_chk, null, false, false);
userForm = new Form([inputUserName, inputUserPass]);
userForm.addEventListener(FormEvent.FORM_SUBMIT_SUCCESS, onUserFormSubmit, false, 0, true);
userLoginButton = new ButtonLobby2(main.user_login_but, LangStrings.multiLoginLogin);
userLoginButton.addEventListener(Button2.CLICK, userForm.submit, false, 0, true);
registerButton = new ButtonLobby2(main.register_but, LangStrings.multiLoginRegister);
registerButton.addEventListener(Button2.CLICK, onClickRegister, false, 0, true);
}
public function openDisplay($errorMessage:String=""):void{
main.user_error_txt.text = "";
main.user_error_txt.text = $errorMessage;
super.open();
uiFrame.showMainMenuButton();
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.multiLoginTitle).toUpperCase();
userLoginButton.refreshLang();
registerButton.refreshLang();
}
private function onClickRegister(e:Event):void{
windowManager.openWindow("RegisterCompetition");
}
private function onUserFormSubmit(e:FormEvent):void{
isGuestSubmit = false;
var cmd:LoginCommand = new LoginCommand(inputUserName.text, inputUserPass.text, false, rememberElement.value);
windowManager.openWindow("LoggingIn", cmd);
}
}
}//package com.freekickfusion.ui.windows
Section 104
//MultiConnecting (com.freekickfusion.ui.windows.MultiConnecting)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.player.*;
import uk.co.inbox.users.commands.events.*;
import uk.co.inbox.users.commands.concrete.*;
import flash.utils.*;
import uk.co.inbox.language.*;
import uk.co.inbox.tracking.*;
public class MultiConnecting extends GameWindow {
private var guestUsername:String;
private var main:Window_MultiConnecting;
private var messageTimer:Timer;
public function MultiConnecting(){
super();
}
private function onLoginSuccess(e:GameServerEvent):void{
if (userHandle.loggedIn){
InboxTag.callTag(InboxTagData.PLAY_MEMBER, userHandle.userDetails.username);
} else {
InboxTag.callTag(InboxTagData.PLAY_GUEST);
};
uiFrame.setPlayer((e.params.player as Player));
windowManager.openWindow("MultiLobbyView");
}
override protected function completeOpen():void{
super.completeOpen();
var loginCmd:LoginCommand = userHandle.init(false);
if (loginCmd == null){
gameServer.connect();
} else {
loginCmd.addEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onUserLoginComplete, false, 0, true);
loginCmd.addEventListener(CommandEvent.EVENT_COMMAND_FAIL, onUserLoginFailed, false, 0, true);
userHandle.runCommand(loginCmd);
};
}
private function onConnectionSuccess(e:GameServerEvent):void{
if (userHandle.loggedIn){
gameServer.login(userHandle.userDetails.username, userHandle.userDetails.key);
} else {
gameServer.loginAsGuest(guestUsername);
};
}
private function onUserLoginComplete(e:CommandEvent):void{
gameServer.connect();
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.multiConnectingTitle).toUpperCase();
}
override public function init():void{
main = new Window_MultiConnecting();
addChild(main);
gameServer.addEventListener(GameServerEvent.CONNECT_SUCCESS, onConnectionSuccess, false, 0, true);
gameServer.addEventListener(GameServerEvent.CONNECT_FAILED, onConnectionFailed, false, 0, true);
gameServer.addEventListener(GameServerEvent.LOGIN_SUCCESS, onLoginSuccess, false, 0, true);
gameServer.addEventListener(GameServerEvent.LOGIN_FAILED, onLoginFailed, false, 0, true);
messageTimer = new Timer(400);
messageTimer.addEventListener(TimerEvent.TIMER, onMessageTimer, false, 0, true);
}
private function onUserLoginFailed(e:CommandEvent):void{
windowManager.openWindow("MultiLogin", e.message);
}
private function onLoginFailed(e:GameServerEvent):void{
InboxTag.callTag(InboxTagData.LOGIN_ERROR, e.params.error);
windowManager.openWindow("MultiLogin", e.params.error);
}
public function openDisplay($guestUsername:String=""):void{
guestUsername = $guestUsername;
messageTimer.start();
super.open();
}
private function onConnectionFailed(e:GameServerEvent):void{
InboxTag.callTag(InboxTagData.SERVER_ERROR, e.params.error);
windowManager.openWindow("MultiConnectionFailed");
}
private function onMessageTimer(e:TimerEvent):void{
var msgStr:String = "Connecting to game server";
var rem:int = ((e.target as Timer).currentCount % 4);
var i:int;
while (i < rem) {
msgStr = (msgStr + ".");
i++;
};
main.body_txt.text = msgStr;
}
override protected function completeClose():void{
super.completeClose();
messageTimer.stop();
}
}
}//package com.freekickfusion.ui.windows
Section 105
//MultiConnectionFailed (com.freekickfusion.ui.windows.MultiConnectionFailed)
package com.freekickfusion.ui.windows {
import com.freekickfusion.ui.buttons.*;
public class MultiConnectionFailed extends GameWindow {
private var main:Window_MultiConnectionFailed;
private var playBut:ButtonMain;
public function MultiConnectionFailed(){
super();
}
override public function init():void{
main = new Window_MultiConnectionFailed();
addChild(main);
}
override public function refreshLang():void{
}
public function openDisplay($errorMessage:String=""):void{
super.open();
}
}
}//package com.freekickfusion.ui.windows
Section 106
//MultiConnectionLost (com.freekickfusion.ui.windows.MultiConnectionLost)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class MultiConnectionLost extends GameWindow {
private var main:Window_MultiConnectionLost;
private var backBut:ButtonMain;
public function MultiConnectionLost(){
super();
}
override public function init():void{
main = new Window_MultiConnectionLost();
addChild(main);
backBut = new ButtonMain(main.mainmenu_but, LangStrings.mainMenu);
backBut.addEventListener(Button2.CLICK, onClickBack, false, 0, true);
}
override public function refreshLang():void{
backBut.refreshLang();
}
private function onClickBack(e:Event):void{
windowManager.openWindow("GameSelection");
}
public function openDisplay($errorMessage:String=""):void{
super.open();
}
}
}//package com.freekickfusion.ui.windows
Section 107
//MultiGameHolder (com.freekickfusion.ui.windows.MultiGameHolder)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.input.*;
import flash.text.*;
import flash.display.*;
import uk.co.inbox.game.score.events.*;
import uk.co.inbox.game.timer.events.*;
import com.freekickfusion.multiplayer.server.*;
import com.freekickfusion.game.score.*;
import com.freekickfusion.multiplayer.lobby.player.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.hub.*;
public class MultiGameHolder extends GameWindow {
private var isTimerPaused:Boolean;// = false
private var main:Window_MultiGameHolder;
private var gameHolder:Sprite;
public function MultiGameHolder(){
super();
}
private function onTargetUpdate(e:GameScoreEvent):void{
}
override protected function completeClose():void{
super.completeClose();
main.scores1.visible = true;
}
private function onUpdateScore1(e:GameScoreEvent):void{
updateScoreList(1, (e.target as MultiGoalScore).scoreList);
}
private function onUpdateScore2(e:GameScoreEvent):void{
updateScoreList(2, (e.target as MultiGoalScore).scoreList);
}
private function updateScoreList($id:int, $scoreList:Array):void{
var i:int;
trace(("MultiGameHolder.updateScoreList - $id:" + $id));
if (((((($scoreList.length >= 5)) && (($id == 2)))) || (((($scoreList.length >= 6)) && (($id == 1)))))){
main.scores1.visible = false;
main.scores2.visible = true;
if ($id == 1){
if ($scoreList[($scoreList.length - 1)] == 1){
main.scores2[(("p" + $id) + "_ball")].gotoAndStop(3);
} else {
main.scores2[(("p" + $id) + "_ball")].gotoAndStop(4);
};
} else {
if ($id == 2){
main.scores2[(("p" + $id) + "_ball")].gotoAndStop(1);
};
};
} else {
main.scores1.visible = true;
main.scores2.visible = false;
i = 1;
while (i <= 5) {
main.scores1[((("p" + $id) + "_ball") + i)].gotoAndStop(1);
i++;
};
i = 0;
while (i < $scoreList.length) {
if ($scoreList[i] == 1){
main.scores1[((("p" + $id) + "_ball") + (i + 1))].gotoAndStop(3);
} else {
if ($scoreList[i] == 0){
main.scores1[((("p" + $id) + "_ball") + (i + 1))].gotoAndStop(4);
};
};
i++;
};
};
}
private function onTimerUpdate(e:GameCountdownEvent):void{
main.time_txt.text = MathTools.formatTime(e.timeLeft, "ss:msms");
}
override public function init():void{
main = new Window_MultiGameHolder();
addChild(main);
main.lobby_but.buttonMode = true;
main.lobby_but.mouseChildren = false;
main.lobby_but.addEventListener(MouseEvent.CLICK, onClickLobby, false, 0, true);
gameHolder = new Sprite();
addChild(gameHolder);
multiGame.gameTimer.addEventListener(GameCountdownEvent.UPDATE, onTimerUpdate, false, 0, true);
multiGame.gameTimer.addEventListener(GameCountdownEvent.TIME_UP, onTimerFinished, false, 0, true);
gameHolder.addChild(multiGame);
gameServer.addEventListener(GameServerEvent.START_GAME, onStartGame, false, 0, true);
gameServer.addEventListener(FreeKickGameServerEvent.START_TURN, onStartTurn, false, 0, true);
main.toggleTimerBut.addEventListener(MouseEvent.MOUSE_OVER, onClickToggleTimer, false, 0, true);
var keySequence:KeySequence = KeyBoardManager.createKeySequenceEvent("debugon");
keySequence.addEventListener(KeySequence.ACTIVATED, onKeySequenceActivated, false, 0, true);
addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
reset();
}
private function onStartGame(e:GameServerEvent):void{
updatePlayersDetails(e.params.playerList);
reset();
}
private function reset():void{
trace("MultiGameHolder.reset");
var i = 1;
while (i <= 5) {
main.scores1[("p1_ball" + i)].gotoAndStop(1);
main.scores1[("p2_ball" + i)].gotoAndStop(1);
i++;
};
main.scores2.p1_ball.gotoAndStop(1);
main.scores2.p2_ball.gotoAndStop(1);
main.scores2.visible = false;
}
public function openDisplay():void{
var playerList:Array = multiGame.playerList;
var player1:FreeKickGamePlayer = (playerList[0] as FreeKickGamePlayer);
var player2:FreeKickGamePlayer = (playerList[1] as FreeKickGamePlayer);
(playerList[0] as FreeKickGamePlayer).goalScore.addEventListener(GameScoreEvent.UPDATE, onUpdateScore1, false, 0, true);
(playerList[1] as FreeKickGamePlayer).goalScore.addEventListener(GameScoreEvent.UPDATE, onUpdateScore2, false, 0, true);
uiFrame.showChat();
super.open();
}
private function updatePlayersDetails($playerList:Array):void{
var playerList:Array = $playerList;
var player1:FreeKickGamePlayer = (playerList[0] as FreeKickGamePlayer);
var player2:FreeKickGamePlayer = (playerList[1] as FreeKickGamePlayer);
TextTools.resizeTextField(main.player1_txt, 113, 18, TextFieldAutoSize.RIGHT, player1.name, 0.6);
main.player1rating_txt.text = ((player1.rating == -1)) ? "Unregistered" : player1.ratingLabel;
TextTools.resizeTextField(main.player2_txt, 119, 18, TextFieldAutoSize.LEFT, player2.name, 0.6);
main.player2rating_txt.text = ((player2.rating == -1)) ? "Unregistered" : player2.ratingLabel;
}
private function onStartTurn(e:FreeKickGameServerEvent):void{
trace(("MultiGameHolder.onStartTurn - e.params.turnIndex:" + e.params.turnIndex));
var id:int = e.params.turnIndex;
var player:FreeKickGamePlayer = multiGame.playerList[id];
trace((((" id:" + id) + ", main.scores1.visible:") + main.scores1.visible));
if (main.scores1.visible){
trace((" (player.goalScore.scoreList.length + 1):" + (player.goalScore.scoreList.length + 1)));
main.scores1[((("p" + (id + 1)) + "_ball") + (player.goalScore.scoreList.length + 1))].gotoAndStop(2);
} else {
if (main.scores2.visible){
main.scores2[(("p" + (id + 1)) + "_ball")].gotoAndStop(2);
};
};
}
override protected function completeOpen():void{
super.completeOpen();
multiGame.start();
}
private function onClickToggleTimer(e:MouseEvent):void{
if (!isTimerPaused){
multiGame.gameTimer.pause();
isTimerPaused = true;
} else {
multiGame.gameTimer.resume();
isTimerPaused = false;
};
}
private function onClickLobby(e:MouseEvent):void{
gameServer.leaveGameRoom();
}
private function onKeySequenceActivated(e:Event):void{
trace("onKeySequenceActivated");
HubLink.showAlert("Freekick Fusion", "Multiplayer Debug Mode attempted", 1);
(gameServer as FreeKickGameServer).activateDebugMode();
}
private function onEnterFrame(e:Event):void{
multiGame.update();
}
override public function close():void{
multiGame.stop();
reset();
super.close();
}
private function onTimerFinished(e:GameCountdownEvent):void{
trace((" e.timeLeft:" + e.timeLeft));
main.time_txt.text = MathTools.formatTime(e.timeLeft, "ss:msms");
}
}
}//package com.freekickfusion.ui.windows
Section 108
//MultiGameOver (com.freekickfusion.ui.windows.MultiGameOver)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.player.*;
import uk.co.inbox.language.*;
import com.freekickfusion.multiplayer.lobby.player.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class MultiGameOver extends GameWindow {
private var noBut:ButtonMain;
private var yesBut:ButtonMain;
private var main:Window_MultiGameOver;
private var backBut:ButtonMain;
private var registerBut:ButtonMain;
public function MultiGameOver(){
super();
}
override protected function completeOpen():void{
trace("MultiGameOver.completeOpen");
super.completeOpen();
uiFrame.showChat();
}
private function onClickYes(e:Event):void{
gameServer.sendReadyGame();
main.playagain_txt.text = "Waiting for opponent...";
yesBut.visible = false;
noBut.visible = false;
}
private function onAbandonGame(e:GameServerEvent):void{
trace("MultiGameOver.onAbandonGame");
uiFrame.hideChat();
uiFrame.resetChat();
yesBut.visible = false;
noBut.visible = false;
backBut.visible = true;
main.playagain_txt.text = "Your opponent has left";
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.multiGameOverTitle).toUpperCase();
yesBut.refreshLang();
noBut.refreshLang();
backBut.refreshLang();
registerBut.refreshLang();
}
private function onClickNo(e:Event):void{
gameServer.leaveGameRoom();
windowManager.openWindow("MultiLobbyView", true);
}
private function onClickRegister(e:Event):void{
gameServer.leaveGameRoom();
windowManager.openWindow("Register", true);
}
override public function init():void{
main = new Window_MultiGameOver();
addChild(main);
yesBut = new ButtonMain(main.yes_but, LangStrings.yes);
yesBut.addEventListener(Button2.CLICK, onClickYes, false, 0, true);
noBut = new ButtonMain(main.no_but, LangStrings.no);
noBut.addEventListener(Button2.CLICK, onClickNo, false, 0, true);
backBut = new ButtonMain(main.backtolobby_but, LangStrings.multiGameOverBack);
backBut.addEventListener(Button2.CLICK, onClickBack, false, 0, true);
registerBut = new ButtonMain(main.register_but, LangStrings.multiGameOverRegister);
registerBut.addEventListener(Button2.CLICK, onClickRegister, false, 0, true);
gameServer.addEventListener(GameServerEvent.START_GAME, onStartGame, false, 0, true);
gameServer.addEventListener(GameServerEvent.COMPLETE_GAME, onCompleteGame, false, 0, true);
gameServer.addEventListener(GameServerEvent.ABANDON_GAME, onAbandonGame, false, 0, true);
}
private function onCompleteGame(e:GameServerEvent):void{
var col:String;
var myPlayer:FreeKickGamePlayer;
var isInc:Boolean;
trace(("MultiGameOver.onCompleteGame - e.params.isValidGame:" + e.params.isValidGame));
backBut.visible = false;
yesBut.visible = true;
noBut.visible = true;
main.new_ranking_txt.visible = false;
main.newranking_label_txt.visible = false;
registerBut.visible = Player.me.isGuest;
main.playagain_txt.text = "Play again?";
if (e.params.isValidGame){
if (e.params.winnerId == Player.me.serverId){
main.subtitle_txt.text = "Well done, you won!";
} else {
main.subtitle_txt.text = "Better luck next time...";
};
main.new_ranking_txt.visible = !(e.params.isGuestGame);
main.newranking_label_txt.visible = !(e.params.isGuestGame);
myPlayer = (GamePlayer.me as FreeKickGamePlayer);
isInc = (myPlayer.rating > myPlayer.oldRating);
if (isInc){
col = "#009900";
} else {
col = "#ff0000";
};
main.new_ranking_txt.htmlText = ((((((("<b>" + myPlayer.rating) + "<font color='") + col) + "' size='10'> (") + (isInc) ? "+" : "") + (myPlayer.rating - myPlayer.oldRating)) + ")</font></b>");
} else {
main.subtitle_txt.text = "Game abandoned";
};
gameServer.getPlayerData(Player.me.serverId);
}
private function onStartGame(e:GameServerEvent):void{
}
private function onClickBack(e:Event):void{
gameServer.leaveGameRoom();
windowManager.openWindow("MultiLobbyView", true);
}
public function openDisplay($isAbandon:Boolean=false):void{
trace("MultiGameOver.openDisplay");
super.open();
}
override public function close():void{
trace("MultiGameOver.close");
super.close();
uiFrame.hideChat();
}
}
}//package com.freekickfusion.ui.windows
Section 109
//MultiGameReady (com.freekickfusion.ui.windows.MultiGameReady)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import flash.utils.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class MultiGameReady extends GameWindow {
private var password:String;
private var countdownLimit:int;// = 10
private var countdownTimer:Timer;
private var main:Window_MultiGameReady;
private var username:String;
private var startBut:ButtonMain;
public function MultiGameReady(){
super();
}
private function onClickStart(e:Event):void{
startBut.visible = false;
main.waiting_txt.visible = true;
gameServer.sendReadyGame();
}
private function updateText():void{
var msg:String = getText(LangStrings.multiGameReadyMessage);
main.body_txt.text = msg.split("<time>").join((countdownLimit - countdownTimer.currentCount));
}
private function onTimer(e:TimerEvent):void{
updateText();
}
override public function close():void{
super.close();
countdownTimer.stop();
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.multiGameReadyTitle).toUpperCase();
main.waiting_txt.text = getText(LangStrings.multiGameReadyWaiting);
startBut.refreshLang();
}
private function onTimerComplete(e:TimerEvent):void{
onClickStart(null);
}
override public function init():void{
main = new Window_MultiGameReady();
addChild(main);
startBut = new ButtonMain(main.start_but, LangStrings.multiGameReadyStart);
startBut.addEventListener(Button2.CLICK, onClickStart, false, 0, true);
countdownTimer = new Timer(1000, countdownLimit);
countdownTimer.addEventListener(TimerEvent.TIMER, onTimer, false, 0, true);
countdownTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete, false, 0, true);
gameServer.addEventListener(GameServerEvent.START_GAME, onStartGame, false, 0, true);
}
private function onStartGame(e:GameServerEvent):void{
windowManager.openWindow("MultiGameHolder");
}
public function openDisplay():void{
super.open();
countdownTimer.reset();
countdownTimer.start();
main.waiting_txt.visible = false;
startBut.visible = true;
updateText();
}
}
}//package com.freekickfusion.ui.windows
Section 110
//MultiGuestLogin (com.freekickfusion.ui.windows.MultiGuestLogin)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.form.events.*;
import uk.co.inbox.form.*;
import uk.co.inbox.language.*;
public class MultiGuestLogin extends GameWindow {
private var form:Form;
private var inputName:FormTextField;
private var main:Window_MultiGuestLogin;
public function MultiGuestLogin(){
super();
}
override public function init():void{
main = new Window_MultiGuestLogin();
addChild(main);
inputName = new FormTextField(main.name_txt, FormTextField.VALIDATION_TEXT, "Username", "Please enter your name");
form = new Form([inputName]);
form.addEventListener(FormEvent.FORM_SUBMIT_SUCCESS, onFormSubmit, false, 0, true);
main.enter_but.addEventListener(MouseEvent.CLICK, form.submit, false, 0, true);
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.multiLoginTitle).toUpperCase();
}
private function onFormSubmit(e:FormEvent):void{
windowManager.openWindow("MultiConnecting", inputName.text);
}
public function openDisplay($errorMessage:String=""):void{
main.error_txt.text = $errorMessage;
super.open();
}
}
}//package com.freekickfusion.ui.windows
Section 111
//MultiLobbyView (com.freekickfusion.ui.windows.MultiLobbyView)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import flash.display.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.utils.*;
import com.freekickfusion.multiplayer.lobby.*;
import uk.co.inbox.buttons.*;
public class MultiLobbyView extends GameWindow {
private var contentHolder:Sprite;
private var mainMenuButton:ButtonLobby2;
private var lobby:FreeKickLobby;
private var main:Window_MultiLobbyView;
public function MultiLobbyView(){
super();
}
private function onClickMainMenu(e:Event):void{
Settings.set({isUserDisconnect:true});
gameServer.addEventListener(GameServerEvent.DISCONNECTED, onDisconnected, false, 0, true);
gameServer.disconnect();
}
private function onEnterGameRoom(e:GameServerEvent):void{
windowManager.openWindow("MultiGameReady");
}
override public function refreshLang():void{
mainMenuButton.refreshLang();
}
override public function init():void{
main = new Window_MultiLobbyView();
addChild(main);
lobby = new FreeKickLobby(gameServer, userHandle, multiGame);
addChild(lobby);
mainMenuButton = new ButtonLobby2(main.mainmenu_but, "Main Menu");
mainMenuButton.addEventListener(Button2.CLICK, onClickMainMenu, false, 0, true);
gameServer.addEventListener(GameServerEvent.INIT_GAME, onEnterGameRoom, false, 0, true);
gameServer.addEventListener(GameServerEvent.WATCH_GAME, onWatchGameRoom, false, 0, true);
}
public function openDisplay($isRefreshLobby:Boolean=false):void{
super.open();
if ($isRefreshLobby){
gameServer.refreshLobby();
};
uiFrame.hideChat();
uiFrame.hideMainMenuButton();
uiFrame.showMultiScorePanel();
}
private function onDisconnected(e:GameServerEvent):void{
Settings.set({isUserDisconnect:false});
windowManager.openWindow("GameSelection");
}
private function onWatchGameRoom(e:GameServerEvent):void{
windowManager.openWindow("GameHolderCheckoutMulti", true);
}
}
}//package com.freekickfusion.ui.windows
Section 112
//MultiLoggingIn (com.freekickfusion.ui.windows.MultiLoggingIn)
package com.freekickfusion.ui.windows {
import uk.co.inbox.users.commands.events.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.language.*;
public class MultiLoggingIn extends GameWindow {
private var loginCommand:LoginCommand;
private var main:Window_MultiLoggingIn;
public function MultiLoggingIn(){
super();
}
override public function init():void{
main = new Window_MultiLoggingIn();
addChild(main);
}
private function onLogInSuccess(e:CommandEvent):void{
trace("onLogInSuccess");
loginCommand.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onLogInSuccess);
loginCommand.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onLogInFailure);
windowManager.openWindow("MultiConnecting");
}
private function onLogInFailure(e:CommandEvent):void{
trace("onLogInFailure");
loginCommand.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onLogInSuccess);
loginCommand.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onLogInFailure);
windowManager.openWindow("MultiLogin", e.message);
}
public function openDisplay($loginCommand:LoginCommand):void{
loginCommand = $loginCommand;
loginCommand.addEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onLogInSuccess, false, 0, true);
loginCommand.addEventListener(CommandEvent.EVENT_COMMAND_FAIL, onLogInFailure, false, 0, true);
super.open();
}
override protected function completeOpen():void{
super.completeOpen();
userHandle.runCommand(loginCommand);
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.loggingInTitle).toUpperCase();
}
}
}//package com.freekickfusion.ui.windows
Section 113
//MultiLogin (com.freekickfusion.ui.windows.MultiLogin)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.form.events.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.form.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class MultiLogin extends GameWindow {
private var guestLoginButton:ButtonLobby2;
private var isGuestSubmit:Boolean;// = false
private var main:Window_MultiLogin;
private var inputGuestName:FormTextField;
private var inputGuestPass:FormPasswordField;
private var inputUserName:FormTextField;
private var inputUserPass:FormPasswordField;
private var userForm:Form;
private var userLoginButton:ButtonLobby2;
private var registerButton:ButtonLobby2;
private var rememberElement:FormCustomCheckBox;
private var guestForm:Form;
public function MultiLogin(){
super();
}
private function onUserFormFocus(e:FormEvent):void{
userForm.enable();
guestForm.disable();
}
override public function init():void{
main = new Window_MultiLogin();
addChild(main);
inputUserName = new FormTextField(main.user_name_txt, FormTextField.VALIDATION_TEXT, LangStrings.username, "Enter your name");
inputUserPass = new FormPasswordField(main.user_password_txt, FormTextField.VALIDATION_PASSWORD, LangStrings.password, "Enter your password");
rememberElement = new FormCustomCheckBox(main.rem_chk, null, false, false);
userForm = new Form([inputUserName, inputUserPass]);
userForm.addEventListener(FormEvent.FORM_SUBMIT_SUCCESS, onUserFormSubmit, false, 0, true);
userForm.addEventListener(FormEvent.ELEMENT_FOCUS, onUserFormFocus, false, 0, true);
userLoginButton = new ButtonLobby2(main.user_login_but, LangStrings.multiLoginLogin);
userLoginButton.addEventListener(Button2.CLICK, userForm.submit, false, 0, true);
inputGuestName = new FormTextField(main.guest_name_txt, FormTextField.VALIDATION_TEXT, LangStrings.username, "Enter a name");
main.guest_name_txt.restrict = "0-9A-Za-z_";
guestForm = new Form([inputGuestName]);
guestForm.addEventListener(FormEvent.FORM_SUBMIT_SUCCESS, onGuestFormSubmit, false, 0, true);
guestForm.addEventListener(FormEvent.ELEMENT_FOCUS, onGuestFormFocus, false, 0, true);
guestLoginButton = new ButtonLobby2(main.guest_login_but, LangStrings.multiLoginLogin);
guestLoginButton.addEventListener(Button2.CLICK, guestForm.submit, false, 0, true);
registerButton = new ButtonLobby2(main.register_but, LangStrings.multiLoginRegister);
registerButton.addEventListener(Button2.CLICK, onClickRegister, false, 0, true);
}
private function onGuestFormSubmit(e:FormEvent):void{
isGuestSubmit = true;
windowManager.openWindow("MultiConnecting", inputGuestName.text);
}
public function openDisplay($errorMessage:String=""):void{
main.guest_error_txt.text = "";
main.user_error_txt.text = "";
if (isGuestSubmit){
main.guest_error_txt.text = $errorMessage;
} else {
main.user_error_txt.text = $errorMessage;
};
super.open();
uiFrame.showMainMenuButton();
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.multiLoginTitle).toUpperCase();
userLoginButton.refreshLang();
guestLoginButton.refreshLang();
registerButton.refreshLang();
}
private function onClickRegister(e:Event):void{
windowManager.openWindow("Register", false, "");
}
private function onUserFormSubmit(e:FormEvent):void{
isGuestSubmit = false;
var cmd:LoginCommand = new LoginCommand(inputUserName.text, inputUserPass.text, false, rememberElement.value);
windowManager.openWindow("MultiLoggingIn", cmd);
}
private function onGuestFormFocus(e:FormEvent):void{
userForm.disable();
guestForm.enable();
}
}
}//package com.freekickfusion.ui.windows
Section 114
//Register (com.freekickfusion.ui.windows.Register)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.form.events.*;
import flash.net.*;
import com.freekickfusion.users.commands.*;
import flash.display.*;
import uk.co.inbox.form.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.buttons.*;
public class Register extends GameWindow {
protected var main:MovieClip;
protected var form:Form;
protected var inputPassword1:FormPasswordField;
protected var inputPassword2:FormPasswordConfirmField;
private var isShowBack:Boolean;
protected var gamenetOptin:FormCustomCheckBox;
protected var inputEmail:FormTextField;
protected var inputName:FormTextField;
protected var registerButton:ButtonLobby2;
public function Register(){
super();
}
protected function onGamenetSecurityError(e:SecurityErrorEvent):void{
trace(("Gamenet onSecurityError - e:" + e));
}
override public function init():void{
main = new Window_Register();
addChild(main);
createForm();
registerButton = new ButtonLobby2(main.register_but, LangStrings.registerRegister);
registerButton.addEventListener(Button2.CLICK, form.submit, false, 0, true);
}
public function openDisplay($isDisconnect:Boolean=false, $errorMessage:String="", $isShowBack:Boolean=false):void{
isShowBack = $isShowBack;
if ($isDisconnect){
Settings.set({isUserDisconnect:true});
gameServer.addEventListener(GameServerEvent.DISCONNECTED, onDisconnected, false, 0, true);
gameServer.disconnect();
};
main.error_txt.text = $errorMessage;
super.open();
uiFrame.showMainMenuButton();
}
protected function createForm():void{
inputName = new FormTextField(main.name_txt, FormTextField.VALIDATION_TEXT, "Enter username", "Please enter your username", "", true, 0, 12);
main.name_txt.restrict = "A-Za-z0-9";
inputPassword1 = new FormPasswordField(main.password1_txt, FormTextField.VALIDATION_PASSWORD, "Enter password", "Please enter your password");
inputPassword2 = new FormPasswordConfirmField(main.password2_txt, inputPassword1, FormTextField.VALIDATION_PASSWORD, "Confirm password", "Please confirm your password");
inputEmail = new FormTextField(main.email_txt, FormTextField.VALIDATION_EMAIL, "Enter email", "Please enter your email");
gamenetOptin = new FormCustomCheckBox(main.gamenet_chk);
form = new Form([inputName, inputPassword1, inputPassword2, inputEmail, gamenetOptin]);
gamenetOptin.setTabIndex(-1);
form.addEventListener(FormEvent.FORM_SUBMIT_SUCCESS, onFormSubmit, false, 0, true);
}
protected function onGamenetComplete(e:Event):void{
trace(("Gamenet onGamenetComplete - e:" + e));
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.registerTitle).toUpperCase();
registerButton.refreshLang();
}
protected function onGamenetIOError(e:IOErrorEvent):void{
trace(("Gamenet onIOError - e:" + e));
}
protected function onDisconnected(e:GameServerEvent):void{
gameServer.removeEventListener(GameServerEvent.DISCONNECTED, onDisconnected);
Settings.set({isUserDisconnect:false});
}
protected function onFormSubmit(e:FormEvent):void{
var req:URLRequest;
var vars:URLVariables;
var urlLoader:URLLoader;
var registerCommand:FreeKickRegisterCommand = new FreeKickRegisterCommand(inputName.text, inputPassword1.text, inputEmail.text, {}, false, "1200", gamenetOptin.value);
windowManager.openWindow("Registering", registerCommand, isShowBack);
if (gamenetOptin.value == 1){
req = new URLRequest("http://www.gamenet.com/newsletter/register/gamenet_generic_reg.php");
req.method = URLRequestMethod.POST;
vars = new URLVariables();
vars.lang = "en";
vars.email = inputEmail.text;
vars.optinstatus = "GamenetInbox";
vars.email_stmt = "the Free Kick Fusion game";
vars.source = "freekickfusion";
req.data = vars;
urlLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, onGamenetComplete);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onGamenetIOError);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onGamenetSecurityError);
urlLoader.load(req);
};
}
}
}//package com.freekickfusion.ui.windows
Section 115
//RegisterCompetition (com.freekickfusion.ui.windows.RegisterCompetition)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.form.events.*;
import flash.net.*;
import com.freekickfusion.users.commands.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class RegisterCompetition extends Register {
private var mainMenuButton:ButtonLobby2;
public function RegisterCompetition(){
super();
}
override public function init():void{
main = new Window_RegisterCompetition();
addChild(main);
createForm();
mainMenuButton = new ButtonLobby2(main.mainmenu_but, "Main Menu");
mainMenuButton.addEventListener(Button2.CLICK, onClickMainMenu, false, 0, true);
registerButton = new ButtonLobby2(main.register_but, LangStrings.registerRegister);
registerButton.addEventListener(Button2.CLICK, form.submit, false, 0, true);
main.terms_but.addEventListener(MouseEvent.CLICK, onClickTerms, false, 0, true);
}
private function onClickMainMenu(e:Event):void{
windowManager.openWindow("GameSelection");
}
override public function refreshLang():void{
registerButton.refreshLang();
mainMenuButton.refreshLang();
}
override protected function onFormSubmit(e:FormEvent):void{
var req:URLRequest;
var vars:URLVariables;
var urlLoader:URLLoader;
var registerCommand:FreeKickRegisterCommand = new FreeKickRegisterCommand(inputName.text, inputPassword1.text, inputEmail.text, {}, false, "1200", gamenetOptin.value);
windowManager.openWindow("RegisteringCompetition", registerCommand);
if (gamenetOptin.value == 1){
trace("test");
req = new URLRequest("http://www.gamenet.com/newsletter/register/gamenet_generic_reg.php");
req.method = URLRequestMethod.POST;
vars = new URLVariables();
vars.lang = "en";
vars.email = inputEmail.text;
vars.optinstatus = "GamenetInbox";
vars.email_stmt = "the Free Kick Fusion game";
vars.source = "freekickfusion";
req.data = vars;
urlLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, onGamenetComplete);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onGamenetIOError);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onGamenetSecurityError);
urlLoader.load(req);
};
}
private function onClickTerms(e:MouseEvent):void{
navigateToURL(new URLRequest("http://www.freekickfusion.com/competition/terms.html"));
}
}
}//package com.freekickfusion.ui.windows
Section 116
//Registering (com.freekickfusion.ui.windows.Registering)
package com.freekickfusion.ui.windows {
import com.freekickfusion.users.commands.*;
import uk.co.inbox.users.commands.events.*;
import uk.co.inbox.language.*;
public class Registering extends GameWindow {
private var registerCommand:FreeKickRegisterCommand;
private var isShowRegisterBack:Boolean;
private var main:Window_Registering;
public function Registering(){
super();
}
private function onInitScoreSuccess(e:CommandEvent):void{
trace("onInitScoreSuccess");
e.target.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onInitScoreSuccess);
e.target.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onInitScoreFailure);
windowManager.openWindow("MultiConnecting", userHandle.userDetails.username);
}
private function onRegisterSuccess(e:CommandEvent):void{
trace("onRegisterSuccess");
registerCommand.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onRegisterSuccess);
registerCommand.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onRegisterFailure);
windowManager.openWindow("MultiConnecting");
}
override protected function completeOpen():void{
super.completeOpen();
userHandle.runCommand(registerCommand);
}
private function onInitScoreFailure(e:CommandEvent):void{
trace("onInitScoreFailure");
e.target.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onInitScoreSuccess);
e.target.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onInitScoreFailure);
windowManager.openWindow("Register", false, e.message, isShowRegisterBack);
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.registeringTitle).toUpperCase();
}
private function onRegisterFailure(e:CommandEvent):void{
trace("onRegisterFailure");
registerCommand.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onRegisterSuccess);
registerCommand.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onRegisterFailure);
windowManager.openWindow("Register", false, e.message, isShowRegisterBack);
}
override public function init():void{
main = new Window_Registering();
addChild(main);
}
public function openDisplay($registerCommand:FreeKickRegisterCommand, $isShowRegisterBack:Boolean):void{
isShowRegisterBack = $isShowRegisterBack;
registerCommand = $registerCommand;
registerCommand.addEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onRegisterSuccess, false, 0, true);
registerCommand.addEventListener(CommandEvent.EVENT_COMMAND_FAIL, onRegisterFailure, false, 0, true);
super.open();
}
}
}//package com.freekickfusion.ui.windows
Section 117
//RegisteringCompetition (com.freekickfusion.ui.windows.RegisteringCompetition)
package com.freekickfusion.ui.windows {
import com.freekickfusion.users.commands.*;
import uk.co.inbox.users.commands.events.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.users.items.*;
import uk.co.inbox.language.*;
import uk.co.inbox.utils.*;
public class RegisteringCompetition extends GameWindow {
private var registerCommand:FreeKickRegisterCommand;
private var main:Window_Registering;
public function RegisteringCompetition(){
super();
}
private function onInitScoreSuccess(e:CommandEvent):void{
trace("RegisteringCompetition.onInitScoreSuccess");
e.target.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onInitScoreSuccess);
e.target.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onInitScoreFailure);
windowManager.openWindow("SingleHowToPlay");
uiFrame.showSingleScorePanel();
}
private function onRegisterSuccess(e:CommandEvent):void{
trace("RegisteringCompetition.onRegisterSuccess");
registerCommand.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onRegisterSuccess);
registerCommand.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onRegisterFailure);
var joinCmd:SetAffiliationCommand = new SetAffiliationCommand(Settings.get("flashVars").competitionId, AffiliationInfo.TYPE_LEAGUE);
joinCmd.addEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onInitScoreSuccess);
joinCmd.addEventListener(CommandEvent.EVENT_COMMAND_FAIL, onInitScoreFailure);
userHandle.runCommand(joinCmd);
}
override protected function completeOpen():void{
super.completeOpen();
userHandle.runCommand(registerCommand);
}
private function onInitScoreFailure(e:CommandEvent):void{
trace("RegisteringCompetition.onInitScoreFailure");
e.target.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onInitScoreSuccess);
e.target.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onInitScoreFailure);
windowManager.openWindow("RegisterCompetition", e.message);
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.registeringTitle).toUpperCase();
}
private function onRegisterFailure(e:CommandEvent):void{
trace("RegisteringCompetition.onRegisterFailure");
registerCommand.removeEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onRegisterSuccess);
registerCommand.removeEventListener(CommandEvent.EVENT_COMMAND_FAIL, onRegisterFailure);
windowManager.openWindow("RegisterCompetition", e.message);
}
override public function init():void{
main = new Window_Registering();
addChild(main);
}
public function openDisplay($registerCommand:FreeKickRegisterCommand):void{
registerCommand = $registerCommand;
registerCommand.addEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onRegisterSuccess, false, 0, true);
registerCommand.addEventListener(CommandEvent.EVENT_COMMAND_FAIL, onRegisterFailure, false, 0, true);
super.open();
}
}
}//package com.freekickfusion.ui.windows
Section 118
//SingleGameComplete (com.freekickfusion.ui.windows.SingleGameComplete)
package com.freekickfusion.ui.windows {
import flash.events.*;
import flash.net.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
public class SingleGameComplete extends GameWindow {
private var main:Window_SingleGameComplete;
private var playBut:ButtonMain;
public function SingleGameComplete(){
super();
}
override public function init():void{
main = new Window_SingleGameComplete();
addChild(main);
main.playagain_but.buttonMode = true;
main.playagain_but.mouseChildren = false;
main.playagain_but.addEventListener(MouseEvent.CLICK, onPlayAgain, false, 0, true);
main.multiplayer_but.buttonMode = true;
main.multiplayer_but.mouseChildren = false;
main.multiplayer_but.addEventListener(MouseEvent.CLICK, onPlayMultiplayer, false, 0, true);
main.playmoregames_but.buttonMode = true;
main.playmoregames_but.mouseChildren = false;
main.playmoregames_but.addEventListener(MouseEvent.CLICK, onPlayMoreGames, false, 0, true);
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.singleGameCompleteTitle).toUpperCase();
main.score_txt.text = String(singleGame.gameScore.score);
}
private function onPlayAgain(e:MouseEvent):void{
singleGame.restart();
windowManager.openWindow("SingleNewLevel");
}
private function onPlayMultiplayer(e:MouseEvent):void{
var loginCmd:LoginCommand = userHandle.init(false);
if (loginCmd == null){
windowManager.openWindow("MultiLogin");
} else {
windowManager.openWindow("MultiLoggingIn", loginCmd);
};
}
public function openDisplay():void{
super.open();
}
private function onPlayMoreGames(e:MouseEvent):void{
navigateToURL(new URLRequest("http://www.gamenet.com/gamenetclick.php?p=2927&c=148&s=Freekick_Fusion"));
}
}
}//package com.freekickfusion.ui.windows
Section 119
//SingleGameHolder (com.freekickfusion.ui.windows.SingleGameHolder)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.users.commands.events.*;
import flash.display.*;
import uk.co.inbox.game.score.events.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.game.timer.events.*;
import uk.co.inbox.score.events.*;
import flash.utils.*;
public class SingleGameHolder extends GameWindow {
private var main:Window_SingleGameHolder;
private var gameHolder:Sprite;
public static const TYPE_RESTART:int = 0;
public static const TYPE_NEXT_LEVEL:int = 1;
public function SingleGameHolder(){
super();
}
override protected function completeOpen():void{
super.completeOpen();
singleGame.start();
}
private function onLevelComplete(e:TimerEvent):void{
windowManager.openWindow("SingleLevelComplete");
}
private function onTimerFinished(e:GameCountdownEvent):void{
windowManager.openWindow("SingleGameOver");
}
private function onAddScoreComplete(e:CommandEvent):void{
}
private function onTargetHit(e:TargetGameScoreEvent):void{
var timer:Timer = new Timer(1000, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onLevelComplete);
timer.start();
}
private function onBestScoreUpdated(e:ScoreEvent):void{
var cmd:AddScoreCommand;
if (userHandle.loggedIn){
cmd = new AddScoreCommand(String(singleGame.mainScore.bestScore), null, null, "SinglePlayer");
cmd.addEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onAddScoreComplete, false, 0, true);
cmd.addEventListener(CommandEvent.EVENT_COMMAND_FAIL, onAddScoreFailed, false, 0, true);
userHandle.runCommand(cmd);
};
}
private function onAddScoreFailed(e:CommandEvent):void{
}
private function reset():void{
var i = 1;
while (i <= 5) {
main.bar[("label" + i)].visible = true;
i++;
};
i = 1;
while (i <= 3) {
main[("ball" + i)].gotoAndStop(1);
i++;
};
}
override public function init():void{
main = new Window_SingleGameHolder();
addChild(main);
gameHolder = new Sprite();
addChild(gameHolder);
singleGame.goalScore.addEventListener(GameScoreEvent.UPDATE, onTargetUpdate, false, 0, true);
singleGame.goalScore.addEventListener(TargetGameScoreEvent.TARGET_HIT, onTargetHit, false, 0, true);
singleGame.gameTimer.addEventListener(GameCountdownEvent.UPDATE, onTimerUpdate, false, 0, true);
singleGame.gameTimer.addEventListener(GameCountdownEvent.TIME_UP, onTimerFinished, false, 0, true);
gameHolder.addChild(singleGame);
var i = 1;
while (i <= 5) {
main.bar[("label" + i)].label_txt.text = ((i + 1) + "x");
main.bar[("label" + i)].label_s_txt.text = ((i + 1) + "x");
i++;
};
addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
singleGame.mainScore.addEventListener(ScoreEvent.BEST_SCORE_UPDATED, onBestScoreUpdated, false, 0, true);
}
private function onEnterFrame(e:Event):void{
singleGame.update();
}
private function onTimerUpdate(e:GameCountdownEvent):void{
main.bar.mask_mc.y = (230 * (1 - (e.timeLeft / e.timeLimit)));
var n:int = Math.floor((((e.timeLimit - e.timeLeft) / 1000) / 11));
var i = 5;
while (i > (5 - n)) {
if (main.bar[("label" + i)].visible){
main.bar[("label" + i)].visible = false;
};
i--;
};
}
public function openDisplay():void{
main.level_txt.text = String(singleGame.levelManager.currentLevel.idLabel);
singleGame.start();
reset();
super.open();
}
private function onTargetUpdate(e:GameScoreEvent):void{
var i = 1;
while (i <= e.currentScore) {
main[("ball" + i)].gotoAndStop(3);
i++;
};
}
override public function close():void{
singleGame.stop();
super.close();
}
}
}//package com.freekickfusion.ui.windows
Section 120
//SingleGameOver (com.freekickfusion.ui.windows.SingleGameOver)
package com.freekickfusion.ui.windows {
import flash.events.*;
import flash.net.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.language.*;
import uk.co.inbox.utils.*;
public class SingleGameOver extends GameWindow {
private var main:Window_SingleGameOver;
public function SingleGameOver(){
super();
}
override public function init():void{
main = new Window_SingleGameOver();
addChild(main);
main.playagain_but.buttonMode = true;
main.playagain_but.mouseChildren = false;
main.playagain_but.addEventListener(MouseEvent.CLICK, onPlayAgain, false, 0, true);
main.multiplayer_but.buttonMode = true;
main.multiplayer_but.mouseChildren = false;
main.multiplayer_but.addEventListener(MouseEvent.CLICK, onPlayMultiplayer, false, 0, true);
main.playmoregames_but.buttonMode = true;
main.playmoregames_but.mouseChildren = false;
main.playmoregames_but.addEventListener(MouseEvent.CLICK, onPlayMoreGames, false, 0, true);
main.viewstandings_but.buttonMode = true;
main.viewstandings_but.mouseChildren = false;
main.viewstandings_but.addEventListener(MouseEvent.CLICK, onViewStandings, false, 0, true);
}
private function onPlayMoreGames(e:MouseEvent):void{
navigateToURL(new URLRequest("http://www.gamenet.com/gamenetclick.php?p=2927&c=148&s=Freekick_Fusion"));
}
private function onPlayMultiplayer(e:MouseEvent):void{
var loginCmd:LoginCommand = userHandle.init(false);
if (loginCmd == null){
windowManager.openWindow("MultiLogin");
} else {
windowManager.openWindow("MultiLoggingIn", loginCmd);
};
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.singleGameOverTitle).toUpperCase();
main.score_txt.text = String(singleGame.gameScore.score);
}
private function onViewStandings(e:MouseEvent):void{
windowManager.openWindow("SingleViewStandingsCompetition", "SingleGameOver");
}
private function onPlayAgain(e:MouseEvent):void{
singleGame.restart();
windowManager.openWindow("SingleNewLevel");
}
public function openDisplay():void{
super.open();
main.viewstandings_but.visible = Settings.get("isCompetition");
main.playmoregames_but.visible = !(Settings.get("isCompetition"));
}
}
}//package com.freekickfusion.ui.windows
Section 121
//SingleHowToPlay (com.freekickfusion.ui.windows.SingleHowToPlay)
package com.freekickfusion.ui.windows {
import flash.events.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class SingleHowToPlay extends GameWindow {
private var main:Window_SingleHowToPlay;
private var playBut:ButtonMain;
public function SingleHowToPlay(){
super();
}
override public function init():void{
main = new Window_SingleHowToPlay();
addChild(main);
playBut = new ButtonMain(main.play_but, LangStrings.singleHowToPlayStart);
playBut.addEventListener(Button2.CLICK, onClickPlay, false, 0, true);
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.singleHowToPlayTitle).toUpperCase();
main.instr1_txt.text = getText(LangStrings.singleHowToPlayBody1);
main.instr2_txt.text = getText(LangStrings.singleHowToPlayBody2);
main.instr3_txt.text = getText(LangStrings.singleHowToPlayBody3);
playBut.refreshLang();
}
private function onClickPlay(e:Event):void{
singleGame.restart();
windowManager.openWindow("SingleNewLevel");
}
public function openDisplay():void{
super.open();
uiFrame.showMainMenuButton();
uiFrame.showSingleScorePanel();
}
}
}//package com.freekickfusion.ui.windows
Section 122
//SingleLevelComplete (com.freekickfusion.ui.windows.SingleLevelComplete)
package com.freekickfusion.ui.windows {
import flash.events.*;
import com.freekickfusion.game.score.events.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class SingleLevelComplete extends GameWindow {
private var main:Window_SingleLevelComplete;
private var playBut:ButtonMain;
public function SingleLevelComplete(){
super();
}
override public function init():void{
main = new Window_SingleLevelComplete();
addChild(main);
playBut = new ButtonMain(main.nextlevel_but, LangStrings.singleLevelCompleteNextLevel);
playBut.addEventListener(Button2.CLICK, onClickPlay, false, 0, true);
singleGame.gameScore.addEventListener(FreeKickGameScoreEvent.UPDATE, onFreeKickScoreUpdate, false, 0, true);
}
private function onFreeKickScoreUpdate(e:FreeKickGameScoreEvent):void{
main.elements_txt.text = String(e.score);
main.multiplier_txt.text = String(e.multiplier);
main.score_txt.text = String((e.multiplier * e.score));
singleGame.mainScore.update(singleGame.gameScore.score);
}
private function onClickPlay(e:Event):void{
if (singleGame.levelManager.isLastLevel){
windowManager.openWindow("SingleGameComplete");
} else {
singleGame.nextLevel();
windowManager.openWindow("SingleNewLevel");
};
}
public function openDisplay():void{
super.open();
}
override public function refreshLang():void{
main.title.label_txt.text = getText(LangStrings.singleLevelComleteTitle).toUpperCase().split(" ").join(((" " + singleGame.levelManager.currentLevel.idLabel) + " "));
main.total_label_txt.text = (getText(LangStrings.singleLevelCompleteTotal) + ":");
main.total_score_txt.text = String(singleGame.gameScore.score);
main.score_txt;
if (singleGame.levelManager.isLastLevel){
playBut.textId = LangStrings.singleLevelCompleteContinue;
} else {
playBut.textId = LangStrings.singleLevelCompleteNextLevel;
};
playBut.refreshLang();
}
}
}//package com.freekickfusion.ui.windows
Section 123
//SingleNewLevel (com.freekickfusion.ui.windows.SingleNewLevel)
package com.freekickfusion.ui.windows {
import flash.events.*;
import com.freekickfusion.game.levels.*;
import uk.co.inbox.language.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.buttons.*;
public class SingleNewLevel extends GameWindow {
private var main:Window_SingleNewLevel;
private var playBut:ButtonMain;
public function SingleNewLevel(){
super();
}
override public function init():void{
main = new Window_SingleNewLevel();
addChild(main);
playBut = new ButtonMain(main.play_but, LangStrings.singleNewLevelStart);
playBut.addEventListener(Button2.CLICK, onClickPlay, false, 0, true);
}
override public function refreshLang():void{
main.title.label_txt.text = ((getText(LangStrings.singleLevel).toUpperCase() + " ") + singleGame.levelManager.currentLevel.idLabel);
main.label_skill_txt.text = (getText(LangStrings.singleNewLevelSkill) + ":");
main.label_players_txt.text = (getText(LangStrings.singleNewLevelPlayers) + ":");
main.skill_txt.text = getText((singleGame.levelManager.currentLevel as FreeKickLevel).goalkeeperLevel.name);
main.players_txt.text = String((singleGame.levelManager.currentLevel as FreeKickLevel).playersInWall);
playBut.refreshLang();
}
private function onClickPlay(e:Event):void{
windowManager.openWindow("SingleGameHolder");
}
public function openDisplay():void{
super.open();
}
}
}//package com.freekickfusion.ui.windows
Section 124
//SingleViewStandingsCompetition (com.freekickfusion.ui.windows.SingleViewStandingsCompetition)
package com.freekickfusion.ui.windows {
import flash.events.*;
import flash.net.*;
import uk.co.inbox.users.commands.events.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.users.items.*;
import com.freekickfusion.ui.buttons.*;
import uk.co.inbox.utils.*;
import com.freekickfusion.ui.league.*;
import uk.co.inbox.buttons.*;
public class SingleViewStandingsCompetition extends GameWindow {
private var prevWindow:String;
private var mainMenuButton:ButtonLobby2;
private var leagueList:LeagueList;
private var main:Window_SingleViewStandingsCompetition;
private var playBut:ButtonMain;
public function SingleViewStandingsCompetition(){
super();
}
private function onGetScoresComplete(e:CommandEvent):void{
var cmd:GetAffiliationScoresCommand = (e.target as GetAffiliationScoresCommand);
leagueList.setScores(cmd.scores);
}
private function onClickMainMenu(e:Event):void{
windowManager.openWindow(prevWindow);
}
override public function refreshLang():void{
mainMenuButton.refreshLang();
}
override public function init():void{
main = new Window_SingleViewStandingsCompetition();
addChild(main);
mainMenuButton = new ButtonLobby2(main.mainmenu_but, "Back");
mainMenuButton.addEventListener(Button2.CLICK, onClickMainMenu, false, 0, true);
leagueList = new LeagueList();
leagueList.x = 24;
leagueList.y = 177;
addChild(leagueList);
main.terms_but.addEventListener(MouseEvent.CLICK, onClickTerms, false, 0, true);
}
private function refreshLeague():void{
var cmd:GetAffiliationScoresCommand = new GetAffiliationScoresCommand(Settings.get("competitionId"), AffiliationInfo.TYPE_LEAGUE, 0, 100, "SinglePlayer");
cmd.addEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, onGetScoresComplete, false, 0, true);
cmd.addEventListener(CommandEvent.EVENT_COMMAND_FAIL, onGetScoresFailed, false, 0, true);
userHandle.runCommand(cmd);
}
private function onGetScoresFailed(e:CommandEvent):void{
}
public function openDisplay($prevWindow:String):void{
prevWindow = $prevWindow;
super.open();
refreshLeague();
}
private function onClickTerms(e:MouseEvent):void{
navigateToURL(new URLRequest("http://www.freekickfusion.com/competition/terms.html"));
}
}
}//package com.freekickfusion.ui.windows
Section 125
//FreeKickRegisterCommand (com.freekickfusion.users.commands.FreeKickRegisterCommand)
package com.freekickfusion.users.commands {
import uk.co.inbox.users.*;
import uk.co.inbox.users.commands.*;
public class FreeKickRegisterCommand extends PluginCommand {
private var tabDetails:Object;
private var data:Object;
private var remember:Boolean;
private var score:String;
private var password:String;
private var email:String;
private var username:String;
private var optin:String;
public function FreeKickRegisterCommand($username:String, $password:String, $email:String, $data:Object=null, $remember:Boolean=false, $score:String=null, $optin:String=null){
username = $username;
password = $password;
email = $email;
data = $data;
remember = $remember;
score = $score;
optin = $optin;
super("FreeKickRegister");
}
override protected function onError():void{
trace(("xmlReturned:" + xmlReturned));
var _local1 = handle;
_local1.userspace::applyLoginFromResult(xmlReturned, remember);
super.onError();
}
override protected function onSuccess():void{
trace(("xmlReturned:" + xmlReturned));
var _local1 = handle;
_local1.userspace::applyLoginFromResult(xmlReturned, remember);
super.onSuccess();
}
override protected function begin():void{
if (handle.usernameFilter.isSafe(username)){
super.begin();
} else {
setError("Invalid username");
onError();
};
}
override protected function appendPOSTData(data:Object):Object{
var i:String;
var post:Object = super.appendPOSTData(data);
post.username = username;
post.password = password;
post.email = email;
post.score = score;
post.scoreb = "0";
post.scorec = "0";
post.optin = optin;
for (i in this.data) {
post[i] = this.data[i];
};
return (post);
}
}
}//package com.freekickfusion.users.commands
Section 126
//Colours (com.freekickfusion.Colours)
package com.freekickfusion {
public class Colours {
public static const ORANGE_STR:String = "#FF6600";
public static const BLUE_STR:String = "#2D4C90";
public static const BLUE:uint = 2968720;
public static const ORANGE:uint = 0xFF6600;
public function Colours(){
super();
}
}
}//package com.freekickfusion
Section 127
//BaseScrollPane (fl.containers.BaseScrollPane)
package fl.containers {
import flash.events.*;
import flash.display.*;
import fl.controls.*;
import fl.events.*;
import flash.geom.*;
import fl.core.*;
public class BaseScrollPane extends UIComponent {
protected var defaultLineScrollSize:Number;// = 4
protected var _maxHorizontalScrollPosition:Number;// = 0
protected var vScrollBar:Boolean;
protected var disabledOverlay:Shape;
protected var hScrollBar:Boolean;
protected var availableWidth:Number;
protected var _verticalPageScrollSize:Number;// = 0
protected var vOffset:Number;// = 0
protected var _verticalScrollBar:ScrollBar;
protected var useFixedHorizontalScrolling:Boolean;// = false
protected var contentWidth:Number;// = 0
protected var contentHeight:Number;// = 0
protected var _horizontalPageScrollSize:Number;// = 0
protected var background:DisplayObject;
protected var _useBitmpScrolling:Boolean;// = false
protected var contentPadding:Number;// = 0
protected var availableHeight:Number;
protected var _horizontalScrollBar:ScrollBar;
protected var contentScrollRect:Rectangle;
protected var _horizontalScrollPolicy:String;
protected var _verticalScrollPolicy:String;
protected static const SCROLL_BAR_STYLES:Object = {upArrowDisabledSkin:"upArrowDisabledSkin", upArrowDownSkin:"upArrowDownSkin", upArrowOverSkin:"upArrowOverSkin", upArrowUpSkin:"upArrowUpSkin", downArrowDisabledSkin:"downArrowDisabledSkin", downArrowDownSkin:"downArrowDownSkin", downArrowOverSkin:"downArrowOverSkin", downArrowUpSkin:"downArrowUpSkin", thumbDisabledSkin:"thumbDisabledSkin", thumbDownSkin:"thumbDownSkin", thumbOverSkin:"thumbOverSkin", thumbUpSkin:"thumbUpSkin", thumbIcon:"thumbIcon", trackDisabledSkin:"trackDisabledSkin", trackDownSkin:"trackDownSkin", trackOverSkin:"trackOverSkin", trackUpSkin:"trackUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval"};
private static var defaultStyles:Object = {repeatDelay:500, repeatInterval:35, skin:"ScrollPane_upSkin", contentPadding:0, disabledAlpha:0.5};
public function BaseScrollPane(){
contentWidth = 0;
contentHeight = 0;
contentPadding = 0;
vOffset = 0;
_maxHorizontalScrollPosition = 0;
_horizontalPageScrollSize = 0;
_verticalPageScrollSize = 0;
defaultLineScrollSize = 4;
useFixedHorizontalScrolling = false;
_useBitmpScrolling = false;
super();
}
protected function handleWheel(_arg1:MouseEvent):void{
if (((((!(enabled)) || (!(_verticalScrollBar.visible)))) || ((contentHeight <= availableHeight)))){
return;
};
_verticalScrollBar.scrollPosition = (_verticalScrollBar.scrollPosition - (_arg1.delta * verticalLineScrollSize));
setVerticalScrollPosition(_verticalScrollBar.scrollPosition);
dispatchEvent(new ScrollEvent(ScrollBarDirection.VERTICAL, _arg1.delta, horizontalScrollPosition));
}
public function get verticalScrollPosition():Number{
return (_verticalScrollBar.scrollPosition);
}
protected function drawDisabledOverlay():void{
if (enabled){
if (contains(disabledOverlay)){
removeChild(disabledOverlay);
};
} else {
disabledOverlay.x = (disabledOverlay.y = contentPadding);
disabledOverlay.width = availableWidth;
disabledOverlay.height = availableHeight;
disabledOverlay.alpha = (getStyleValue("disabledAlpha") as Number);
addChild(disabledOverlay);
};
}
public function set verticalScrollPosition(_arg1:Number):void{
drawNow();
_verticalScrollBar.scrollPosition = _arg1;
setVerticalScrollPosition(_verticalScrollBar.scrollPosition, false);
}
protected function setContentSize(_arg1:Number, _arg2:Number):void{
if ((((((contentWidth == _arg1)) || (useFixedHorizontalScrolling))) && ((contentHeight == _arg2)))){
return;
};
contentWidth = _arg1;
contentHeight = _arg2;
invalidate(InvalidationType.SIZE);
}
public function get horizontalScrollPosition():Number{
return (_horizontalScrollBar.scrollPosition);
}
public function get horizontalScrollBar():ScrollBar{
return (_horizontalScrollBar);
}
override public function set enabled(_arg1:Boolean):void{
if (enabled == _arg1){
return;
};
_verticalScrollBar.enabled = _arg1;
_horizontalScrollBar.enabled = _arg1;
super.enabled = _arg1;
}
public function get verticalLineScrollSize():Number{
return (_verticalScrollBar.lineScrollSize);
}
public function get horizontalScrollPolicy():String{
return (_horizontalScrollPolicy);
}
protected function calculateAvailableSize():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local1 = ScrollBar.WIDTH;
_local2 = (contentPadding = Number(getStyleValue("contentPadding")));
_local3 = ((height - (2 * _local2)) - vOffset);
vScrollBar = (((_verticalScrollPolicy == ScrollPolicy.ON)) || ((((_verticalScrollPolicy == ScrollPolicy.AUTO)) && ((contentHeight > _local3)))));
_local4 = ((width - (vScrollBar) ? _local1 : 0) - (2 * _local2));
_local5 = (useFixedHorizontalScrolling) ? _maxHorizontalScrollPosition : (contentWidth - _local4);
hScrollBar = (((_horizontalScrollPolicy == ScrollPolicy.ON)) || ((((_horizontalScrollPolicy == ScrollPolicy.AUTO)) && ((_local5 > 0)))));
if (hScrollBar){
_local3 = (_local3 - _local1);
};
if (((((((hScrollBar) && (!(vScrollBar)))) && ((_verticalScrollPolicy == ScrollPolicy.AUTO)))) && ((contentHeight > _local3)))){
vScrollBar = true;
_local4 = (_local4 - _local1);
};
availableHeight = (_local3 + vOffset);
availableWidth = _local4;
}
public function get maxVerticalScrollPosition():Number{
drawNow();
return (Math.max(0, (contentHeight - availableHeight)));
}
public function set horizontalScrollPosition(_arg1:Number):void{
drawNow();
_horizontalScrollBar.scrollPosition = _arg1;
setHorizontalScrollPosition(_horizontalScrollBar.scrollPosition, false);
}
public function get horizontalLineScrollSize():Number{
return (_horizontalScrollBar.lineScrollSize);
}
public function set verticalPageScrollSize(_arg1:Number):void{
_verticalPageScrollSize = _arg1;
invalidate(InvalidationType.SIZE);
}
public function get verticalScrollPolicy():String{
return (_verticalScrollPolicy);
}
protected function setHorizontalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
}
public function get useBitmapScrolling():Boolean{
return (_useBitmpScrolling);
}
protected function handleScroll(_arg1:ScrollEvent):void{
if (_arg1.target == _verticalScrollBar){
setVerticalScrollPosition(_arg1.position);
} else {
setHorizontalScrollPosition(_arg1.position);
};
}
public function set verticalLineScrollSize(_arg1:Number):void{
_verticalScrollBar.lineScrollSize = _arg1;
}
public function get verticalScrollBar():ScrollBar{
return (_verticalScrollBar);
}
protected function setVerticalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
}
public function set horizontalPageScrollSize(_arg1:Number):void{
_horizontalPageScrollSize = _arg1;
invalidate(InvalidationType.SIZE);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES)){
setStyles();
drawBackground();
if (contentPadding != getStyleValue("contentPadding")){
invalidate(InvalidationType.SIZE, false);
};
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STATE)){
drawLayout();
};
updateChildren();
super.draw();
}
public function set horizontalScrollPolicy(_arg1:String):void{
_horizontalScrollPolicy = _arg1;
invalidate(InvalidationType.SIZE);
}
override protected function configUI():void{
var _local1:Graphics;
super.configUI();
contentScrollRect = new Rectangle(0, 0, 85, 85);
_verticalScrollBar = new ScrollBar();
_verticalScrollBar.addEventListener(ScrollEvent.SCROLL, handleScroll, false, 0, true);
_verticalScrollBar.visible = false;
_verticalScrollBar.lineScrollSize = defaultLineScrollSize;
addChild(_verticalScrollBar);
copyStylesToChild(_verticalScrollBar, SCROLL_BAR_STYLES);
_horizontalScrollBar = new ScrollBar();
_horizontalScrollBar.direction = ScrollBarDirection.HORIZONTAL;
_horizontalScrollBar.addEventListener(ScrollEvent.SCROLL, handleScroll, false, 0, true);
_horizontalScrollBar.visible = false;
_horizontalScrollBar.lineScrollSize = defaultLineScrollSize;
addChild(_horizontalScrollBar);
copyStylesToChild(_horizontalScrollBar, SCROLL_BAR_STYLES);
disabledOverlay = new Shape();
_local1 = disabledOverlay.graphics;
_local1.beginFill(0xFFFFFF);
_local1.drawRect(0, 0, width, height);
_local1.endFill();
addEventListener(MouseEvent.MOUSE_WHEEL, handleWheel, false, 0, true);
}
protected function calculateContentWidth():void{
}
public function get verticalPageScrollSize():Number{
if (isNaN(availableHeight)){
drawNow();
};
return (((((_verticalPageScrollSize == 0)) && (!(isNaN(availableHeight))))) ? availableHeight : _verticalPageScrollSize);
}
protected function drawLayout():void{
calculateAvailableSize();
calculateContentWidth();
background.width = width;
background.height = height;
if (vScrollBar){
_verticalScrollBar.visible = true;
_verticalScrollBar.x = ((width - ScrollBar.WIDTH) - contentPadding);
_verticalScrollBar.y = contentPadding;
_verticalScrollBar.height = availableHeight;
} else {
_verticalScrollBar.visible = false;
};
_verticalScrollBar.setScrollProperties(availableHeight, 0, (contentHeight - availableHeight), verticalPageScrollSize);
setVerticalScrollPosition(_verticalScrollBar.scrollPosition, false);
if (hScrollBar){
_horizontalScrollBar.visible = true;
_horizontalScrollBar.x = contentPadding;
_horizontalScrollBar.y = ((height - ScrollBar.WIDTH) - contentPadding);
_horizontalScrollBar.width = availableWidth;
} else {
_horizontalScrollBar.visible = false;
};
_horizontalScrollBar.setScrollProperties(availableWidth, 0, (useFixedHorizontalScrolling) ? _maxHorizontalScrollPosition : (contentWidth - availableWidth), horizontalPageScrollSize);
setHorizontalScrollPosition(_horizontalScrollBar.scrollPosition, false);
drawDisabledOverlay();
}
protected function drawBackground():void{
var _local1:DisplayObject;
_local1 = background;
background = getDisplayObjectInstance(getStyleValue("skin"));
background.width = width;
background.height = height;
addChildAt(background, 0);
if (((!((_local1 == null))) && (!((_local1 == background))))){
removeChild(_local1);
};
}
public function set horizontalLineScrollSize(_arg1:Number):void{
_horizontalScrollBar.lineScrollSize = _arg1;
}
public function get horizontalPageScrollSize():Number{
if (isNaN(availableWidth)){
drawNow();
};
return (((((_horizontalPageScrollSize == 0)) && (!(isNaN(availableWidth))))) ? availableWidth : _horizontalPageScrollSize);
}
public function get maxHorizontalScrollPosition():Number{
drawNow();
return (Math.max(0, (contentWidth - availableWidth)));
}
protected function setStyles():void{
copyStylesToChild(_verticalScrollBar, SCROLL_BAR_STYLES);
copyStylesToChild(_horizontalScrollBar, SCROLL_BAR_STYLES);
}
protected function updateChildren():void{
_verticalScrollBar.enabled = (_horizontalScrollBar.enabled = enabled);
_verticalScrollBar.drawNow();
_horizontalScrollBar.drawNow();
}
public function set verticalScrollPolicy(_arg1:String):void{
_verticalScrollPolicy = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set useBitmapScrolling(_arg1:Boolean):void{
_useBitmpScrolling = _arg1;
invalidate(InvalidationType.STATE);
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, ScrollBar.getStyleDefinition()));
}
}
}//package fl.containers
Section 128
//CellRenderer (fl.controls.listClasses.CellRenderer)
package fl.controls.listClasses {
import flash.events.*;
import fl.controls.*;
public class CellRenderer extends LabelButton implements ICellRenderer {
protected var _data:Object;
protected var _listData:ListData;
private static var defaultStyles:Object = {upSkin:"CellRenderer_upSkin", downSkin:"CellRenderer_downSkin", overSkin:"CellRenderer_overSkin", disabledSkin:"CellRenderer_disabledSkin", selectedDisabledSkin:"CellRenderer_selectedDisabledSkin", selectedUpSkin:"CellRenderer_selectedUpSkin", selectedDownSkin:"CellRenderer_selectedDownSkin", selectedOverSkin:"CellRenderer_selectedOverSkin", textFormat:null, disabledTextFormat:null, embedFonts:null, textPadding:5};
public function CellRenderer():void{
toggle = true;
focusEnabled = false;
}
override protected function toggleSelected(_arg1:MouseEvent):void{
}
override public function get selected():Boolean{
return (super.selected);
}
public function set listData(_arg1:ListData):void{
_listData = _arg1;
label = _listData.label;
setStyle("icon", _listData.icon);
}
override public function set selected(_arg1:Boolean):void{
super.selected = _arg1;
}
public function set data(_arg1:Object):void{
_data = _arg1;
}
public function get listData():ListData{
return (_listData);
}
override public function setSize(_arg1:Number, _arg2:Number):void{
super.setSize(_arg1, _arg2);
}
override protected function drawLayout():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
_local1 = Number(getStyleValue("textPadding"));
_local2 = 0;
if (icon != null){
icon.x = _local1;
icon.y = Math.round(((height - icon.height) >> 1));
_local2 = (icon.width + _local1);
};
if (label.length > 0){
textField.visible = true;
_local3 = Math.max(0, ((width - _local2) - (_local1 * 2)));
textField.width = _local3;
textField.height = (textField.textHeight + 4);
textField.x = (_local2 + _local1);
textField.y = Math.round(((height - textField.height) >> 1));
} else {
textField.visible = false;
};
background.width = width;
background.height = height;
}
public function get data():Object{
return (_data);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls.listClasses
Section 129
//ICellRenderer (fl.controls.listClasses.ICellRenderer)
package fl.controls.listClasses {
public interface ICellRenderer {
function setSize(_arg1:Number, _arg2:Number):void;
function get listData():ListData;
function get data():Object;
function setMouseState(_arg1:String):void;
function set x(_arg1:Number):void;
function set y(_arg1:Number):void;
function set data(_arg1:Object):void;
function set selected(_arg1:Boolean):void;
function set listData(_arg1:ListData):void;
function get selected():Boolean;
}
}//package fl.controls.listClasses
Section 130
//ListData (fl.controls.listClasses.ListData)
package fl.controls.listClasses {
import fl.core.*;
public class ListData {
protected var _index:uint;
protected var _owner:UIComponent;
protected var _label:String;
protected var _icon:Object;// = null
protected var _row:uint;
protected var _column:uint;
public function ListData(_arg1:String, _arg2:Object, _arg3:UIComponent, _arg4:uint, _arg5:uint, _arg6:uint=0){
_icon = null;
super();
_label = _arg1;
_icon = _arg2;
_owner = _arg3;
_index = _arg4;
_row = _arg5;
_column = _arg6;
}
public function get owner():UIComponent{
return (_owner);
}
public function get label():String{
return (_label);
}
public function get row():uint{
return (_row);
}
public function get index():uint{
return (_index);
}
public function get icon():Object{
return (_icon);
}
public function get column():uint{
return (_column);
}
}
}//package fl.controls.listClasses
Section 131
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import fl.events.*;
import fl.core.*;
public class BaseButton extends UIComponent {
protected var _selected:Boolean;// = false
private var unlockedMouseState:String;
protected var pressTimer:Timer;
protected var mouseState:String;
protected var background:DisplayObject;
private var _mouseStateLocked:Boolean;// = false
protected var _autoRepeat:Boolean;// = false
private static var defaultStyles:Object = {upSkin:"Button_upSkin", downSkin:"Button_downSkin", overSkin:"Button_overSkin", disabledSkin:"Button_disabledSkin", selectedDisabledSkin:"Button_selectedDisabledSkin", selectedUpSkin:"Button_selectedUpSkin", selectedDownSkin:"Button_selectedDownSkin", selectedOverSkin:"Button_selectedOverSkin", focusRectSkin:null, focusRectPadding:null, repeatDelay:500, repeatInterval:35};
public function BaseButton(){
_selected = false;
_autoRepeat = false;
_mouseStateLocked = false;
super();
buttonMode = true;
mouseChildren = false;
useHandCursor = false;
setupMouseEvents();
setMouseState("up");
pressTimer = new Timer(1, 0);
pressTimer.addEventListener(TimerEvent.TIMER, buttonDown, false, 0, true);
}
protected function endPress():void{
pressTimer.reset();
}
public function set mouseStateLocked(_arg1:Boolean):void{
_mouseStateLocked = _arg1;
if (_arg1 == false){
setMouseState(unlockedMouseState);
} else {
unlockedMouseState = mouseState;
};
}
public function get autoRepeat():Boolean{
return (_autoRepeat);
}
public function set autoRepeat(_arg1:Boolean):void{
_autoRepeat = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
mouseEnabled = _arg1;
}
public function get selected():Boolean{
return (_selected);
}
protected function mouseEventHandler(_arg1:MouseEvent):void{
if (_arg1.type == MouseEvent.MOUSE_DOWN){
setMouseState("down");
startPress();
} else {
if ((((_arg1.type == MouseEvent.ROLL_OVER)) || ((_arg1.type == MouseEvent.MOUSE_UP)))){
setMouseState("over");
endPress();
} else {
if (_arg1.type == MouseEvent.ROLL_OUT){
setMouseState("up");
endPress();
};
};
};
}
public function setMouseState(_arg1:String):void{
if (_mouseStateLocked){
unlockedMouseState = _arg1;
return;
};
if (mouseState == _arg1){
return;
};
mouseState = _arg1;
invalidate(InvalidationType.STATE);
}
protected function startPress():void{
if (_autoRepeat){
pressTimer.delay = Number(getStyleValue("repeatDelay"));
pressTimer.start();
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
protected function buttonDown(_arg1:TimerEvent):void{
if (!_autoRepeat){
endPress();
return;
};
if (pressTimer.currentCount == 1){
pressTimer.delay = Number(getStyleValue("repeatInterval"));
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
public function set selected(_arg1:Boolean):void{
if (_selected == _arg1){
return;
};
_selected = _arg1;
invalidate(InvalidationType.STATE);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function setupMouseEvents():void{
addEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false, 0, true);
}
protected function drawLayout():void{
background.width = width;
background.height = height;
}
protected function drawBackground():void{
var _local1:String;
var _local2:DisplayObject;
_local1 = (enabled) ? mouseState : "disabled";
if (selected){
_local1 = (("selected" + _local1.substr(0, 1).toUpperCase()) + _local1.substr(1));
};
_local1 = (_local1 + "Skin");
_local2 = background;
background = getDisplayObjectInstance(getStyleValue(_local1));
addChildAt(background, 0);
if (((!((_local2 == null))) && (!((_local2 == background))))){
removeChild(_local2);
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 132
//Button (fl.controls.Button)
package fl.controls {
import flash.display.*;
import fl.managers.*;
import fl.core.*;
public class Button extends LabelButton implements IFocusManagerComponent {
protected var emphasizedBorder:DisplayObject;
protected var _emphasized:Boolean;// = false
private static var defaultStyles:Object = {emphasizedSkin:"Button_emphasizedSkin", emphasizedPadding:2};
public static var createAccessibilityImplementation:Function;
public function Button(){
_emphasized = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
var _local3:*;
super.drawFocus(_arg1);
if (_arg1){
_local2 = Number(getStyleValue("emphasizedPadding"));
if ((((_local2 < 0)) || (!(_emphasized)))){
_local2 = 0;
};
_local3 = getStyleValue("focusRectPadding");
_local3 = ((_local3)==null) ? 2 : _local3;
_local3 = (_local3 + _local2);
uiFocusRect.x = -(_local3);
uiFocusRect.y = -(_local3);
uiFocusRect.width = (width + (_local3 * 2));
uiFocusRect.height = (height + (_local3 * 2));
};
}
public function set emphasized(_arg1:Boolean):void{
_emphasized = _arg1;
invalidate(InvalidationType.STYLES);
}
override protected function draw():void{
if (((isInvalid(InvalidationType.STYLES)) || (isInvalid(InvalidationType.SIZE)))){
drawEmphasized();
};
super.draw();
if (emphasizedBorder != null){
setChildIndex(emphasizedBorder, (numChildren - 1));
};
}
public function get emphasized():Boolean{
return (_emphasized);
}
override protected function initializeAccessibility():void{
if (Button.createAccessibilityImplementation != null){
Button.createAccessibilityImplementation(this);
};
}
protected function drawEmphasized():void{
var _local1:Object;
var _local2:Number;
if (emphasizedBorder != null){
removeChild(emphasizedBorder);
};
emphasizedBorder = null;
if (!_emphasized){
return;
};
_local1 = getStyleValue("emphasizedSkin");
if (_local1 != null){
emphasizedBorder = getDisplayObjectInstance(_local1);
};
if (emphasizedBorder != null){
addChildAt(emphasizedBorder, 0);
_local2 = Number(getStyleValue("emphasizedPadding"));
emphasizedBorder.x = (emphasizedBorder.y = -(_local2));
emphasizedBorder.width = (width + (_local2 * 2));
emphasizedBorder.height = (height + (_local2 * 2));
};
}
public static function getStyleDefinition():Object{
return (UIComponent.mergeStyles(LabelButton.getStyleDefinition(), defaultStyles));
}
}
}//package fl.controls
Section 133
//ButtonLabelPlacement (fl.controls.ButtonLabelPlacement)
package fl.controls {
public class ButtonLabelPlacement {
public static const TOP:String = "top";
public static const LEFT:String = "left";
public static const BOTTOM:String = "bottom";
public static const RIGHT:String = "right";
}
}//package fl.controls
Section 134
//ComboBox (fl.controls.ComboBox)
package fl.controls {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import fl.events.*;
import flash.geom.*;
import fl.managers.*;
import fl.core.*;
import fl.controls.listClasses.*;
import fl.data.*;
import flash.ui.*;
public class ComboBox extends UIComponent implements IFocusManagerComponent {
protected var _dropdownWidth:Number;
protected var highlightedCell:int;// = -1
protected var _prompt:String;
protected var isOpen:Boolean;// = false
protected var list:List;
protected var _rowCount:uint;// = 5
protected var currentIndex:int;
protected var isKeyDown:Boolean;// = false
protected var _labels:Array;
protected var background:BaseButton;
protected var inputField:TextInput;
protected var listOverIndex:uint;
protected var editableValue:String;
protected var _editable:Boolean;// = false
private var collectionItemImport:SimpleCollectionItem;
protected static const BACKGROUND_STYLES:Object = {overSkin:"overSkin", downSkin:"downSkin", upSkin:"upSkin", disabledSkin:"disabledSkin", repeatInterval:"repeatInterval"};
protected static const LIST_STYLES:Object = {upSkin:"comboListUpSkin", overSkin:"comboListOverSkin", downSkin:"comobListDownSkin", disabledSkin:"comboListDisabledSkin", downArrowDisabledSkin:"downArrowDisabledSkin", downArrowDownSkin:"downArrowDownSkin", downArrowOverSkin:"downArrowOverSkin", downArrowUpSkin:"downArrowUpSkin", upArrowDisabledSkin:"upArrowDisabledSkin", upArrowDownSkin:"upArrowDownSkin", upArrowOverSkin:"upArrowOverSkin", upArrowUpSkin:"upArrowUpSkin", thumbDisabledSkin:"thumbDisabledSkin", thumbDownSkin:"thumbDownSkin", thumbOverSkin:"thumbOverSkin", thumbUpSkin:"thumbUpSkin", thumbIcon:"thumbIcon", trackDisabledSkin:"trackDisabledSkin", trackDownSkin:"trackDownSkin", trackOverSkin:"trackOverSkin", trackUpSkin:"trackUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval", textFormat:"textFormat", disabledAlpha:"disabledAlpha", skin:"listSkin"};
private static var defaultStyles:Object = {upSkin:"ComboBox_upSkin", downSkin:"ComboBox_downSkin", overSkin:"ComboBox_overSkin", disabledSkin:"ComboBox_disabledSkin", focusRectSkin:null, focusRectPadding:null, textFormat:null, disabledTextFormat:null, textPadding:3, buttonWidth:24, disabledAlpha:null, listSkin:null};
public static var createAccessibilityImplementation:Function;
public function ComboBox(){
_rowCount = 5;
_editable = false;
isOpen = false;
highlightedCell = -1;
isKeyDown = false;
super();
}
protected function drawList():void{
list.rowCount = Math.max(0, Math.min(_rowCount, list.dataProvider.length));
}
public function set imeMode(_arg1:String):void{
inputField.imeMode = _arg1;
}
public function get dropdown():List{
return (list);
}
public function get dropdownWidth():Number{
return (list.width);
}
public function sortItemsOn(_arg1:String, _arg2:Object=null){
return (list.sortItemsOn(_arg1, _arg2));
}
protected function onEnter(_arg1:ComponentEvent):void{
_arg1.stopPropagation();
}
public function removeItemAt(_arg1:uint):void{
list.removeItemAt(_arg1);
invalidate(InvalidationType.DATA);
}
public function open():void{
currentIndex = selectedIndex;
if (((isOpen) || ((length == 0)))){
return;
};
dispatchEvent(new Event(Event.OPEN));
isOpen = true;
addEventListener(Event.ENTER_FRAME, addCloseListener, false, 0, true);
positionList();
list.scrollToSelected();
stage.addChild(list);
}
public function get selectedItem():Object{
return (list.selectedItem);
}
public function set text(_arg1:String):void{
if (!editable){
return;
};
inputField.text = _arg1;
}
public function get labelField():String{
return (list.labelField);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
var _local2:int;
var _local3:uint;
var _local4:Number;
var _local5:int;
isKeyDown = true;
if (_arg1.ctrlKey){
switch (_arg1.keyCode){
case Keyboard.UP:
if (highlightedCell > -1){
selectedIndex = highlightedCell;
dispatchEvent(new Event(Event.CHANGE));
};
close();
break;
case Keyboard.DOWN:
open();
break;
};
return;
};
_arg1.stopPropagation();
_local2 = Math.max(((calculateAvailableHeight() / list.rowHeight) << 0), 1);
_local3 = selectedIndex;
_local4 = ((highlightedCell)==-1) ? selectedIndex : highlightedCell;
_local5 = -1;
switch (_arg1.keyCode){
case Keyboard.SPACE:
if (isOpen){
close();
} else {
open();
};
return;
case Keyboard.ESCAPE:
if (isOpen){
if (highlightedCell > -1){
selectedIndex = selectedIndex;
};
close();
};
return;
case Keyboard.UP:
_local5 = Math.max(0, (_local4 - 1));
break;
case Keyboard.DOWN:
_local5 = Math.min((length - 1), (_local4 + 1));
break;
case Keyboard.PAGE_UP:
_local5 = Math.max((_local4 - _local2), 0);
break;
case Keyboard.PAGE_DOWN:
_local5 = Math.min((_local4 + _local2), (length - 1));
break;
case Keyboard.HOME:
_local5 = 0;
break;
case Keyboard.END:
_local5 = (length - 1);
break;
case Keyboard.ENTER:
if (((_editable) && ((highlightedCell == -1)))){
editableValue = inputField.text;
selectedIndex = -1;
} else {
if (((isOpen) && ((highlightedCell > -1)))){
editableValue = null;
selectedIndex = highlightedCell;
dispatchEvent(new Event(Event.CHANGE));
};
};
dispatchEvent(new ComponentEvent(ComponentEvent.ENTER));
close();
return;
default:
if (editable){
break;
};
_local5 = list.getNextIndexAtLetter(String.fromCharCode(_arg1.keyCode), _local4);
break;
};
if (_local5 > -1){
if (isOpen){
highlightCell(_local5);
inputField.text = list.itemToLabel(getItemAt(_local5));
} else {
highlightCell();
selectedIndex = _local5;
dispatchEvent(new Event(Event.CHANGE));
};
};
}
public function set dropdownWidth(_arg1:Number):void{
_dropdownWidth = _arg1;
invalidate(InvalidationType.SIZE);
}
public function get editable():Boolean{
return (_editable);
}
override protected function focusInHandler(_arg1:FocusEvent):void{
super.focusInHandler(_arg1);
if (editable){
stage.focus = inputField.textField;
};
}
protected function onStageClick(_arg1:MouseEvent):void{
if (!isOpen){
return;
};
if (((!(contains((_arg1.target as DisplayObject)))) && (!(list.contains((_arg1.target as DisplayObject)))))){
if (highlightedCell != -1){
selectedIndex = highlightedCell;
dispatchEvent(new Event(Event.CHANGE));
};
close();
};
}
protected function handleDataChange(_arg1:DataChangeEvent):void{
invalidate(InvalidationType.DATA);
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
isKeyDown = false;
}
protected function onListItemUp(_arg1:MouseEvent):void{
var _local2:*;
stage.removeEventListener(MouseEvent.MOUSE_UP, onListItemUp);
if (((!((_arg1.target is ICellRenderer))) || (!(list.contains((_arg1.target as DisplayObject)))))){
return;
};
editableValue = null;
_local2 = selectedIndex;
selectedIndex = _arg1.target.listData.index;
if (_local2 != selectedIndex){
dispatchEvent(new Event(Event.CHANGE));
};
close();
}
public function removeAll():void{
list.removeAll();
inputField.text = "";
invalidate(InvalidationType.DATA);
}
public function set selectedItem(_arg1:Object):void{
list.selectedItem = _arg1;
invalidate(InvalidationType.SELECTED);
}
protected function highlightCell(_arg1:int=-1):void{
var _local2:ICellRenderer;
if (highlightedCell > -1){
_local2 = list.itemToCellRenderer(getItemAt(highlightedCell));
if (_local2 != null){
_local2.setMouseState("up");
};
};
if (_arg1 == -1){
return;
};
list.scrollToIndex(_arg1);
list.drawNow();
_local2 = list.itemToCellRenderer(getItemAt(_arg1));
if (_local2 != null){
_local2.setMouseState("over");
highlightedCell = _arg1;
};
}
public function itemToLabel(_arg1:Object):String{
if (_arg1 == null){
return ("");
};
return (list.itemToLabel(_arg1));
}
public function addItemAt(_arg1:Object, _arg2:uint):void{
list.addItemAt(_arg1, _arg2);
invalidate(InvalidationType.DATA);
}
public function replaceItemAt(_arg1:Object, _arg2:uint):Object{
return (list.replaceItemAt(_arg1, _arg2));
}
protected function showPrompt():void{
inputField.text = _prompt;
}
public function set rowCount(_arg1:uint):void{
_rowCount = _arg1;
invalidate(InvalidationType.SIZE);
}
public function get restrict():String{
return (inputField.restrict);
}
protected function setEmbedFonts():void{
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
inputField.textField.embedFonts = _local1;
};
}
public function sortItems(... _args){
return (list.sortItems.apply(list, _args));
}
public function set labelField(_arg1:String):void{
list.labelField = _arg1;
invalidate(InvalidationType.DATA);
}
public function set editable(_arg1:Boolean):void{
_editable = _arg1;
drawTextField();
}
public function set prompt(_arg1:String):void{
if (_arg1 == ""){
_prompt = null;
} else {
_prompt = _arg1;
};
invalidate(InvalidationType.STATE);
}
public function get length():int{
return (list.length);
}
protected function drawTextField():void{
inputField.setStyle("upSkin", "");
inputField.setStyle("disabledSkin", "");
inputField.enabled = enabled;
inputField.editable = _editable;
inputField.textField.selectable = ((enabled) && (_editable));
inputField.mouseEnabled = (inputField.mouseChildren = ((enabled) && (_editable)));
inputField.focusEnabled = false;
if (_editable){
inputField.addEventListener(FocusEvent.FOCUS_IN, onInputFieldFocus, false, 0, true);
inputField.addEventListener(FocusEvent.FOCUS_OUT, onInputFieldFocusOut, false, 0, true);
} else {
inputField.removeEventListener(FocusEvent.FOCUS_IN, onInputFieldFocus);
inputField.removeEventListener(FocusEvent.FOCUS_OUT, onInputFieldFocusOut);
};
}
protected function onInputFieldFocusOut(_arg1:FocusEvent):void{
inputField.removeEventListener(ComponentEvent.ENTER, onEnter);
selectedIndex = selectedIndex;
}
protected function passEvent(_arg1:Event):void{
dispatchEvent(_arg1);
}
public function get imeMode():String{
return (inputField.imeMode);
}
public function get labelFunction():Function{
return (list.labelFunction);
}
protected function calculateAvailableHeight():Number{
var _local1:Number;
_local1 = Number(getStyleValue("contentPadding"));
return ((list.height - (_local1 * 2)));
}
public function get selectedIndex():int{
return (list.selectedIndex);
}
override protected function focusOutHandler(_arg1:FocusEvent):void{
isKeyDown = false;
if (isOpen){
if (((!(_arg1.relatedObject)) || (!(list.contains(_arg1.relatedObject))))){
if (((!((highlightedCell == -1))) && (!((highlightedCell == selectedIndex))))){
selectedIndex = highlightedCell;
dispatchEvent(new Event(Event.CHANGE));
};
close();
};
};
super.focusOutHandler(_arg1);
}
public function get selectedLabel():String{
if (editableValue != null){
return (editableValue);
};
if (selectedIndex == -1){
return (null);
};
return (itemToLabel(selectedItem));
}
public function get text():String{
return (inputField.text);
}
protected function onListChange(_arg1:Event):void{
editableValue = null;
dispatchEvent(_arg1);
invalidate(InvalidationType.SELECTED);
if (isKeyDown){
return;
};
close();
}
protected function onToggleListVisibility(_arg1:MouseEvent):void{
_arg1.stopPropagation();
dispatchEvent(_arg1);
if (isOpen){
close();
} else {
open();
stage.addEventListener(MouseEvent.MOUSE_UP, onListItemUp, false, 0, true);
};
}
override protected function draw():void{
var _local1:*;
_local1 = selectedIndex;
if ((((_local1 == -1)) && (((((!((prompt == null))) || (editable))) || ((length == 0)))))){
_local1 = Math.max(-1, Math.min(_local1, (length - 1)));
} else {
editableValue = null;
_local1 = Math.max(0, Math.min(_local1, (length - 1)));
};
if (list.selectedIndex != _local1){
list.selectedIndex = _local1;
invalidate(InvalidationType.SELECTED, false);
};
if (isInvalid(InvalidationType.STYLES)){
setStyles();
setEmbedFonts();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.DATA, InvalidationType.STATE)){
drawTextFormat();
drawLayout();
invalidate(InvalidationType.DATA);
};
if (isInvalid(InvalidationType.DATA)){
drawList();
invalidate(InvalidationType.SELECTED, true);
};
if (isInvalid(InvalidationType.SELECTED)){
if ((((_local1 == -1)) && (!((editableValue == null))))){
inputField.text = editableValue;
} else {
if (_local1 > -1){
if (length > 0){
inputField.horizontalScrollPosition = 0;
inputField.text = itemToLabel(list.selectedItem);
};
} else {
if ((((_local1 == -1)) && (!((_prompt == null))))){
showPrompt();
} else {
inputField.text = "";
};
};
};
if (((((editable) && ((selectedIndex > -1)))) && ((stage.focus == inputField.textField)))){
inputField.setSelection(0, inputField.length);
};
};
drawTextField();
super.draw();
}
public function addItem(_arg1:Object):void{
list.addItem(_arg1);
invalidate(InvalidationType.DATA);
}
public function get rowCount():uint{
return (_rowCount);
}
override protected function configUI():void{
super.configUI();
background = new BaseButton();
background.focusEnabled = false;
copyStylesToChild(background, BACKGROUND_STYLES);
background.addEventListener(MouseEvent.MOUSE_DOWN, onToggleListVisibility, false, 0, true);
addChild(background);
inputField = new TextInput();
inputField.focusTarget = (this as IFocusManagerComponent);
inputField.focusEnabled = false;
inputField.addEventListener(Event.CHANGE, onTextInput, false, 0, true);
addChild(inputField);
list = new List();
list.focusEnabled = false;
copyStylesToChild(list, LIST_STYLES);
list.addEventListener(Event.CHANGE, onListChange, false, 0, true);
list.addEventListener(ListEvent.ITEM_CLICK, onListChange, false, 0, true);
list.addEventListener(ListEvent.ITEM_ROLL_OUT, passEvent, false, 0, true);
list.addEventListener(ListEvent.ITEM_ROLL_OVER, passEvent, false, 0, true);
list.verticalScrollBar.addEventListener(Event.SCROLL, passEvent, false, 0, true);
}
protected function positionList():void{
var _local1:Point;
_local1 = localToGlobal(new Point(0, 0));
list.x = _local1.x;
if (((_local1.y + height) + list.height) > stage.stageHeight){
list.y = (_local1.y - list.height);
} else {
list.y = (_local1.y + height);
};
}
public function get value():String{
var _local1:Object;
if (editableValue != null){
return (editableValue);
};
_local1 = selectedItem;
if (((!(_editable)) && (!((_local1.data == null))))){
return (_local1.data);
};
return (itemToLabel(_local1));
}
public function get prompt():String{
return (_prompt);
}
public function set dataProvider(_arg1:DataProvider):void{
_arg1.addEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange, false, 0, true);
list.dataProvider = _arg1;
invalidate(InvalidationType.DATA);
}
public function set restrict(_arg1:String):void{
if (((componentInspectorSetting) && ((_arg1 == "")))){
_arg1 = null;
};
if (!_editable){
return;
};
inputField.restrict = _arg1;
}
protected function onTextInput(_arg1:Event):void{
_arg1.stopPropagation();
if (!_editable){
return;
};
editableValue = inputField.text;
selectedIndex = -1;
dispatchEvent(new Event(Event.CHANGE));
}
protected function onInputFieldFocus(_arg1:FocusEvent):void{
inputField.addEventListener(ComponentEvent.ENTER, onEnter, false, 0, true);
close();
}
public function getItemAt(_arg1:uint):Object{
return (list.getItemAt(_arg1));
}
override protected function initializeAccessibility():void{
if (ComboBox.createAccessibilityImplementation != null){
ComboBox.createAccessibilityImplementation(this);
};
}
protected function drawLayout():void{
var _local1:Number;
var _local2:Number;
_local1 = (getStyleValue("buttonWidth") as Number);
_local2 = (getStyleValue("textPadding") as Number);
background.setSize(width, height);
inputField.x = (inputField.y = _local2);
inputField.setSize(((width - _local1) - _local2), (height - _local2));
list.width = (isNaN(_dropdownWidth)) ? width : _dropdownWidth;
background.enabled = enabled;
background.drawNow();
}
public function removeItem(_arg1:Object):Object{
return (list.removeItem(_arg1));
}
private function addCloseListener(_arg1:Event){
removeEventListener(Event.ENTER_FRAME, addCloseListener);
if (!isOpen){
return;
};
stage.addEventListener(MouseEvent.MOUSE_DOWN, onStageClick, false, 0, true);
}
public function get dataProvider():DataProvider{
return (list.dataProvider);
}
public function get textField():TextInput{
return (inputField);
}
protected function setStyles():void{
copyStylesToChild(background, BACKGROUND_STYLES);
copyStylesToChild(list, LIST_STYLES);
}
public function set labelFunction(_arg1:Function):void{
list.labelFunction = _arg1;
invalidate(InvalidationType.DATA);
}
protected function drawTextFormat():void{
var _local1:TextFormat;
_local1 = (getStyleValue((_enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local1 == null){
_local1 = new TextFormat();
};
inputField.textField.defaultTextFormat = _local1;
inputField.textField.setTextFormat(_local1);
setEmbedFonts();
}
public function set selectedIndex(_arg1:int):void{
list.selectedIndex = _arg1;
highlightCell();
invalidate(InvalidationType.SELECTED);
}
public function close():void{
highlightCell();
highlightedCell = -1;
if (!isOpen){
return;
};
dispatchEvent(new Event(Event.CLOSE));
stage.removeEventListener(MouseEvent.MOUSE_DOWN, onStageClick);
isOpen = false;
stage.removeChild(list);
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, List.getStyleDefinition()));
}
}
}//package fl.controls
Section 135
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import fl.events.*;
import fl.managers.*;
import fl.core.*;
import flash.ui.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
protected var _labelPlacement:String;// = "right"
protected var _toggle:Boolean;// = false
protected var icon:DisplayObject;
protected var oldMouseState:String;
protected var mode:String;// = "center"
public var textField:TextField;
protected var _label:String;// = "Label"
private static var defaultStyles:Object = {icon:null, upIcon:null, downIcon:null, overIcon:null, disabledIcon:null, selectedDisabledIcon:null, selectedUpIcon:null, selectedDownIcon:null, selectedOverIcon:null, textFormat:null, disabledTextFormat:null, textPadding:5, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function LabelButton(){
_labelPlacement = ButtonLabelPlacement.RIGHT;
_toggle = false;
_label = "Label";
mode = "center";
super();
}
protected function toggleSelected(_arg1:MouseEvent):void{
selected = !(selected);
dispatchEvent(new Event(Event.CHANGE, true));
}
public function get labelPlacement():String{
return (_labelPlacement);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
if (oldMouseState == null){
oldMouseState = mouseState;
};
setMouseState("down");
startPress();
};
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
setMouseState(oldMouseState);
oldMouseState = null;
endPress();
dispatchEvent(new MouseEvent(MouseEvent.CLICK));
};
}
override public function get selected():Boolean{
return ((_toggle) ? _selected : false);
}
public function set labelPlacement(_arg1:String):void{
_labelPlacement = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set toggle(_arg1:Boolean):void{
if (((!(_arg1)) && (super.selected))){
selected = false;
};
_toggle = _arg1;
if (_toggle){
addEventListener(MouseEvent.CLICK, toggleSelected, false, 0, true);
} else {
removeEventListener(MouseEvent.CLICK, toggleSelected);
};
invalidate(InvalidationType.STATE);
}
public function get label():String{
return (_label);
}
override public function set selected(_arg1:Boolean):void{
_selected = _arg1;
if (_toggle){
invalidate(InvalidationType.STATE);
};
}
override protected function draw():void{
if (textField.text != _label){
label = _label;
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
drawIcon();
drawTextFormat();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
public function get toggle():Boolean{
return (_toggle);
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
addChild(textField);
}
override protected function drawLayout():void{
var _local1:Number;
var _local2:String;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local1 = Number(getStyleValue("textPadding"));
_local2 = ((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement;
textField.height = (textField.textHeight + 4);
_local3 = (textField.textWidth + 4);
_local4 = (textField.textHeight + 4);
_local5 = ((icon)==null) ? 0 : (icon.width + _local1);
_local6 = ((icon)==null) ? 0 : (icon.height + _local1);
textField.visible = (label.length > 0);
if (icon != null){
icon.x = Math.round(((width - icon.width) / 2));
icon.y = Math.round(((height - icon.height) / 2));
};
if (textField.visible == false){
textField.width = 0;
textField.height = 0;
} else {
if ((((_local2 == ButtonLabelPlacement.BOTTOM)) || ((_local2 == ButtonLabelPlacement.TOP)))){
_local7 = Math.max(0, Math.min(_local3, (width - (2 * _local1))));
if ((height - 2) > _local4){
_local8 = _local4;
} else {
_local8 = (height - 2);
};
_local3 = _local7;
textField.width = _local3;
_local4 = _local8;
textField.height = _local4;
textField.x = Math.round(((width - _local3) / 2));
textField.y = Math.round(((((height - textField.height) - _local6) / 2) + ((_local2)==ButtonLabelPlacement.BOTTOM) ? _local6 : 0));
if (icon != null){
icon.y = Math.round(((_local2)==ButtonLabelPlacement.BOTTOM) ? (textField.y - _local6) : ((textField.y + textField.height) + _local1));
};
} else {
_local7 = Math.max(0, Math.min(_local3, ((width - _local5) - (2 * _local1))));
_local3 = _local7;
textField.width = _local3;
textField.x = Math.round(((((width - _local3) - _local5) / 2) + ((_local2)!=ButtonLabelPlacement.LEFT) ? _local5 : 0));
textField.y = Math.round(((height - textField.height) / 2));
if (icon != null){
icon.x = Math.round(((_local2)!=ButtonLabelPlacement.LEFT) ? (textField.x - _local5) : ((textField.x + _local3) + _local1));
};
};
};
super.drawLayout();
}
override protected function initializeAccessibility():void{
if (LabelButton.createAccessibilityImplementation != null){
LabelButton.createAccessibilityImplementation(this);
};
}
protected function drawIcon():void{
var _local1:DisplayObject;
var _local2:String;
var _local3:Object;
_local1 = icon;
_local2 = (enabled) ? mouseState : "disabled";
if (selected){
_local2 = (("selected" + _local2.substr(0, 1).toUpperCase()) + _local2.substr(1));
};
_local2 = (_local2 + "Icon");
_local3 = getStyleValue(_local2);
if (_local3 == null){
_local3 = getStyleValue("icon");
};
if (_local3 != null){
icon = getDisplayObjectInstance(_local3);
};
if (icon != null){
addChildAt(icon, 1);
};
if (((!((_local1 == null))) && (!((_local1 == icon))))){
removeChild(_local1);
};
}
public function set label(_arg1:String):void{
_label = _arg1;
if (textField.text != _label){
textField.text = _label;
dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE));
};
invalidate(InvalidationType.SIZE);
invalidate(InvalidationType.STYLES);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
}
}
}//package fl.controls
Section 136
//List (fl.controls.List)
package fl.controls {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import fl.managers.*;
import fl.core.*;
import fl.controls.listClasses.*;
import flash.ui.*;
public class List extends SelectableList implements IFocusManagerComponent {
protected var _labelField:String;// = "label"
protected var _rowHeight:Number;// = 20
protected var _cellRenderer:Object;
protected var _iconField:String;// = "icon"
protected var _labelFunction:Function;
protected var _iconFunction:Function;
private static var defaultStyles:Object = {focusRectSkin:null, focusRectPadding:null};
public static var createAccessibilityImplementation:Function;
public function List(){
_rowHeight = 20;
_labelField = "label";
_iconField = "icon";
super();
}
public function get iconField():String{
return (_iconField);
}
protected function doKeySelection(_arg1:int, _arg2:Boolean, _arg3:Boolean):void{
var _local4:Boolean;
var _local5:int;
var _local6:Array;
var _local7:int;
var _local8:int;
_local4 = false;
if (_arg2){
_local6 = [];
_local7 = lastCaretIndex;
_local8 = _arg1;
if (_local7 == -1){
_local7 = ((caretIndex)!=-1) ? caretIndex : _arg1;
};
if (_local7 > _local8){
_local8 = _local7;
_local7 = _arg1;
};
_local5 = _local7;
while (_local5 <= _local8) {
_local6.push(_local5);
_local5++;
};
selectedIndices = _local6;
caretIndex = _arg1;
_local4 = true;
} else {
selectedIndex = _arg1;
caretIndex = (lastCaretIndex = _arg1);
_local4 = true;
};
if (_local4){
dispatchEvent(new Event(Event.CHANGE));
};
invalidate(InvalidationType.DATA);
}
override protected function drawList():void{
var _local1:Rectangle;
var _local2:uint;
var _local3:uint;
var _local4:uint;
var _local5:Object;
var _local6:ICellRenderer;
var _local7:Dictionary;
var _local8:Dictionary;
var _local9:Boolean;
var _local10:String;
var _local11:Object;
var _local12:Sprite;
var _local13:String;
listHolder.x = (listHolder.y = contentPadding);
_local1 = listHolder.scrollRect;
_local1.x = _horizontalScrollPosition;
_local1.y = (Math.floor(_verticalScrollPosition) % rowHeight);
listHolder.scrollRect = _local1;
listHolder.cacheAsBitmap = useBitmapScrolling;
_local2 = Math.floor((_verticalScrollPosition / rowHeight));
_local3 = Math.min(length, ((_local2 + rowCount) + 1));
_local7 = (renderedItems = new Dictionary(true));
_local4 = _local2;
while (_local4 < _local3) {
_local7[_dataProvider.getItemAt(_local4)] = true;
_local4++;
};
_local8 = new Dictionary(true);
while (activeCellRenderers.length > 0) {
_local6 = (activeCellRenderers.pop() as ICellRenderer);
_local5 = _local6.data;
if ((((_local7[_local5] == null)) || ((invalidItems[_local5] == true)))){
availableCellRenderers.push(_local6);
} else {
_local8[_local5] = _local6;
invalidItems[_local5] = true;
};
list.removeChild((_local6 as DisplayObject));
};
invalidItems = new Dictionary(true);
_local4 = _local2;
while (_local4 < _local3) {
_local9 = false;
_local5 = _dataProvider.getItemAt(_local4);
if (_local8[_local5] != null){
_local9 = true;
_local6 = _local8[_local5];
delete _local8[_local5];
} else {
if (availableCellRenderers.length > 0){
_local6 = (availableCellRenderers.pop() as ICellRenderer);
} else {
_local6 = (getDisplayObjectInstance(getStyleValue("cellRenderer")) as ICellRenderer);
_local12 = (_local6 as Sprite);
if (_local12 != null){
_local12.addEventListener(MouseEvent.CLICK, handleCellRendererClick, false, 0, true);
_local12.addEventListener(MouseEvent.ROLL_OVER, handleCellRendererMouseEvent, false, 0, true);
_local12.addEventListener(MouseEvent.ROLL_OUT, handleCellRendererMouseEvent, false, 0, true);
_local12.addEventListener(Event.CHANGE, handleCellRendererChange, false, 0, true);
_local12.doubleClickEnabled = true;
_local12.addEventListener(MouseEvent.DOUBLE_CLICK, handleCellRendererDoubleClick, false, 0, true);
if (_local12["setStyle"] != null){
for (_local13 in rendererStyles) {
var _local16 = _local12;
_local16["setStyle"](_local13, rendererStyles[_local13]);
};
};
};
};
};
list.addChild((_local6 as Sprite));
activeCellRenderers.push(_local6);
_local6.y = (rowHeight * (_local4 - _local2));
_local6.setSize((availableWidth + _maxHorizontalScrollPosition), rowHeight);
_local10 = itemToLabel(_local5);
_local11 = null;
if (_iconFunction != null){
_local11 = _iconFunction(_local5);
} else {
if (_iconField != null){
_local11 = _local5[_iconField];
};
};
if (!_local9){
_local6.data = _local5;
};
_local6.listData = new ListData(_local10, _local11, this, _local4, _local4, 0);
_local6.selected = !((_selectedIndices.indexOf(_local4) == -1));
if ((_local6 is UIComponent)){
(_local6 as UIComponent).drawNow();
};
_local4++;
};
}
public function get iconFunction():Function{
return (_iconFunction);
}
public function set iconField(_arg1:String):void{
if (_arg1 == _iconField){
return;
};
_iconField = _arg1;
invalidate(InvalidationType.DATA);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
var _local2:int;
if (!selectable){
return;
};
switch (_arg1.keyCode){
case Keyboard.UP:
case Keyboard.DOWN:
case Keyboard.END:
case Keyboard.HOME:
case Keyboard.PAGE_UP:
case Keyboard.PAGE_DOWN:
moveSelectionVertically(_arg1.keyCode, ((_arg1.shiftKey) && (_allowMultipleSelection)), ((_arg1.ctrlKey) && (_allowMultipleSelection)));
break;
case Keyboard.LEFT:
case Keyboard.RIGHT:
moveSelectionHorizontally(_arg1.keyCode, ((_arg1.shiftKey) && (_allowMultipleSelection)), ((_arg1.ctrlKey) && (_allowMultipleSelection)));
break;
case Keyboard.SPACE:
if (caretIndex == -1){
caretIndex = 0;
};
doKeySelection(caretIndex, _arg1.shiftKey, _arg1.ctrlKey);
scrollToSelected();
break;
default:
_local2 = getNextIndexAtLetter(String.fromCharCode(_arg1.keyCode), selectedIndex);
if (_local2 > -1){
selectedIndex = _local2;
scrollToSelected();
};
break;
};
_arg1.stopPropagation();
}
override public function itemToLabel(_arg1:Object):String{
if (_labelFunction != null){
return (String(_labelFunction(_arg1)));
};
return (((_arg1[_labelField])!=null) ? String(_arg1[_labelField]) : "");
}
public function get labelField():String{
return (_labelField);
}
override protected function moveSelectionVertically(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
var _local4:int;
var _local5:int;
var _local6:int;
_local4 = Math.max(Math.floor((calculateAvailableHeight() / rowHeight)), 1);
_local5 = -1;
_local6 = 0;
switch (_arg1){
case Keyboard.UP:
if (caretIndex > 0){
_local5 = (caretIndex - 1);
};
break;
case Keyboard.DOWN:
if (caretIndex < (length - 1)){
_local5 = (caretIndex + 1);
};
break;
case Keyboard.PAGE_UP:
if (caretIndex > 0){
_local5 = Math.max((caretIndex - _local4), 0);
};
break;
case Keyboard.PAGE_DOWN:
if (caretIndex < (length - 1)){
_local5 = Math.min((caretIndex + _local4), (length - 1));
};
break;
case Keyboard.HOME:
if (caretIndex > 0){
_local5 = 0;
};
break;
case Keyboard.END:
if (caretIndex < (length - 1)){
_local5 = (length - 1);
};
break;
};
if (_local5 >= 0){
doKeySelection(_local5, _arg2, _arg3);
scrollToSelected();
};
}
public function set labelField(_arg1:String):void{
if (_arg1 == _labelField){
return;
};
_labelField = _arg1;
invalidate(InvalidationType.DATA);
}
public function set rowCount(_arg1:uint):void{
var _local2:Number;
var _local3:Number;
_local2 = Number(getStyleValue("contentPadding"));
_local3 = ((((_horizontalScrollPolicy == ScrollPolicy.ON)) || ((((_horizontalScrollPolicy == ScrollPolicy.AUTO)) && ((_maxHorizontalScrollPosition > 0)))))) ? 15 : 0;
height = (((rowHeight * _arg1) + (2 * _local2)) + _local3);
}
override protected function setHorizontalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
list.x = -(_arg1);
super.setHorizontalScrollPosition(_arg1, true);
}
public function set iconFunction(_arg1:Function):void{
if (_iconFunction == _arg1){
return;
};
_iconFunction = _arg1;
invalidate(InvalidationType.DATA);
}
public function get labelFunction():Function{
return (_labelFunction);
}
override protected function moveSelectionHorizontally(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
}
override protected function setVerticalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
invalidate(InvalidationType.SCROLL);
super.setVerticalScrollPosition(_arg1, true);
}
protected function calculateAvailableHeight():Number{
var _local1:Number;
_local1 = Number(getStyleValue("contentPadding"));
return (((height - (_local1 * 2)) - ((((_horizontalScrollPolicy == ScrollPolicy.ON)) || ((((_horizontalScrollPolicy == ScrollPolicy.AUTO)) && ((_maxHorizontalScrollPosition > 0)))))) ? 15 : 0));
}
override protected function draw():void{
var _local1:Boolean;
_local1 = !((contentHeight == (rowHeight * length)));
contentHeight = (rowHeight * length);
if (isInvalid(InvalidationType.STYLES)){
setStyles();
drawBackground();
if (contentPadding != getStyleValue("contentPadding")){
invalidate(InvalidationType.SIZE, false);
};
if (_cellRenderer != getStyleValue("cellRenderer")){
_invalidateList();
_cellRenderer = getStyleValue("cellRenderer");
};
};
if (((isInvalid(InvalidationType.SIZE, InvalidationType.STATE)) || (_local1))){
drawLayout();
};
if (isInvalid(InvalidationType.RENDERER_STYLES)){
updateRendererStyles();
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.SIZE, InvalidationType.DATA, InvalidationType.SCROLL, InvalidationType.SELECTED)){
drawList();
};
updateChildren();
validate();
}
override protected function configUI():void{
useFixedHorizontalScrolling = true;
_horizontalScrollPolicy = ScrollPolicy.AUTO;
_verticalScrollPolicy = ScrollPolicy.AUTO;
super.configUI();
}
override public function get rowCount():uint{
return (Math.ceil((calculateAvailableHeight() / rowHeight)));
}
override protected function initializeAccessibility():void{
if (List.createAccessibilityImplementation != null){
List.createAccessibilityImplementation(this);
};
}
override public function scrollToIndex(_arg1:int):void{
var _local2:uint;
var _local3:uint;
drawNow();
_local2 = (Math.floor(((_verticalScrollPosition + availableHeight) / rowHeight)) - 1);
_local3 = Math.ceil((_verticalScrollPosition / rowHeight));
if (_arg1 < _local3){
verticalScrollPosition = (_arg1 * rowHeight);
} else {
if (_arg1 > _local2){
verticalScrollPosition = (((_arg1 + 1) * rowHeight) - availableHeight);
};
};
}
public function get rowHeight():Number{
return (_rowHeight);
}
public function set labelFunction(_arg1:Function):void{
if (_labelFunction == _arg1){
return;
};
_labelFunction = _arg1;
invalidate(InvalidationType.DATA);
}
public function set rowHeight(_arg1:Number):void{
_rowHeight = _arg1;
invalidate(InvalidationType.SIZE);
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, SelectableList.getStyleDefinition()));
}
}
}//package fl.controls
Section 137
//ScrollBar (fl.controls.ScrollBar)
package fl.controls {
import flash.events.*;
import fl.events.*;
import fl.core.*;
public class ScrollBar extends UIComponent {
private var _direction:String;// = "vertical"
protected var inDrag:Boolean;// = false
protected var upArrow:BaseButton;
private var _pageScrollSize:Number;// = 0
protected var downArrow:BaseButton;
private var _pageSize:Number;// = 10
private var thumbScrollOffset:Number;
private var _maxScrollPosition:Number;// = 0
private var _scrollPosition:Number;// = 0
protected var track:BaseButton;
private var _minScrollPosition:Number;// = 0
private var _lineScrollSize:Number;// = 1
protected var thumb:LabelButton;
protected static const THUMB_STYLES:Object = {disabledSkin:"thumbDisabledSkin", downSkin:"thumbDownSkin", overSkin:"thumbOverSkin", upSkin:"thumbUpSkin", icon:"thumbIcon", textPadding:0};
public static const WIDTH:Number = 15;
protected static const DOWN_ARROW_STYLES:Object = {disabledSkin:"downArrowDisabledSkin", downSkin:"downArrowDownSkin", overSkin:"downArrowOverSkin", upSkin:"downArrowUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval"};
protected static const UP_ARROW_STYLES:Object = {disabledSkin:"upArrowDisabledSkin", downSkin:"upArrowDownSkin", overSkin:"upArrowOverSkin", upSkin:"upArrowUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval"};
protected static const TRACK_STYLES:Object = {disabledSkin:"trackDisabledSkin", downSkin:"trackDownSkin", overSkin:"trackOverSkin", upSkin:"trackUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval"};
private static var defaultStyles:Object = {downArrowDisabledSkin:"ScrollArrowDown_disabledSkin", downArrowDownSkin:"ScrollArrowDown_downSkin", downArrowOverSkin:"ScrollArrowDown_overSkin", downArrowUpSkin:"ScrollArrowDown_upSkin", thumbDisabledSkin:"ScrollThumb_upSkin", thumbDownSkin:"ScrollThumb_downSkin", thumbOverSkin:"ScrollThumb_overSkin", thumbUpSkin:"ScrollThumb_upSkin", trackDisabledSkin:"ScrollTrack_skin", trackDownSkin:"ScrollTrack_skin", trackOverSkin:"ScrollTrack_skin", trackUpSkin:"ScrollTrack_skin", upArrowDisabledSkin:"ScrollArrowUp_disabledSkin", upArrowDownSkin:"ScrollArrowUp_downSkin", upArrowOverSkin:"ScrollArrowUp_overSkin", upArrowUpSkin:"ScrollArrowUp_upSkin", thumbIcon:"ScrollBar_thumbIcon", repeatDelay:500, repeatInterval:35};
public function ScrollBar(){
_pageSize = 10;
_pageScrollSize = 0;
_lineScrollSize = 1;
_minScrollPosition = 0;
_maxScrollPosition = 0;
_scrollPosition = 0;
_direction = ScrollBarDirection.VERTICAL;
inDrag = false;
super();
setStyles();
focusEnabled = false;
}
public function get minScrollPosition():Number{
return (_minScrollPosition);
}
public function set minScrollPosition(_arg1:Number):void{
setScrollProperties(_pageSize, _arg1, _maxScrollPosition);
}
public function setScrollPosition(_arg1:Number, _arg2:Boolean=true):void{
var _local3:Number;
_local3 = scrollPosition;
_scrollPosition = Math.max(_minScrollPosition, Math.min(_maxScrollPosition, _arg1));
if (_local3 == _scrollPosition){
return;
};
if (_arg2){
dispatchEvent(new ScrollEvent(_direction, (scrollPosition - _local3), scrollPosition));
};
updateThumb();
}
public function set scrollPosition(_arg1:Number):void{
setScrollPosition(_arg1, true);
}
public function get pageScrollSize():Number{
return (((_pageScrollSize)==0) ? _pageSize : _pageScrollSize);
}
public function set pageSize(_arg1:Number):void{
if (_arg1 > 0){
_pageSize = _arg1;
};
}
public function setScrollProperties(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=0):void{
this.pageSize = _arg1;
_minScrollPosition = _arg2;
_maxScrollPosition = _arg3;
if (_arg4 >= 0){
_pageScrollSize = _arg4;
};
enabled = (_maxScrollPosition > _minScrollPosition);
setScrollPosition(_scrollPosition, false);
updateThumb();
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
downArrow.enabled = (track.enabled = (thumb.enabled = (upArrow.enabled = ((enabled) && ((_maxScrollPosition > _minScrollPosition))))));
updateThumb();
}
protected function updateThumb():void{
var _local1:Number;
_local1 = ((_maxScrollPosition - _minScrollPosition) + _pageSize);
if ((((((track.height <= 12)) || ((_maxScrollPosition <= _minScrollPosition)))) || ((((_local1 == 0)) || (isNaN(_local1)))))){
thumb.height = 12;
thumb.visible = false;
} else {
thumb.height = Math.max(13, ((_pageSize / _local1) * track.height));
thumb.y = (track.y + ((track.height - thumb.height) * ((_scrollPosition - _minScrollPosition) / (_maxScrollPosition - _minScrollPosition))));
thumb.visible = enabled;
};
}
protected function thumbPressHandler(_arg1:MouseEvent):void{
inDrag = true;
thumbScrollOffset = (mouseY - thumb.y);
thumb.mouseStateLocked = true;
mouseChildren = false;
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleThumbDrag, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbReleaseHandler, false, 0, true);
}
protected function thumbReleaseHandler(_arg1:MouseEvent):void{
inDrag = false;
mouseChildren = true;
thumb.mouseStateLocked = false;
stage.removeEventListener(MouseEvent.MOUSE_MOVE, handleThumbDrag);
stage.removeEventListener(MouseEvent.MOUSE_UP, thumbReleaseHandler);
}
public function set pageScrollSize(_arg1:Number):void{
if (_arg1 >= 0){
_pageScrollSize = _arg1;
};
}
protected function handleThumbDrag(_arg1:MouseEvent):void{
var _local2:Number;
_local2 = Math.max(0, Math.min((track.height - thumb.height), ((mouseY - track.y) - thumbScrollOffset)));
setScrollPosition((((_local2 / (track.height - thumb.height)) * (_maxScrollPosition - _minScrollPosition)) + _minScrollPosition));
}
public function set direction(_arg1:String):void{
var _local2:Boolean;
if (_direction == _arg1){
return;
};
_direction = _arg1;
if (isLivePreview){
return;
};
setScaleY(1);
_local2 = (_direction == ScrollBarDirection.HORIZONTAL);
if (((_local2) && (componentInspectorSetting))){
if (rotation == 90){
return;
};
setScaleX(-1);
rotation = -90;
};
if (!componentInspectorSetting){
if (((_local2) && ((rotation == 0)))){
rotation = -90;
setScaleX(-1);
} else {
if (((!(_local2)) && ((rotation == -90)))){
rotation = 0;
setScaleX(1);
};
};
};
invalidate(InvalidationType.SIZE);
}
public function set lineScrollSize(_arg1:Number):void{
if (_arg1 > 0){
_lineScrollSize = _arg1;
};
}
override public function get height():Number{
return (((_direction)==ScrollBarDirection.HORIZONTAL) ? super.width : super.height);
}
protected function scrollPressHandler(_arg1:ComponentEvent):void{
var _local2:Number;
var _local3:Number;
_arg1.stopImmediatePropagation();
if (_arg1.currentTarget == upArrow){
setScrollPosition((_scrollPosition - _lineScrollSize));
} else {
if (_arg1.currentTarget == downArrow){
setScrollPosition((_scrollPosition + _lineScrollSize));
} else {
_local2 = (((track.mouseY / track.height) * (_maxScrollPosition - _minScrollPosition)) + _minScrollPosition);
_local3 = ((pageScrollSize)==0) ? pageSize : pageScrollSize;
if (_scrollPosition < _local2){
setScrollPosition(Math.min(_local2, (_scrollPosition + _local3)));
} else {
if (_scrollPosition > _local2){
setScrollPosition(Math.max(_local2, (_scrollPosition - _local3)));
};
};
};
};
}
public function get pageSize():Number{
return (_pageSize);
}
public function set maxScrollPosition(_arg1:Number):void{
setScrollProperties(_pageSize, _minScrollPosition, _arg1);
}
public function get scrollPosition():Number{
return (_scrollPosition);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override protected function draw():void{
var _local1:Number;
if (isInvalid(InvalidationType.SIZE)){
_local1 = super.height;
downArrow.move(0, Math.max(upArrow.height, (_local1 - downArrow.height)));
track.setSize(WIDTH, Math.max(0, (_local1 - (downArrow.height + upArrow.height))));
updateThumb();
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
setStyles();
};
downArrow.drawNow();
upArrow.drawNow();
track.drawNow();
thumb.drawNow();
validate();
}
override protected function configUI():void{
super.configUI();
track = new BaseButton();
track.move(0, 14);
track.useHandCursor = false;
track.autoRepeat = true;
track.focusEnabled = false;
addChild(track);
thumb = new LabelButton();
thumb.label = "";
thumb.setSize(WIDTH, 15);
thumb.move(0, 15);
thumb.focusEnabled = false;
addChild(thumb);
downArrow = new BaseButton();
downArrow.setSize(WIDTH, 14);
downArrow.autoRepeat = true;
downArrow.focusEnabled = false;
addChild(downArrow);
upArrow = new BaseButton();
upArrow.setSize(WIDTH, 14);
upArrow.move(0, 0);
upArrow.autoRepeat = true;
upArrow.focusEnabled = false;
addChild(upArrow);
upArrow.addEventListener(ComponentEvent.BUTTON_DOWN, scrollPressHandler, false, 0, true);
downArrow.addEventListener(ComponentEvent.BUTTON_DOWN, scrollPressHandler, false, 0, true);
track.addEventListener(ComponentEvent.BUTTON_DOWN, scrollPressHandler, false, 0, true);
thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbPressHandler, false, 0, true);
enabled = false;
}
public function get direction():String{
return (_direction);
}
public function get lineScrollSize():Number{
return (_lineScrollSize);
}
override public function setSize(_arg1:Number, _arg2:Number):void{
if (_direction == ScrollBarDirection.HORIZONTAL){
super.setSize(_arg2, _arg1);
} else {
super.setSize(_arg1, _arg2);
};
}
public function get maxScrollPosition():Number{
return (_maxScrollPosition);
}
override public function get width():Number{
return (((_direction)==ScrollBarDirection.HORIZONTAL) ? super.height : super.width);
}
protected function setStyles():void{
copyStylesToChild(downArrow, DOWN_ARROW_STYLES);
copyStylesToChild(thumb, THUMB_STYLES);
copyStylesToChild(track, TRACK_STYLES);
copyStylesToChild(upArrow, UP_ARROW_STYLES);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 138
//ScrollBarDirection (fl.controls.ScrollBarDirection)
package fl.controls {
public class ScrollBarDirection {
public static const HORIZONTAL:String = "horizontal";
public static const VERTICAL:String = "vertical";
}
}//package fl.controls
Section 139
//ScrollPolicy (fl.controls.ScrollPolicy)
package fl.controls {
public class ScrollPolicy {
public static const OFF:String = "off";
public static const ON:String = "on";
public static const AUTO:String = "auto";
}
}//package fl.controls
Section 140
//SelectableList (fl.controls.SelectableList)
package fl.controls {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import fl.events.*;
import fl.managers.*;
import fl.core.*;
import fl.controls.listClasses.*;
import fl.data.*;
import fl.containers.*;
import flash.ui.*;
public class SelectableList extends BaseScrollPane implements IFocusManagerComponent {
protected var invalidItems:Dictionary;
protected var renderedItems:Dictionary;
protected var listHolder:Sprite;
protected var _allowMultipleSelection:Boolean;// = false
protected var lastCaretIndex:int;// = -1
protected var _selectedIndices:Array;
protected var availableCellRenderers:Array;
protected var list:Sprite;
protected var caretIndex:int;// = -1
protected var updatedRendererStyles:Object;
protected var preChangeItems:Array;
protected var activeCellRenderers:Array;
protected var rendererStyles:Object;
protected var _verticalScrollPosition:Number;
protected var _dataProvider:DataProvider;
protected var _horizontalScrollPosition:Number;
private var collectionItemImport:SimpleCollectionItem;
protected var _selectable:Boolean;// = true
private static var defaultStyles:Object = {skin:"List_skin", cellRenderer:CellRenderer, contentPadding:null, disabledAlpha:null};
public static var createAccessibilityImplementation:Function;
public function SelectableList(){
_allowMultipleSelection = false;
_selectable = true;
caretIndex = -1;
lastCaretIndex = -1;
super();
activeCellRenderers = [];
availableCellRenderers = [];
invalidItems = new Dictionary(true);
renderedItems = new Dictionary(true);
_selectedIndices = [];
if (dataProvider == null){
dataProvider = new DataProvider();
};
verticalScrollPolicy = ScrollPolicy.AUTO;
rendererStyles = {};
updatedRendererStyles = {};
}
protected function drawList():void{
}
public function set allowMultipleSelection(_arg1:Boolean):void{
if (_arg1 == _allowMultipleSelection){
return;
};
_allowMultipleSelection = _arg1;
if (((!(_arg1)) && ((_selectedIndices.length > 1)))){
_selectedIndices = [_selectedIndices.pop()];
invalidate(InvalidationType.DATA);
};
}
public function sortItemsOn(_arg1:String, _arg2:Object=null){
return (_dataProvider.sortOn(_arg1, _arg2));
}
public function removeItemAt(_arg1:uint):Object{
return (_dataProvider.removeItemAt(_arg1));
}
public function get selectedItem():Object{
return (((_selectedIndices.length)==0) ? null : _dataProvider.getItemAt(selectedIndex));
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!selectable){
return;
};
switch (_arg1.keyCode){
case Keyboard.UP:
case Keyboard.DOWN:
case Keyboard.END:
case Keyboard.HOME:
case Keyboard.PAGE_UP:
case Keyboard.PAGE_DOWN:
moveSelectionVertically(_arg1.keyCode, ((_arg1.shiftKey) && (_allowMultipleSelection)), ((_arg1.ctrlKey) && (_allowMultipleSelection)));
_arg1.stopPropagation();
break;
case Keyboard.LEFT:
case Keyboard.RIGHT:
moveSelectionHorizontally(_arg1.keyCode, ((_arg1.shiftKey) && (_allowMultipleSelection)), ((_arg1.ctrlKey) && (_allowMultipleSelection)));
_arg1.stopPropagation();
break;
};
}
public function get selectable():Boolean{
return (_selectable);
}
public function itemToCellRenderer(_arg1:Object):ICellRenderer{
var _local2:*;
var _local3:ICellRenderer;
if (_arg1 != null){
for (_local2 in activeCellRenderers) {
_local3 = (activeCellRenderers[_local2] as ICellRenderer);
if (_local3.data == _arg1){
return (_local3);
};
};
};
return (null);
}
public function getNextIndexAtLetter(_arg1:String, _arg2:int=-1):int{
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:Object;
var _local7:String;
if (length == 0){
return (-1);
};
_arg1 = _arg1.toUpperCase();
_local3 = (length - 1);
_local4 = 0;
while (_local4 < _local3) {
_local5 = ((_arg2 + 1) + _local4);
if (_local5 > (length - 1)){
_local5 = (_local5 - length);
};
_local6 = getItemAt(_local5);
if (_local6 == null){
break;
};
_local7 = itemToLabel(_local6);
if (_local7 == null){
} else {
if (_local7.charAt(0).toUpperCase() == _arg1){
return (_local5);
};
};
_local4++;
};
return (-1);
}
public function invalidateList():void{
_invalidateList();
invalidate(InvalidationType.DATA);
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
list.mouseChildren = _enabled;
}
public function get selectedIndices():Array{
return (_selectedIndices.concat());
}
public function set selectable(_arg1:Boolean):void{
if (_arg1 == _selectable){
return;
};
if (!_arg1){
selectedIndices = [];
};
_selectable = _arg1;
}
public function itemToLabel(_arg1:Object):String{
return (_arg1["label"]);
}
public function addItemAt(_arg1:Object, _arg2:uint):void{
_dataProvider.addItemAt(_arg1, _arg2);
invalidateList();
}
public function replaceItemAt(_arg1:Object, _arg2:uint):Object{
return (_dataProvider.replaceItemAt(_arg1, _arg2));
}
protected function handleDataChange(_arg1:DataChangeEvent):void{
var _local2:int;
var _local3:int;
var _local4:String;
var _local5:uint;
_local2 = _arg1.startIndex;
_local3 = _arg1.endIndex;
_local4 = _arg1.changeType;
if (_local4 == DataChangeType.INVALIDATE_ALL){
clearSelection();
invalidateList();
} else {
if (_local4 == DataChangeType.INVALIDATE){
_local5 = 0;
while (_local5 < _arg1.items.length) {
invalidateItem(_arg1.items[_local5]);
_local5++;
};
} else {
if (_local4 == DataChangeType.ADD){
_local5 = 0;
while (_local5 < _selectedIndices.length) {
if (_selectedIndices[_local5] >= _local2){
_selectedIndices[_local5] = (_selectedIndices[_local5] + (_local2 - _local3));
};
_local5++;
};
} else {
if (_local4 == DataChangeType.REMOVE){
_local5 = 0;
while (_local5 < _selectedIndices.length) {
if (_selectedIndices[_local5] >= _local2){
if (_selectedIndices[_local5] <= _local3){
delete _selectedIndices[_local5];
} else {
_selectedIndices[_local5] = (_selectedIndices[_local5] - ((_local2 - _local3) + 1));
};
};
_local5++;
};
} else {
if (_local4 == DataChangeType.REMOVE_ALL){
clearSelection();
} else {
if (_local4 == DataChangeType.REPLACE){
} else {
selectedItems = preChangeItems;
preChangeItems = null;
};
};
};
};
};
};
invalidate(InvalidationType.DATA);
}
protected function _invalidateList():void{
availableCellRenderers = [];
while (activeCellRenderers.length > 0) {
list.removeChild((activeCellRenderers.pop() as DisplayObject));
};
}
protected function updateRendererStyles():void{
var _local1:Array;
var _local2:uint;
var _local3:uint;
var _local4:String;
_local1 = availableCellRenderers.concat(activeCellRenderers);
_local2 = _local1.length;
_local3 = 0;
while (_local3 < _local2) {
if (_local1[_local3].setStyle == null){
} else {
for (_local4 in updatedRendererStyles) {
_local1[_local3].setStyle(_local4, updatedRendererStyles[_local4]);
};
_local1[_local3].drawNow();
};
_local3++;
};
updatedRendererStyles = {};
}
public function set selectedItem(_arg1:Object):void{
var _local2:int;
_local2 = _dataProvider.getItemIndex(_arg1);
selectedIndex = _local2;
}
public function sortItems(... _args){
return (_dataProvider.sort.apply(_dataProvider, _args));
}
public function removeAll():void{
_dataProvider.removeAll();
}
protected function handleCellRendererChange(_arg1:Event):void{
var _local2:ICellRenderer;
var _local3:uint;
_local2 = (_arg1.currentTarget as ICellRenderer);
_local3 = _local2.listData.index;
_dataProvider.invalidateItemAt(_local3);
}
protected function moveSelectionVertically(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
}
override protected function setHorizontalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
var _local3:Number;
if (_arg1 == _horizontalScrollPosition){
return;
};
_local3 = (_arg1 - _horizontalScrollPosition);
_horizontalScrollPosition = _arg1;
if (_arg2){
dispatchEvent(new ScrollEvent(ScrollBarDirection.HORIZONTAL, _local3, _arg1));
};
}
public function scrollToSelected():void{
scrollToIndex(selectedIndex);
}
public function invalidateItem(_arg1:Object):void{
if (renderedItems[_arg1] == null){
return;
};
invalidItems[_arg1] = true;
invalidate(InvalidationType.DATA);
}
protected function handleCellRendererClick(_arg1:MouseEvent):void{
var _local2:ICellRenderer;
var _local3:uint;
var _local4:int;
var _local5:int;
var _local6:uint;
if (!_enabled){
return;
};
_local2 = (_arg1.currentTarget as ICellRenderer);
_local3 = _local2.listData.index;
if (((!(dispatchEvent(new ListEvent(ListEvent.ITEM_CLICK, false, true, _local2.listData.column, _local2.listData.row, _local3, _local2.data)))) || (!(_selectable)))){
return;
};
_local4 = selectedIndices.indexOf(_local3);
if (!_allowMultipleSelection){
if (_local4 != -1){
return;
};
_local2.selected = true;
_selectedIndices = [_local3];
lastCaretIndex = (caretIndex = _local3);
} else {
if (_arg1.shiftKey){
_local6 = ((_selectedIndices.length)>0) ? _selectedIndices[0] : _local3;
_selectedIndices = [];
if (_local6 > _local3){
_local5 = _local6;
while (_local5 >= _local3) {
_selectedIndices.push(_local5);
_local5--;
};
} else {
_local5 = _local6;
while (_local5 <= _local3) {
_selectedIndices.push(_local5);
_local5++;
};
};
caretIndex = _local3;
} else {
if (_arg1.ctrlKey){
if (_local4 != -1){
_local2.selected = false;
_selectedIndices.splice(_local4, 1);
} else {
_local2.selected = true;
_selectedIndices.push(_local3);
};
caretIndex = _local3;
} else {
_selectedIndices = [_local3];
lastCaretIndex = (caretIndex = _local3);
};
};
};
dispatchEvent(new Event(Event.CHANGE));
invalidate(InvalidationType.DATA);
}
public function get length():uint{
return (_dataProvider.length);
}
public function get allowMultipleSelection():Boolean{
return (_allowMultipleSelection);
}
protected function onPreChange(_arg1:DataChangeEvent):void{
switch (_arg1.changeType){
case DataChangeType.REMOVE:
case DataChangeType.ADD:
case DataChangeType.INVALIDATE:
case DataChangeType.REMOVE_ALL:
case DataChangeType.REPLACE:
case DataChangeType.INVALIDATE_ALL:
break;
default:
preChangeItems = selectedItems;
break;
};
}
public function getRendererStyle(_arg1:String, _arg2:int=-1):Object{
return (rendererStyles[_arg1]);
}
override protected function setVerticalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
var _local3:Number;
if (_arg1 == _verticalScrollPosition){
return;
};
_local3 = (_arg1 - _verticalScrollPosition);
_verticalScrollPosition = _arg1;
if (_arg2){
dispatchEvent(new ScrollEvent(ScrollBarDirection.VERTICAL, _local3, _arg1));
};
}
protected function moveSelectionHorizontally(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
}
public function set selectedIndices(_arg1:Array):void{
if (!_selectable){
return;
};
_selectedIndices = ((_arg1)==null) ? [] : _arg1.concat();
invalidate(InvalidationType.SELECTED);
}
public function get selectedIndex():int{
return (((_selectedIndices.length)==0) ? -1 : _selectedIndices[(_selectedIndices.length - 1)]);
}
override protected function draw():void{
super.draw();
}
override protected function configUI():void{
super.configUI();
listHolder = new Sprite();
addChild(listHolder);
listHolder.scrollRect = contentScrollRect;
list = new Sprite();
listHolder.addChild(list);
}
public function addItem(_arg1:Object):void{
_dataProvider.addItem(_arg1);
invalidateList();
}
protected function handleCellRendererMouseEvent(_arg1:MouseEvent):void{
var _local2:ICellRenderer;
var _local3:String;
_local2 = (_arg1.target as ICellRenderer);
_local3 = ((_arg1.type)==MouseEvent.ROLL_OVER) ? ListEvent.ITEM_ROLL_OVER : ListEvent.ITEM_ROLL_OUT;
dispatchEvent(new ListEvent(_local3, false, false, _local2.listData.column, _local2.listData.row, _local2.listData.index, _local2.data));
}
public function clearRendererStyle(_arg1:String, _arg2:int=-1):void{
delete rendererStyles[_arg1];
updatedRendererStyles[_arg1] = null;
invalidate(InvalidationType.RENDERER_STYLES);
}
protected function handleCellRendererDoubleClick(_arg1:MouseEvent):void{
var _local2:ICellRenderer;
var _local3:uint;
if (!_enabled){
return;
};
_local2 = (_arg1.currentTarget as ICellRenderer);
_local3 = _local2.listData.index;
dispatchEvent(new ListEvent(ListEvent.ITEM_DOUBLE_CLICK, false, true, _local2.listData.column, _local2.listData.row, _local3, _local2.data));
}
public function get rowCount():uint{
return (0);
}
public function isItemSelected(_arg1:Object):Boolean{
return ((selectedItems.indexOf(_arg1) > -1));
}
public function set dataProvider(_arg1:DataProvider):void{
if (_dataProvider != null){
_dataProvider.removeEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange);
_dataProvider.removeEventListener(DataChangeEvent.PRE_DATA_CHANGE, onPreChange);
};
_dataProvider = _arg1;
_dataProvider.addEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange, false, 0, true);
_dataProvider.addEventListener(DataChangeEvent.PRE_DATA_CHANGE, onPreChange, false, 0, true);
clearSelection();
invalidateList();
}
override protected function drawLayout():void{
super.drawLayout();
contentScrollRect = listHolder.scrollRect;
contentScrollRect.width = availableWidth;
contentScrollRect.height = availableHeight;
listHolder.scrollRect = contentScrollRect;
}
public function getItemAt(_arg1:uint):Object{
return (_dataProvider.getItemAt(_arg1));
}
override protected function initializeAccessibility():void{
if (SelectableList.createAccessibilityImplementation != null){
SelectableList.createAccessibilityImplementation(this);
};
}
public function scrollToIndex(_arg1:int):void{
}
public function removeItem(_arg1:Object):Object{
return (_dataProvider.removeItem(_arg1));
}
public function get dataProvider():DataProvider{
return (_dataProvider);
}
public function set maxHorizontalScrollPosition(_arg1:Number):void{
_maxHorizontalScrollPosition = _arg1;
invalidate(InvalidationType.SIZE);
}
public function setRendererStyle(_arg1:String, _arg2:Object, _arg3:uint=0):void{
if (rendererStyles[_arg1] == _arg2){
return;
};
updatedRendererStyles[_arg1] = _arg2;
rendererStyles[_arg1] = _arg2;
invalidate(InvalidationType.RENDERER_STYLES);
}
public function invalidateItemAt(_arg1:uint):void{
var _local2:Object;
_local2 = _dataProvider.getItemAt(_arg1);
if (_local2 != null){
invalidateItem(_local2);
};
}
public function set selectedItems(_arg1:Array):void{
var _local2:Array;
var _local3:uint;
var _local4:int;
if (_arg1 == null){
selectedIndices = null;
return;
};
_local2 = [];
_local3 = 0;
while (_local3 < _arg1.length) {
_local4 = _dataProvider.getItemIndex(_arg1[_local3]);
if (_local4 != -1){
_local2.push(_local4);
};
_local3++;
};
selectedIndices = _local2;
}
public function clearSelection():void{
selectedIndex = -1;
}
override public function get maxHorizontalScrollPosition():Number{
return (_maxHorizontalScrollPosition);
}
public function get selectedItems():Array{
var _local1:Array;
var _local2:uint;
_local1 = [];
_local2 = 0;
while (_local2 < _selectedIndices.length) {
_local1.push(_dataProvider.getItemAt(_selectedIndices[_local2]));
_local2++;
};
return (_local1);
}
public function set selectedIndex(_arg1:int):void{
selectedIndices = ((_arg1)==-1) ? null : [_arg1];
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseScrollPane.getStyleDefinition()));
}
}
}//package fl.controls
Section 141
//TextInput (fl.controls.TextInput)
package fl.controls {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import fl.events.*;
import fl.managers.*;
import fl.core.*;
import flash.ui.*;
public class TextInput extends UIComponent implements IFocusManagerComponent {
protected var _html:Boolean;// = false
protected var _savedHTML:String;
protected var background:DisplayObject;
protected var _editable:Boolean;// = true
public var textField:TextField;
private static var defaultStyles:Object = {upSkin:"TextInput_upSkin", disabledSkin:"TextInput_disabledSkin", focusRectSkin:null, focusRectPadding:null, textFormat:null, disabledTextFormat:null, textPadding:0, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function TextInput(){
_editable = true;
_html = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
if (focusTarget != null){
focusTarget.drawFocus(_arg1);
return;
};
super.drawFocus(_arg1);
}
public function set imeMode(_arg1:String):void{
_imeMode = _arg1;
}
override protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((((_arg1 == textField)) || (super.isOurFocus(_arg1))));
}
protected function handleKeyDown(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.ENTER){
dispatchEvent(new ComponentEvent(ComponentEvent.ENTER, true));
};
}
public function set text(_arg1:String):void{
textField.text = _arg1;
_html = false;
invalidate(InvalidationType.DATA);
invalidate(InvalidationType.STYLES);
}
protected function updateTextFieldType():void{
textField.type = (((enabled) && (editable))) ? TextFieldType.INPUT : TextFieldType.DYNAMIC;
textField.selectable = enabled;
}
public function get selectionEndIndex():int{
return (textField.selectionEndIndex);
}
public function get editable():Boolean{
return (_editable);
}
override protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (_arg1.target == this){
stage.focus = textField;
};
_local2 = focusManager;
if (((editable) && (_local2))){
_local2.showFocusIndicator = true;
if (((textField.selectable) && ((textField.selectionBeginIndex == textField.selectionBeginIndex)))){
setSelection(0, textField.length);
};
};
super.focusInHandler(_arg1);
if (editable){
setIMEMode(true);
};
}
public function get selectionBeginIndex():int{
return (textField.selectionBeginIndex);
}
public function set alwaysShowSelection(_arg1:Boolean):void{
textField.alwaysShowSelection = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
updateTextFieldType();
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
public function get horizontalScrollPosition():int{
return (textField.scrollH);
}
public function set condenseWhite(_arg1:Boolean):void{
textField.condenseWhite = _arg1;
}
public function set displayAsPassword(_arg1:Boolean):void{
textField.displayAsPassword = _arg1;
}
public function set horizontalScrollPosition(_arg1:int):void{
textField.scrollH = _arg1;
}
public function get restrict():String{
return (textField.restrict);
}
public function get textWidth():Number{
return (textField.textWidth);
}
public function get textHeight():Number{
return (textField.textHeight);
}
public function set editable(_arg1:Boolean):void{
_editable = _arg1;
updateTextFieldType();
}
public function get maxChars():int{
return (textField.maxChars);
}
public function get length():int{
return (textField.length);
}
public function getLineMetrics(_arg1:int):TextLineMetrics{
return (textField.getLineMetrics(_arg1));
}
public function get imeMode():String{
return (_imeMode);
}
override protected function focusOutHandler(_arg1:FocusEvent):void{
super.focusOutHandler(_arg1);
if (editable){
setIMEMode(false);
};
}
public function set htmlText(_arg1:String):void{
if (_arg1 == ""){
text = "";
return;
};
_html = true;
_savedHTML = _arg1;
textField.htmlText = _arg1;
invalidate(InvalidationType.DATA);
invalidate(InvalidationType.STYLES);
}
public function get text():String{
return (textField.text);
}
override public function get enabled():Boolean{
return (super.enabled);
}
public function get condenseWhite():Boolean{
return (textField.condenseWhite);
}
public function get alwaysShowSelection():Boolean{
return (textField.alwaysShowSelection);
}
override protected function draw():void{
var _local1:Object;
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawTextFormat();
drawBackground();
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function handleTextInput(_arg1:TextEvent):void{
_arg1.stopPropagation();
dispatchEvent(new TextEvent(TextEvent.TEXT_INPUT, true, false, _arg1.text));
}
override protected function configUI():void{
super.configUI();
tabChildren = true;
textField = new TextField();
addChild(textField);
updateTextFieldType();
textField.addEventListener(TextEvent.TEXT_INPUT, handleTextInput, false, 0, true);
textField.addEventListener(Event.CHANGE, handleChange, false, 0, true);
textField.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true);
}
public function setSelection(_arg1:int, _arg2:int):void{
textField.setSelection(_arg1, _arg2);
}
public function get displayAsPassword():Boolean{
return (textField.displayAsPassword);
}
public function appendText(_arg1:String):void{
textField.appendText(_arg1);
}
public function set restrict(_arg1:String):void{
if (((componentInspectorSetting) && ((_arg1 == "")))){
_arg1 = null;
};
textField.restrict = _arg1;
}
public function get htmlText():String{
return (textField.htmlText);
}
protected function drawBackground():void{
var _local1:DisplayObject;
var _local2:String;
_local1 = background;
_local2 = (enabled) ? "upSkin" : "disabledSkin";
background = getDisplayObjectInstance(getStyleValue(_local2));
if (background == null){
return;
};
addChildAt(background, 0);
if (((((!((_local1 == null))) && (!((_local1 == background))))) && (contains(_local1)))){
removeChild(_local1);
};
}
override public function setFocus():void{
stage.focus = textField;
}
protected function drawLayout():void{
var _local1:Number;
_local1 = Number(getStyleValue("textPadding"));
if (background != null){
background.width = width;
background.height = height;
};
textField.width = (width - (2 * _local1));
textField.height = (height - (2 * _local1));
textField.x = (textField.y = _local1);
}
public function set maxChars(_arg1:int):void{
textField.maxChars = _arg1;
}
public function get maxHorizontalScrollPosition():int{
return (textField.maxScrollH);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
if (_html){
textField.htmlText = _savedHTML;
};
}
protected function handleChange(_arg1:Event):void{
_arg1.stopPropagation();
dispatchEvent(new Event(Event.CHANGE, true));
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 142
//UIScrollBar (fl.controls.UIScrollBar)
package fl.controls {
import flash.events.*;
import flash.text.*;
import fl.events.*;
import fl.core.*;
public class UIScrollBar extends ScrollBar {
protected var inScroll:Boolean;// = false
protected var _scrollTarget:TextField;
protected var inEdit:Boolean;// = false
private static var defaultStyles:Object = {};
public function UIScrollBar(){
inEdit = false;
inScroll = false;
super();
}
protected function handleTargetScroll(_arg1:Event):void{
if (inDrag){
return;
};
if (!enabled){
return;
};
inEdit = true;
updateScrollTargetProperties();
scrollPosition = ((direction)==ScrollBarDirection.HORIZONTAL) ? _scrollTarget.scrollH : _scrollTarget.scrollV;
inEdit = false;
}
override public function set minScrollPosition(_arg1:Number):void{
super.minScrollPosition = ((_arg1)<0) ? 0 : _arg1;
}
override public function setScrollPosition(_arg1:Number, _arg2:Boolean=true):void{
super.setScrollPosition(_arg1, _arg2);
if (!_scrollTarget){
inScroll = false;
return;
};
updateTargetScroll();
}
override public function setScrollProperties(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=0):void{
var _local5:Number;
var _local6:Number;
_local5 = _arg3;
_local6 = ((_arg2)<0) ? 0 : _arg2;
if (_scrollTarget != null){
if (direction == ScrollBarDirection.HORIZONTAL){
_local5 = ((_arg3)>_scrollTarget.maxScrollH) ? _scrollTarget.maxScrollH : _local5;
} else {
_local5 = ((_arg3)>_scrollTarget.maxScrollV) ? _scrollTarget.maxScrollV : _local5;
};
};
super.setScrollProperties(_arg1, _local6, _local5, _arg4);
}
public function get scrollTargetName():String{
return (_scrollTarget.name);
}
public function get scrollTarget():TextField{
return (_scrollTarget);
}
protected function updateScrollTargetProperties():void{
var _local1:Boolean;
var _local2:Number;
if (_scrollTarget == null){
setScrollProperties(pageSize, minScrollPosition, maxScrollPosition, pageScrollSize);
scrollPosition = 0;
} else {
_local1 = (direction == ScrollBarDirection.HORIZONTAL);
_local2 = (_local1) ? _scrollTarget.width : 10;
setScrollProperties(_local2, (_local1) ? 0 : 1, (_local1) ? _scrollTarget.maxScrollH : _scrollTarget.maxScrollV, pageScrollSize);
scrollPosition = (_local1) ? _scrollTarget.scrollH : _scrollTarget.scrollV;
};
}
public function update():void{
inEdit = true;
updateScrollTargetProperties();
inEdit = false;
}
public function set scrollTargetName(_arg1:String):void{
var target = _arg1;
try {
scrollTarget = (parent.getChildByName(target) as TextField);
} catch(error:Error) {
throw (new Error("ScrollTarget not found, or is not a TextField"));
};
}
override public function set direction(_arg1:String):void{
if (isLivePreview){
return;
};
super.direction = _arg1;
updateScrollTargetProperties();
}
protected function handleTargetChange(_arg1:Event):void{
inEdit = true;
setScrollPosition(((direction)==ScrollBarDirection.HORIZONTAL) ? _scrollTarget.scrollH : _scrollTarget.scrollV, true);
updateScrollTargetProperties();
inEdit = false;
}
override public function set maxScrollPosition(_arg1:Number):void{
var _local2:Number;
_local2 = _arg1;
if (_scrollTarget != null){
if (direction == ScrollBarDirection.HORIZONTAL){
_local2 = ((_local2)>_scrollTarget.maxScrollH) ? _scrollTarget.maxScrollH : _local2;
} else {
_local2 = ((_local2)>_scrollTarget.maxScrollV) ? _scrollTarget.maxScrollV : _local2;
};
};
super.maxScrollPosition = _local2;
}
protected function updateTargetScroll(_arg1:ScrollEvent=null):void{
if (inEdit){
return;
};
if (direction == ScrollBarDirection.HORIZONTAL){
_scrollTarget.scrollH = scrollPosition;
} else {
_scrollTarget.scrollV = scrollPosition;
};
}
override protected function draw():void{
if (isInvalid(InvalidationType.DATA)){
updateScrollTargetProperties();
};
super.draw();
}
public function set scrollTarget(_arg1:TextField):void{
if (_scrollTarget != null){
_scrollTarget.removeEventListener(Event.CHANGE, handleTargetChange, false);
_scrollTarget.removeEventListener(TextEvent.TEXT_INPUT, handleTargetChange, false);
_scrollTarget.removeEventListener(Event.SCROLL, handleTargetScroll, false);
removeEventListener(ScrollEvent.SCROLL, updateTargetScroll, false);
};
_scrollTarget = _arg1;
if (_scrollTarget != null){
_scrollTarget.addEventListener(Event.CHANGE, handleTargetChange, false, 0, true);
_scrollTarget.addEventListener(TextEvent.TEXT_INPUT, handleTargetChange, false, 0, true);
_scrollTarget.addEventListener(Event.SCROLL, handleTargetScroll, false, 0, true);
addEventListener(ScrollEvent.SCROLL, updateTargetScroll, false, 0, true);
};
invalidate(InvalidationType.DATA);
}
override public function get direction():String{
return (super.direction);
}
public static function getStyleDefinition():Object{
return (UIComponent.mergeStyles(defaultStyles, ScrollBar.getStyleDefinition()));
}
}
}//package fl.controls
Section 143
//ComponentShim (fl.core.ComponentShim)
package fl.core {
import flash.display.*;
public dynamic class ComponentShim extends MovieClip {
}
}//package fl.core
Section 144
//InvalidationType (fl.core.InvalidationType)
package fl.core {
public class InvalidationType {
public static const SIZE:String = "size";
public static const ALL:String = "all";
public static const DATA:String = "data";
public static const SCROLL:String = "scroll";
public static const STATE:String = "state";
public static const STYLES:String = "styles";
public static const SELECTED:String = "selected";
public static const RENDERER_STYLES:String = "rendererStyles";
}
}//package fl.core
Section 145
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.utils.*;
import fl.events.*;
import fl.managers.*;
import flash.system.*;
public class UIComponent extends Sprite {
protected var _enabled:Boolean;// = true
private var _mouseFocusEnabled:Boolean;// = true
protected var startHeight:Number;
protected var _height:Number;
protected var _oldIMEMode:String;// = null
protected var startWidth:Number;
public var focusTarget:IFocusManagerComponent;
protected var errorCaught:Boolean;// = false
protected var uiFocusRect:DisplayObject;
protected var _width:Number;
public var version:String;// = "3.0.0.15"
protected var isFocused:Boolean;// = false
protected var callLaterMethods:Dictionary;
private var _focusEnabled:Boolean;// = true
private var tempText:TextField;
protected var invalidateFlag:Boolean;// = false
protected var _inspector:Boolean;// = false
protected var sharedStyles:Object;
protected var invalidHash:Object;
protected var isLivePreview:Boolean;// = false
protected var _imeMode:String;// = null
protected var instanceStyles:Object;
protected var _x:Number;
protected var _y:Number;
public static var inCallLaterPhase:Boolean = false;
private static var defaultStyles:Object = {focusRectSkin:"focusRectSkin", focusRectPadding:2, textFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), disabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultTextFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultDisabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0)};
public static var createAccessibilityImplementation:Function;
private static var focusManagers:Dictionary = new Dictionary(false);
public function UIComponent(){
version = "3.0.0.15";
isLivePreview = false;
invalidateFlag = false;
_enabled = true;
isFocused = false;
_focusEnabled = true;
_mouseFocusEnabled = true;
_imeMode = null;
_oldIMEMode = null;
errorCaught = false;
_inspector = false;
super();
instanceStyles = {};
sharedStyles = {};
invalidHash = {};
callLaterMethods = new Dictionary();
StyleManager.registerInstance(this);
configUI();
invalidate(InvalidationType.ALL);
tabEnabled = (this is IFocusManagerComponent);
focusRect = false;
if (tabEnabled){
addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
};
initializeFocusManager();
addEventListener(Event.ENTER_FRAME, hookAccessibility, false, 0, true);
}
public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
isFocused = _arg1;
if (((!((uiFocusRect == null))) && (contains(uiFocusRect)))){
removeChild(uiFocusRect);
uiFocusRect = null;
};
if (_arg1){
uiFocusRect = (getDisplayObjectInstance(getStyleValue("focusRectSkin")) as Sprite);
if (uiFocusRect == null){
return;
};
_local2 = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = -(_local2);
uiFocusRect.y = -(_local2);
uiFocusRect.width = (width + (_local2 * 2));
uiFocusRect.height = (height + (_local2 * 2));
addChildAt(uiFocusRect, 0);
};
}
private function callLaterDispatcher(_arg1:Event):void{
var _local2:Dictionary;
var _local3:Object;
if (_arg1.type == Event.ADDED_TO_STAGE){
removeEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher);
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
return;
};
_arg1.target.removeEventListener(Event.RENDER, callLaterDispatcher);
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
return;
};
inCallLaterPhase = true;
_local2 = callLaterMethods;
for (_local3 in _local2) {
_local3();
delete _local2[_local3];
};
inCallLaterPhase = false;
}
private function addedHandler(_arg1:Event):void{
removeEventListener("addedToStage", addedHandler);
initializeFocusManager();
}
protected function getStyleValue(_arg1:String):Object{
return (((instanceStyles[_arg1])==null) ? sharedStyles[_arg1] : instanceStyles[_arg1]);
}
protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((_arg1 == this));
}
override public function get scaleX():Number{
return ((width / startWidth));
}
override public function get scaleY():Number{
return ((height / startHeight));
}
override public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
setSize(width, _arg1);
}
protected function keyDownHandler(_arg1:KeyboardEvent):void{
}
protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (isOurFocus((_arg1.target as DisplayObject))){
_local2 = focusManager;
if (((_local2) && (_local2.showFocusIndicator))){
drawFocus(true);
isFocused = true;
};
};
}
public function setStyle(_arg1:String, _arg2:Object):void{
if ((((instanceStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
instanceStyles[_arg1] = _arg2;
invalidate(InvalidationType.STYLES);
}
override public function get visible():Boolean{
return (super.visible);
}
public function get componentInspectorSetting():Boolean{
return (_inspector);
}
override public function get x():Number{
return ((isNaN(_x)) ? super.x : _x);
}
override public function get y():Number{
return ((isNaN(_y)) ? super.y : _y);
}
protected function setIMEMode(_arg1:Boolean){
var enabled = _arg1;
if (_imeMode != null){
if (enabled){
IME.enabled = true;
_oldIMEMode = IME.conversionMode;
try {
if (((!(errorCaught)) && (!((IME.conversionMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _imeMode;
};
errorCaught = false;
} catch(e:Error) {
errorCaught = true;
throw (new Error(("IME mode not supported: " + _imeMode)));
};
} else {
if (((!((IME.conversionMode == IMEConversionMode.UNKNOWN))) && (!((_oldIMEMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _oldIMEMode;
};
IME.enabled = false;
};
};
}
public function set enabled(_arg1:Boolean):void{
if (_arg1 == _enabled){
return;
};
_enabled = _arg1;
invalidate(InvalidationType.STATE);
}
public function setSharedStyle(_arg1:String, _arg2:Object):void{
if ((((sharedStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
sharedStyles[_arg1] = _arg2;
if (instanceStyles[_arg1] == null){
invalidate(InvalidationType.STYLES);
};
}
protected function keyUpHandler(_arg1:KeyboardEvent):void{
}
public function set focusEnabled(_arg1:Boolean):void{
_focusEnabled = _arg1;
}
override public function set scaleX(_arg1:Number):void{
setSize((startWidth * _arg1), height);
}
public function get mouseFocusEnabled():Boolean{
return (_mouseFocusEnabled);
}
override public function set scaleY(_arg1:Number):void{
setSize(width, (startHeight * _arg1));
}
protected function getDisplayObjectInstance(_arg1:Object):DisplayObject{
var classDef:Object;
var skin = _arg1;
classDef = null;
if ((skin is Class)){
return ((new (skin) as DisplayObject));
};
if ((skin is DisplayObject)){
(skin as DisplayObject).x = 0;
(skin as DisplayObject).y = 0;
return ((skin as DisplayObject));
};
try {
classDef = getDefinitionByName(skin.toString());
} catch(e:Error) {
try {
classDef = (loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object);
} catch(e:Error) {
};
};
if (classDef == null){
return (null);
};
return ((new (classDef) as DisplayObject));
}
protected function copyStylesToChild(_arg1:UIComponent, _arg2:Object):void{
var _local3:String;
for (_local3 in _arg2) {
_arg1.setStyle(_local3, getStyleValue(_arg2[_local3]));
};
}
protected function beforeComponentParameters():void{
}
protected function callLater(_arg1:Function):void{
if (inCallLaterPhase){
return;
};
callLaterMethods[_arg1] = true;
if (stage != null){
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
} else {
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
};
}
protected function createFocusManager():void{
if (focusManagers[stage] == null){
focusManagers[stage] = new FocusManager(stage);
};
}
override public function set visible(_arg1:Boolean):void{
var _local2:String;
if (super.visible == _arg1){
return;
};
super.visible = _arg1;
_local2 = (_arg1) ? ComponentEvent.SHOW : ComponentEvent.HIDE;
dispatchEvent(new ComponentEvent(_local2, true));
}
protected function hookAccessibility(_arg1:Event):void{
removeEventListener(Event.ENTER_FRAME, hookAccessibility);
initializeAccessibility();
}
public function set componentInspectorSetting(_arg1:Boolean):void{
_inspector = _arg1;
if (_inspector){
beforeComponentParameters();
} else {
afterComponentParameters();
};
}
override public function set x(_arg1:Number):void{
move(_arg1, _y);
}
public function drawNow():void{
draw();
}
override public function set y(_arg1:Number):void{
move(_x, _arg1);
}
protected function checkLivePreview():Boolean{
var className:String;
if (parent == null){
return (false);
};
try {
className = getQualifiedClassName(parent);
} catch(e:Error) {
};
return ((className == "fl.livepreview::LivePreviewParent"));
}
protected function focusOutHandler(_arg1:FocusEvent):void{
if (isOurFocus((_arg1.target as DisplayObject))){
drawFocus(false);
isFocused = false;
};
}
public function set mouseFocusEnabled(_arg1:Boolean):void{
_mouseFocusEnabled = _arg1;
}
public function getFocus():InteractiveObject{
if (stage){
return (stage.focus);
};
return (null);
}
protected function validate():void{
invalidHash = {};
}
override public function get height():Number{
return (_height);
}
public function invalidate(_arg1:String="all", _arg2:Boolean=true):void{
invalidHash[_arg1] = true;
if (_arg2){
this.callLater(draw);
};
}
public function get enabled():Boolean{
return (_enabled);
}
protected function getScaleX():Number{
return (super.scaleX);
}
protected function getScaleY():Number{
return (super.scaleY);
}
public function get focusEnabled():Boolean{
return (_focusEnabled);
}
protected function afterComponentParameters():void{
}
protected function draw():void{
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
protected function configUI():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
isLivePreview = checkLivePreview();
_local1 = rotation;
rotation = 0;
_local2 = super.width;
_local3 = super.height;
var _local4 = 1;
super.scaleY = _local4;
super.scaleX = _local4;
setSize(_local2, _local3);
move(super.x, super.y);
rotation = _local1;
startWidth = _local2;
startHeight = _local3;
if (numChildren > 0){
removeChildAt(0);
};
}
protected function setScaleX(_arg1:Number):void{
super.scaleX = _arg1;
}
protected function setScaleY(_arg1:Number):void{
super.scaleY = _arg1;
}
private function initializeFocusManager():void{
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
} else {
createFocusManager();
};
}
public function set focusManager(_arg1:IFocusManager):void{
UIComponent.focusManagers[this] = _arg1;
}
public function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
protected function isInvalid(_arg1:String, ... _args):Boolean{
if (((invalidHash[_arg1]) || (invalidHash[InvalidationType.ALL]))){
return (true);
};
while (_args.length > 0) {
if (invalidHash[_args.pop()]){
return (true);
};
};
return (false);
}
public function setSize(_arg1:Number, _arg2:Number):void{
_width = _arg1;
_height = _arg2;
invalidate(InvalidationType.SIZE);
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
}
override public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
setSize(_arg1, height);
}
public function setFocus():void{
if (stage){
stage.focus = this;
};
}
protected function initializeAccessibility():void{
if (UIComponent.createAccessibilityImplementation != null){
UIComponent.createAccessibilityImplementation(this);
};
}
public function get focusManager():IFocusManager{
var _local1:DisplayObject;
_local1 = this;
while (_local1) {
if (UIComponent.focusManagers[_local1] != null){
return (IFocusManager(UIComponent.focusManagers[_local1]));
};
_local1 = _local1.parent;
};
return (null);
}
override public function get width():Number{
return (_width);
}
public function move(_arg1:Number, _arg2:Number):void{
_x = _arg1;
_y = _arg2;
super.x = Math.round(_arg1);
super.y = Math.round(_arg2);
dispatchEvent(new ComponentEvent(ComponentEvent.MOVE));
}
public function validateNow():void{
invalidate(InvalidationType.ALL, false);
draw();
}
public function getStyle(_arg1:String):Object{
return (instanceStyles[_arg1]);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
public static function mergeStyles(... _args):Object{
var _local2:Object;
var _local3:uint;
var _local4:uint;
var _local5:Object;
var _local6:String;
_local2 = {};
_local3 = _args.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = _args[_local4];
for (_local6 in _local5) {
if (_local2[_local6] != null){
} else {
_local2[_local6] = _args[_local4][_local6];
};
};
_local4++;
};
return (_local2);
}
}
}//package fl.core
Section 146
//DataProvider (fl.data.DataProvider)
package fl.data {
import flash.events.*;
import fl.events.*;
public class DataProvider extends EventDispatcher {
protected var data:Array;
public function DataProvider(_arg1:Object=null){
if (_arg1 == null){
data = [];
} else {
data = getDataFromObject(_arg1);
};
}
protected function dispatchPreChangeEvent(_arg1:String, _arg2:Array, _arg3:int, _arg4:int):void{
dispatchEvent(new DataChangeEvent(DataChangeEvent.PRE_DATA_CHANGE, _arg1, _arg2, _arg3, _arg4));
}
public function invalidateItemAt(_arg1:int):void{
checkIndex(_arg1, (data.length - 1));
dispatchChangeEvent(DataChangeType.INVALIDATE, [data[_arg1]], _arg1, _arg1);
}
public function getItemIndex(_arg1:Object):int{
return (data.indexOf(_arg1));
}
protected function getDataFromObject(_arg1:Object):Array{
var _local2:Array;
var _local3:Array;
var _local4:uint;
var _local5:Object;
var _local6:XML;
var _local7:XMLList;
var _local8:XML;
var _local9:XMLList;
var _local10:XML;
var _local11:XMLList;
var _local12:XML;
if ((_arg1 is Array)){
_local3 = (_arg1 as Array);
if (_local3.length > 0){
if ((((_local3[0] is String)) || ((_local3[0] is Number)))){
_local2 = [];
_local4 = 0;
while (_local4 < _local3.length) {
_local5 = {label:String(_local3[_local4]), data:_local3[_local4]};
_local2.push(_local5);
_local4++;
};
return (_local2);
};
};
return (_arg1.concat());
//unresolved jump
};
if ((_arg1 is DataProvider)){
return (_arg1.toArray());
};
if ((_arg1 is XML)){
_local6 = (_arg1 as XML);
_local2 = [];
_local7 = _local6.*;
for each (_local8 in _local7) {
_arg1 = {};
_local9 = _local8.attributes();
for each (_local10 in _local9) {
_arg1[_local10.localName()] = _local10.toString();
};
_local11 = _local8.*;
for each (_local12 in _local11) {
if (_local12.hasSimpleContent()){
_arg1[_local12.localName()] = _local12.toString();
};
};
_local2.push(_arg1);
};
return (_local2);
//unresolved jump
};
throw (new TypeError((("Error: Type Coercion failed: cannot convert " + _arg1) + " to Array or DataProvider.")));
}
public function removeItemAt(_arg1:uint):Object{
var _local2:Array;
checkIndex(_arg1, (data.length - 1));
dispatchPreChangeEvent(DataChangeType.REMOVE, data.slice(_arg1, (_arg1 + 1)), _arg1, _arg1);
_local2 = data.splice(_arg1, 1);
dispatchChangeEvent(DataChangeType.REMOVE, _local2, _arg1, _arg1);
return (_local2[0]);
}
public function addItem(_arg1:Object):void{
dispatchPreChangeEvent(DataChangeType.ADD, [_arg1], (data.length - 1), (data.length - 1));
data.push(_arg1);
dispatchChangeEvent(DataChangeType.ADD, [_arg1], (data.length - 1), (data.length - 1));
}
public function sortOn(_arg1:Object, _arg2:Object=null){
var _local3:Array;
dispatchPreChangeEvent(DataChangeType.SORT, data.concat(), 0, (data.length - 1));
_local3 = data.sortOn(_arg1, _arg2);
dispatchChangeEvent(DataChangeType.SORT, data.concat(), 0, (data.length - 1));
return (_local3);
}
public function sort(... _args){
var _local2:Array;
dispatchPreChangeEvent(DataChangeType.SORT, data.concat(), 0, (data.length - 1));
_local2 = data.sort.apply(data, _args);
dispatchChangeEvent(DataChangeType.SORT, data.concat(), 0, (data.length - 1));
return (_local2);
}
public function addItems(_arg1:Object):void{
addItemsAt(_arg1, data.length);
}
public function concat(_arg1:Object):void{
addItems(_arg1);
}
public function clone():DataProvider{
return (new DataProvider(data));
}
public function toArray():Array{
return (data.concat());
}
public function get length():uint{
return (data.length);
}
public function addItemAt(_arg1:Object, _arg2:uint):void{
checkIndex(_arg2, data.length);
dispatchPreChangeEvent(DataChangeType.ADD, [_arg1], _arg2, _arg2);
data.splice(_arg2, 0, _arg1);
dispatchChangeEvent(DataChangeType.ADD, [_arg1], _arg2, _arg2);
}
public function getItemAt(_arg1:uint):Object{
checkIndex(_arg1, (data.length - 1));
return (data[_arg1]);
}
override public function toString():String{
return ((("DataProvider [" + data.join(" , ")) + "]"));
}
public function invalidateItem(_arg1:Object):void{
var _local2:uint;
_local2 = getItemIndex(_arg1);
if (_local2 == -1){
return;
};
invalidateItemAt(_local2);
}
protected function dispatchChangeEvent(_arg1:String, _arg2:Array, _arg3:int, _arg4:int):void{
dispatchEvent(new DataChangeEvent(DataChangeEvent.DATA_CHANGE, _arg1, _arg2, _arg3, _arg4));
}
protected function checkIndex(_arg1:int, _arg2:int):void{
if ((((_arg1 > _arg2)) || ((_arg1 < 0)))){
throw (new RangeError((((("DataProvider index (" + _arg1) + ") is not in acceptable range (0 - ") + _arg2) + ")")));
};
}
public function addItemsAt(_arg1:Object, _arg2:uint):void{
var _local3:Array;
checkIndex(_arg2, data.length);
_local3 = getDataFromObject(_arg1);
dispatchPreChangeEvent(DataChangeType.ADD, _local3, _arg2, ((_arg2 + _local3.length) - 1));
data.splice.apply(data, [_arg2, 0].concat(_local3));
dispatchChangeEvent(DataChangeType.ADD, _local3, _arg2, ((_arg2 + _local3.length) - 1));
}
public function replaceItem(_arg1:Object, _arg2:Object):Object{
var _local3:int;
_local3 = getItemIndex(_arg2);
if (_local3 != -1){
return (replaceItemAt(_arg1, _local3));
};
return (null);
}
public function removeItem(_arg1:Object):Object{
var _local2:int;
_local2 = getItemIndex(_arg1);
if (_local2 != -1){
return (removeItemAt(_local2));
};
return (null);
}
public function merge(_arg1:Object):void{
var _local2:Array;
var _local3:uint;
var _local4:uint;
var _local5:uint;
var _local6:Object;
_local2 = getDataFromObject(_arg1);
_local3 = _local2.length;
_local4 = data.length;
dispatchPreChangeEvent(DataChangeType.ADD, data.slice(_local4, data.length), _local4, (this.data.length - 1));
_local5 = 0;
while (_local5 < _local3) {
_local6 = _local2[_local5];
if (getItemIndex(_local6) == -1){
data.push(_local6);
};
_local5++;
};
if (data.length > _local4){
dispatchChangeEvent(DataChangeType.ADD, data.slice(_local4, data.length), _local4, (this.data.length - 1));
} else {
dispatchChangeEvent(DataChangeType.ADD, [], -1, -1);
};
}
public function replaceItemAt(_arg1:Object, _arg2:uint):Object{
var _local3:Array;
checkIndex(_arg2, (data.length - 1));
_local3 = [data[_arg2]];
dispatchPreChangeEvent(DataChangeType.REPLACE, _local3, _arg2, _arg2);
data[_arg2] = _arg1;
dispatchChangeEvent(DataChangeType.REPLACE, _local3, _arg2, _arg2);
return (_local3[0]);
}
public function invalidate():void{
dispatchEvent(new DataChangeEvent(DataChangeEvent.DATA_CHANGE, DataChangeType.INVALIDATE_ALL, data.concat(), 0, data.length));
}
public function removeAll():void{
var _local1:Array;
_local1 = data.concat();
dispatchPreChangeEvent(DataChangeType.REMOVE_ALL, _local1, 0, _local1.length);
data = [];
dispatchChangeEvent(DataChangeType.REMOVE_ALL, _local1, 0, _local1.length);
}
}
}//package fl.data
Section 147
//SimpleCollectionItem (fl.data.SimpleCollectionItem)
package fl.data {
public dynamic class SimpleCollectionItem {
public var label:String;
public var data:String;
public function toString():String{
return ((((("[SimpleCollectionItem: " + label) + ",") + data) + "]"));
}
}
}//package fl.data
Section 148
//ComponentEvent (fl.events.ComponentEvent)
package fl.events {
import flash.events.*;
public class ComponentEvent extends Event {
public static const HIDE:String = "hide";
public static const BUTTON_DOWN:String = "buttonDown";
public static const MOVE:String = "move";
public static const RESIZE:String = "resize";
public static const ENTER:String = "enter";
public static const LABEL_CHANGE:String = "labelChange";
public static const SHOW:String = "show";
public function ComponentEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
override public function toString():String{
return (formatToString("ComponentEvent", "type", "bubbles", "cancelable"));
}
override public function clone():Event{
return (new ComponentEvent(type, bubbles, cancelable));
}
}
}//package fl.events
Section 149
//DataChangeEvent (fl.events.DataChangeEvent)
package fl.events {
import flash.events.*;
public class DataChangeEvent extends Event {
protected var _items:Array;
protected var _endIndex:uint;
protected var _changeType:String;
protected var _startIndex:uint;
public static const PRE_DATA_CHANGE:String = "preDataChange";
public static const DATA_CHANGE:String = "dataChange";
public function DataChangeEvent(_arg1:String, _arg2:String, _arg3:Array, _arg4:int=-1, _arg5:int=-1):void{
super(_arg1);
_changeType = _arg2;
_startIndex = _arg4;
_items = _arg3;
_endIndex = ((_arg5)==-1) ? _startIndex : _arg5;
}
public function get changeType():String{
return (_changeType);
}
public function get startIndex():uint{
return (_startIndex);
}
public function get items():Array{
return (_items);
}
override public function clone():Event{
return (new DataChangeEvent(type, _changeType, _items, _startIndex, _endIndex));
}
override public function toString():String{
return (formatToString("DataChangeEvent", "type", "changeType", "startIndex", "endIndex", "bubbles", "cancelable"));
}
public function get endIndex():uint{
return (_endIndex);
}
}
}//package fl.events
Section 150
//DataChangeType (fl.events.DataChangeType)
package fl.events {
public class DataChangeType {
public static const ADD:String = "add";
public static const REMOVE:String = "remove";
public static const REMOVE_ALL:String = "removeAll";
public static const CHANGE:String = "change";
public static const REPLACE:String = "replace";
public static const INVALIDATE:String = "invalidate";
public static const INVALIDATE_ALL:String = "invalidateAll";
public static const SORT:String = "sort";
}
}//package fl.events
Section 151
//ListEvent (fl.events.ListEvent)
package fl.events {
import flash.events.*;
public class ListEvent extends Event {
protected var _index:int;
protected var _item:Object;
protected var _columnIndex:int;
protected var _rowIndex:int;
public static const ITEM_DOUBLE_CLICK:String = "itemDoubleClick";
public static const ITEM_ROLL_OUT:String = "itemRollOut";
public static const ITEM_ROLL_OVER:String = "itemRollOver";
public static const ITEM_CLICK:String = "itemClick";
public function ListEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:int=-1, _arg5:int=-1, _arg6:int=-1, _arg7:Object=null){
super(_arg1, _arg2, _arg3);
_rowIndex = _arg5;
_columnIndex = _arg4;
_index = _arg6;
_item = _arg7;
}
public function get rowIndex():Object{
return (_rowIndex);
}
public function get index():int{
return (_index);
}
public function get item():Object{
return (_item);
}
public function get columnIndex():int{
return (_columnIndex);
}
override public function clone():Event{
return (new ListEvent(type, bubbles, cancelable, _columnIndex, _rowIndex));
}
override public function toString():String{
return (formatToString("ListEvent", "type", "bubbles", "cancelable", "columnIndex", "rowIndex", "index", "item"));
}
}
}//package fl.events
Section 152
//ScrollEvent (fl.events.ScrollEvent)
package fl.events {
import flash.events.*;
public class ScrollEvent extends Event {
private var _position:Number;
private var _direction:String;
private var _delta:Number;
public static const SCROLL:String = "scroll";
public function ScrollEvent(_arg1:String, _arg2:Number, _arg3:Number){
super(ScrollEvent.SCROLL, false, false);
_direction = _arg1;
_delta = _arg2;
_position = _arg3;
}
override public function clone():Event{
return (new ScrollEvent(_direction, _delta, _position));
}
public function get position():Number{
return (_position);
}
override public function toString():String{
return (formatToString("ScrollEvent", "type", "bubbles", "cancelable", "direction", "delta", "position"));
}
public function get delta():Number{
return (_delta);
}
public function get direction():String{
return (_direction);
}
}
}//package fl.events
Section 153
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.utils.*;
import fl.controls.*;
import fl.core.*;
import flash.ui.*;
public class FocusManager implements IFocusManager {
private var focusableObjects:Dictionary;
private var _showFocusIndicator:Boolean;// = true
private var defButton:Button;
private var focusableCandidates:Array;
private var _form:DisplayObjectContainer;
private var _defaultButtonEnabled:Boolean;// = true
private var activated:Boolean;// = false
private var _defaultButton:Button;
private var calculateCandidates:Boolean;// = true
private var lastFocus:InteractiveObject;
private var lastAction:String;
public function FocusManager(_arg1:DisplayObjectContainer){
activated = false;
calculateCandidates = true;
_showFocusIndicator = true;
_defaultButtonEnabled = true;
super();
focusableObjects = new Dictionary(true);
if (_arg1 != null){
_form = _arg1;
addFocusables(DisplayObject(_arg1));
_arg1.addEventListener(Event.ADDED, addedHandler);
_arg1.addEventListener(Event.REMOVED, removedHandler);
activate();
};
}
public function get showFocusIndicator():Boolean{
return (_showFocusIndicator);
}
private function getIndexOfNextObject(_arg1:int, _arg2:Boolean, _arg3:Boolean, _arg4:String):int{
var _local5:int;
var _local6:int;
var _local7:DisplayObject;
var _local8:IFocusManagerGroup;
var _local9:int;
var _local10:DisplayObject;
var _local11:IFocusManagerGroup;
_local5 = focusableCandidates.length;
_local6 = _arg1;
while (true) {
if (_arg2){
_arg1--;
} else {
_arg1++;
};
if (_arg3){
if (((_arg2) && ((_arg1 < 0)))){
break;
};
if (((!(_arg2)) && ((_arg1 == _local5)))){
break;
};
} else {
_arg1 = ((_arg1 + _local5) % _local5);
if (_local6 == _arg1){
break;
};
};
if (isValidFocusCandidate(focusableCandidates[_arg1], _arg4)){
_local7 = DisplayObject(findFocusManagerComponent(focusableCandidates[_arg1]));
if ((_local7 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local7);
_local9 = 0;
while (_local9 < focusableCandidates.length) {
_local10 = focusableCandidates[_local9];
if ((_local10 is IFocusManagerGroup)){
_local11 = IFocusManagerGroup(_local10);
if ((((_local11.groupName == _local8.groupName)) && (_local11.selected))){
_arg1 = _local9;
break;
};
};
_local9++;
};
};
return (_arg1);
};
};
return (_arg1);
}
public function set form(_arg1:DisplayObjectContainer):void{
_form = _arg1;
}
private function addFocusables(_arg1:DisplayObject, _arg2:Boolean=false):void{
var focusable:IFocusManagerComponent;
var io:InteractiveObject;
var doc:DisplayObjectContainer;
var i:int;
var child:DisplayObject;
var o = _arg1;
var skipTopLevel = _arg2;
if (!skipTopLevel){
if ((o is IFocusManagerComponent)){
focusable = IFocusManagerComponent(o);
if (focusable.focusEnabled){
if (((focusable.tabEnabled) && (isTabVisible(o)))){
focusableObjects[o] = true;
calculateCandidates = true;
};
o.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
o.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
} else {
if ((o is InteractiveObject)){
io = (o as InteractiveObject);
if (((((io) && (io.tabEnabled))) && ((findFocusManagerComponent(io) == io)))){
focusableObjects[io] = true;
calculateCandidates = true;
};
io.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
io.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
};
};
if ((o is DisplayObjectContainer)){
doc = DisplayObjectContainer(o);
o.addEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
if ((((((doc is Stage)) || ((doc.parent is Stage)))) || (doc.tabChildren))){
i = 0;
while (i < doc.numChildren) {
try {
child = doc.getChildAt(i);
if (child != null){
addFocusables(doc.getChildAt(i));
};
} catch(error:SecurityError) {
};
i = (i + 1);
};
};
};
}
private function getChildIndex(_arg1:DisplayObjectContainer, _arg2:DisplayObject):int{
return (_arg1.getChildIndex(_arg2));
}
private function mouseFocusChangeHandler(_arg1:FocusEvent):void{
if ((_arg1.relatedObject is TextField)){
return;
};
_arg1.preventDefault();
}
private function focusOutHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
_local2 = (_arg1.target as InteractiveObject);
}
private function isValidFocusCandidate(_arg1:DisplayObject, _arg2:String):Boolean{
var _local3:IFocusManagerGroup;
if (!isEnabledAndVisible(_arg1)){
return (false);
};
if ((_arg1 is IFocusManagerGroup)){
_local3 = IFocusManagerGroup(_arg1);
if (_arg2 == _local3.groupName){
return (false);
};
};
return (true);
}
public function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject{
var _local2:InteractiveObject;
_local2 = _arg1;
while (_arg1) {
if ((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
};
return (_local2);
}
private function sortFocusableObjectsTabIndex():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))){
focusableCandidates.push(_local2);
};
};
focusableCandidates.sort(sortByTabIndex);
}
private function removeFocusables(_arg1:DisplayObject):void{
var _local2:Object;
var _local3:DisplayObject;
if ((_arg1 is DisplayObjectContainer)){
_arg1.removeEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
_arg1.removeEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
for (_local2 in focusableObjects) {
_local3 = DisplayObject(_local2);
if (DisplayObjectContainer(_arg1).contains(_local3)){
if (_local3 == lastFocus){
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local2];
calculateCandidates = true;
};
};
};
}
private function addedHandler(_arg1:Event):void{
var _local2:DisplayObject;
_local2 = DisplayObject(_arg1.target);
if (_local2.stage){
addFocusables(DisplayObject(_arg1.target));
};
}
private function getTopLevelFocusTarget(_arg1:InteractiveObject):InteractiveObject{
while (_arg1 != InteractiveObject(form)) {
if ((((((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))) && (IFocusManagerComponent(_arg1).mouseFocusEnabled))) && (UIComponent(_arg1).enabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
if (_arg1 == null){
break;
};
};
return (null);
}
private function tabChildrenChangeHandler(_arg1:Event):void{
var _local2:DisplayObjectContainer;
if (_arg1.target != _arg1.currentTarget){
return;
};
calculateCandidates = true;
_local2 = DisplayObjectContainer(_arg1.target);
if (_local2.tabChildren){
addFocusables(_local2, true);
} else {
removeFocusables(_local2);
};
}
public function sendDefaultButtonEvent():void{
defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
public function getFocus():InteractiveObject{
var _local1:InteractiveObject;
_local1 = form.stage.focus;
return (findFocusManagerComponent(_local1));
}
private function isEnabledAndVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
var _local3:TextField;
var _local4:SimpleButton;
_local2 = DisplayObject(form).parent;
while (_arg1 != _local2) {
if ((_arg1 is UIComponent)){
if (!UIComponent(_arg1).enabled){
return (false);
};
} else {
if ((_arg1 is TextField)){
_local3 = TextField(_arg1);
if ((((_local3.type == TextFieldType.DYNAMIC)) || (!(_local3.selectable)))){
return (false);
};
} else {
if ((_arg1 is SimpleButton)){
_local4 = SimpleButton(_arg1);
if (!_local4.enabled){
return (false);
};
};
};
};
if (!_arg1.visible){
return (false);
};
_arg1 = _arg1.parent;
};
return (true);
}
public function set defaultButton(_arg1:Button):void{
var _local2:Button;
_local2 = (_arg1) ? Button(_arg1) : null;
if (_local2 != _defaultButton){
if (_defaultButton){
_defaultButton.emphasized = false;
};
if (defButton){
defButton.emphasized = false;
};
_defaultButton = _local2;
defButton = _local2;
if (_local2){
_local2.emphasized = true;
};
};
}
private function deactivateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
}
public function setFocus(_arg1:InteractiveObject):void{
if ((_arg1 is IFocusManagerComponent)){
IFocusManagerComponent(_arg1).setFocus();
} else {
form.stage.focus = _arg1;
};
}
private function setFocusToNextObject(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
if (!hasFocusableObjects()){
return;
};
_local2 = getNextFocusManagerComponent(_arg1.shiftKey);
if (_local2){
setFocus(_local2);
};
}
private function hasFocusableObjects():Boolean{
var _local1:Object;
for (_local1 in focusableObjects) {
return (true);
};
return (false);
}
private function tabIndexChangeHandler(_arg1:Event):void{
calculateCandidates = true;
}
private function sortFocusableObjects():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))) && ((_local2.tabIndex > 0)))){
sortFocusableObjectsTabIndex();
return;
};
focusableCandidates.push(_local2);
};
focusableCandidates.sort(sortByDepth);
}
private function keyFocusChangeHandler(_arg1:FocusEvent):void{
showFocusIndicator = true;
if ((((((_arg1.keyCode == Keyboard.TAB)) || ((_arg1.keyCode == 0)))) && (!(_arg1.isDefaultPrevented())))){
setFocusToNextObject(_arg1);
_arg1.preventDefault();
};
}
private function getIndexOfFocusedObject(_arg1:DisplayObject):int{
var _local2:int;
var _local3:int;
_local2 = focusableCandidates.length;
_local3 = 0;
_local3 = 0;
while (_local3 < _local2) {
if (focusableCandidates[_local3] == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
public function hideFocus():void{
}
private function removedHandler(_arg1:Event):void{
var _local2:int;
var _local3:DisplayObject;
var _local4:InteractiveObject;
_local3 = DisplayObject(_arg1.target);
if ((((_local3 is IFocusManagerComponent)) && ((focusableObjects[_local3] == true)))){
if (_local3 == lastFocus){
IFocusManagerComponent(lastFocus).drawFocus(false);
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local3];
calculateCandidates = true;
} else {
if ((((_local3 is InteractiveObject)) && ((focusableObjects[_local3] == true)))){
_local4 = (_local3 as InteractiveObject);
if (_local4){
if (_local4 == lastFocus){
lastFocus = null;
};
delete focusableObjects[_local4];
calculateCandidates = true;
};
_local3.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
};
};
removeFocusables(_local3);
}
private function sortByDepth(_arg1:InteractiveObject, _arg2:InteractiveObject):Number{
var _local3:String;
var _local4:String;
var _local5:int;
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:DisplayObject;
var _local10:DisplayObject;
_local3 = "";
_local4 = "";
_local8 = "0000";
_local9 = DisplayObject(_arg1);
_local10 = DisplayObject(_arg2);
while (((!((_local9 == DisplayObject(form)))) && (_local9.parent))) {
_local5 = getChildIndex(_local9.parent, _local9);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local3 = (_local7 + _local3);
_local9 = _local9.parent;
};
while (((!((_local10 == DisplayObject(form)))) && (_local10.parent))) {
_local5 = getChildIndex(_local10.parent, _local10);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local4 = (_local7 + _local4);
_local10 = _local10.parent;
};
return (((_local3 > _local4)) ? 1 : ((_local3 < _local4)) ? -1 : 0);
}
public function get defaultButton():Button{
return (_defaultButton);
}
private function activateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
if (lastFocus){
if ((lastFocus is IFocusManagerComponent)){
IFocusManagerComponent(lastFocus).setFocus();
} else {
form.stage.focus = lastFocus;
};
};
lastAction = "ACTIVATE";
}
public function showFocus():void{
}
public function set defaultButtonEnabled(_arg1:Boolean):void{
_defaultButtonEnabled = _arg1;
}
public function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject{
var _local2:DisplayObject;
var _local3:String;
var _local4:int;
var _local5:Boolean;
var _local6:int;
var _local7:int;
var _local8:IFocusManagerGroup;
if (!hasFocusableObjects()){
return (null);
};
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
_local2 = form.stage.focus;
_local2 = DisplayObject(findFocusManagerComponent(InteractiveObject(_local2)));
_local3 = "";
if ((_local2 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local2);
_local3 = _local8.groupName;
};
_local4 = getIndexOfFocusedObject(_local2);
_local5 = false;
_local6 = _local4;
if (_local4 == -1){
if (_arg1){
_local4 = focusableCandidates.length;
};
_local5 = true;
};
_local7 = getIndexOfNextObject(_local4, _arg1, _local5, _local3);
return (findFocusManagerComponent(focusableCandidates[_local7]));
}
private function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:InteractiveObject;
if (_arg1.isDefaultPrevented()){
return;
};
_local2 = getTopLevelFocusTarget(InteractiveObject(_arg1.target));
if (!_local2){
return;
};
showFocusIndicator = false;
if (((((!((_local2 == lastFocus))) || ((lastAction == "ACTIVATE")))) && (!((_local2 is TextField))))){
setFocus(_local2);
};
lastAction = "MOUSEDOWN";
}
private function isTabVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
_local2 = _arg1.parent;
while (((((_local2) && (!((_local2 is Stage))))) && (!(((_local2.parent) && ((_local2.parent is Stage))))))) {
if (!_local2.tabChildren){
return (false);
};
_local2 = _local2.parent;
};
return (true);
}
public function get nextTabIndex():int{
return (0);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.TAB){
lastAction = "KEY";
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
};
if (((((((defaultButtonEnabled) && ((_arg1.keyCode == Keyboard.ENTER)))) && (defaultButton))) && (defButton.enabled))){
sendDefaultButtonEvent();
};
}
private function focusInHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
var _local3:Button;
_local2 = InteractiveObject(_arg1.target);
if (form.contains(_local2)){
lastFocus = findFocusManagerComponent(InteractiveObject(_local2));
if ((lastFocus is Button)){
_local3 = Button(lastFocus);
if (defButton){
defButton.emphasized = false;
defButton = _local3;
_local3.emphasized = true;
};
} else {
if (((defButton) && (!((defButton == _defaultButton))))){
defButton.emphasized = false;
defButton = _defaultButton;
_defaultButton.emphasized = true;
};
};
};
}
private function tabEnabledChangeHandler(_arg1:Event):void{
var _local2:InteractiveObject;
var _local3:Boolean;
calculateCandidates = true;
_local2 = InteractiveObject(_arg1.target);
_local3 = (focusableObjects[_local2] == true);
if (_local2.tabEnabled){
if (((!(_local3)) && (isTabVisible(_local2)))){
if (!(_local2 is IFocusManagerComponent)){
_local2.focusRect = false;
};
focusableObjects[_local2] = true;
};
} else {
if (_local3){
delete focusableObjects[_local2];
};
};
}
public function set showFocusIndicator(_arg1:Boolean):void{
_showFocusIndicator = _arg1;
}
public function get form():DisplayObjectContainer{
return (_form);
}
private function sortByTabIndex(_arg1:InteractiveObject, _arg2:InteractiveObject):int{
return (((_arg1.tabIndex > _arg2.tabIndex)) ? 1 : ((_arg1.tabIndex < _arg2.tabIndex)) ? -1 : sortByDepth(_arg1, _arg2));
}
public function activate():void{
if (activated){
return;
};
form.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false, 0, true);
form.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false, 0, true);
form.addEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.addEventListener(Event.ACTIVATE, activateHandler, false, 0, true);
form.stage.addEventListener(Event.DEACTIVATE, deactivateHandler, false, 0, true);
form.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = true;
if (lastFocus){
setFocus(lastFocus);
};
}
public function deactivate():void{
form.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler);
form.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler);
form.removeEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.removeEventListener(Event.ACTIVATE, activateHandler);
form.stage.removeEventListener(Event.DEACTIVATE, deactivateHandler);
form.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = false;
}
public function get defaultButtonEnabled():Boolean{
return (_defaultButtonEnabled);
}
}
}//package fl.managers
Section 154
//IFocusManager (fl.managers.IFocusManager)
package fl.managers {
import flash.display.*;
import fl.controls.*;
public interface IFocusManager {
function getFocus():InteractiveObject;
function deactivate():void;
function set defaultButton(_arg1:Button):void;
function set showFocusIndicator(_arg1:Boolean):void;
function get defaultButtonEnabled():Boolean;
function get nextTabIndex():int;
function get defaultButton():Button;
function get showFocusIndicator():Boolean;
function setFocus(_arg1:InteractiveObject):void;
function activate():void;
function showFocus():void;
function set defaultButtonEnabled(_arg1:Boolean):void;
function hideFocus():void;
function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject;
function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject;
}
}//package fl.managers
Section 155
//IFocusManagerComponent (fl.managers.IFocusManagerComponent)
package fl.managers {
public interface IFocusManagerComponent {
function set focusEnabled(_arg1:Boolean):void;
function drawFocus(_arg1:Boolean):void;
function setFocus():void;
function get focusEnabled():Boolean;
function get tabEnabled():Boolean;
function get tabIndex():int;
function get mouseFocusEnabled():Boolean;
}
}//package fl.managers
Section 156
//IFocusManagerGroup (fl.managers.IFocusManagerGroup)
package fl.managers {
public interface IFocusManagerGroup {
function set groupName(_arg1:String):void;
function set selected(_arg1:Boolean):void;
function get groupName():String;
function get selected():Boolean;
}
}//package fl.managers
Section 157
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import flash.text.*;
import flash.utils.*;
import fl.core.*;
public class StyleManager {
private var globalStyles:Object;
private var classToDefaultStylesDict:Dictionary;
private var styleToClassesHash:Object;
private var classToStylesDict:Dictionary;
private var classToInstancesDict:Dictionary;
private static var _instance:StyleManager;
public function StyleManager(){
styleToClassesHash = {};
classToInstancesDict = new Dictionary(true);
classToStylesDict = new Dictionary(true);
classToDefaultStylesDict = new Dictionary(true);
globalStyles = UIComponent.getStyleDefinition();
}
public static function clearComponentStyle(_arg1:Object, _arg2:String):void{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
if (((!((_local4 == null))) && (!((_local4[_arg2] == null))))){
delete _local4[_arg2];
invalidateComponentStyle(_local3, _arg2);
};
}
private static function getClassDef(_arg1:Object):Class{
var component = _arg1;
if ((component is Class)){
return ((component as Class));
};
try {
return ((getDefinitionByName(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
if ((component is UIComponent)){
try {
return ((component.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
};
};
};
return (null);
}
public static function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
public static function setComponentStyle(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Class;
var _local5:Object;
_local4 = getClassDef(_arg1);
_local5 = getInstance().classToStylesDict[_local4];
if (_local5 == null){
_local5 = (getInstance().classToStylesDict[_local4] = {});
};
if (_local5 == _arg3){
return;
};
_local5[_arg2] = _arg3;
invalidateComponentStyle(_local4, _arg2);
}
private static function setSharedStyles(_arg1:UIComponent):void{
var _local2:StyleManager;
var _local3:Class;
var _local4:Object;
var _local5:String;
_local2 = getInstance();
_local3 = getClassDef(_arg1);
_local4 = _local2.classToDefaultStylesDict[_local3];
for (_local5 in _local4) {
_arg1.setSharedStyle(_local5, getSharedStyle(_arg1, _local5));
};
}
public static function getComponentStyle(_arg1:Object, _arg2:String):Object{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
return (((_local4)==null) ? null : _local4[_arg2]);
}
private static function getInstance(){
if (_instance == null){
_instance = new (StyleManager);
};
return (_instance);
}
private static function invalidateComponentStyle(_arg1:Class, _arg2:String):void{
var _local3:Dictionary;
var _local4:Object;
var _local5:UIComponent;
_local3 = getInstance().classToInstancesDict[_arg1];
if (_local3 == null){
return;
};
for (_local4 in _local3) {
_local5 = (_local4 as UIComponent);
if (_local5 == null){
} else {
_local5.setSharedStyle(_arg2, getSharedStyle(_local5, _arg2));
};
};
}
private static function invalidateStyle(_arg1:String):void{
var _local2:Dictionary;
var _local3:Object;
_local2 = getInstance().styleToClassesHash[_arg1];
if (_local2 == null){
return;
};
for (_local3 in _local2) {
invalidateComponentStyle(Class(_local3), _arg1);
};
}
public static function registerInstance(_arg1:UIComponent):void{
var inst:StyleManager;
var classDef:Class;
var target:Class;
var defaultStyles:Object;
var styleToClasses:Object;
var n:String;
var instance = _arg1;
inst = getInstance();
classDef = getClassDef(instance);
if (classDef == null){
return;
};
if (inst.classToInstancesDict[classDef] == null){
inst.classToInstancesDict[classDef] = new Dictionary(true);
target = classDef;
while (defaultStyles == null) {
if (target["getStyleDefinition"] != null){
defaultStyles = target["getStyleDefinition"]();
break;
};
try {
target = (instance.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(target)) as Class);
} catch(err:Error) {
try {
target = (getDefinitionByName(getQualifiedSuperclassName(target)) as Class);
} catch(e:Error) {
defaultStyles = UIComponent.getStyleDefinition();
break;
};
};
};
styleToClasses = inst.styleToClassesHash;
for (n in defaultStyles) {
if (styleToClasses[n] == null){
styleToClasses[n] = new Dictionary(true);
};
styleToClasses[n][classDef] = true;
};
inst.classToDefaultStylesDict[classDef] = defaultStyles;
inst.classToStylesDict[classDef] = {};
};
inst.classToInstancesDict[classDef][instance] = true;
setSharedStyles(instance);
}
public static function getStyle(_arg1:String):Object{
return (getInstance().globalStyles[_arg1]);
}
private static function getSharedStyle(_arg1:UIComponent, _arg2:String):Object{
var _local3:Class;
var _local4:StyleManager;
var _local5:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance();
_local5 = _local4.classToStylesDict[_local3][_arg2];
if (_local5 != null){
return (_local5);
};
_local5 = _local4.globalStyles[_arg2];
if (_local5 != null){
return (_local5);
};
return (_local4.classToDefaultStylesDict[_local3][_arg2]);
}
public static function setStyle(_arg1:String, _arg2:Object):void{
var _local3:Object;
_local3 = getInstance().globalStyles;
if ((((_local3[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
_local3[_arg1] = _arg2;
invalidateStyle(_arg1);
}
}
}//package fl.managers
Section 158
//Quad (gs.easing.Quad)
package gs.easing {
public class Quad {
public function Quad(){
super();
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / d);
return ((((-(c) * t) * (t - 2)) + b));
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / d);
return ((((c * t) * t) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / (d / 2));
if (t < 1){
return (((((c / 2) * t) * t) + b));
};
--t;
return ((((-(c) / 2) * ((t * (t - 2)) - 1)) + b));
}
}
}//package gs.easing
Section 159
//TweenEvent (gs.events.TweenEvent)
package gs.events {
import flash.events.*;
public class TweenEvent extends Event {
public var info:Object;
public static const UPDATE:String = "update";
public static const START:String = "start";
public static const version:Number = 0.9;
public static const COMPLETE:String = "complete";
public function TweenEvent($type:String, $info:Object=null, $bubbles:Boolean=false, $cancelable:Boolean=false){
super($type, $bubbles, $cancelable);
this.info = $info;
}
override public function clone():Event{
return (new TweenEvent(this.type, this.info, this.bubbles, this.cancelable));
}
}
}//package gs.events
Section 160
//AutoAlphaPlugin (gs.plugins.AutoAlphaPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
public class AutoAlphaPlugin extends TweenPlugin {
protected var _tweenVisible:Boolean;
protected var _target:Object;
protected var _visible:Boolean;
protected var _tween:TweenLite;
public static const VERSION:Number = 1;
public static const API:Number = 1;
public function AutoAlphaPlugin(){
super();
this.propName = "autoAlpha";
this.overwriteProps = ["alpha", "visible"];
this.onComplete = onCompleteTween;
}
override public function killProps($lookup:Object):void{
super.killProps($lookup);
_tweenVisible = !(Boolean(("visible" in $lookup)));
}
public function onCompleteTween():void{
if (((((_tweenVisible) && (!((_tween.vars.runBackwards == true))))) && ((_tween.ease == _tween.vars.ease)))){
_target.visible = _visible;
};
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
_target = $target;
_tween = $tween;
_visible = Boolean(!(($value == 0)));
_tweenVisible = true;
addTween($target, "alpha", $target.alpha, $value, "alpha");
return (true);
}
override public function set changeFactor($n:Number):void{
updateTweens($n);
if (((!((_target.visible == true))) && (_tweenVisible))){
_target.visible = true;
};
}
}
}//package gs.plugins
Section 161
//BevelFilterPlugin (gs.plugins.BevelFilterPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
import flash.filters.*;
public class BevelFilterPlugin extends FilterPlugin {
public static const VERSION:Number = 1;
public static const API:Number = 1;
public function BevelFilterPlugin(){
super();
this.propName = "bevelFilter";
this.overwriteProps = ["bevelFilter"];
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
_target = $target;
_type = BevelFilter;
initFilter($value, new BevelFilter(0, 0, 0xFFFFFF, 0.5, 0, 0.5, 2, 2, 0, (($value.quality) || (2))));
return (true);
}
}
}//package gs.plugins
Section 162
//BezierPlugin (gs.plugins.BezierPlugin)
package gs.plugins {
import gs.*;
import gs.utils.tween.*;
public class BezierPlugin extends TweenPlugin {
protected var _future:Object;
protected var _orient:Boolean;
protected var _orientData:Array;
protected var _target:Object;
protected var _beziers:Object;
protected static const _RAD2DEG:Number = 57.2957795130823;
public static const VERSION:Number = 1.01;
public static const API:Number = 1;
public function BezierPlugin(){
_future = {};
super();
this.propName = "bezier";
this.overwriteProps = [];
}
override public function killProps($lookup:Object):void{
var p:String;
for (p in _beziers) {
if ((p in $lookup)){
delete _beziers[p];
};
};
super.killProps($lookup);
}
protected function init($tween:TweenLite, $beziers:Array, $through:Boolean):void{
var i:int;
var p:String;
_target = $tween.target;
if ($tween.exposedVars.orientToBezier == true){
_orientData = [["x", "y", "rotation", 0]];
_orient = true;
} else {
if (($tween.exposedVars.orientToBezier is Array)){
_orientData = $tween.exposedVars.orientToBezier;
_orient = true;
};
};
var props:Object = {};
i = 0;
while (i < $beziers.length) {
for (p in $beziers[i]) {
if (props[p] == undefined){
props[p] = [$tween.target[p]];
};
if (typeof($beziers[i][p]) == "number"){
props[p].push($beziers[i][p]);
} else {
props[p].push(($tween.target[p] + Number($beziers[i][p])));
};
};
i++;
};
for (p in props) {
this.overwriteProps[this.overwriteProps.length] = p;
if ($tween.exposedVars[p] != undefined){
if (typeof($tween.exposedVars[p]) == "number"){
props[p].push($tween.exposedVars[p]);
} else {
props[p].push(($tween.target[p] + Number($tween.exposedVars[p])));
};
delete $tween.exposedVars[p];
i = ($tween.tweens.length - 1);
while (i > -1) {
if ($tween.tweens[i].name == p){
$tween.tweens.splice(i, 1);
};
i--;
};
};
};
_beziers = parseBeziers(props, $through);
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
if (!($value is Array)){
return (false);
};
init($tween, ($value as Array), false);
return (true);
}
override public function set changeFactor($n:Number):void{
var i:int;
var p:String;
var b:Object;
var t:Number;
var segments:uint;
var val:Number;
var neg:int;
var oldTarget:Object;
var oldRound:Boolean;
var dx:Number;
var dy:Number;
var cotb:Array;
var toAdd:Number;
if ($n == 1){
for (p in _beziers) {
i = (_beziers[p].length - 1);
_target[p] = _beziers[p][i][2];
};
} else {
for (p in _beziers) {
segments = _beziers[p].length;
if ($n < 0){
i = 0;
} else {
if ($n >= 1){
i = (segments - 1);
} else {
i = int((segments * $n));
};
};
t = (($n - (i * (1 / segments))) * segments);
b = _beziers[p][i];
if (this.round){
val = (b[0] + (t * (((2 * (1 - t)) * (b[1] - b[0])) + (t * (b[2] - b[0])))));
neg = ((val)<0) ? -1 : 1;
_target[p] = ((((val % 1) * neg))>0.5) ? (int(val) + neg) : int(val);
} else {
_target[p] = (b[0] + (t * (((2 * (1 - t)) * (b[1] - b[0])) + (t * (b[2] - b[0])))));
};
};
};
if (_orient){
oldTarget = _target;
oldRound = this.round;
_target = _future;
this.round = false;
_orient = false;
this.changeFactor = ($n + 0.01);
_target = oldTarget;
this.round = oldRound;
_orient = true;
i = 0;
while (i < _orientData.length) {
cotb = _orientData[i];
toAdd = ((cotb[3]) || (0));
dx = (_future[cotb[0]] - _target[cotb[0]]);
dy = (_future[cotb[1]] - _target[cotb[1]]);
_target[cotb[2]] = ((Math.atan2(dy, dx) * _RAD2DEG) + toAdd);
i++;
};
};
}
public static function parseBeziers($props:Object, $through:Boolean=false):Object{
var i:int;
var a:Array;
var b:Object;
var p:String;
var all:Object = {};
if ($through){
for (p in $props) {
a = $props[p];
b = [];
all[p] = b;
if (a.length > 2){
b[b.length] = [a[0], (a[1] - ((a[2] - a[0]) / 4)), a[1]];
i = 1;
while (i < (a.length - 1)) {
b[b.length] = [a[i], (a[i] + (a[i] - b[(i - 1)][1])), a[(i + 1)]];
i++;
};
} else {
b[b.length] = [a[0], ((a[0] + a[1]) / 2), a[1]];
};
};
} else {
for (p in $props) {
a = $props[p];
b = [];
all[p] = b;
if (a.length > 3){
b[b.length] = [a[0], a[1], ((a[1] + a[2]) / 2)];
i = 2;
while (i < (a.length - 2)) {
b[b.length] = [b[(i - 2)][2], a[i], ((a[i] + a[(i + 1)]) / 2)];
i++;
};
b[b.length] = [b[(b.length - 1)][2], a[(a.length - 2)], a[(a.length - 1)]];
} else {
if (a.length == 3){
b[b.length] = [a[0], a[1], a[2]];
} else {
if (a.length == 2){
b[b.length] = [a[0], ((a[0] + a[1]) / 2), a[1]];
};
};
};
};
};
return (all);
}
}
}//package gs.plugins
Section 163
//BezierThroughPlugin (gs.plugins.BezierThroughPlugin)
package gs.plugins {
import gs.*;
public class BezierThroughPlugin extends BezierPlugin {
public static const VERSION:Number = 1;
public static const API:Number = 1;
public function BezierThroughPlugin(){
super();
this.propName = "bezierThrough";
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
if (!($value is Array)){
return (false);
};
init($tween, ($value as Array), true);
return (true);
}
}
}//package gs.plugins
Section 164
//BlurFilterPlugin (gs.plugins.BlurFilterPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
import flash.filters.*;
public class BlurFilterPlugin extends FilterPlugin {
public static const VERSION:Number = 1;
public static const API:Number = 1;
public function BlurFilterPlugin(){
super();
this.propName = "blurFilter";
this.overwriteProps = ["blurFilter"];
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
_target = $target;
_type = BlurFilter;
initFilter($value, new BlurFilter(0, 0, (($value.quality) || (2))));
return (true);
}
}
}//package gs.plugins
Section 165
//ColorMatrixFilterPlugin (gs.plugins.ColorMatrixFilterPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
import flash.filters.*;
public class ColorMatrixFilterPlugin extends FilterPlugin {
protected var _matrix:Array;
protected var _matrixTween:EndArrayPlugin;
public static const API:Number = 1;
public static const VERSION:Number = 1.1;
protected static var _lumG:Number = 0.71516;
protected static var _lumR:Number = 0.212671;
protected static var _idMatrix:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
protected static var _lumB:Number = 0.072169;
public function ColorMatrixFilterPlugin(){
super();
this.propName = "colorMatrixFilter";
this.overwriteProps = ["colorMatrixFilter"];
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
_target = $target;
_type = ColorMatrixFilter;
var cmf:Object = $value;
initFilter({remove:$value.remove, index:$value.index, addFilter:$value.addFilter}, new ColorMatrixFilter(_idMatrix.slice()));
_matrix = ColorMatrixFilter(_filter).matrix;
var endMatrix:Array = [];
if (((!((cmf.matrix == null))) && ((cmf.matrix is Array)))){
endMatrix = cmf.matrix;
} else {
if (cmf.relative == true){
endMatrix = _matrix.slice();
} else {
endMatrix = _idMatrix.slice();
};
endMatrix = setBrightness(endMatrix, cmf.brightness);
endMatrix = setContrast(endMatrix, cmf.contrast);
endMatrix = setHue(endMatrix, cmf.hue);
endMatrix = setSaturation(endMatrix, cmf.saturation);
endMatrix = setThreshold(endMatrix, cmf.threshold);
if (!isNaN(cmf.colorize)){
endMatrix = colorize(endMatrix, cmf.colorize, cmf.amount);
};
};
_matrixTween = new EndArrayPlugin();
_matrixTween.init(_matrix, endMatrix);
return (true);
}
override public function set changeFactor($n:Number):void{
_matrixTween.changeFactor = $n;
ColorMatrixFilter(_filter).matrix = _matrix;
super.changeFactor = $n;
}
public static function setSaturation($m:Array, $n:Number):Array{
if (isNaN($n)){
return ($m);
};
var inv:Number = (1 - $n);
var r:Number = (inv * _lumR);
var g:Number = (inv * _lumG);
var b:Number = (inv * _lumB);
var temp:Array = [(r + $n), g, b, 0, 0, r, (g + $n), b, 0, 0, r, g, (b + $n), 0, 0, 0, 0, 0, 1, 0];
return (applyMatrix(temp, $m));
}
public static function setHue($m:Array, $n:Number):Array{
if (isNaN($n)){
return ($m);
};
$n = ($n * (Math.PI / 180));
var c:Number = Math.cos($n);
var s:Number = Math.sin($n);
var temp:Array = [((_lumR + (c * (1 - _lumR))) + (s * -(_lumR))), ((_lumG + (c * -(_lumG))) + (s * -(_lumG))), ((_lumB + (c * -(_lumB))) + (s * (1 - _lumB))), 0, 0, ((_lumR + (c * -(_lumR))) + (s * 0.143)), ((_lumG + (c * (1 - _lumG))) + (s * 0.14)), ((_lumB + (c * -(_lumB))) + (s * -0.283)), 0, 0, ((_lumR + (c * -(_lumR))) + (s * -((1 - _lumR)))), ((_lumG + (c * -(_lumG))) + (s * _lumG)), ((_lumB + (c * (1 - _lumB))) + (s * _lumB)), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1];
return (applyMatrix(temp, $m));
}
public static function setThreshold($m:Array, $n:Number):Array{
if (isNaN($n)){
return ($m);
};
var temp:Array = [(_lumR * 0x0100), (_lumG * 0x0100), (_lumB * 0x0100), 0, (-256 * $n), (_lumR * 0x0100), (_lumG * 0x0100), (_lumB * 0x0100), 0, (-256 * $n), (_lumR * 0x0100), (_lumG * 0x0100), (_lumB * 0x0100), 0, (-256 * $n), 0, 0, 0, 1, 0];
return (applyMatrix(temp, $m));
}
public static function applyMatrix($m:Array, $m2:Array):Array{
var y:int;
var x:int;
if (((!(($m is Array))) || (!(($m2 is Array))))){
return ($m2);
};
var temp:Array = [];
var i:int;
var z:int;
y = 0;
while (y < 4) {
x = 0;
while (x < 5) {
if (x == 4){
z = $m[(i + 4)];
} else {
z = 0;
};
temp[(i + x)] = ((((($m[i] * $m2[x]) + ($m[(i + 1)] * $m2[(x + 5)])) + ($m[(i + 2)] * $m2[(x + 10)])) + ($m[(i + 3)] * $m2[(x + 15)])) + z);
x++;
};
i = (i + 5);
y++;
};
return (temp);
}
public static function colorize($m:Array, $color:Number, $amount:Number=1):Array{
if (isNaN($color)){
return ($m);
};
if (isNaN($amount)){
$amount = 1;
};
var r:Number = ((($color >> 16) & 0xFF) / 0xFF);
var g:Number = ((($color >> 8) & 0xFF) / 0xFF);
var b:Number = (($color & 0xFF) / 0xFF);
var inv:Number = (1 - $amount);
var temp:Array = [(inv + (($amount * r) * _lumR)), (($amount * r) * _lumG), (($amount * r) * _lumB), 0, 0, (($amount * g) * _lumR), (inv + (($amount * g) * _lumG)), (($amount * g) * _lumB), 0, 0, (($amount * b) * _lumR), (($amount * b) * _lumG), (inv + (($amount * b) * _lumB)), 0, 0, 0, 0, 0, 1, 0];
return (applyMatrix(temp, $m));
}
public static function setBrightness($m:Array, $n:Number):Array{
if (isNaN($n)){
return ($m);
};
$n = (($n * 100) - 100);
return (applyMatrix([1, 0, 0, 0, $n, 0, 1, 0, 0, $n, 0, 0, 1, 0, $n, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], $m));
}
public static function setContrast($m:Array, $n:Number):Array{
if (isNaN($n)){
return ($m);
};
$n = ($n + 0.01);
var temp:Array = [$n, 0, 0, 0, (128 * (1 - $n)), 0, $n, 0, 0, (128 * (1 - $n)), 0, 0, $n, 0, (128 * (1 - $n)), 0, 0, 0, 1, 0];
return (applyMatrix(temp, $m));
}
}
}//package gs.plugins
Section 166
//DropShadowFilterPlugin (gs.plugins.DropShadowFilterPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
import flash.filters.*;
public class DropShadowFilterPlugin extends FilterPlugin {
public static const VERSION:Number = 1;
public static const API:Number = 1;
public function DropShadowFilterPlugin(){
super();
this.propName = "dropShadowFilter";
this.overwriteProps = ["dropShadowFilter"];
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
_target = $target;
_type = DropShadowFilter;
initFilter($value, new DropShadowFilter(0, 45, 0, 0, 0, 0, 1, (($value.quality) || (2)), $value.inner, $value.knockout, $value.hideObject));
return (true);
}
}
}//package gs.plugins
Section 167
//EndArrayPlugin (gs.plugins.EndArrayPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
import gs.utils.tween.*;
public class EndArrayPlugin extends TweenPlugin {
protected var _a:Array;
protected var _info:Array;
public static const VERSION:Number = 1.01;
public static const API:Number = 1;
public function EndArrayPlugin(){
_info = [];
super();
this.propName = "endArray";
this.overwriteProps = ["endArray"];
}
public function init($start:Array, $end:Array):void{
_a = $start;
var i:int = ($end.length - 1);
while (i > -1) {
if (((!(($start[i] == $end[i]))) && (!(($start[i] == null))))){
_info[_info.length] = new ArrayTweenInfo(i, _a[i], ($end[i] - _a[i]));
};
i--;
};
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
if (((!(($target is Array))) || (!(($value is Array))))){
return (false);
};
init(($target as Array), $value);
return (true);
}
override public function set changeFactor($n:Number):void{
var i:int;
var ti:ArrayTweenInfo;
var val:Number;
var neg:int;
if (this.round){
i = (_info.length - 1);
while (i > -1) {
ti = _info[i];
val = (ti.start + (ti.change * $n));
neg = ((val)<0) ? -1 : 1;
_a[ti.index] = ((((val % 1) * neg))>0.5) ? (int(val) + neg) : int(val);
i--;
};
} else {
i = (_info.length - 1);
while (i > -1) {
ti = _info[i];
_a[ti.index] = (ti.start + (ti.change * $n));
i--;
};
};
}
}
}//package gs.plugins
Section 168
//FilterPlugin (gs.plugins.FilterPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
import flash.filters.*;
import gs.utils.tween.*;
public class FilterPlugin extends TweenPlugin {
protected var _remove:Boolean;
protected var _target:Object;
protected var _index:int;
protected var _filter:BitmapFilter;
protected var _type:Class;
public static const VERSION:Number = 1.03;
public static const API:Number = 1;
public function FilterPlugin(){
super();
}
public function onCompleteTween():void{
var i:int;
var filters:Array;
if (_remove){
filters = _target.filters;
if (!(filters[_index] is _type)){
i = (filters.length - 1);
while (i > -1) {
if ((filters[i] is _type)){
filters.splice(i, 1);
break;
};
i--;
};
} else {
filters.splice(_index, 1);
};
_target.filters = filters;
};
}
protected function initFilter($props:Object, $default:BitmapFilter):void{
var p:String;
var i:int;
var colorTween:HexColorsPlugin;
var filters:Array = _target.filters;
_index = -1;
if ($props.index != null){
_index = $props.index;
} else {
i = (filters.length - 1);
while (i > -1) {
if ((filters[i] is _type)){
_index = i;
break;
};
i--;
};
};
if ((((((_index == -1)) || ((filters[_index] == null)))) || (($props.addFilter == true)))){
_index = (($props.index)!=null) ? $props.index : filters.length;
filters[_index] = $default;
_target.filters = filters;
};
_filter = filters[_index];
_remove = Boolean(($props.remove == true));
if (_remove){
this.onComplete = onCompleteTween;
};
var props:Object = (($props.isTV)==true) ? $props.exposedVars : $props;
for (p in props) {
if (((((((((!((p in _filter))) || ((_filter[p] == props[p])))) || ((p == "remove")))) || ((p == "index")))) || ((p == "addFilter")))){
} else {
if ((((((p == "color")) || ((p == "highlightColor")))) || ((p == "shadowColor")))){
colorTween = new HexColorsPlugin();
colorTween.initColor(_filter, p, _filter[p], props[p]);
_tweens[_tweens.length] = new TweenInfo(colorTween, "changeFactor", 0, 1, p, false);
} else {
if ((((((((p == "quality")) || ((p == "inner")))) || ((p == "knockout")))) || ((p == "hideObject")))){
_filter[p] = props[p];
} else {
addTween(_filter, p, _filter[p], props[p], p);
};
};
};
};
}
override public function set changeFactor($n:Number):void{
var i:int;
var ti:TweenInfo;
var filters:Array = _target.filters;
i = (_tweens.length - 1);
while (i > -1) {
ti = _tweens[i];
ti.target[ti.property] = (ti.start + (ti.change * $n));
i--;
};
if (!(filters[_index] is _type)){
_index = (filters.length - 1);
i = (filters.length - 1);
while (i > -1) {
if ((filters[i] is _type)){
_index = i;
break;
};
i--;
};
};
filters[_index] = _filter;
_target.filters = filters;
}
}
}//package gs.plugins
Section 169
//FramePlugin (gs.plugins.FramePlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
public class FramePlugin extends TweenPlugin {
protected var _target:MovieClip;
public var frame:int;
public static const VERSION:Number = 1.01;
public static const API:Number = 1;
public function FramePlugin(){
super();
this.propName = "frame";
this.overwriteProps = ["frame"];
this.round = true;
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
if (((!(($target is MovieClip))) || (isNaN($value)))){
return (false);
};
_target = ($target as MovieClip);
this.frame = _target.currentFrame;
addTween(this, "frame", this.frame, $value, "frame");
return (true);
}
override public function set changeFactor($n:Number):void{
updateTweens($n);
_target.gotoAndStop(this.frame);
}
}
}//package gs.plugins
Section 170
//GlowFilterPlugin (gs.plugins.GlowFilterPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
import flash.filters.*;
public class GlowFilterPlugin extends FilterPlugin {
public static const VERSION:Number = 1;
public static const API:Number = 1;
public function GlowFilterPlugin(){
super();
this.propName = "glowFilter";
this.overwriteProps = ["glowFilter"];
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
_target = $target;
_type = GlowFilter;
initFilter($value, new GlowFilter(0xFFFFFF, 0, 0, 0, (($value.strength) || (1)), (($value.quality) || (2)), $value.inner, $value.knockout));
return (true);
}
}
}//package gs.plugins
Section 171
//HexColorsPlugin (gs.plugins.HexColorsPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
public class HexColorsPlugin extends TweenPlugin {
protected var _colors:Array;
public static const VERSION:Number = 1.01;
public static const API:Number = 1;
public function HexColorsPlugin(){
super();
this.propName = "hexColors";
this.overwriteProps = [];
_colors = [];
}
override public function killProps($lookup:Object):void{
var i:int = (_colors.length - 1);
while (i > -1) {
if ($lookup[_colors[i][1]] != undefined){
_colors.splice(i, 1);
};
i--;
};
super.killProps($lookup);
}
public function initColor($target:Object, $propName:String, $start:uint, $end:uint):void{
var r:Number;
var g:Number;
var b:Number;
if ($start != $end){
r = ($start >> 16);
g = (($start >> 8) & 0xFF);
b = ($start & 0xFF);
_colors[_colors.length] = [$target, $propName, r, (($end >> 16) - r), g, ((($end >> 8) & 0xFF) - g), b, (($end & 0xFF) - b)];
this.overwriteProps[this.overwriteProps.length] = $propName;
};
}
override public function set changeFactor($n:Number):void{
var i:int;
var a:Array;
i = (_colors.length - 1);
while (i > -1) {
a = _colors[i];
a[0][a[1]] = ((((a[2] + ($n * a[3])) << 16) | ((a[4] + ($n * a[5])) << 8)) | (a[6] + ($n * a[7])));
i--;
};
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
var p:String;
for (p in $value) {
initColor($target, p, uint($target[p]), uint($value[p]));
};
return (true);
}
}
}//package gs.plugins
Section 172
//RemoveTintPlugin (gs.plugins.RemoveTintPlugin)
package gs.plugins {
public class RemoveTintPlugin extends TintPlugin {
public static const VERSION:Number = 1.01;
public static const API:Number = 1;
public function RemoveTintPlugin(){
super();
this.propName = "removeTint";
}
}
}//package gs.plugins
Section 173
//RoundPropsPlugin (gs.plugins.RoundPropsPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
public class RoundPropsPlugin extends TweenPlugin {
public static const VERSION:Number = 1;
public static const API:Number = 1;
public function RoundPropsPlugin(){
super();
this.propName = "roundProps";
this.overwriteProps = [];
this.round = true;
}
public function add($object:Object, $propName:String, $start:Number, $change:Number):void{
addTween($object, $propName, $start, ($start + $change), $propName);
this.overwriteProps[this.overwriteProps.length] = $propName;
}
}
}//package gs.plugins
Section 174
//ShortRotationPlugin (gs.plugins.ShortRotationPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
public class ShortRotationPlugin extends TweenPlugin {
public static const VERSION:Number = 1;
public static const API:Number = 1;
public function ShortRotationPlugin(){
super();
this.propName = "shortRotation";
this.overwriteProps = [];
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
var p:String;
if (typeof($value) == "number"){
trace("WARNING: You appear to be using the old shortRotation syntax. Instead of passing a number, please pass an object with properties that correspond to the rotations values For example, TweenMax.to(mc, 2, {shortRotation:{rotationX:-170, rotationY:25}})");
return (false);
};
for (p in $value) {
initRotation($target, p, $target[p], $value[p]);
};
return (true);
}
public function initRotation($target:Object, $propName:String, $start:Number, $end:Number):void{
var dif:Number = (($end - $start) % 360);
if (dif != (dif % 180)){
dif = ((dif)<0) ? (dif + 360) : (dif - 360);
};
addTween($target, $propName, $start, ($start + dif), $propName);
this.overwriteProps[this.overwriteProps.length] = $propName;
}
}
}//package gs.plugins
Section 175
//TintPlugin (gs.plugins.TintPlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
import flash.geom.*;
import gs.utils.tween.*;
public class TintPlugin extends TweenPlugin {
protected var _target:DisplayObject;
protected var _ct:ColorTransform;
protected var _ignoreAlpha:Boolean;
public static const VERSION:Number = 1.1;
public static const API:Number = 1;
protected static var _props:Array = ["redMultiplier", "greenMultiplier", "blueMultiplier", "alphaMultiplier", "redOffset", "greenOffset", "blueOffset", "alphaOffset"];
public function TintPlugin(){
super();
this.propName = "tint";
this.overwriteProps = ["tint"];
}
public function init($target:DisplayObject, $end:ColorTransform):void{
var i:int;
var p:String;
_target = $target;
_ct = _target.transform.colorTransform;
i = (_props.length - 1);
while (i > -1) {
p = _props[i];
if (_ct[p] != $end[p]){
_tweens[_tweens.length] = new TweenInfo(_ct, p, _ct[p], ($end[p] - _ct[p]), "tint", false);
};
i--;
};
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
if (!($target is DisplayObject)){
return (false);
};
var end:ColorTransform = new ColorTransform();
if (((!(($value == null))) && (!(($tween.exposedVars.removeTint == true))))){
end.color = uint($value);
};
_ignoreAlpha = true;
init(($target as DisplayObject), end);
return (true);
}
override public function set changeFactor($n:Number):void{
var ct:ColorTransform;
updateTweens($n);
if (_ignoreAlpha){
ct = _target.transform.colorTransform;
_ct.alphaMultiplier = ct.alphaMultiplier;
_ct.alphaOffset = ct.alphaOffset;
};
_target.transform.colorTransform = _ct;
}
}
}//package gs.plugins
Section 176
//TweenPlugin (gs.plugins.TweenPlugin)
package gs.plugins {
import gs.*;
import gs.utils.tween.*;
public class TweenPlugin {
public var overwriteProps:Array;
protected var _tweens:Array;
public var propName:String;
public var onComplete:Function;
public var round:Boolean;
protected var _changeFactor:Number;// = 0
public static const VERSION:Number = 1.03;
public static const API:Number = 1;
public function TweenPlugin(){
_tweens = [];
super();
}
protected function updateTweens($changeFactor:Number):void{
var i:int;
var ti:TweenInfo;
var val:Number;
var neg:int;
if (this.round){
i = (_tweens.length - 1);
while (i > -1) {
ti = _tweens[i];
val = (ti.start + (ti.change * $changeFactor));
neg = ((val)<0) ? -1 : 1;
ti.target[ti.property] = ((((val % 1) * neg))>0.5) ? (int(val) + neg) : int(val);
i--;
};
} else {
i = (_tweens.length - 1);
while (i > -1) {
ti = _tweens[i];
ti.target[ti.property] = (ti.start + (ti.change * $changeFactor));
i--;
};
};
}
public function set changeFactor($n:Number):void{
updateTweens($n);
_changeFactor = $n;
}
protected function addTween($object:Object, $propName:String, $start:Number, $end, $overwriteProp:String=null):void{
var change:Number;
if ($end != null){
change = ((typeof($end))=="number") ? ($end - $start) : Number($end);
if (change != 0){
_tweens[_tweens.length] = new TweenInfo($object, $propName, $start, change, (($overwriteProp) || ($propName)), false);
};
};
}
public function killProps($lookup:Object):void{
var i:int;
i = (this.overwriteProps.length - 1);
while (i > -1) {
if ((this.overwriteProps[i] in $lookup)){
this.overwriteProps.splice(i, 1);
};
i--;
};
i = (_tweens.length - 1);
while (i > -1) {
if ((_tweens[i].name in $lookup)){
_tweens.splice(i, 1);
};
i--;
};
}
public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
addTween($target, this.propName, $target[this.propName], $value, this.propName);
return (true);
}
public function get changeFactor():Number{
return (_changeFactor);
}
public static function activate($plugins:Array):Boolean{
var i:int;
var instance:Object;
i = ($plugins.length - 1);
while (i > -1) {
instance = new ($plugins[i]);
TweenLite.plugins[instance.propName] = $plugins[i];
i--;
};
return (true);
}
}
}//package gs.plugins
Section 177
//VisiblePlugin (gs.plugins.VisiblePlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
public class VisiblePlugin extends TweenPlugin {
protected var _target:Object;
protected var _visible:Boolean;
protected var _tween:TweenLite;
public static const VERSION:Number = 1;
public static const API:Number = 1;
public function VisiblePlugin(){
super();
this.propName = "visible";
this.overwriteProps = ["visible"];
this.onComplete = onCompleteTween;
}
public function onCompleteTween():void{
if (((!((_tween.vars.runBackwards == true))) && ((_tween.ease == _tween.vars.ease)))){
_target.visible = _visible;
};
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
_target = $target;
_tween = $tween;
_visible = Boolean($value);
return (true);
}
override public function set changeFactor($n:Number):void{
if (_target.visible != true){
_target.visible = true;
};
}
}
}//package gs.plugins
Section 178
//VolumePlugin (gs.plugins.VolumePlugin)
package gs.plugins {
import flash.display.*;
import gs.*;
import flash.media.*;
public class VolumePlugin extends TweenPlugin {
protected var _target:Object;
protected var _st:SoundTransform;
public static const VERSION:Number = 1.01;
public static const API:Number = 1;
public function VolumePlugin(){
super();
this.propName = "volume";
this.overwriteProps = ["volume"];
}
override public function onInitTween($target:Object, $value, $tween:TweenLite):Boolean{
if (((isNaN($value)) || (!($target.hasOwnProperty("soundTransform"))))){
return (false);
};
_target = $target;
_st = _target.soundTransform;
addTween(_st, "volume", _st.volume, $value, "volume");
return (true);
}
override public function set changeFactor($n:Number):void{
updateTweens($n);
_target.soundTransform = _st;
}
}
}//package gs.plugins
Section 179
//ArrayTweenInfo (gs.utils.tween.ArrayTweenInfo)
package gs.utils.tween {
public class ArrayTweenInfo {
public var change:Number;
public var start:Number;
public var index:uint;
public function ArrayTweenInfo($index:uint, $start:Number, $change:Number){
super();
this.index = $index;
this.start = $start;
this.change = $change;
}
}
}//package gs.utils.tween
Section 180
//TweenInfo (gs.utils.tween.TweenInfo)
package gs.utils.tween {
public class TweenInfo {
public var start:Number;
public var name:String;
public var change:Number;
public var target:Object;
public var property:String;
public var isPlugin:Boolean;
public function TweenInfo($target:Object, $property:String, $start:Number, $change:Number, $name:String, $isPlugin:Boolean){
super();
this.target = $target;
this.property = $property;
this.start = $start;
this.change = $change;
this.name = $name;
this.isPlugin = $isPlugin;
}
}
}//package gs.utils.tween
Section 181
//OverwriteManager (gs.OverwriteManager)
package gs {
import flash.utils.*;
import gs.utils.tween.*;
import flash.errors.*;
public class OverwriteManager {
public static const ALL:int = 1;
public static const NONE:int = 0;
public static const AUTO:int = 2;
public static const CONCURRENT:int = 3;
public static const version:Number = 3.12;
public static var mode:int;
public static var enabled:Boolean;
public function OverwriteManager(){
super();
}
public static function killVars($killVars:Object, $vars:Object, $tweens:Array):void{
var i:int;
var p:String;
var ti:TweenInfo;
i = ($tweens.length - 1);
while (i > -1) {
ti = $tweens[i];
if ((ti.name in $killVars)){
$tweens.splice(i, 1);
} else {
if (((ti.isPlugin) && ((ti.name == "_MULTIPLE_")))){
ti.target.killProps($killVars);
if (ti.target.overwriteProps.length == 0){
$tweens.splice(i, 1);
};
};
};
i--;
};
for (p in $killVars) {
delete $vars[p];
};
}
public static function manageOverwrites($tween:TweenLite, $targetTweens:Array):void{
var i:int;
var tween:TweenLite;
var tweens:Array;
var v:Object;
var j:int;
var ti:TweenInfo;
var overwriteProps:Array;
var vars:Object = $tween.vars;
var m:int = ((vars.overwrite)==undefined) ? mode : int(vars.overwrite);
if ((((m < 2)) || (($targetTweens == null)))){
return;
};
var startTime:Number = $tween.startTime;
var a:Array = [];
var index = -1;
i = ($targetTweens.length - 1);
while (i > -1) {
tween = $targetTweens[i];
if (tween == $tween){
index = i;
} else {
if ((((((i < index)) && ((tween.startTime <= startTime)))) && (((tween.startTime + ((tween.duration * 1000) / tween.combinedTimeScale)) > startTime)))){
a[a.length] = tween;
};
};
i--;
};
if ((((a.length == 0)) || (($tween.tweens.length == 0)))){
return;
};
if (m == AUTO){
tweens = $tween.tweens;
v = {};
i = (tweens.length - 1);
while (i > -1) {
ti = tweens[i];
if (ti.isPlugin){
if (ti.name == "_MULTIPLE_"){
overwriteProps = ti.target.overwriteProps;
j = (overwriteProps.length - 1);
while (j > -1) {
v[overwriteProps[j]] = true;
j--;
};
} else {
v[ti.name] = true;
};
v[ti.target.propName] = true;
} else {
v[ti.name] = true;
};
i--;
};
i = (a.length - 1);
while (i > -1) {
killVars(v, a[i].exposedVars, a[i].tweens);
i--;
};
} else {
i = (a.length - 1);
while (i > -1) {
a[i].enabled = false;
i--;
};
};
}
public static function init($mode:int=2):int{
if (TweenLite.version < 10.09){
trace("TweenLite warning: Your TweenLite class needs to be updated to work with OverwriteManager (or you may need to clear your ASO files). Please download and install the latest version from http://www.tweenlite.com.");
};
TweenLite.overwriteManager = OverwriteManager;
mode = $mode;
enabled = true;
return (mode);
}
}
}//package gs
Section 182
//TweenLite (gs.TweenLite)
package gs {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import gs.plugins.*;
import gs.utils.tween.*;
public class TweenLite {
public var started:Boolean;
public var delay:Number;
protected var _hasUpdate:Boolean;
protected var _hasPlugins:Boolean;
public var initted:Boolean;
public var active:Boolean;
public var startTime:Number;
public var target:Object;
public var duration:Number;
public var gc:Boolean;
public var tweens:Array;
public var vars:Object;
public var ease:Function;
public var exposedVars:Object;
public var initTime:Number;
public var combinedTimeScale:Number;
public static const version:Number = 10.092;
private static var _timer:Timer = new Timer(2000);
public static var defaultEase:Function = TweenLite.easeOut;
public static var plugins:Object = {};
public static var currentTime:uint;
public static var masterList:Dictionary = new Dictionary(false);
protected static var _reservedProps:Object = {ease:1, delay:1, overwrite:1, onComplete:1, onCompleteParams:1, runBackwards:1, startAt:1, onUpdate:1, onUpdateParams:1, roundProps:1, onStart:1, onStartParams:1, persist:1, renderOnStart:1, proxiedEase:1, easeParams:1, yoyo:1, loop:1, onCompleteListener:1, onUpdateListener:1, onStartListener:1, orientToBezier:1, timeScale:1};
public static var killDelayedCallsTo:Function = TweenLite.killTweensOf;
public static var timingSprite:Sprite = new Sprite();
public static var overwriteManager:Object;
private static var _tlInitted:Boolean;
public function TweenLite($target:Object, $duration:Number, $vars:Object){
super();
if ($target == null){
return;
};
if (!_tlInitted){
TweenPlugin.activate([TintPlugin, RemoveTintPlugin, FramePlugin, AutoAlphaPlugin, VisiblePlugin, VolumePlugin, EndArrayPlugin]);
currentTime = getTimer();
timingSprite.addEventListener(Event.ENTER_FRAME, updateAll, false, 0, true);
if (overwriteManager == null){
overwriteManager = {mode:1, enabled:false};
};
_timer.addEventListener("timer", killGarbage, false, 0, true);
_timer.start();
_tlInitted = true;
};
this.vars = $vars;
this.duration = (($duration) || (0.001));
this.delay = (($vars.delay) || (0));
this.combinedTimeScale = (($vars.timeScale) || (1));
this.active = Boolean(((($duration == 0)) && ((this.delay == 0))));
this.target = $target;
if (typeof(this.vars.ease) != "function"){
this.vars.ease = defaultEase;
};
if (this.vars.easeParams != null){
this.vars.proxiedEase = this.vars.ease;
this.vars.ease = easeProxy;
};
this.ease = this.vars.ease;
this.exposedVars = ((this.vars.isTV)==true) ? this.vars.exposedVars : this.vars;
this.tweens = [];
this.initTime = currentTime;
this.startTime = (this.initTime + (this.delay * 1000));
var mode:int = (((($vars.overwrite == undefined)) || (((!(overwriteManager.enabled)) && (($vars.overwrite > 1)))))) ? overwriteManager.mode : int($vars.overwrite);
if (((!(($target in masterList))) || ((mode == 1)))){
masterList[$target] = [this];
} else {
masterList[$target].push(this);
};
if ((((((this.vars.runBackwards == true)) && (!((this.vars.renderOnStart == true))))) || (this.active))){
initTweenVals();
if (this.active){
render((this.startTime + 1));
} else {
render(this.startTime);
};
if (((((!((this.exposedVars.visible == null))) && ((this.vars.runBackwards == true)))) && ((this.target is DisplayObject)))){
this.target.visible = this.exposedVars.visible;
};
};
}
public function get enabled():Boolean{
return ((this.gc) ? false : true);
}
public function set enabled($b:Boolean):void{
var a:Array;
var found:Boolean;
var i:int;
if ($b){
if (!(this.target in masterList)){
masterList[this.target] = [this];
} else {
a = masterList[this.target];
i = (a.length - 1);
while (i > -1) {
if (a[i] == this){
found = true;
break;
};
i--;
};
if (!found){
a[a.length] = this;
};
};
};
this.gc = ($b) ? false : true;
if (this.gc){
this.active = false;
} else {
this.active = this.started;
};
}
public function clear():void{
this.tweens = [];
this.vars = (this.exposedVars = {ease:this.vars.ease});
_hasUpdate = false;
}
public function render($t:uint):void{
var factor:Number;
var ti:TweenInfo;
var i:int;
var time:Number = (($t - this.startTime) * 0.001);
if (time >= this.duration){
time = this.duration;
factor = ((((this.ease == this.vars.ease)) || ((this.duration == 0.001)))) ? 1 : 0;
} else {
factor = this.ease(time, 0, 1, this.duration);
};
i = (this.tweens.length - 1);
while (i > -1) {
ti = this.tweens[i];
ti.target[ti.property] = (ti.start + (factor * ti.change));
i--;
};
if (_hasUpdate){
this.vars.onUpdate.apply(null, this.vars.onUpdateParams);
};
if (time == this.duration){
complete(true);
};
}
public function activate():void{
this.started = (this.active = true);
if (!this.initted){
initTweenVals();
};
if (this.vars.onStart != null){
this.vars.onStart.apply(null, this.vars.onStartParams);
};
if (this.duration == 0.001){
this.startTime = (this.startTime - 1);
};
}
public function initTweenVals():void{
var p:String;
var i:int;
var plugin:*;
var ti:TweenInfo;
if (((!((this.exposedVars.timeScale == undefined))) && (this.target.hasOwnProperty("timeScale")))){
this.tweens[this.tweens.length] = new TweenInfo(this.target, "timeScale", this.target.timeScale, (this.exposedVars.timeScale - this.target.timeScale), "timeScale", false);
};
for (p in this.exposedVars) {
if ((p in _reservedProps)){
} else {
if ((p in plugins)){
plugin = new (plugins[p]);
if (plugin.onInitTween(this.target, this.exposedVars[p], this) == false){
this.tweens[this.tweens.length] = new TweenInfo(this.target, p, this.target[p], ((typeof(this.exposedVars[p]))=="number") ? (this.exposedVars[p] - this.target[p]) : Number(this.exposedVars[p]), p, false);
} else {
this.tweens[this.tweens.length] = new TweenInfo(plugin, "changeFactor", 0, 1, ((plugin.overwriteProps.length)==1) ? plugin.overwriteProps[0] : "_MULTIPLE_", true);
_hasPlugins = true;
};
} else {
this.tweens[this.tweens.length] = new TweenInfo(this.target, p, this.target[p], ((typeof(this.exposedVars[p]))=="number") ? (this.exposedVars[p] - this.target[p]) : Number(this.exposedVars[p]), p, false);
};
};
};
if (this.vars.runBackwards == true){
i = (this.tweens.length - 1);
while (i > -1) {
ti = this.tweens[i];
ti.start = (ti.start + ti.change);
ti.change = -(ti.change);
i--;
};
};
if (this.vars.onUpdate != null){
_hasUpdate = true;
};
if (((TweenLite.overwriteManager.enabled) && ((this.target in masterList)))){
overwriteManager.manageOverwrites(this, masterList[this.target]);
};
this.initted = true;
}
protected function easeProxy($t:Number, $b:Number, $c:Number, $d:Number):Number{
return (this.vars.proxiedEase.apply(null, arguments.concat(this.vars.easeParams)));
}
public function killVars($vars:Object):void{
if (overwriteManager.enabled){
overwriteManager.killVars($vars, this.exposedVars, this.tweens);
};
}
public function complete($skipRender:Boolean=false):void{
var i:int;
if (!$skipRender){
if (!this.initted){
initTweenVals();
};
this.startTime = (currentTime - ((this.duration * 1000) / this.combinedTimeScale));
render(currentTime);
return;
};
if (_hasPlugins){
i = (this.tweens.length - 1);
while (i > -1) {
if (((this.tweens[i].isPlugin) && (!((this.tweens[i].target.onComplete == null))))){
this.tweens[i].target.onComplete();
};
i--;
};
};
if (this.vars.persist != true){
this.enabled = false;
};
if (this.vars.onComplete != null){
this.vars.onComplete.apply(null, this.vars.onCompleteParams);
};
}
public static function updateAll($e:Event=null):void{
var a:Array;
var i:int;
var tween:TweenLite;
var time:uint = (currentTime = getTimer());
var ml:Dictionary = masterList;
for each (a in ml) {
i = (a.length - 1);
while (i > -1) {
tween = a[i];
if (tween.active){
tween.render(time);
} else {
if (tween.gc){
a.splice(i, 1);
} else {
if (time >= tween.startTime){
tween.activate();
tween.render(time);
};
};
};
i--;
};
};
}
public static function removeTween($tween:TweenLite, $clear:Boolean=true):void{
if ($tween != null){
if ($clear){
$tween.clear();
};
$tween.enabled = false;
};
}
public static function killTweensOf($target:Object=null, $complete:Boolean=false):void{
var a:Array;
var i:int;
var tween:TweenLite;
if (((!(($target == null))) && (($target in masterList)))){
a = masterList[$target];
i = (a.length - 1);
while (i > -1) {
tween = a[i];
if ((($complete) && (!(tween.gc)))){
tween.complete(false);
};
tween.clear();
i--;
};
delete masterList[$target];
};
}
public static function from($target:Object, $duration:Number, $vars:Object):TweenLite{
$vars.runBackwards = true;
return (new TweenLite($target, $duration, $vars));
}
public static function easeOut($t:Number, $b:Number, $c:Number, $d:Number):Number{
$t = ($t / $d);
return ((((-($c) * $t) * ($t - 2)) + $b));
}
protected static function killGarbage($e:TimerEvent):void{
var tgt:Object;
var ml:Dictionary = masterList;
for (tgt in ml) {
if (ml[tgt].length == 0){
delete ml[tgt];
};
};
}
public static function delayedCall($delay:Number, $onComplete:Function, $onCompleteParams:Array=null):TweenLite{
return (new TweenLite($onComplete, 0, {delay:$delay, onComplete:$onComplete, onCompleteParams:$onCompleteParams, overwrite:0}));
}
public static function to($target:Object, $duration:Number, $vars:Object):TweenLite{
return (new TweenLite($target, $duration, $vars));
}
}
}//package gs
Section 183
//TweenMax (gs.TweenMax)
package gs {
import flash.events.*;
import flash.utils.*;
import gs.plugins.*;
import gs.utils.tween.*;
import gs.events.*;
public class TweenMax extends TweenLite implements IEventDispatcher {
protected var _dispatcher:EventDispatcher;
protected var _callbacks:Object;
public var pauseTime:Number;
protected var _repeatCount:Number;
protected var _timeScale:Number;
public static const version:Number = 10.12;
public static var removeTween:Function = TweenLite.removeTween;
private static var _overwriteMode:int = (OverwriteManager.enabled) ? OverwriteManager.mode : OverwriteManager.init();
;
protected static var _pausedTweens:Dictionary = new Dictionary(false);
protected static var _globalTimeScale:Number = 1;
public static var killTweensOf:Function = TweenLite.killTweensOf;
public static var killDelayedCallsTo:Function = TweenLite.killTweensOf;
private static var _activatedPlugins:Boolean = TweenPlugin.activate([TintPlugin, RemoveTintPlugin, FramePlugin, AutoAlphaPlugin, VisiblePlugin, VolumePlugin, EndArrayPlugin, HexColorsPlugin, BlurFilterPlugin, ColorMatrixFilterPlugin, BevelFilterPlugin, DropShadowFilterPlugin, GlowFilterPlugin, RoundPropsPlugin, BezierPlugin, BezierThroughPlugin, ShortRotationPlugin]);
public function TweenMax($target:Object, $duration:Number, $vars:Object){
super($target, $duration, $vars);
if (TweenLite.version < 10.092){
trace("TweenMax error! Please update your TweenLite class or try deleting your ASO files. TweenMax requires a more recent version. Download updates at http://www.TweenMax.com.");
};
if (((!((this.combinedTimeScale == 1))) && ((this.target is TweenMax)))){
_timeScale = 1;
this.combinedTimeScale = _globalTimeScale;
} else {
_timeScale = this.combinedTimeScale;
this.combinedTimeScale = (this.combinedTimeScale * _globalTimeScale);
};
if (((!((this.combinedTimeScale == 1))) && (!((this.delay == 0))))){
this.startTime = (this.initTime + (this.delay * (1000 / this.combinedTimeScale)));
};
if (((((!((this.vars.onCompleteListener == null))) || (!((this.vars.onUpdateListener == null))))) || (!((this.vars.onStartListener == null))))){
initDispatcher();
if (((($duration == 0)) && ((this.delay == 0)))){
onUpdateDispatcher();
onCompleteDispatcher();
};
};
_repeatCount = 0;
if (((!(isNaN(this.vars.yoyo))) || (!(isNaN(this.vars.loop))))){
this.vars.persist = true;
};
if ((((this.delay == 0)) && (!((this.vars.startAt == null))))){
this.vars.startAt.overwrite = 0;
new TweenMax(this.target, 0, this.vars.startAt);
};
}
public function dispatchEvent($e:Event):Boolean{
if (_dispatcher == null){
return (false);
};
return (_dispatcher.dispatchEvent($e));
}
public function get reversed():Boolean{
return ((this.ease == reverseEase));
}
public function set reversed($b:Boolean):void{
if (this.reversed != $b){
reverse();
};
}
public function get progress():Number{
var t:Number = (isNaN(this.pauseTime)) ? currentTime : this.pauseTime;
var p:Number = (((((t - this.initTime) * 0.001) - (this.delay / this.combinedTimeScale)) / this.duration) * this.combinedTimeScale);
if (p > 1){
return (1);
};
if (p < 0){
return (0);
};
return (p);
}
override public function set enabled($b:Boolean):void{
if (!$b){
_pausedTweens[this] = null;
delete _pausedTweens[this];
};
super.enabled = $b;
if ($b){
this.combinedTimeScale = (_timeScale * _globalTimeScale);
};
}
protected function onStartDispatcher(... _args):void{
if (_callbacks.onStart != null){
_callbacks.onStart.apply(null, this.vars.onStartParams);
};
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.START));
}
public function setDestination($property:String, $value, $adjustStartValues:Boolean=true):void{
var i:int;
var ti:TweenInfo;
var varsOld:Object;
var exposedVarsOld:Object;
var tweensOld:Array;
var hadPlugins:Boolean;
var addedTweens:Array;
var killVars:Object;
var p:Number = this.progress;
if (this.initted){
if (!$adjustStartValues){
i = (this.tweens.length - 1);
while (i > -1) {
ti = this.tweens[i];
if (ti.name == $property){
ti.target[ti.property] = ti.start;
};
i--;
};
};
varsOld = this.vars;
exposedVarsOld = this.exposedVars;
tweensOld = this.tweens;
hadPlugins = _hasPlugins;
this.tweens = [];
this.vars = (this.exposedVars = {});
this.vars[$property] = $value;
initTweenVals();
if (((!((this.ease == reverseEase))) && ((varsOld.ease is Function)))){
this.ease = varsOld.ease;
};
if ((($adjustStartValues) && (!((p == 0))))){
adjustStartValues();
};
addedTweens = this.tweens;
this.vars = varsOld;
this.exposedVars = exposedVarsOld;
this.tweens = tweensOld;
killVars = {};
killVars[$property] = true;
i = (this.tweens.length - 1);
while (i > -1) {
ti = this.tweens[i];
if (ti.name == $property){
this.tweens.splice(i, 1);
} else {
if (((ti.isPlugin) && ((ti.name == "_MULTIPLE_")))){
ti.target.killProps(killVars);
if (ti.target.overwriteProps.length == 0){
this.tweens.splice(i, 1);
};
};
};
i--;
};
this.tweens = this.tweens.concat(addedTweens);
_hasPlugins = Boolean(((hadPlugins) || (_hasPlugins)));
};
this.vars[$property] = (this.exposedVars[$property] = $value);
}
override public function initTweenVals():void{
var i:int;
var j:int;
var prop:String;
var multiProps:String;
var rp:Array;
var plugin:Object;
var ti:TweenInfo;
if (((!((this.vars.startAt == null))) && (!((this.delay == 0))))){
this.vars.startAt.overwrite = 0;
new TweenMax(this.target, 0, this.vars.startAt);
};
super.initTweenVals();
if ((((this.exposedVars.roundProps is Array)) && (!((TweenLite.plugins.roundProps == null))))){
rp = this.exposedVars.roundProps;
i = (rp.length - 1);
while (i > -1) {
prop = rp[i];
j = (this.tweens.length - 1);
while (j > -1) {
ti = this.tweens[j];
if (ti.name == prop){
if (ti.isPlugin){
ti.target.round = true;
} else {
if (plugin == null){
plugin = new TweenLite.plugins.roundProps();
plugin.add(ti.target, prop, ti.start, ti.change);
_hasPlugins = true;
this.tweens[j] = new TweenInfo(plugin, "changeFactor", 0, 1, prop, true);
} else {
plugin.add(ti.target, prop, ti.start, ti.change);
this.tweens.splice(j, 1);
};
};
} else {
if (((((ti.isPlugin) && ((ti.name == "_MULTIPLE_")))) && (!(ti.target.round)))){
multiProps = ((" " + ti.target.overwriteProps.join(" ")) + " ");
if (multiProps.indexOf(((" " + prop) + " ")) != -1){
ti.target.round = true;
};
};
};
j--;
};
i--;
};
};
}
public function restart($includeDelay:Boolean=false):void{
if ($includeDelay){
this.initTime = currentTime;
this.startTime = (currentTime + (this.delay * (1000 / this.combinedTimeScale)));
} else {
this.startTime = currentTime;
this.initTime = (currentTime - (this.delay * (1000 / this.combinedTimeScale)));
};
_repeatCount = 0;
if (this.target != this.vars.onComplete){
render(this.startTime);
};
this.pauseTime = NaN;
_pausedTweens[this] = null;
delete _pausedTweens[this];
this.enabled = true;
}
public function removeEventListener($type:String, $listener:Function, $useCapture:Boolean=false):void{
if (_dispatcher != null){
_dispatcher.removeEventListener($type, $listener, $useCapture);
};
}
public function addEventListener($type:String, $listener:Function, $useCapture:Boolean=false, $priority:int=0, $useWeakReference:Boolean=false):void{
if (_dispatcher == null){
initDispatcher();
};
if (((($type == TweenEvent.UPDATE)) && (!((this.vars.onUpdate == onUpdateDispatcher))))){
this.vars.onUpdate = onUpdateDispatcher;
_hasUpdate = true;
};
_dispatcher.addEventListener($type, $listener, $useCapture, $priority, $useWeakReference);
}
protected function adjustStartValues():void{
var factor:Number;
var inv:Number;
var endValue:Number;
var ti:TweenInfo;
var i:int;
var p:Number = this.progress;
if (p != 0){
factor = this.ease(p, 0, 1, 1);
inv = (1 / (1 - factor));
i = (this.tweens.length - 1);
while (i > -1) {
ti = this.tweens[i];
endValue = (ti.start + ti.change);
if (ti.isPlugin){
ti.change = ((endValue - factor) * inv);
} else {
ti.change = ((endValue - ti.target[ti.property]) * inv);
};
ti.start = (endValue - ti.change);
i--;
};
};
}
override public function render($t:uint):void{
var factor:Number;
var ti:TweenInfo;
var i:int;
var time:Number = ((($t - this.startTime) * 0.001) * this.combinedTimeScale);
if (time >= this.duration){
time = this.duration;
factor = ((((this.ease == this.vars.ease)) || ((this.duration == 0.001)))) ? 1 : 0;
} else {
factor = this.ease(time, 0, 1, this.duration);
};
i = (this.tweens.length - 1);
while (i > -1) {
ti = this.tweens[i];
ti.target[ti.property] = (ti.start + (factor * ti.change));
i--;
};
if (_hasUpdate){
this.vars.onUpdate.apply(null, this.vars.onUpdateParams);
};
if (time == this.duration){
complete(true);
};
}
protected function initDispatcher():void{
var v:Object;
var p:String;
if (_dispatcher == null){
_dispatcher = new EventDispatcher(this);
_callbacks = {onStart:this.vars.onStart, onUpdate:this.vars.onUpdate, onComplete:this.vars.onComplete};
if (this.vars.isTV == true){
this.vars = this.vars.clone();
} else {
v = {};
for (p in this.vars) {
v[p] = this.vars[p];
};
this.vars = v;
};
this.vars.onStart = onStartDispatcher;
this.vars.onComplete = onCompleteDispatcher;
if ((this.vars.onStartListener is Function)){
_dispatcher.addEventListener(TweenEvent.START, this.vars.onStartListener, false, 0, true);
};
if ((this.vars.onUpdateListener is Function)){
_dispatcher.addEventListener(TweenEvent.UPDATE, this.vars.onUpdateListener, false, 0, true);
this.vars.onUpdate = onUpdateDispatcher;
_hasUpdate = true;
};
if ((this.vars.onCompleteListener is Function)){
_dispatcher.addEventListener(TweenEvent.COMPLETE, this.vars.onCompleteListener, false, 0, true);
};
};
}
public function willTrigger($type:String):Boolean{
if (_dispatcher == null){
return (false);
};
return (_dispatcher.willTrigger($type));
}
public function get repeatCount():Number{
return (_repeatCount);
}
public function reverse($adjustDuration:Boolean=true, $forcePlay:Boolean=true):void{
this.ease = ((this.vars.ease)==this.ease) ? reverseEase : this.vars.ease;
var p:Number = this.progress;
if ((($adjustDuration) && ((p > 0)))){
this.startTime = (currentTime - ((((1 - p) * this.duration) * 1000) / this.combinedTimeScale));
this.initTime = (this.startTime - (this.delay * (1000 / this.combinedTimeScale)));
};
if ($forcePlay != false){
if (p < 1){
resume();
} else {
restart();
};
};
}
protected function onUpdateDispatcher(... _args):void{
if (_callbacks.onUpdate != null){
_callbacks.onUpdate.apply(null, this.vars.onUpdateParams);
};
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.UPDATE));
}
public function set paused($b:Boolean):void{
if ($b){
pause();
} else {
resume();
};
}
public function resume():void{
this.enabled = true;
if (!isNaN(this.pauseTime)){
this.initTime = (this.initTime + (currentTime - this.pauseTime));
this.startTime = (this.initTime + (this.delay * (1000 / this.combinedTimeScale)));
this.pauseTime = NaN;
if (((!(this.started)) && ((currentTime >= this.startTime)))){
activate();
} else {
this.active = this.started;
};
_pausedTweens[this] = null;
delete _pausedTweens[this];
};
}
public function get paused():Boolean{
return (!(isNaN(this.pauseTime)));
}
public function set repeatCount($n:Number):void{
_repeatCount = $n;
}
public function reverseEase($t:Number, $b:Number, $c:Number, $d:Number):Number{
return (this.vars.ease(($d - $t), $b, $c, $d));
}
public function killProperties($names:Array):void{
var i:int;
var v:Object = {};
i = ($names.length - 1);
while (i > -1) {
v[$names[i]] = true;
i--;
};
killVars(v);
}
public function set progress($n:Number):void{
this.startTime = (currentTime - ((this.duration * $n) * 1000));
this.initTime = (this.startTime - (this.delay * (1000 / this.combinedTimeScale)));
if (!this.started){
activate();
};
render(currentTime);
if (!isNaN(this.pauseTime)){
this.pauseTime = currentTime;
this.startTime = 999999999999999;
this.active = false;
};
}
public function hasEventListener($type:String):Boolean{
if (_dispatcher == null){
return (false);
};
return (_dispatcher.hasEventListener($type));
}
public function pause():void{
if (isNaN(this.pauseTime)){
this.pauseTime = currentTime;
this.startTime = 999999999999999;
this.enabled = false;
_pausedTweens[this] = this;
};
}
override public function complete($skipRender:Boolean=false):void{
if (((((!(isNaN(this.vars.yoyo))) && ((((_repeatCount < this.vars.yoyo)) || ((this.vars.yoyo == 0)))))) || (((!(isNaN(this.vars.loop))) && ((((_repeatCount < this.vars.loop)) || ((this.vars.loop == 0)))))))){
_repeatCount++;
if (!isNaN(this.vars.yoyo)){
this.ease = ((this.vars.ease)==this.ease) ? reverseEase : this.vars.ease;
};
this.startTime = ($skipRender) ? (this.startTime + (this.duration * (1000 / this.combinedTimeScale))) : currentTime;
this.initTime = (this.startTime - (this.delay * (1000 / this.combinedTimeScale)));
} else {
if (this.vars.persist == true){
pause();
};
};
super.complete($skipRender);
}
public function set timeScale($n:Number):void{
if ($n < 1E-5){
$n = (_timeScale = 1E-5);
} else {
_timeScale = $n;
$n = ($n * _globalTimeScale);
};
this.initTime = ((currentTime - ((((currentTime - this.initTime) - (this.delay * (1000 / this.combinedTimeScale))) * this.combinedTimeScale) * (1 / $n))) - (this.delay * (1000 / $n)));
if (this.startTime != 999999999999999){
this.startTime = (this.initTime + (this.delay * (1000 / $n)));
};
this.combinedTimeScale = $n;
}
public function invalidate($adjustStartValues:Boolean=true):void{
var p:Number;
if (this.initted){
p = this.progress;
if (((!($adjustStartValues)) && (!((p == 0))))){
this.progress = 0;
};
this.tweens = [];
_hasPlugins = false;
this.exposedVars = ((this.vars.isTV)==true) ? this.vars.exposedProps : this.vars;
initTweenVals();
_timeScale = ((this.vars.timeScale) || (1));
this.combinedTimeScale = (_timeScale * _globalTimeScale);
this.delay = ((this.vars.delay) || (0));
if (isNaN(this.pauseTime)){
this.startTime = (this.initTime + ((this.delay * 1000) / this.combinedTimeScale));
};
if (((((!((this.vars.onCompleteListener == null))) || (!((this.vars.onUpdateListener == null))))) || (!((this.vars.onStartListener == null))))){
if (_dispatcher != null){
this.vars.onStart = _callbacks.onStart;
this.vars.onUpdate = _callbacks.onUpdate;
this.vars.onComplete = _callbacks.onComplete;
_dispatcher = null;
};
initDispatcher();
};
if (p != 0){
if ($adjustStartValues){
adjustStartValues();
} else {
this.progress = p;
};
};
};
}
public function get timeScale():Number{
return (_timeScale);
}
protected function onCompleteDispatcher(... _args):void{
if (_callbacks.onComplete != null){
_callbacks.onComplete.apply(null, this.vars.onCompleteParams);
};
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.COMPLETE));
}
public static function set globalTimeScale($n:Number):void{
setGlobalTimeScale($n);
}
public static function pauseAll($tweens:Boolean=true, $delayedCalls:Boolean=false):void{
changePause(true, $tweens, $delayedCalls);
}
public static function killAllDelayedCalls($complete:Boolean=false):void{
killAll($complete, false, true);
}
public static function setGlobalTimeScale($scale:Number):void{
var i:int;
var a:Array;
if ($scale < 1E-5){
$scale = 1E-5;
};
var ml:Dictionary = masterList;
_globalTimeScale = $scale;
for each (a in ml) {
i = (a.length - 1);
while (i > -1) {
if ((a[i] is TweenMax)){
a[i].timeScale = (a[i].timeScale * 1);
};
i--;
};
};
}
public static function get globalTimeScale():Number{
return (_globalTimeScale);
}
public static function getTweensOf($target:Object):Array{
var tween:TweenLite;
var i:int;
var a:Array = masterList[$target];
var toReturn:Array = [];
if (a != null){
i = (a.length - 1);
while (i > -1) {
if (!a[i].gc){
toReturn[toReturn.length] = a[i];
};
i--;
};
};
for each (tween in _pausedTweens) {
if (tween.target == $target){
toReturn[toReturn.length] = tween;
};
};
return (toReturn);
}
public static function delayedCall($delay:Number, $onComplete:Function, $onCompleteParams:Array=null, $persist:Boolean=false):TweenMax{
return (new TweenMax($onComplete, 0, {delay:$delay, onComplete:$onComplete, onCompleteParams:$onCompleteParams, persist:$persist, overwrite:0}));
}
public static function isTweening($target:Object):Boolean{
var a:Array = getTweensOf($target);
var i:int = (a.length - 1);
while (i > -1) {
if (((((a[i].active) || ((a[i].startTime == currentTime)))) && (!(a[i].gc)))){
return (true);
};
i--;
};
return (false);
}
public static function changePause($pause:Boolean, $tweens:Boolean=true, $delayedCalls:Boolean=false):void{
var isDC:Boolean;
var a:Array = getAllTweens();
var i:int = (a.length - 1);
while (i > -1) {
isDC = (a[i].target == a[i].vars.onComplete);
if ((((a[i] is TweenMax)) && ((((isDC == $delayedCalls)) || (!((isDC == $tweens))))))){
a[i].paused = $pause;
};
i--;
};
}
public static function killAllTweens($complete:Boolean=false):void{
killAll($complete, true, false);
}
public static function from($target:Object, $duration:Number, $vars:Object):TweenMax{
$vars.runBackwards = true;
return (new TweenMax($target, $duration, $vars));
}
public static function killAll($complete:Boolean=false, $tweens:Boolean=true, $delayedCalls:Boolean=true):void{
var isDC:Boolean;
var i:int;
var a:Array = getAllTweens();
i = (a.length - 1);
while (i > -1) {
isDC = (a[i].target == a[i].vars.onComplete);
if ((((isDC == $delayedCalls)) || (!((isDC == $tweens))))){
if ($complete){
a[i].complete(false);
a[i].clear();
} else {
TweenLite.removeTween(a[i], true);
};
};
i--;
};
}
public static function getAllTweens():Array{
var a:Array;
var i:int;
var tween:TweenLite;
var ml:Dictionary = masterList;
var toReturn:Array = [];
for each (a in ml) {
i = (a.length - 1);
while (i > -1) {
if (!a[i].gc){
toReturn[toReturn.length] = a[i];
};
i--;
};
};
for each (tween in _pausedTweens) {
toReturn[toReturn.length] = tween;
};
return (toReturn);
}
public static function resumeAll($tweens:Boolean=true, $delayedCalls:Boolean=false):void{
changePause(false, $tweens, $delayedCalls);
}
public static function to($target:Object, $duration:Number, $vars:Object):TweenMax{
return (new TweenMax($target, $duration, $vars));
}
}
}//package gs
Section 184
//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(id:int, name:String, maxUsers:int, maxSpectators:int, isTemp:Boolean, isGame:Boolean, isPrivate:Boolean, isLimbo:Boolean, userCount:int=0, specCount:int=0){
super();
this.id = id;
this.name = name;
this.maxSpectators = maxSpectators;
this.maxUsers = maxUsers;
this.temp = isTemp;
this.game = isGame;
this.priv = isPrivate;
this.limbo = isLimbo;
this.userCount = userCount;
this.specCount = specCount;
this.userList = [];
this.variables = [];
}
public function getUser(userId):User{
var i:String;
var u:User;
var user:User;
if (typeof(userId) == "number"){
user = userList[userId];
} else {
if (typeof(userId) == "string"){
for (i in userList) {
u = this.userList[i];
if (u.getName() == userId){
user = u;
break;
};
};
};
};
return (user);
}
public function setUserCount(n:int):void{
this.userCount = n;
}
public function getMyPlayerIndex():int{
return (this.myPlayerIndex);
}
public function removeUser(id:int):void{
var u:User = userList[id];
if (((this.game) && (u.isSpectator()))){
specCount--;
} else {
userCount--;
};
delete userList[id];
}
public function addUser(u:User, id:int):void{
userList[id] = u;
if (((this.game) && (u.isSpectator()))){
specCount++;
} else {
userCount++;
};
}
public function getUserCount():int{
return (this.userCount);
}
public function getId():int{
return (this.id);
}
public function setIsLimbo(b:Boolean):void{
this.limbo = b;
}
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(n:int):void{
this.specCount = n;
}
public function clearVariables():void{
this.variables = [];
}
public function isTemp():Boolean{
return (this.temp);
}
public function setVariables(vars:Array):void{
this.variables = vars;
}
public function getSpectatorCount():int{
return (this.specCount);
}
public function getVariable(varName:String){
return (variables[varName]);
}
public function setMyPlayerIndex(id:int):void{
this.myPlayerIndex = id;
}
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 185
//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(id:int, name:String){
super();
this.id = id;
this.name = name;
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(b:Boolean):void{
this.isMod = b;
}
public function isSpectator():Boolean{
return (this.isSpec);
}
public function getId():int{
return (this.id);
}
public function isModerator():Boolean{
return (this.isMod);
}
public function setVariables(o:Object):void{
var key:String;
var v:*;
for (key in o) {
v = o[key];
if (v != null){
this.variables[key] = v;
} else {
delete this.variables[key];
};
};
}
public function getVariable(varName:String){
return (this.variables[varName]);
}
public function setIsSpectator(b:Boolean):void{
this.isSpec = b;
}
public function setPlayerId(pid:int):void{
this.pId = pid;
}
public function getPlayerId():int{
return (this.pId);
}
}
}//package it.gotoandplay.smartfoxserver.data
Section 186
//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(sfs:SmartFoxClient){
super();
this.sfs = sfs;
}
public function handleMessage(msgObj:Object, type:String):void{
var params:Object;
var evt:SFSEvent;
var xmlData:XML;
var action:String;
var roomId:int;
var xmlStr:String;
var asObj:Object;
if (type == SmartFoxClient.XTMSG_TYPE_XML){
xmlData = (msgObj as XML);
action = xmlData.body.@action;
roomId = int(xmlData.body.@id);
if (action == "xtRes"){
xmlStr = xmlData.body.toString();
asObj = ObjectSerializer.getInstance().deserialize(xmlStr);
params = {};
params.dataObj = asObj;
params.type = type;
evt = new SFSEvent(SFSEvent.onExtensionResponse, params);
sfs.dispatchEvent(evt);
};
} else {
if (type == SmartFoxClient.XTMSG_TYPE_JSON){
params = {};
params.dataObj = msgObj.o;
params.type = type;
evt = new SFSEvent(SFSEvent.onExtensionResponse, params);
sfs.dispatchEvent(evt);
} else {
if (type == SmartFoxClient.XTMSG_TYPE_STR){
params = {};
params.dataObj = msgObj;
params.type = type;
evt = new SFSEvent(SFSEvent.onExtensionResponse, params);
sfs.dispatchEvent(evt);
};
};
};
}
}
}//package it.gotoandplay.smartfoxserver.handlers
Section 187
//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 188
//SysHandler (it.gotoandplay.smartfoxserver.handlers.SysHandler)
package it.gotoandplay.smartfoxserver.handlers {
import it.gotoandplay.smartfoxserver.*;
import it.gotoandplay.smartfoxserver.data.*;
import flash.utils.*;
import it.gotoandplay.smartfoxserver.util.*;
public class SysHandler implements IMessageHandler {
private var sfs:SmartFoxClient;
private var handlersTable:Array;
public function SysHandler(sfs:SmartFoxClient){
super();
this.sfs = sfs;
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(variables:Array, xmlData:Object, changedVars:Array=null):void{
var v:XML;
var vName:String;
var vType:String;
var vValue:String;
for each (v in xmlData.vars["var"]) {
vName = v.@n;
vType = v.@t;
vValue = v;
if (changedVars != null){
changedVars.push(vName);
changedVars[vName] = true;
};
if (vType == "b"){
variables[vName] = ((vValue == "1")) ? true : false;
} else {
if (vType == "n"){
variables[vName] = Number(vValue);
} else {
if (vType == "s"){
variables[vName] = vValue;
} else {
if (vType == "x"){
delete variables[vName];
};
};
};
};
};
}
private function handleRoomDeleted(o:Object):void{
var roomId:int = int(o.body.rm.@id);
var roomList:Array = sfs.getAllRooms();
var params:Object = {};
params.room = roomList[roomId];
delete roomList[roomId];
var evt:SFSEvent = new SFSEvent(SFSEvent.onRoomDeleted, params);
sfs.dispatchEvent(evt);
}
public function handleAdminMessage(o:Object):void{
var roomId:int = int(o.body.@r);
var userId:int = int(o.body.user.@id);
var message:String = o.body.txt;
var params:Object = {};
params.message = Entities.decodeEntities(message);
var evt:SFSEvent = new SFSEvent(SFSEvent.onAdminMessage, params);
sfs.dispatchEvent(evt);
}
public function handleUserVarsUpdate(o:Object):void{
var changedVars:Array;
var room:Room;
var params:Object;
var evt:SFSEvent;
var userId:int = int(o.body.user.@id);
var varOwner:User;
if (o.body.vars.toString().length > 0){
for each (room in sfs.getAllRooms()) {
varOwner = room.getUser(userId);
if (varOwner != null){
changedVars = [];
populateVariables(varOwner.getVariables(), o.body, changedVars);
};
};
params = {};
params.user = ((sfs.getActiveRoom().getUser(userId))!=null) ? sfs.getActiveRoom().getUser(userId) : varOwner;
params.changedVars = changedVars;
evt = new SFSEvent(SFSEvent.onUserVariablesUpdate, params);
sfs.dispatchEvent(evt);
};
}
private function handleCreateRoomError(o:Object):void{
var errMsg:String = o.body.room.@e;
var params:Object = {};
params.error = errMsg;
var evt:SFSEvent = new SFSEvent(SFSEvent.onCreateRoomError, params);
sfs.dispatchEvent(evt);
}
public function handlePrivateMessage(o:Object):void{
var roomId:int = int(o.body.@r);
var userId:int = int(o.body.user.@id);
var message:String = o.body.txt;
var sender:User = sfs.getRoom(roomId).getUser(userId);
var params:Object = {};
params.message = Entities.decodeEntities(message);
params.sender = sender;
params.roomId = roomId;
params.userId = userId;
var evt:SFSEvent = new SFSEvent(SFSEvent.onPrivateMessage, params);
sfs.dispatchEvent(evt);
}
private function handleBuddyRoom(o:Object):void{
var roomIds:String = o.body.br.@r;
var ids:Array = roomIds.split(",");
var i:int;
while (i < ids.length) {
ids[i] = int(ids[i]);
i++;
};
var params:Object = {};
params.idList = ids;
var evt:SFSEvent = new SFSEvent(SFSEvent.onBuddyRoom, params);
sfs.dispatchEvent(evt);
}
public function handleLogout(o:Object):void{
sfs.__logout();
var evt:SFSEvent = new SFSEvent(SFSEvent.onLogout, {});
sfs.dispatchEvent(evt);
}
public function handleUserCountChange(o:Object):void{
var params:Object;
var evt:SFSEvent;
var uCount:int = int(o.body.@u);
var sCount:int = int(o.body.@s);
var roomId:int = int(o.body.@r);
var room:Room = sfs.getAllRooms()[roomId];
if (room != null){
room.setUserCount(uCount);
room.setSpectatorCount(sCount);
params = {};
params.room = room;
evt = new SFSEvent(SFSEvent.onUserCountChange, params);
sfs.dispatchEvent(evt);
};
}
private function handleRandomKey(o:Object):void{
var key:String = o.body.k.toString();
var params:Object = {};
params.key = key;
var evt:SFSEvent = new SFSEvent(SFSEvent.onRandomKey, params);
sfs.dispatchEvent(evt);
}
public function handlePublicMessage(o:Object):void{
var roomId:int = int(o.body.@r);
var userId:int = int(o.body.user.@id);
var message:String = o.body.txt;
var sender:User = sfs.getRoom(roomId).getUser(userId);
var params:Object = {};
params.message = Entities.decodeEntities(message);
params.sender = sender;
params.roomId = roomId;
var evt:SFSEvent = new SFSEvent(SFSEvent.onPublicMessage, params);
sfs.dispatchEvent(evt);
}
public function handleUserEnterRoom(o:Object):void{
var roomId:int = int(o.body.@r);
var usrId:int = int(o.body.u.@i);
var usrName:String = o.body.u.n;
var isMod = (o.body.u.@m == "1");
var isSpec = (o.body.u.@s == "1");
var pid:int = ((o.body.u.@p)!=null) ? int(o.body.u.@p) : -1;
var varList:XMLList = o.body.u.vars["var"];
var currRoom:Room = sfs.getRoom(roomId);
var newUser:User = new User(usrId, usrName);
newUser.setModerator(isMod);
newUser.setIsSpectator(isSpec);
newUser.setPlayerId(pid);
currRoom.addUser(newUser, usrId);
if (o.body.u.vars.toString().length > 0){
populateVariables(newUser.getVariables(), o.body.u);
};
var params:Object = {};
params.roomId = roomId;
params.user = newUser;
var evt:SFSEvent = new SFSEvent(SFSEvent.onUserEnterRoom, params);
sfs.dispatchEvent(evt);
}
public function dispatchDisconnection():void{
var evt:SFSEvent = new SFSEvent(SFSEvent.onConnectionLost, null);
sfs.dispatchEvent(evt);
}
private function handleRemoveBuddy(o:Object):void{
var it:String;
var params:Object;
var evt:SFSEvent;
var buddyName:String = o.body.n.toString();
var buddy:Object;
for (it in sfs.buddyList) {
buddy = sfs.buddyList[it];
if (buddy.name == buddyName){
delete sfs.buddyList[it];
params = {};
params.list = sfs.buddyList;
evt = new SFSEvent(SFSEvent.onBuddyList, params);
sfs.dispatchEvent(evt);
break;
};
};
}
private function handleAddBuddyPermission(o:Object):void{
var params:Object = {};
params.sender = o.body.n.toString();
params.message = "";
if (o.body.txt != undefined){
params.message = Entities.decodeEntities(o.body.txt);
};
var evt:SFSEvent = new SFSEvent(SFSEvent.onBuddyPermissionRequest, params);
sfs.dispatchEvent(evt);
}
public function handleLoginOk(o:Object):void{
var uid:int = int(o.body.login.@id);
var mod:int = int(o.body.login.@mod);
var name:String = o.body.login.@n;
sfs.amIModerator = (mod == 1);
sfs.myUserId = uid;
sfs.myUserName = name;
sfs.playerId = -1;
var params:Object = {};
params.success = true;
params.name = name;
params.error = "";
var evt:SFSEvent = new SFSEvent(SFSEvent.onLogin, params);
sfs.dispatchEvent(evt);
sfs.getRoomList();
}
private function handleBuddyListUpdate(o:Object):void{
var buddy:Object;
var bVars:XMLList;
var tempB:Object;
var found:Boolean;
var it:String;
var bVar:XML;
var params:Object = {};
var evt:SFSEvent;
if (o.body.b != null){
buddy = {};
buddy.isOnline = ((o.body.b.@s == "1")) ? true : false;
buddy.name = o.body.b.n.toString();
buddy.id = o.body.b.@i;
buddy.isBlocked = ((o.body.b.@x == "1")) ? true : false;
bVars = o.body.b.vs;
tempB = null;
found = false;
for (it in sfs.buddyList) {
tempB = sfs.buddyList[it];
if (tempB.name == buddy.name){
sfs.buddyList[it] = buddy;
buddy.isBlocked = tempB.isBlocked;
buddy.variables = tempB.variables;
if (bVars.toString().length > 0){
for each (bVar in bVars.v) {
buddy.variables[bVar.@n.toString()] = bVar.toString();
};
};
found = true;
break;
};
};
if (found){
params.buddy = buddy;
evt = new SFSEvent(SFSEvent.onBuddyListUpdate, params);
sfs.dispatchEvent(evt);
};
} else {
params.error = o.body.err.toString();
evt = new SFSEvent(SFSEvent.onBuddyListError, params);
sfs.dispatchEvent(evt);
};
}
public function handleRoomVarsUpdate(o:Object):void{
var roomId:int = int(o.body.@r);
var userId:int = int(o.body.user.@id);
var currRoom:Room = sfs.getRoom(roomId);
var changedVars:Array = [];
if (o.body.vars.toString().length > 0){
populateVariables(currRoom.getVariables(), o.body, changedVars);
};
var params:Object = {};
params.room = currRoom;
params.changedVars = changedVars;
var evt:SFSEvent = new SFSEvent(SFSEvent.onRoomVariablesUpdate, params);
sfs.dispatchEvent(evt);
}
public function handleRoomList(o:Object):void{
var roomXml:XML;
var params:Object;
var evt:SFSEvent;
var roomId:int;
var room:Room;
sfs.clearRoomList();
var roomList:Array = sfs.getAllRooms();
for each (roomXml in o.body.rmList.rm) {
roomId = int(roomXml.@id);
room = new Room(roomId, roomXml.n, int(roomXml.@maxu), int(roomXml.@maxs), (roomXml.@temp == "1"), (roomXml.@game == "1"), (roomXml.@priv == "1"), (roomXml.@lmb == "1"), int(roomXml.@ucnt), int(roomXml.@scnt));
if (roomXml.vars.toString().length > 0){
populateVariables(room.getVariables(), roomXml);
};
roomList[roomId] = room;
};
params = {};
params.roomList = roomList;
evt = new SFSEvent(SFSEvent.onRoomListUpdate, params);
sfs.dispatchEvent(evt);
}
private function handleBuddyAdded(o:Object):void{
var bVar:XML;
var buddy:Object = {};
buddy.isOnline = ((o.body.b.@s == "1")) ? true : false;
buddy.name = o.body.b.n.toString();
buddy.id = o.body.b.@i;
buddy.isBlocked = ((o.body.b.@x == "1")) ? true : false;
buddy.variables = {};
var bVars:XMLList = o.body.b.vs;
if (bVars.toString().length > 0){
for each (bVar in bVars.v) {
buddy.variables[bVar.@n.toString()] = bVar.toString();
};
};
sfs.buddyList.push(buddy);
var params:Object = {};
params.list = sfs.buddyList;
var evt:SFSEvent = new SFSEvent(SFSEvent.onBuddyList, params);
sfs.dispatchEvent(evt);
}
private function handleRoomAdded(o:Object):void{
var rId:int = int(o.body.rm.@id);
var rName:String = o.body.rm.name;
var rMax:int = int(o.body.rm.@max);
var rSpec:int = int(o.body.rm.@spec);
var isTemp:Boolean = ((o.body.rm.@temp == "1")) ? true : false;
var isGame:Boolean = ((o.body.rm.@game == "1")) ? true : false;
var isPriv:Boolean = ((o.body.rm.@priv == "1")) ? true : false;
var isLimbo:Boolean = ((o.body.rm.@limbo == "1")) ? true : false;
var newRoom:Room = new Room(rId, rName, rMax, rSpec, isTemp, isGame, isPriv, isLimbo);
var rList:Array = sfs.getAllRooms();
rList[rId] = newRoom;
if (o.body.rm.vars.toString().length > 0){
populateVariables(newRoom.getVariables(), o.body.rm);
};
var params:Object = {};
params.room = newRoom;
var evt:SFSEvent = new SFSEvent(SFSEvent.onRoomAdded, params);
sfs.dispatchEvent(evt);
}
public function handleUserLeaveRoom(o:Object):void{
var userId:int = int(o.body.user.@id);
var roomId:int = int(o.body.@r);
var theRoom:Room = sfs.getRoom(roomId);
var uName:String = theRoom.getUser(userId).getName();
theRoom.removeUser(userId);
var params:Object = {};
params.roomId = roomId;
params.userId = userId;
params.userName = uName;
var evt:SFSEvent = new SFSEvent(SFSEvent.onUserLeaveRoom, params);
sfs.dispatchEvent(evt);
}
private function handleSpectatorSwitched(o:Object):void{
var userId:int;
var user:User;
var params:Object;
var evt:SFSEvent;
var roomId:int = int(o.body.@r);
var playerId:int = int(o.body.pid.@id);
var theRoom:Room = sfs.getRoom(roomId);
if (playerId > 0){
theRoom.setUserCount((theRoom.getUserCount() + 1));
theRoom.setSpectatorCount((theRoom.getSpectatorCount() - 1));
};
if (o.body.pid.@u != undefined){
userId = int(o.body.pid.@u);
user = theRoom.getUser(userId);
if (user != null){
user.setIsSpectator(false);
user.setPlayerId(playerId);
};
} else {
sfs.playerId = playerId;
params = {};
params.success = (sfs.playerId > 0);
params.newId = sfs.playerId;
params.room = theRoom;
evt = new SFSEvent(SFSEvent.onSpectatorSwitched, params);
sfs.dispatchEvent(evt);
};
}
private function handleLeaveRoom(o:Object):void{
var roomLeft:int = int(o.body.rm.@id);
var params:Object = {};
params.roomId = roomLeft;
var evt:SFSEvent = new SFSEvent(SFSEvent.onRoomLeft, params);
sfs.dispatchEvent(evt);
}
public function handleLoginKo(o:Object):void{
var params:Object = {};
params.success = false;
params.error = o.body.login.@e;
var evt:SFSEvent = new SFSEvent(SFSEvent.onLogin, params);
sfs.dispatchEvent(evt);
}
public function handleModMessage(o:Object):void{
var roomId:int = int(o.body.@r);
var userId:int = int(o.body.user.@id);
var message:String = o.body.txt;
var sender:User;
var room:Room = sfs.getRoom(roomId);
if (room != null){
sender = sfs.getRoom(roomId).getUser(userId);
};
var params:Object = {};
params.message = Entities.decodeEntities(message);
params.sender = sender;
var evt:SFSEvent = new SFSEvent(SFSEvent.onModeratorMessage, params);
sfs.dispatchEvent(evt);
}
public function handleApiOK(o:Object):void{
sfs.isConnected = true;
var evt:SFSEvent = new SFSEvent(SFSEvent.onConnection, {success:true});
sfs.dispatchEvent(evt);
}
private function handleRoundTripBench(o:Object):void{
var now:int = getTimer();
var res:int = (now - sfs.getBenchStartTime());
var params:Object = {};
params.elapsed = res;
var evt:SFSEvent = new SFSEvent(SFSEvent.onRoundTripResponse, params);
sfs.dispatchEvent(evt);
}
public function handleJoinOk(o:Object):void{
var usr:XML;
var params:Object;
var evt:SFSEvent;
var name:String;
var id:int;
var isMod:Boolean;
var isSpec:Boolean;
var pId:int;
var user:User;
var roomId:int = int(o.body.@r);
var roomVarsXml:XMLList = o.body;
var userListXml:XMLList = o.body.uLs.u;
var playerId:int = int(o.body.pid.@id);
sfs.activeRoomId = roomId;
var currRoom:Room = sfs.getRoom(roomId);
currRoom.clearUserList();
sfs.playerId = playerId;
currRoom.setMyPlayerIndex(playerId);
if (roomVarsXml.vars.toString().length > 0){
currRoom.clearVariables();
populateVariables(currRoom.getVariables(), roomVarsXml);
};
for each (usr in userListXml) {
name = usr.n;
id = int(usr.@i);
isMod = ((usr.@m == "1")) ? true : false;
isSpec = ((usr.@s == "1")) ? true : false;
pId = ((usr.@p == null)) ? -1 : int(usr.@p);
user = new User(id, name);
user.setModerator(isMod);
user.setIsSpectator(isSpec);
user.setPlayerId(pId);
if (usr.vars.toString().length > 0){
populateVariables(user.getVariables(), usr);
};
currRoom.addUser(user, id);
};
sfs.changingRoom = false;
params = {};
params.room = currRoom;
evt = new SFSEvent(SFSEvent.onJoinRoom, params);
sfs.dispatchEvent(evt);
}
public function handleApiKO(o:Object):void{
var params:Object = {};
params.success = false;
params.error = "API are obsolete, please upgrade";
var evt:SFSEvent = new SFSEvent(SFSEvent.onConnection, params);
sfs.dispatchEvent(evt);
}
public function handleASObject(o:Object):void{
var roomId:int = int(o.body.@r);
var userId:int = int(o.body.user.@id);
var xmlStr:String = o.body.dataObj;
var sender:User = sfs.getRoom(roomId).getUser(userId);
var asObj:Object = ObjectSerializer.getInstance().deserialize(new XML(xmlStr));
var params:Object = {};
params.obj = asObj;
params.sender = sender;
var evt:SFSEvent = new SFSEvent(SFSEvent.onObjectReceived, params);
sfs.dispatchEvent(evt);
}
private function handleBuddyList(o:Object):void{
var buddy:Object;
var myVar:XML;
var b:XML;
var bVars:XMLList;
var bVar:XML;
var bList:XMLList = o.body.bList;
var myVars:XMLList = o.body.mv;
var params:Object = {};
var evt:SFSEvent;
if (((!((myVars == null))) && ((myVars.toString().length > 0)))){
for each (myVar in myVars.v) {
sfs.myBuddyVars[myVar.@n.toString()] = myVar.toString();
};
};
if (((!((bList == null))) && (!((bList.b.length == null))))){
if (bList.toString().length > 0){
for each (b in bList.b) {
buddy = {};
buddy.isOnline = ((b.@s == "1")) ? true : false;
buddy.name = b.n.toString();
buddy.id = b.@i;
buddy.isBlocked = ((b.@x == "1")) ? true : false;
buddy.variables = {};
bVars = b.vs;
if (bVars.toString().length > 0){
for each (bVar in bVars.v) {
buddy.variables[bVar.@n.toString()] = bVar.toString();
};
};
sfs.buddyList.push(buddy);
};
};
params.list = sfs.buddyList;
evt = new SFSEvent(SFSEvent.onBuddyList, params);
sfs.dispatchEvent(evt);
} else {
params.error = o.body.err.toString();
evt = new SFSEvent(SFSEvent.onBuddyListError, params);
sfs.dispatchEvent(evt);
};
}
public function handleJoinKo(o:Object):void{
sfs.changingRoom = false;
var params:Object = {};
params.error = o.body.error.@msg;
var evt:SFSEvent = new SFSEvent(SFSEvent.onJoinRoomError, params);
sfs.dispatchEvent(evt);
}
public function handleMessage(msgObj:Object, type:String):void{
var xmlData:XML = (msgObj as XML);
var action:String = xmlData.body.@action;
var fn:Function = handlersTable[action];
if (fn != null){
fn.apply(this, [msgObj]);
} else {
trace(("Unknown sys command: " + action));
};
}
}
}//package it.gotoandplay.smartfoxserver.handlers
Section 189
//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(){
super();
codec = new RawProtocolCodec();
urlLoaderFactory = new LoaderFactory(handleResponse, handleIOError);
}
public function close():void{
send(DISCONNECT);
}
public function getSessionId():String{
return (this.sessionId);
}
private function handleIOError(error:IOErrorEvent):void{
var params:Object = {};
params.message = error.text;
var event:HttpEvent = new HttpEvent(HttpEvent.onHttpError, params);
dispatchEvent(event);
}
public function send(message:String):void{
var vars:URLVariables;
var urlLoader:URLLoader;
if (((((connected) || (((!(connected)) && ((message == HANDSHAKE)))))) || (((!(connected)) && ((message == "poll")))))){
vars = new URLVariables();
vars[paramName] = codec.encode(this.sessionId, message);
urlRequest.data = vars;
if (message != "poll"){
trace(("[ Send ]: " + urlRequest.data));
};
urlLoader = urlLoaderFactory.getLoader();
urlLoader.data = vars;
urlLoader.load(urlRequest);
};
}
public function connect(addr:String, port:int=8080):void{
this.ipAddr = addr;
this.port = port;
this.webUrl = ((((("http://" + this.ipAddr) + ":") + this.port) + "/") + servletUrl);
this.sessionId = null;
urlRequest = new URLRequest(webUrl);
urlRequest.method = URLRequestMethod.POST;
send(HANDSHAKE);
}
private function handleResponse(evt:Event):void{
var event:HttpEvent;
var loader:URLLoader = (evt.target as URLLoader);
var data:String = (loader.data as String);
var params:Object = {};
if (data.charAt(0) == HANDSHAKE_TOKEN){
if (sessionId == null){
sessionId = codec.decode(data);
connected = true;
params.sessionId = this.sessionId;
params.success = true;
event = new HttpEvent(HttpEvent.onHttpConnect, params);
dispatchEvent(event);
} else {
trace("**ERROR** SessionId is being rewritten");
};
} else {
if (data.indexOf(CONN_LOST) == 0){
params.data = {};
event = new HttpEvent(HttpEvent.onHttpClose, params);
} else {
params.data = data;
event = new HttpEvent(HttpEvent.onHttpData, params);
};
dispatchEvent(event);
};
}
public function isConnected():Boolean{
return (this.connected);
}
}
}//package it.gotoandplay.smartfoxserver.http
Section 190
//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(type:String, params:Object){
super(type);
this.params = params;
this.evtType = type;
}
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 191
//IHttpProtocolCodec (it.gotoandplay.smartfoxserver.http.IHttpProtocolCodec)
package it.gotoandplay.smartfoxserver.http {
public interface IHttpProtocolCodec {
function decode(:String):String;
function encode(_arg1:String, _arg2:String):String;
}
}//package it.gotoandplay.smartfoxserver.http
Section 192
//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(responseHandler:Function, errorHandler:Function, poolSize:int=8){
var urlLoader:URLLoader;
super();
loadersPool = [];
var i:int;
while (i < poolSize) {
urlLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.addEventListener(Event.COMPLETE, responseHandler);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
urlLoader.addEventListener(IOErrorEvent.NETWORK_ERROR, errorHandler);
loadersPool.push(urlLoader);
i++;
};
currentLoaderIndex = 0;
}
public function getLoader():URLLoader{
var urlLoader:URLLoader = loadersPool[currentLoaderIndex];
currentLoaderIndex++;
if (currentLoaderIndex >= loadersPool.length){
currentLoaderIndex = 0;
};
return (urlLoader);
}
}
}//package it.gotoandplay.smartfoxserver.http
Section 193
//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 RawProtocolCodec(){
super();
}
public function decode(message:String):String{
var decoded:String;
if (message.charAt(0) == HttpConnection.HANDSHAKE_TOKEN){
decoded = message.substr(1, SESSION_ID_LEN);
};
return (decoded);
}
public function encode(sessionId:String, message:String):String{
return ((((sessionId == null)) ? "" : sessionId + message));
}
}
}//package it.gotoandplay.smartfoxserver.http
Section 194
//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 function Entities(){
super();
}
public static function decodeEntities(st:String):String{
var strbuff:String;
var ch:String;
var ent:String;
var chi:String;
var item:String;
var i:int;
strbuff = "";
while (i < st.length) {
ch = st.charAt(i);
if (ch == "&"){
ent = ch;
do {
i++;
chi = st.charAt(i);
ent = (ent + chi);
} while (((!((chi == ";"))) && ((i < st.length))));
item = ascTabRev[ent];
if (item != null){
strbuff = (strbuff + item);
} else {
strbuff = (strbuff + String.fromCharCode(getCharCode(ent)));
};
} else {
strbuff = (strbuff + ch);
};
i++;
};
return (strbuff);
}
public static function encodeEntities(st:String):String{
var ch:String;
var cod:int;
var strbuff:String = "";
var i:int;
while (i < st.length) {
ch = st.charAt(i);
cod = st.charCodeAt(i);
if ((((((cod == 9)) || ((cod == 10)))) || ((cod == 13)))){
strbuff = (strbuff + ch);
} else {
if ((((cod >= 32)) && ((cod <= 126)))){
if (ascTab[ch] != null){
strbuff = (strbuff + ascTab[ch]);
} else {
strbuff = (strbuff + ch);
};
} else {
strbuff = (strbuff + ch);
};
};
i++;
};
return (strbuff);
}
public static function getCharCode(ent:String):Number{
var hex:String = ent.substr(3, ent.length);
hex = hex.substr(0, (hex.length - 1));
return (Number(("0x" + hex)));
}
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 195
//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(debug:Boolean=false){
super();
this.tabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t";
setDebug(debug);
}
public function serialize(o:Object):String{
var result:Object = {};
obj2xml(o, result);
return (result.xmlStr);
}
private function xml2obj(x:XML, o:Object):void{
var nodeName:String;
var node:XML;
var objName:String;
var objType:String;
var varName:String;
var varType:String;
var varVal:String;
var i:int;
var nodes:XMLList = x.children();
for each (node in nodes) {
nodeName = node.name().toString();
if (nodeName == "obj"){
objName = node.@o;
objType = node.@t;
if (objType == "a"){
o[objName] = [];
} else {
if (objType == "o"){
o[objName] = {};
};
};
xml2obj(node, o[objName]);
} else {
if (nodeName == "var"){
varName = node.@n;
varType = node.@t;
varVal = node.toString();
if (varType == "b"){
o[varName] = ((varVal == "0")) ? false : true;
} else {
if (varType == "n"){
o[varName] = Number(varVal);
} else {
if (varType == "s"){
o[varName] = varVal;
} else {
if (varType == "x"){
o[varName] = null;
};
};
};
};
};
};
};
}
private function setDebug(b:Boolean):void{
this.debug = b;
if (this.debug){
this.eof = "\n";
} else {
this.eof = "";
};
}
private function encodeEntities(s:String):String{
return (s);
}
private function obj2xml(srcObj:Object, trgObj:Object, depth:int=0, objName:String=""):void{
var i:String;
var ot:String;
var t:String;
var o:*;
if (depth == 0){
trgObj.xmlStr = ("<dataObj>" + this.eof);
} else {
if (this.debug){
trgObj.xmlStr = (trgObj.xmlStr + this.tabs.substr(0, depth));
};
ot = ((srcObj is Array)) ? "a" : "o";
trgObj.xmlStr = (trgObj.xmlStr + ((((("<obj t='" + ot) + "' o='") + objName) + "'>") + this.eof));
};
for (i in srcObj) {
t = typeof(srcObj[i]);
o = srcObj[i];
if ((((((((t == "boolean")) || ((t == "number")))) || ((t == "string")))) || ((t == "null")))){
if (t == "boolean"){
o = Number(o);
} else {
if (t == "null"){
t = "x";
o = "";
} else {
if (t == "string"){
o = Entities.encodeEntities(o);
};
};
};
if (this.debug){
trgObj.xmlStr = (trgObj.xmlStr + this.tabs.substr(0, (depth + 1)));
};
trgObj.xmlStr = (trgObj.xmlStr + ((((((("<var n='" + i) + "' t='") + t.substr(0, 1)) + "'>") + o) + "</var>") + this.eof));
} else {
if (t == "object"){
obj2xml(o, trgObj, (depth + 1), i);
if (this.debug){
trgObj.xmlStr = (trgObj.xmlStr + this.tabs.substr(0, (depth + 1)));
};
trgObj.xmlStr = (trgObj.xmlStr + ("</obj>" + this.eof));
};
};
};
if (depth == 0){
trgObj.xmlStr = (trgObj.xmlStr + ("</dataObj>" + this.eof));
};
}
public function deserialize(xmlString:String):Object{
var xmlData:XML = new XML(xmlString);
var resObj:Object = {};
xml2obj(xmlData, resObj);
return (resObj);
}
public static function getInstance(debug:Boolean=false):ObjectSerializer{
if (instance == null){
instance = new ObjectSerializer(debug);
};
return (instance);
}
}
}//package it.gotoandplay.smartfoxserver.util
Section 196
//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(type:String, params:Object){
super(type);
this.params = params;
}
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 197
//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 flash.utils.*;
import it.gotoandplay.smartfoxserver.util.*;
import com.adobe.serialization.json.*;
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 properties:Object;// = null
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(debug:Boolean=false){
_httpPollSpeed = DEFAULT_POLL_SPEED;
super();
this.majVersion = 1;
this.minVersion = 5;
this.subVersion = 6;
this.activeRoomId = -1;
this.debug = debug;
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(uVars:Object):String{
var val:*;
var t:String;
var type:String;
var key:String;
var xmlStr:String = "<vars>";
for (key in uVars) {
val = uVars[key];
type = typeof(val);
t = null;
if (type == "boolean"){
t = "b";
val = (val) ? "1" : "0";
} else {
if (type == "number"){
t = "n";
} else {
if (type == "string"){
t = "s";
} else {
if ((((((val == null)) && ((type == "object")))) || ((type == "undefined")))){
t = "x";
val = "";
};
};
};
};
if (t != null){
xmlStr = (xmlStr + (((((("<var n='" + key) + "' t='") + t) + "'><![CDATA[") + val) + "]]></var>"));
};
};
xmlStr = (xmlStr + "</vars>");
return (xmlStr);
}
private function jsonReceived(msg:String):void{
var jso:Object = JSON.decode(msg);
var handlerId:String = jso["t"];
var handler:IMessageHandler = messageHandlers[handlerId];
if (handler != null){
handler.handleMessage(jso["b"], XTMSG_TYPE_JSON);
};
}
private function onConfigLoadFailure(evt:IOErrorEvent):void{
var params:Object = {message:evt.text};
var sfsEvt:SFSEvent = new SFSEvent(SFSEvent.onConfigLoadFailure, params);
dispatchEvent(sfsEvt);
}
public function getActiveRoom():Room{
if (((!(checkRoomList())) || (!(checkJoin())))){
return (null);
};
return (roomList[activeRoomId]);
}
public function getBuddyRoom(buddy:Object):void{
if (buddy.id != -1){
send({t:"sys"}, "roomB", -1, (("<b id='" + buddy.id) + "' />"));
};
}
private function checkBuddyDuplicates(buddyName:String):Boolean{
var buddy:Object;
var res:Boolean;
for each (buddy in buddyList) {
if (buddy.name == buddyName){
res = true;
break;
};
};
return (res);
}
private function handleHttpClose(evt:HttpEvent):void{
initialize();
var sfse:SFSEvent = new SFSEvent(SFSEvent.onConnectionLost, {});
dispatchEvent(sfse);
}
private function getXmlRoomVariable(rVar:Object):String{
var vName:String = rVar.name.toString();
var vValue:* = rVar.val;
var vPrivate:String = (rVar.priv) ? "1" : "0";
var vPersistent:String = (rVar.persistent) ? "1" : "0";
var t:String;
var type = typeof(vValue);
if (type == "boolean"){
t = "b";
vValue = (vValue) ? "1" : "0";
} else {
if (type == "number"){
t = "n";
} else {
if (type == "string"){
t = "s";
} else {
if ((((((vValue == null)) && ((type == "object")))) || ((type == "undefined")))){
t = "x";
vValue = "";
};
};
};
};
if (t != null){
return ((((((((((("<var n='" + vName) + "' t='") + t) + "' pr='") + vPrivate) + "' pe='") + vPersistent) + "'><![CDATA[") + vValue) + "]]></var>"));
};
return ("");
}
public function getBuddyById(id:int):Object{
var buddy:Object;
for each (buddy in buddyList) {
if (buddy.id == id){
return (buddy);
};
};
return (null);
}
private function handleSocketDisconnection(evt:Event):void{
initialize();
var sfse:SFSEvent = new SFSEvent(SFSEvent.onConnectionLost, {});
dispatchEvent(sfse);
}
private function handleSocketError(evt:SecurityErrorEvent):void{
debugMessage(("Socket Error: " + evt.text));
}
private function xmlReceived(msg:String):void{
var xmlData:XML = new XML(msg);
var handlerId:String = xmlData.@t;
var action:String = xmlData.body.@action;
var roomId:int = xmlData.body.@r;
var handler:IMessageHandler = messageHandlers[handlerId];
if (handler != null){
handler.handleMessage(xmlData, XTMSG_TYPE_XML);
};
}
public function switchSpectator(roomId:int=-1):void{
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
if (roomId == -1){
roomId = activeRoomId;
};
send({t:"sys"}, "swSpec", roomId, "");
}
public function roundTripBench():void{
this.benchStartTime = getTimer();
send({t:"sys"}, "roundTrip", activeRoomId, "");
}
private function handleHttpError(evt:HttpEvent):void{
trace("HttpError");
if (!connected){
dispatchConnectionError();
};
}
public function joinRoom(newRoom, pword:String="", isSpectator:Boolean=false, dontLeave:Boolean=false, oldRoom:int=-1):void{
var r:Room;
var header:Object;
var leaveCurrRoom:String;
var roomToLeave:int;
var message:String;
if (!checkRoomList()){
return;
};
var newRoomId = -1;
var isSpec:int = (isSpectator) ? 1 : 0;
if (!this.changingRoom){
if (typeof(newRoom) == "number"){
newRoomId = int(newRoom);
} else {
if (typeof(newRoom) == "string"){
for each (r in roomList) {
if (r.getName() == newRoom){
newRoomId = r.getId();
break;
};
};
};
};
if (newRoomId != -1){
header = {t:"sys"};
leaveCurrRoom = (dontLeave) ? "0" : "1";
roomToLeave = ((oldRoom > -1)) ? oldRoom : activeRoomId;
if (activeRoomId == -1){
leaveCurrRoom = "0";
roomToLeave = -1;
};
message = (((((((((("<room id='" + newRoomId) + "' pwd='") + pword) + "' spec='") + isSpec) + "' leave='") + leaveCurrRoom) + "' old='") + roomToLeave) + "' />");
send(header, "joinRoom", activeRoomId, message);
changingRoom = true;
} else {
debugMessage("SmartFoxError: requested room to join does not exist!");
};
};
}
public function get httpPollSpeed():int{
return (this._httpPollSpeed);
}
public function uploadFile(fileRef:FileReference, id:int=-1, nick:String="", port:int=-1):void{
if (id == -1){
id = this.myUserId;
};
if (nick == ""){
nick = this.myUserName;
};
if (port == -1){
port = this.httpPort;
};
fileRef.upload(new URLRequest(((((((("http://" + this.ipAddress) + ":") + port) + "/default/Upload.py?id=") + id) + "&nick=") + nick)));
debugMessage(((((((("[UPLOAD]: http://" + this.ipAddress) + ":") + port) + "/default/Upload.py?id=") + id) + "&nick=") + nick));
}
private function debugMessage(message:String):void{
var evt:SFSEvent;
if (this.debug){
trace(message);
evt = new SFSEvent(SFSEvent.onDebugMessage, {message:message});
dispatchEvent(evt);
};
}
private function errorTrace(msg:String):void{
trace("\n****************************************************************");
trace("Internal error:");
trace(msg);
trace("****************************************************************");
}
private function makeXmlHeader(headerObj:Object):String{
var item:String;
var xmlData:String = "<msg";
for (item in headerObj) {
xmlData = (xmlData + ((((" " + item) + "='") + headerObj[item]) + "'"));
};
xmlData = (xmlData + ">");
return (xmlData);
}
public function loadBuddyList():void{
send({t:"sys"}, "loadB", -1, "");
}
private function handleSocketConnection(e:Event):void{
var header:Object = {t:"sys"};
var xmlMsg = (((("<ver v='" + this.majVersion.toString()) + this.minVersion.toString()) + this.subVersion.toString()) + "' />");
send(header, "verChk", 0, xmlMsg);
}
public function set httpPollSpeed(sp:int):void{
if ((((sp >= 0)) && ((sp <= 10000)))){
this._httpPollSpeed = sp;
};
}
public function leaveRoom(roomId:int):void{
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
var header:Object = {t:"sys"};
var xmlMsg = (("<rm id='" + roomId) + "' />");
send(header, "leaveRoom", roomId, xmlMsg);
}
private function checkRoomList():Boolean{
var success:Boolean;
if ((((roomList == null)) || ((roomList.length == 0)))){
success = false;
errorTrace("The room list is empty!\nThe client API cannot function properly until the room list is populated.\nPlease consult the documentation for more infos.");
};
return (success);
}
private function strReceived(msg:String):void{
var params:Array = msg.substr(1, (msg.length - 2)).split(MSG_STR);
var handlerId:String = params[0];
var handler:IMessageHandler = messageHandlers[handlerId];
if (handler != null){
handler.handleMessage(params.splice(1, (params.length - 1)), XTMSG_TYPE_STR);
};
}
public function getRoomByName(roomName:String):Room{
var r:Room;
if (!checkRoomList()){
return (null);
};
var room:Room;
for each (r in roomList) {
if (r.getName() == roomName){
room = r;
break;
};
};
return (room);
}
public function getAllRooms():Array{
return (roomList);
}
public function getRoom(roomId:int):Room{
if (!checkRoomList()){
return (null);
};
return (roomList[roomId]);
}
private function tryBlueBoxConnection(evt:ErrorEvent):void{
var __ip:String;
var __port:int;
if (!connected){
if (smartConnect){
debugMessage("Socket connection failed. Trying BlueBox");
isHttpMode = true;
__ip = ((blueBoxIpAddress)!=null) ? blueBoxIpAddress : ipAddress;
__port = ((blueBoxPort)!=0) ? blueBoxPort : httpPort;
httpConnection.connect(__ip, __port);
} else {
dispatchConnectionError();
};
} else {
dispatchEvent(evt);
debugMessage(("[WARN] Connection error: " + evt.text));
};
}
private function checkJoin():Boolean{
var success:Boolean;
if (activeRoomId < 0){
success = false;
errorTrace("You haven't joined any rooms!\nIn order to interact with the server you should join at least one room.\nPlease consult the documentation for more infos.");
};
return (success);
}
public function setBuddyVariables(varList:Array):void{
var vName:String;
var vValue:String;
var header:Object = {t:"sys"};
var xmlMsg:String = "<vars>";
for (vName in varList) {
vValue = varList[vName];
if (myBuddyVars[vName] != vValue){
myBuddyVars[vName] = vValue;
xmlMsg = (xmlMsg + (((("<var n='" + vName) + "'><![CDATA[") + vValue) + "]]></var>"));
};
};
xmlMsg = (xmlMsg + "</vars>");
this.send(header, "setBvars", -1, xmlMsg);
}
private function addMessageHandler(key:String, handler:IMessageHandler):void{
if (this.messageHandlers[key] == null){
this.messageHandlers[key] = handler;
} else {
debugMessage((("Warning, message handler called: " + key) + " already exist!"));
};
}
private function handleSecurityError(evt:SecurityErrorEvent):void{
tryBlueBoxConnection(evt);
}
private function handleIOError(evt:IOErrorEvent):void{
tryBlueBoxConnection(evt);
}
private function dispatchConnectionError():void{
var params:Object = {};
params.success = false;
params.error = "I/O Error";
var sfse:SFSEvent = new SFSEvent(SFSEvent.onConnection, params);
dispatchEvent(sfse);
}
public function login(zone:String, name:String, pass:String):void{
var header:Object = {t:"sys"};
var message = (((((("<login z='" + zone) + "'><nick><![CDATA[") + name) + "]]></nick><pword><![CDATA[") + pass) + "]]></pword></login>");
send(header, "login", 0, message);
}
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{
if (!checkRoomList()){
return;
};
var header:Object = {t:"sys"};
this.send(header, "autoJoin", (this.activeRoomId) ? this.activeRoomId : -1, "");
}
private function onConfigLoadSuccess(evt:Event):void{
var sfsEvt:SFSEvent;
var loader:URLLoader = (evt.target as URLLoader);
var xmlDoc:XML = new XML(loader.data);
this.ipAddress = (this.blueBoxIpAddress = xmlDoc.ip);
this.port = int(xmlDoc.port);
this.defaultZone = xmlDoc.zone;
if (xmlDoc.blueBoxIpAddress != undefined){
this.blueBoxIpAddress = xmlDoc.blueBoxIpAddress;
};
if (xmlDoc.blueBoxPort != undefined){
this.blueBoxPort = xmlDoc.blueBoxPort;
};
if (xmlDoc.debug != undefined){
this.debug = ((xmlDoc.debug.toLowerCase() == "true")) ? true : false;
};
if (xmlDoc.smartConnect != undefined){
this.smartConnect = ((xmlDoc.smartConnect.toLowerCase() == "true")) ? true : false;
};
if (xmlDoc.httpPort != undefined){
this.httpPort = int(xmlDoc.httpPort);
};
if (xmlDoc.httpPollSpeed != undefined){
this.httpPollSpeed = int(xmlDoc.httpPollSpeed);
};
if (xmlDoc.rawProtocolSeparator != undefined){
rawProtocolSeparator = xmlDoc.rawProtocolSeparator;
};
if (autoConnectOnConfigSuccess){
this.connect(ipAddress, port);
} else {
sfsEvt = new SFSEvent(SFSEvent.onConfigLoadSuccess, {});
dispatchEvent(sfsEvt);
};
}
private function send(header:Object, action:String, fromRoom:Number, message:String):void{
var xmlMsg:String = makeXmlHeader(header);
xmlMsg = (xmlMsg + ((((((("<body action='" + action) + "' r='") + fromRoom) + "'>") + message) + "</body>") + closeHeader()));
debugMessage((("[Sending]: " + xmlMsg) + "\n"));
if (isHttpMode){
httpConnection.send(xmlMsg);
} else {
writeToSocket(xmlMsg);
};
}
private function handleSocketData(evt:Event):void{
var b:int;
var bytes:int = socketConnection.bytesAvailable;
while (--bytes >= 0) {
b = socketConnection.readByte();
if (b != 0){
byteBuffer.writeByte(b);
} else {
handleMessage(byteBuffer.toString());
byteBuffer = new ByteArray();
};
};
}
public function logout():void{
var header:Object = {t:"sys"};
send(header, "logout", -1, "");
}
public function getRoomList():void{
var header:Object = {t:"sys"};
send(header, "getRmList", activeRoomId, "");
}
public function getConnectionMode():String{
var mode:String = CONNECTION_MODE_DISCONNECTED;
if (this.isConnected){
if (this.isHttpMode){
mode = CONNECTION_MODE_HTTP;
} else {
mode = CONNECTION_MODE_SOCKET;
};
};
return (mode);
}
public function disconnect():void{
connected = false;
if (!isHttpMode){
socketConnection.close();
} else {
httpConnection.close();
};
sysHandler.dispatchDisconnection();
}
public function clearRoomList():void{
this.roomList = [];
}
public function sendJson(jsMessage:String):void{
debugMessage((("[Sending - JSON]: " + jsMessage) + "\n"));
if (isHttpMode){
httpConnection.send(jsMessage);
} else {
writeToSocket(jsMessage);
};
}
public function setRoomVariables(varList:Array, roomId:int=-1, setOwnership:Boolean=true):void{
var xmlMsg:String;
var rv:Object;
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
if (roomId == -1){
roomId = activeRoomId;
};
var header:Object = {t:"sys"};
if (setOwnership){
xmlMsg = "<vars>";
} else {
xmlMsg = "<vars so='0'>";
};
for each (rv in varList) {
xmlMsg = (xmlMsg + getXmlRoomVariable(rv));
};
xmlMsg = (xmlMsg + "</vars>");
send(header, "setRvars", roomId, xmlMsg);
}
public function addBuddy(buddyName:String):void{
var xmlMsg:String;
if (((!((buddyName == myUserName))) && (!(checkBuddyDuplicates(buddyName))))){
xmlMsg = (("<n>" + buddyName) + "</n>");
send({t:"sys"}, "addB", -1, xmlMsg);
};
}
private function initialize(isLogOut: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 (!isLogOut){
this.connected = false;
this.isHttpMode = false;
};
}
public function getVersion():String{
return (((((this.majVersion + ".") + this.minVersion) + ".") + this.subVersion));
}
public function setUserVariables(varObj:Object, roomId:int=-1):void{
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
if (roomId == -1){
roomId = activeRoomId;
};
var header:Object = {t:"sys"};
var currRoom:Room = getActiveRoom();
var user:User = currRoom.getUser(myUserId);
user.setVariables(varObj);
var xmlMsg:String = getXmlUserVariable(varObj);
send(header, "setUvars", roomId, xmlMsg);
}
public function sendPrivateMessage(message:String, recipientId:int, roomId:int=-1):void{
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
if (roomId == -1){
roomId = activeRoomId;
};
var header:Object = {t:"sys"};
var xmlMsg = (((("<txt rcp='" + recipientId) + "'><![CDATA[") + Entities.encodeEntities(message)) + "]]></txt>");
send(header, "prvMsg", roomId, xmlMsg);
}
public function getBuddyByName(buddyName:String):Object{
var buddy:Object;
for each (buddy in buddyList) {
if (buddy.name == buddyName){
return (buddy);
};
};
return (null);
}
private function closeHeader():String{
return ("</msg>");
}
public function sendPublicMessage(message:String, roomId:int=-1):void{
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
if (roomId == -1){
roomId = activeRoomId;
};
var header:Object = {t:"sys"};
var xmlMsg = (("<txt><![CDATA[" + Entities.encodeEntities(message)) + "]]></txt>");
send(header, "pubMsg", roomId, xmlMsg);
}
public function clearBuddyList():void{
buddyList = [];
send({t:"sys"}, "clearB", -1, "");
var params:Object = {};
params.list = buddyList;
var evt:SFSEvent = new SFSEvent(SFSEvent.onBuddyList, params);
dispatchEvent(evt);
}
public function sendString(strMessage:String):void{
debugMessage((("[Sending - STR]: " + strMessage) + "\n"));
if (isHttpMode){
httpConnection.send(strMessage);
} else {
writeToSocket(strMessage);
};
}
public function removeBuddy(buddyName:String):void{
var buddy:Object;
var it:String;
var header:Object;
var xmlMsg:String;
var params:Object;
var evt:SFSEvent;
var found:Boolean;
for (it in buddyList) {
buddy = buddyList[it];
if (buddy.name == buddyName){
delete buddyList[it];
found = true;
break;
};
};
if (found){
header = {t:"sys"};
xmlMsg = (("<n>" + buddyName) + "</n>");
send(header, "remB", -1, xmlMsg);
params = {};
params.list = buddyList;
evt = new SFSEvent(SFSEvent.onBuddyList, params);
dispatchEvent(evt);
};
}
public function setBuddyBlockStatus(buddyName:String, status:Boolean):void{
var xmlMsg:String;
var params:Object;
var evt:SFSEvent;
var b:Object = getBuddyByName(buddyName);
if (b != null){
if (b.isBlocked != status){
b.isBlocked = status;
xmlMsg = (((("<n x='" + (status) ? "1" : "0") + "'>") + buddyName) + "</n>");
send({t:"sys"}, "setB", -1, xmlMsg);
params = {};
params.buddy = b;
evt = new SFSEvent(SFSEvent.onBuddyListUpdate, params);
dispatchEvent(evt);
};
};
}
private function handleMessage(msg:String):void{
if (msg != "ok"){
debugMessage((((("[ RECEIVED ]: " + msg) + ", (len: ") + msg.length) + ")"));
};
var type:String = msg.charAt(0);
if (type == MSG_XML){
xmlReceived(msg);
} else {
if (type == MSG_STR){
strReceived(msg);
} else {
if (type == MSG_JSON){
jsonReceived(msg);
};
};
};
}
public function getUploadPath():String{
return ((((("http://" + this.ipAddress) + ":") + this.httpPort) + "/default/uploads/"));
}
private function handleHttpData(evt:HttpEvent):void{
var message:String;
var i:int;
var data:String = (evt.params.data as String);
var messages:Array = data.split("\n");
if (messages[0] != ""){
i = 0;
while (i < (messages.length - 1)) {
message = messages[i];
if (message.length > 0){
handleMessage(message);
};
i++;
};
if (this._httpPollSpeed > 0){
setTimeout(this.handleDelayedPoll, this._httpPollSpeed);
} else {
handleDelayedPoll();
};
};
}
public function loadConfig(configFile:String="config.xml", autoConnect:Boolean=true):void{
this.autoConnectOnConfigSuccess = autoConnect;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onConfigLoadSuccess);
loader.addEventListener(IOErrorEvent.IO_ERROR, onConfigLoadFailure);
loader.load(new URLRequest(configFile));
}
public function set rawProtocolSeparator(value:String):void{
if (((!((value == "<"))) && (!((value == "{"))))){
MSG_STR = value;
};
}
private function writeToSocket(msg:String):void{
var byteBuff:ByteArray = new ByteArray();
byteBuff.writeMultiByte(msg, "utf-8");
byteBuff.writeByte(0);
socketConnection.writeBytes(byteBuff);
socketConnection.flush();
}
public function sendXtMessage(xtName:String, cmd:String, paramObj, type:String="xml", roomId:int=-1):void{
var header:Object;
var xtReq:Object;
var xmlmsg:String;
var hdr:String;
var i:Number;
var body:Object;
var obj:Object;
var msg:String;
if (!checkRoomList()){
return;
};
if (roomId == -1){
roomId = activeRoomId;
};
if (type == XTMSG_TYPE_XML){
header = {t:"xt"};
xtReq = {name:xtName, cmd:cmd, param:paramObj};
xmlmsg = (("<![CDATA[" + ObjectSerializer.getInstance().serialize(xtReq)) + "]]>");
send(header, "xtReq", roomId, xmlmsg);
} else {
if (type == XTMSG_TYPE_STR){
hdr = ((((((((MSG_STR + "xt") + MSG_STR) + xtName) + MSG_STR) + cmd) + MSG_STR) + roomId) + MSG_STR);
i = 0;
while (i < paramObj.length) {
hdr = (hdr + (paramObj[i].toString() + MSG_STR));
i++;
};
sendString(hdr);
} else {
if (type == XTMSG_TYPE_JSON){
body = {};
body.x = xtName;
body.c = cmd;
body.r = roomId;
body.p = paramObj;
obj = {};
obj.t = "xt";
obj.b = body;
msg = JSON.encode(obj);
sendJson(msg);
};
};
};
}
public function sendObjectToGroup(obj:Object, userList:Array, roomId:int=-1):void{
var i:String;
var header:Object;
var xmlMsg:String;
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
if (roomId == -1){
roomId = activeRoomId;
};
var strList:String = "";
for (i in userList) {
if (!isNaN(userList[i])){
strList = (strList + (userList[i] + ","));
};
};
strList = strList.substr(0, (strList.length - 1));
obj._$$_ = strList;
header = {t:"sys"};
xmlMsg = (("<![CDATA[" + ObjectSerializer.getInstance().serialize(obj)) + "]]>");
send(header, "asObjG", roomId, xmlMsg);
}
public function get rawProtocolSeparator():String{
return (MSG_STR);
}
public function getRandomKey():void{
send({t:"sys"}, "rndK", -1, "");
}
public function sendObject(obj:Object, roomId:int=-1):void{
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
if (roomId == -1){
roomId = activeRoomId;
};
var xmlData = (("<![CDATA[" + ObjectSerializer.getInstance().serialize(obj)) + "]]>");
var header:Object = {t:"sys"};
send(header, "asObj", roomId, xmlData);
}
public function connect(ipAdr:String, port:int=9339):void{
if (!connected){
initialize();
this.ipAddress = ipAdr;
this.port = port;
socketConnection.connect(ipAdr, port);
} else {
debugMessage("*** ALREADY CONNECTED ***");
};
}
public function sendBuddyPermissionResponse(allowBuddy:Boolean, targetBuddy:String):void{
var header:Object = {t:"sys"};
var xmlMsg = (((("<n res='" + (allowBuddy) ? "g" : "r") + "'>") + targetBuddy) + "</n>");
send(header, "bPrm", -1, xmlMsg);
}
public function sendModeratorMessage(message:String, type:String, id:int=-1):void{
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
var header:Object = {t:"sys"};
var xmlMsg = (((((("<txt t='" + type) + "' id='") + id) + "'><![CDATA[") + Entities.encodeEntities(message)) + "]]></txt>");
send(header, "modMsg", activeRoomId, xmlMsg);
}
public function getBenchStartTime():int{
return (this.benchStartTime);
}
public function createRoom(roomObj:Object, roomId:int=-1):void{
var i:String;
if (((!(checkRoomList())) || (!(checkJoin())))){
return;
};
if (roomId == -1){
roomId = activeRoomId;
};
var header:Object = {t:"sys"};
var isGame:String = (roomObj.isGame) ? "1" : "0";
var exitCurrentRoom:String = "1";
var maxUsers:String = ((roomObj.maxUsers == null)) ? "0" : String(roomObj.maxUsers);
var maxSpectators:String = ((roomObj.maxSpectators == null)) ? "0" : String(roomObj.maxSpectators);
var joinAsSpectator:String = (roomObj.joinAsSpectator) ? "1" : "0";
if (((roomObj.isGame) && (!((roomObj.exitCurrentRoom == null))))){
exitCurrentRoom = (roomObj.exitCurrentRoom) ? "1" : "0";
};
var xmlMsg = (((((((("<room tmp='1' gam='" + isGame) + "' spec='") + maxSpectators) + "' exit='") + exitCurrentRoom) + "' jas='") + joinAsSpectator) + "'>");
xmlMsg = (xmlMsg + (("<name><![CDATA[" + ((roomObj.name == null)) ? "" : roomObj.name) + "]]></name>"));
xmlMsg = (xmlMsg + (("<pwd><![CDATA[" + ((roomObj.password == null)) ? "" : roomObj.password) + "]]></pwd>"));
xmlMsg = (xmlMsg + (("<max>" + maxUsers) + "</max>"));
if (roomObj.uCount != null){
xmlMsg = (xmlMsg + (("<uCnt>" + (roomObj.uCount) ? "1" : "0") + "</uCnt>"));
};
if (roomObj.extension != null){
xmlMsg = (xmlMsg + ("<xt n='" + roomObj.extension.name));
xmlMsg = (xmlMsg + (("' s='" + roomObj.extension.script) + "' />"));
};
if (roomObj.vars == null){
xmlMsg = (xmlMsg + "<vars></vars>");
} else {
xmlMsg = (xmlMsg + "<vars>");
for (i in roomObj.vars) {
xmlMsg = (xmlMsg + getXmlRoomVariable(roomObj.vars[i]));
};
xmlMsg = (xmlMsg + "</vars>");
};
xmlMsg = (xmlMsg + "</room>");
send(header, "createRoom", roomId, xmlMsg);
}
private function handleDelayedPoll():void{
httpConnection.send(HTTP_POLL_REQUEST);
}
private function handleHttpConnect(evt:HttpEvent):void{
this.handleSocketConnection(null);
connected = true;
httpConnection.send(HTTP_POLL_REQUEST);
}
public function set isConnected(b:Boolean):void{
this.connected = b;
}
public function get isConnected():Boolean{
return (this.connected);
}
}
}//package it.gotoandplay.smartfoxserver
Section 198
//MonsterDebugger (nl.demonsters.debugger.MonsterDebugger)
package nl.demonsters.debugger {
import flash.events.*;
import flash.net.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.system.*;
public class MonsterDebugger {
private const TYPE_BOOLEAN:String = "Boolean";
private const COMMAND_GET_DISPLAYOBJECT:String = "GET_DISPLAYOBJECT";
private const TYPE_VECTOR:String = "Vector";
private const TYPE_XMLLIST:String = "XMLList";
private const COMMAND_TRACE:String = "TRACE";
private const ACCESS_METHOD:String = "method";
private const TYPE_XMLVALUE:String = "XMLValue";
private const COMMAND_NOTFOUND:String = "NOTFOUND";
protected const MAX_BUFFER_SIZE:int = 500;
private const COMMAND_MONITOR:String = "MONITOR";
private const ACCESS_CONSTANT:String = "constant";
protected const HIGHLIGHT_BORDER:int = 4;
private const TYPE_FUNCTION:String = "Function";
private const TYPE_UINT:String = "uint";
private const TYPE_INT:String = "int";
protected const MAX_PACKAGE_BYTES:int = 40000;
private const LINE_IN:String = "_debuggerBlue";
private const TYPE_XMLATTRIBUTE:String = "XMLAttribute";
private const COMMAND_SNAPSHOT:String = "SNAPSHOT";
private const ALLOWED_DOMAIN:String = "*";
private const ICON_VARIABLE_READONLY:String = "iconVariableReadonly";
private const ICON_DEFAULT:String = "iconDefault";
private const LINE_OUT:String = "_debuggerRed";
private const COMMAND_BASE:String = "BASE";
private const COMMAND_SHOW_HIGHLIGHT:String = "SHOW_HIGHLIGHT";
private const COMMAND_HIDE_HIGHLIGHT:String = "HIDE_HIGHLIGHT";
private const TYPE_BYTEARRAY:String = "ByteArray";
private const ICON_VARIABLE_WRITEONLY:String = "iconVariableWriteonly";
private const COMMAND_GET_PROPERTIES:String = "GET_PROPERTIES";
private const TYPE_XML:String = "XML";
private const TYPE_XMLNODE:String = "XMLNode";
private const COMMAND_ROOT:String = "ROOT";
private const TYPE_WARNING:String = "Warning";
private const TYPE_VOID:String = "void";
private const PERMISSION_WRITEONLY:String = "writeonly";
private const PERMISSION_READWRITE:String = "readwrite";
private const ICON_VARIABLE:String = "iconVariable";
private const TYPE_METHOD:String = "MethodClosure";
private const ICON_XMLATTRIBUTE:String = "iconXMLAttribute";
private const COMMAND_HELLO:String = "HELLO";
private const COMMAND_GET_FUNCTIONS:String = "GET_FUNCTIONS";
private const PERMISSION_READONLY:String = "readonly";
private const ICON_XMLNODE:String = "iconXMLNode";
private const COMMAND_CLEAR_TRACES:String = "CLEAR_TRACES";
protected const VERSION:Number = 2.51;
private const ICON_WARNING:String = "iconWarning";
private const COMMAND_HELLO_RESPONSE:String = "HELLO_RESPONSE";
private const ICON_XMLVALUE:String = "iconXMLValue";
private const ACCESS_ACCESSOR:String = "accessor";
private const COMMAND_SET_PROPERTY:String = "SET_PROPERTY";
private const TYPE_STRING:String = "String";
private const COMMAND_CALL_METHOD:String = "CALL_METHOD";
private const ICON_FUNCTION:String = "iconFunction";
protected const HIGHLIGHT_COLOR:uint = 0xFFFF00;
private const COMMAND_INSPECT:String = "INSPECT";
private const TYPE_OBJECT:String = "Object";
private const TYPE_NUMBER:String = "Number";
private const ICON_ROOT:String = "iconRoot";
private const TYPE_ARRAY:String = "Array";
private const ACCESS_VARIABLE:String = "variable";
private const COMMAND_GET_OBJECT:String = "GET_OBJECT";
protected const FPS_UPDATE:int = 500;
protected var isConnected:Boolean;// = false
protected var monitorStart:Number;
private var lineIn:LocalConnection;
protected var buffer:Array;
protected var monitorTime:Number;
protected var monitor:Timer;
public var logger:Function;
protected var monitorFrames:uint;
private var lineOut:LocalConnection;
protected var highlight:Sprite;// = null
protected var monitorSprite:Sprite;
protected var isEnabled:Boolean;// = true
protected var root:Object;// = null
public static const COLOR_WARNING:uint = 0xFF3300;
public static const COLOR_NORMAL:uint = 0x111111;
public static const COLOR_ERROR:uint = 0xFF0000;
private static var instance:MonsterDebugger = null;
public function MonsterDebugger(target:Object=null){
var target = target;
buffer = new Array();
super();
if (instance == null){
instance = this;
lineOut = new LocalConnection();
lineOut.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler, false, 0, true);
lineOut.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler, false, 0, true);
lineOut.addEventListener(StatusEvent.STATUS, statusHandler, false, 0, true);
lineIn = new LocalConnection();
lineIn.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler, false, 0, true);
lineIn.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler, false, 0, true);
lineIn.addEventListener(StatusEvent.STATUS, statusHandler, false, 0, true);
lineIn.allowDomain(ALLOWED_DOMAIN);
lineIn.client = this;
monitorTime = new Date().time;
monitorStart = new Date().time;
monitorFrames = 0;
monitorSprite = new Sprite();
monitorSprite.addEventListener(Event.ENTER_FRAME, enterFrameHandler, false, 0, true);
monitor = new Timer(FPS_UPDATE);
monitor.addEventListener(TimerEvent.TIMER, monitorHandler, false, 0, true);
monitor.start();
lineIn.connect(LINE_IN);
//unresolved jump
var _slot1 = error;
};
instance.root = target;
instance.send({text:COMMAND_HELLO, version:VERSION});
}
private function statusHandler(event:StatusEvent):void{
if (event.level == "error"){
isConnected = false;
};
}
private function asyncErrorHandler(event:AsyncErrorEvent):void{
isConnected = false;
}
protected function htmlEscape(s:String):String{
var xml:XML;
if (s){
if (s.indexOf("&") != -1){
s = s.split("&").join("&");
};
if (s.indexOf("<") != -1){
s = s.split("<").join("<");
};
if (s.indexOf(">") != -1){
s = s.split(">").join(">");
};
if (s.indexOf("'") != -1){
s = s.split("'").join("'");
};
if (s.indexOf("\"") != -1){
s = s.split("\"").join(""");
};
xml = new XML((("<a>" + ??esc_xelem
) + "</a>"));
return (xml.toXMLString().replace(/(^<a>)|(<\/a>$)|(^<a\/>$)/g, ""));
//unresolved jump
};
return ("");
}
protected function sendBuffer():void{
if (buffer.length > 0){
while (buffer.length != 0) {
send(buffer.shift());
};
};
}
protected function createNode(title:String, object:Object=null, close:Boolean=false):String{
var prop:*;
var xml:String = "";
xml = (xml + ("<" + title));
if (object){
for (prop in object) {
xml = (xml + ((((" " + prop) + "=\"") + object[prop]) + "\""));
};
};
if (close){
xml = (xml + (("></" + title) + ">"));
} else {
xml = (xml + ">");
};
return (xml);
}
protected function enterFrameHandler(event:Event):void{
if (isEnabled){
monitorFrames++;
};
}
protected function traceInternal(target:Object, object, color:uint=0x111111, functions:Boolean=false, depth:int=4):void{
var xml:XML;
var memory:uint;
var obj:Object;
if (isEnabled){
xml = XML(parseObject(object, "", functions, 1, depth));
memory = System.totalMemory;
obj = {text:COMMAND_TRACE, date:new Date(), target:String(target), xml:xml, color:color, memory:memory};
if (isConnected){
send(obj);
} else {
sendToBuffer(obj);
};
};
}
protected function getObject(target:String="", parent:int=0){
var splitted:Array;
var i:int;
var index:Number;
var obj:Object;
var target = target;
var parent = parent;
var object:* = instance.root;
if (target != ""){
splitted = target.split(".");
i = 0;
for (;i < (splitted.length - parent);(i = (i + 1))) {
if (splitted[i] != ""){
if (splitted[i] == "children()"){
object = object.children();
} else {
if (splitted[i].indexOf("getChildAt(") == 0){
index = splitted[i].substring(11, splitted[i].indexOf(")", 11));
object = DisplayObjectContainer(object).getChildAt(index);
} else {
object = object[splitted[i]];
};
};
continue;
var _slot1 = error;
obj = {text:COMMAND_NOTFOUND, target:target};
if (isConnected){
send(obj);
} else {
sendToBuffer(obj);
};
break;
};
};
};
return (object);
}
protected function sendToBuffer(obj:Object):void{
buffer.push(obj);
if (buffer.length > MAX_BUFFER_SIZE){
buffer.shift();
};
}
protected function printObject(object, type:String):String{
var s:String = "";
if (type == TYPE_BYTEARRAY){
s = (object["length"] + " bytes");
} else {
s = htmlEscape(String(object));
};
return (s);
}
protected function clearTracesInternal():void{
var obj:Object;
if (isEnabled){
obj = {text:COMMAND_CLEAR_TRACES};
if (isConnected){
send(obj);
} else {
sendToBuffer(obj);
};
};
}
protected function parseXML(node, target:String="", currentDepth:int=1, maxDepth:int=-1):String{
var childTarget:String;
var xml:String = "";
var i:int;
if ((((maxDepth == -1)) || ((currentDepth <= maxDepth)))){
if (target.indexOf("@") != -1){
xml = (xml + createNode("node", {icon:ICON_XMLATTRIBUTE, label:node, name:"", type:TYPE_XMLATTRIBUTE, value:node, target:target, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, true));
} else {
if (node.name() == null){
xml = (xml + createNode("node", {icon:ICON_XMLVALUE, label:((("(" + TYPE_XMLVALUE) + ") = ") + printObject(node, TYPE_XMLVALUE)), name:"", type:TYPE_XMLVALUE, value:printObject(node, TYPE_XMLVALUE), target:target, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, true));
} else {
if (node.hasSimpleContent()){
xml = (xml + createNode("node", {icon:ICON_XMLNODE, label:(((node.name() + " (") + TYPE_XMLNODE) + ")"), name:node.name(), type:TYPE_XMLNODE, value:"", target:target, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}));
if (node != ""){
xml = (xml + createNode("node", {icon:ICON_XMLVALUE, label:((("(" + TYPE_XMLVALUE) + ") = ") + printObject(node, TYPE_XMLVALUE)), name:"", type:TYPE_XMLVALUE, value:printObject(node, TYPE_XMLVALUE), target:target, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, true));
};
i = 0;
while (i < node.attributes().length()) {
xml = (xml + createNode("node", {icon:ICON_XMLATTRIBUTE, label:((((("@" + node.attributes()[i].name()) + " (") + TYPE_XMLATTRIBUTE) + ") = ") + node.attributes()[i]), name:"", type:TYPE_XMLATTRIBUTE, value:node.attributes()[i], target:(((target + ".") + "@") + node.attributes()[i].name()), access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, true));
i++;
};
xml = (xml + createNode("/node"));
} else {
xml = (xml + createNode("node", {icon:ICON_XMLNODE, label:(((node.name() + " (") + TYPE_XMLNODE) + ")"), name:node.name(), type:TYPE_XMLNODE, value:"", target:target, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}));
i = 0;
while (i < node.attributes().length()) {
xml = (xml + createNode("node", {icon:ICON_XMLATTRIBUTE, label:((((("@" + node.attributes()[i].name()) + " (") + TYPE_XMLATTRIBUTE) + ") = ") + node.attributes()[i]), name:"", type:TYPE_XMLATTRIBUTE, value:node.attributes()[i], target:(((target + ".") + "@") + node.attributes()[i].name()), access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, true));
i++;
};
i = 0;
while (i < node.children().length()) {
childTarget = ((((target + ".") + "children()") + ".") + i);
xml = (xml + parseXML(node.children()[i], childTarget, (currentDepth + 1), maxDepth));
i++;
};
xml = (xml + createNode("/node"));
};
};
};
};
return (xml);
}
protected function send(data:Object):void{
var item:ByteArray;
var dataPackages:Array;
var i:int;
var bytesAvailable:int;
var offset:int;
var total:int;
var length:int;
var tmp:ByteArray;
var data = data;
if (isEnabled){
item = new ByteArray();
item.writeObject(data);
item.compress();
dataPackages = new Array();
i = 0;
if (item.length > MAX_PACKAGE_BYTES){
bytesAvailable = item.length;
offset = 0;
total = Math.ceil((item.length / MAX_PACKAGE_BYTES));
i = 0;
while (i < total) {
length = bytesAvailable;
if (length > MAX_PACKAGE_BYTES){
length = MAX_PACKAGE_BYTES;
};
tmp = new ByteArray();
tmp.writeBytes(item, offset, length);
dataPackages.push({total:total, nr:(i + 1), bytes:tmp});
bytesAvailable = (bytesAvailable - length);
offset = (offset + length);
i = (i + 1);
};
} else {
dataPackages.push({total:1, nr:1, bytes:item});
};
i = 0;
for (;i < dataPackages.length;(i = (i + 1))) {
lineOut.send(LINE_OUT, "onReceivedData", dataPackages[i]);
continue;
var _slot1 = error;
break;
};
};
}
private function securityErrorHandler(event:SecurityErrorEvent):void{
isConnected = false;
}
protected function monitorHandler(event:TimerEvent):void{
var memory:uint;
var now:Number;
var delta:Number;
var fps:uint;
var obj:Object;
if (isEnabled){
memory = System.totalMemory;
now = new Date().time;
delta = (now - monitorTime);
fps = ((monitorFrames / delta) * 1000);
monitorFrames = 0;
monitorTime = now;
obj = {text:COMMAND_MONITOR, memory:memory, fps:fps, time:now, start:monitorStart};
if (isConnected){
send(obj);
} else {
sendToBuffer(obj);
};
};
}
protected function snapshotInternal(target:DisplayObject, color:uint=0x111111):void{
var bitmapData:BitmapData;
var bytes:ByteArray;
var memory:uint;
var obj:Object;
if (isEnabled){
bitmapData = new BitmapData(target.width, target.height);
bitmapData.draw(target);
bytes = bitmapData.getPixels(new Rectangle(0, 0, target.width, target.height));
memory = System.totalMemory;
obj = {text:COMMAND_SNAPSHOT, date:new Date(), target:String(target), bytes:bytes, width:target.width, height:target.height, color:color, memory:memory};
if (isConnected){
send(obj);
} else {
sendToBuffer(obj);
};
bitmapData.dispose();
bytes = null;
};
}
protected function isDisplayObject(object):Boolean{
return ((((object is DisplayObject)) || ((object is DisplayObjectContainer))));
}
public function onReceivedData(data:ByteArray):void{
var object:*;
var method:Function;
var xml:XML;
var command:Object;
var bounds:Rectangle;
var data = data;
if (isEnabled){
data.uncompress();
command = data.readObject();
switch (command["text"]){
case COMMAND_HELLO:
isConnected = true;
send({text:COMMAND_HELLO, version:VERSION});
break;
case COMMAND_HELLO_RESPONSE:
isConnected = true;
sendBuffer();
break;
case COMMAND_ROOT:
object = getObject("", 0);
if (object != null){
xml = XML(parseObject(object, "", command["functions"], 1, 2));
send({text:COMMAND_ROOT, xml:xml});
if (isDisplayObject(object)){
xml = XML(parseDisplayObject(object, "", command["functions"], 1, 2));
send({text:COMMAND_BASE, xml:xml});
};
};
break;
case COMMAND_GET_OBJECT:
object = getObject(command["target"], 0);
if (object != null){
xml = XML(parseObject(object, command["target"], command["functions"], 1, 2));
send({text:COMMAND_GET_OBJECT, xml:xml});
};
break;
case COMMAND_GET_DISPLAYOBJECT:
object = getObject(command["target"], 0);
if (object != null){
if (isDisplayObject(object)){
xml = XML(parseDisplayObject(object, command["target"], command["functions"], 1, 2));
send({text:COMMAND_GET_DISPLAYOBJECT, xml:xml});
};
};
break;
case COMMAND_GET_PROPERTIES:
object = getObject(command["target"], 0);
if (object != null){
xml = XML(parseObject(object, command["target"], false, 1, 1));
send({text:COMMAND_GET_PROPERTIES, xml:xml});
};
break;
case COMMAND_GET_FUNCTIONS:
object = getObject(command["target"], 0);
if (object != null){
xml = XML(getFunctions(object, command["target"]));
send({text:COMMAND_GET_FUNCTIONS, xml:xml});
};
break;
case COMMAND_SET_PROPERTY:
object = getObject(command["target"], 1);
if (object != null){
object[command["name"]] = command["value"];
send({text:COMMAND_SET_PROPERTY, value:object[command["name"]]});
//unresolved jump
var _slot1 = error;
send({text:COMMAND_NOTFOUND, target:command["target"]});
break;
};
break;
case COMMAND_CALL_METHOD:
method = getObject(command["target"], 0);
if (method != null){
if (command["returnType"] == TYPE_VOID){
method.apply(this, command["arguments"]);
} else {
object = method.apply(this, command["arguments"]);
xml = XML(parseObject(object, "", false, 1, 4));
send({text:COMMAND_CALL_METHOD, id:command["id"], xml:xml});
};
};
break;
case COMMAND_SHOW_HIGHLIGHT:
if (highlight != null){
highlight.parent.removeChild(highlight);
highlight = null;
//unresolved jump
var _slot1 = error;
};
object = getObject(command["target"], 0);
if (((isDisplayObject(object)) && (isDisplayObject(object["parent"])))){
bounds = object.getBounds(object["parent"]);
highlight = new Sprite();
highlight.x = 0;
highlight.y = 0;
highlight.graphics.beginFill(0, 0);
highlight.graphics.lineStyle(HIGHLIGHT_BORDER, HIGHLIGHT_COLOR);
highlight.graphics.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
highlight.graphics.endFill();
highlight.mouseChildren = false;
highlight.mouseEnabled = false;
object["parent"].addChild(highlight);
//unresolved jump
var _slot1 = error;
highlight = null;
};
break;
case COMMAND_HIDE_HIGHLIGHT:
if (highlight != null){
highlight.parent.removeChild(highlight);
highlight = null;
//unresolved jump
var _slot1 = error;
};
break;
};
};
}
protected function parseDisplayObject(object, target:String="", functions:Boolean=false, currentDepth:int=1, maxDepth:int=4):String{
var xml:String;
var childs:Array;
var child:DisplayObject;
var ojectName:String;
var msg:String;
var obj:Object;
var object = object;
var target = target;
var functions = functions;
var currentDepth = currentDepth;
var maxDepth = maxDepth;
xml = "";
var childType = "";
var childIcon = "";
var childName = "";
var childTarget = "";
var childChildren = "";
var i:int;
if ((((maxDepth == -1)) || ((currentDepth <= maxDepth)))){
if (currentDepth == 1){
xml = (xml + createNode("root"));
};
if (currentDepth == 1){
ojectName = DisplayObject(object).name;
if ((((ojectName == null)) || ((ojectName == "null")))){
ojectName = "DisplayObject";
};
xml = (xml + createNode("node", {icon:ICON_ROOT, label:(("(" + ojectName) + ")"), target:target}));
};
childs = new Array();
i = 0;
while (i < DisplayObjectContainer(object).numChildren) {
childs.push(DisplayObjectContainer(object).getChildAt(i));
i = (i + 1);
};
i = 0;
for (;i < childs.length;(xml = (xml + createNode("/node"))), (i = (i + 1))) {
child = childs[i];
childName = describeType(child).@name;
childType = parseType(childName);
childTarget = ((((target + ".") + "getChildAt(") + i) + ")");
childIcon = ((child is DisplayObjectContainer)) ? ICON_ROOT : ICON_VARIABLE;
childChildren = ((child is DisplayObjectContainer)) ? String(DisplayObjectContainer(child).numChildren) : "";
xml = (xml + createNode("node", {icon:childIcon, label:((((child.name + " (") + childType) + ") ") + childChildren), name:child.name, type:childType, value:printObject(child, childType), target:childTarget, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}));
xml = (xml + parseDisplayObject(child, childTarget, functions, (currentDepth + 1), maxDepth));
continue;
var _slot1 = error;
xml = (xml + createNode("node", {icon:ICON_WARNING, type:TYPE_WARNING, label:"Unreadable", name:"Unreadable"}, true));
};
if (currentDepth == 1){
xml = (xml + createNode("/node"));
};
//unresolved jump
var _slot1 = error;
msg = "";
msg = (msg + createNode("root"));
msg = (msg + createNode("node", {icon:ICON_WARNING, type:TYPE_WARNING, label:"Not found", name:"Not found"}, true));
msg = (msg + createNode("/root"));
obj = {text:COMMAND_NOTFOUND, target:target, xml:XML(msg)};
if (isConnected){
send(obj);
} else {
sendToBuffer(obj);
};
if (currentDepth == 1){
xml = (xml + createNode("/root"));
};
};
return (xml);
}
protected function parseType(type:String):String{
var s:String = type;
if (type.lastIndexOf("::") != -1){
s = type.substring((type.lastIndexOf("::") + 2), type.length);
};
if (s.lastIndexOf(".") != -1){
s = s.substring(0, s.lastIndexOf("."));
};
if (s == TYPE_METHOD){
s = TYPE_FUNCTION;
};
return (htmlEscape(s));
}
protected function parseObject(object, target:String="", functions:Boolean=false, currentDepth:int=1, maxDepth:int=4):String{
var xml:String;
var isXMLString:XML;
var keys:Array;
var key:*;
var properties:Array;
var prop:*;
var variables:XMLList;
var accessors:XMLList;
var constants:XMLList;
var methods:XMLList;
var variablesArr:Array;
var methodsArr:Array;
var double:Boolean;
var permission:String;
var icon:String;
var returnType:String;
var parameters:XMLList;
var args:Array;
var msg:String;
var obj:Object;
var object = object;
var target = target;
var functions = functions;
var currentDepth = currentDepth;
var maxDepth = maxDepth;
xml = "";
var childType = "";
var childName = "";
var childTarget = "";
var description:XML = new XML();
var type = "";
var base = "";
var isXML:Boolean;
var i:int;
var n:int;
if ((((maxDepth == -1)) || ((currentDepth <= maxDepth)))){
if (currentDepth == 1){
xml = (xml + createNode("root"));
};
description = describeType(object);
type = parseType(description.@name);
base = parseType(description.@base);
if (((functions) && ((base == TYPE_FUNCTION)))){
xml = (xml + createNode("node", {icon:ICON_FUNCTION, label:"(Function)", name:"", type:TYPE_FUNCTION, value:"", target:target, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, true));
} else {
if ((((type == TYPE_ARRAY)) || ((type == TYPE_VECTOR)))){
if (currentDepth == 1){
xml = (xml + createNode("node", {icon:ICON_ROOT, label:(("(" + type) + ")"), target:target}));
};
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:(((("length" + " (") + TYPE_UINT) + ") = ") + object["length"]), name:"length", type:TYPE_UINT, value:object["length"], target:((target + ".") + "length"), access:ACCESS_VARIABLE, permission:PERMISSION_READONLY}, true));
keys = new Array();
for (key in object) {
keys.push(key);
};
keys.sort();
i = 0;
for (;i < keys.length;(i = (i + 1))) {
childType = parseType(describeType(object[keys[i]]).@name);
childTarget = ((target + ".") + String(keys[i]));
if ((((((((((((childType == TYPE_STRING)) || ((childType == TYPE_BOOLEAN)))) || ((childType == TYPE_NUMBER)))) || ((childType == TYPE_INT)))) || ((childType == TYPE_UINT)))) || ((childType == TYPE_FUNCTION)))){
isXML = false;
isXMLString = new XML();
if (childType == TYPE_STRING){
isXMLString = new XML(object[keys[i]]);
if (((!(isXMLString.hasSimpleContent())) && ((isXMLString.children().length() > 0)))){
isXML = true;
};
//unresolved jump
var _slot1 = error;
};
if (!isXML){
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:((((("[" + keys[i]) + "] (") + childType) + ") = ") + printObject(object[keys[i]], childType)), name:(("[" + keys[i]) + "]"), type:childType, value:printObject(object[keys[i]], childType), target:childTarget, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, true));
} else {
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:(((("[" + keys[i]) + "] (") + childType) + ")"), name:(("[" + keys[i]) + "]"), type:childType, value:"", target:childTarget, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, false));
xml = (xml + parseXML(isXMLString, ((childTarget + ".") + "cildren()"), currentDepth, maxDepth));
xml = (xml + createNode("/node"));
};
//unresolved jump
var _slot1 = error;
continue;
};
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:(((("[" + keys[i]) + "] (") + childType) + ")"), name:(("[" + keys[i]) + "]"), type:childType, value:"", target:childTarget, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}));
xml = (xml + parseObject(object[keys[i]], childTarget, functions, (currentDepth + 1), maxDepth));
//unresolved jump
var _slot1 = error;
xml = (xml + createNode("node", {icon:ICON_WARNING, type:TYPE_WARNING, label:"Unreadable", name:"Unreadable"}, true));
};
if (currentDepth == 1){
xml = (xml + createNode("/node"));
};
} else {
if (type == TYPE_OBJECT){
if (currentDepth == 1){
xml = (xml + createNode("node", {icon:ICON_ROOT, label:(("(" + type) + ")"), target:target}));
};
properties = new Array();
for (prop in object) {
properties.push(prop);
};
properties.sort();
i = 0;
for (;i < properties.length;(i = (i + 1))) {
childType = parseType(describeType(object[properties[i]]).@name);
childTarget = ((target + ".") + properties[i]);
if ((((((((((((childType == TYPE_STRING)) || ((childType == TYPE_BOOLEAN)))) || ((childType == TYPE_NUMBER)))) || ((childType == TYPE_INT)))) || ((childType == TYPE_UINT)))) || ((childType == TYPE_FUNCTION)))){
isXML = false;
isXMLString = new XML();
if (childType == TYPE_STRING){
isXMLString = new XML(object[properties[i]]);
if (((!(isXMLString.hasSimpleContent())) && ((isXMLString.children().length() > 0)))){
isXML = true;
};
//unresolved jump
var _slot1 = error;
};
if (!isXML){
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:((((properties[i] + " (") + childType) + ") = ") + printObject(object[properties[i]], childType)), name:properties[i], type:childType, value:printObject(object[properties[i]], childType), target:childTarget, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, true));
} else {
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:(((properties[i] + " (") + childType) + ")"), name:properties[i], type:childType, value:"", target:childTarget, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, false));
xml = (xml + parseXML(isXMLString, ((childTarget + ".") + "cildren()"), currentDepth, maxDepth));
xml = (xml + createNode("/node"));
};
//unresolved jump
var _slot1 = error;
continue;
};
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:(((properties[i] + " (") + childType) + ")"), name:properties[i], type:childType, value:"", target:childTarget, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}));
xml = (xml + parseObject(object[properties[i]], childTarget, functions, (currentDepth + 1), maxDepth));
//unresolved jump
var _slot1 = error;
xml = (xml + createNode("node", {icon:ICON_WARNING, type:TYPE_WARNING, label:"Unreadable", name:"Unreadable"}, true));
};
if (currentDepth == 1){
xml = (xml + createNode("/node"));
};
} else {
if (type == TYPE_XML){
if (currentDepth == 1){
xml = (xml + createNode("node", {icon:ICON_ROOT, label:(("(" + type) + ")"), target:target}));
};
xml = (xml + parseXML(object, ((target + ".") + "cildren()"), currentDepth, maxDepth));
if (currentDepth == 1){
xml = (xml + createNode("/node"));
};
} else {
if (type == TYPE_XMLLIST){
if (currentDepth == 1){
xml = (xml + createNode("node", {icon:ICON_ROOT, label:(("(" + type) + ")"), target:target}));
};
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:(((("length" + " (") + TYPE_UINT) + ") = ") + object.length()), name:"length", type:TYPE_UINT, value:object.length(), target:((target + ".") + "length"), access:ACCESS_VARIABLE, permission:PERMISSION_READONLY}, true));
i = 0;
while (i < object.length()) {
xml = (xml + parseXML(object[i], (((target + ".") + String(i)) + ".children()"), currentDepth, maxDepth));
i = (i + 1);
};
if (currentDepth == 1){
xml = (xml + createNode("/node"));
};
} else {
if ((((((((((type == TYPE_STRING)) || ((type == TYPE_BOOLEAN)))) || ((type == TYPE_NUMBER)))) || ((type == TYPE_INT)))) || ((type == TYPE_UINT)))){
isXML = false;
isXMLString = new XML();
if (type == TYPE_STRING){
isXMLString = new XML(object);
if (((!(isXMLString.hasSimpleContent())) && ((isXMLString.children().length() > 0)))){
isXML = true;
};
//unresolved jump
var _slot1 = error;
};
if (!isXML){
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:((("(" + type) + ") = ") + printObject(object, type)), name:"", type:type, value:printObject(object, type), target:target, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, true));
} else {
xml = (xml + createNode("node", {icon:ICON_VARIABLE, label:(("(" + type) + ")"), name:"", type:type, value:"", target:target, access:ACCESS_VARIABLE, permission:PERMISSION_READWRITE}, false));
xml = (xml + parseXML(isXMLString, ((target + ".") + "cildren()"), currentDepth, maxDepth));
xml = (xml + createNode("/node"));
};
//unresolved jump
var _slot1 = error;
} else {
if (currentDepth == 1){
xml = (xml + createNode("node", {icon:ICON_ROOT, label:(("(" + type) + ")"), target:target}));
};
variables = description..variable;
accessors = description..accessor;
constants = description..constant;
methods = description..method;
variablesArr = new Array();
methodsArr = new Array();
double = false;
permission = "";
icon = "";
double = false;
i = 0;
while (i < variables.length()) {
n = 0;
while (n < variablesArr.length) {
if (variablesArr[n].name == variables[i].@name){
double = true;
break;
};
n = (n + 1);
};
if (!double){
variablesArr.push({name:variables[i].@name, xml:variables[i], access:ACCESS_VARIABLE});
};
i = (i + 1);
};
double = false;
i = 0;
while (i < accessors.length()) {
n = 0;
while (n < variablesArr.length) {
if (variablesArr[n].name == accessors[i].@name){
double = true;
break;
};
n = (n + 1);
};
if (!double){
variablesArr.push({name:accessors[i].@name, xml:accessors[i], access:ACCESS_ACCESSOR});
};
i = (i + 1);
};
double = false;
i = 0;
while (i < constants.length()) {
n = 0;
while (n < variablesArr.length) {
if (variablesArr[n].name == constants[i].@name){
double = true;
break;
};
n = (n + 1);
};
if (!double){
variablesArr.push({name:constants[i].@name, xml:constants[i], access:ACCESS_CONSTANT});
};
i = (i + 1);
};
double = false;
i = 0;
while (i < methods.length()) {
n = 0;
while (n < methodsArr.length) {
if (methodsArr[n].name == methods[i].@name){
double = true;
break;
};
n = (n + 1);
};
if (!double){
methodsArr.push({name:methods[i].@name, xml:methods[i], access:ACCESS_METHOD});
};
i = (i + 1);
};
variablesArr.sortOn("name");
methodsArr.sortOn("name");
i = 0;
for (;i < variablesArr.length;(i = (i + 1))) {
childType = parseType(variablesArr[i].xml.@type);
childName = variablesArr[i].xml.@name;
childTarget = ((target + ".") + childName);
permission = PERMISSION_READWRITE;
icon = ICON_VARIABLE;
if (variablesArr[i].access == ACCESS_CONSTANT){
permission = PERMISSION_READONLY;
icon = ICON_VARIABLE_READONLY;
};
if (variablesArr[i].xml.@access == PERMISSION_READONLY){
permission = PERMISSION_READONLY;
icon = ICON_VARIABLE_READONLY;
};
if (variablesArr[i].xml.@access == PERMISSION_WRITEONLY){
permission = PERMISSION_WRITEONLY;
icon = ICON_VARIABLE_WRITEONLY;
};
//unresolved if
if ((((((((((((childType == TYPE_STRING)) || ((childType == TYPE_BOOLEAN)))) || ((childType == TYPE_NUMBER)))) || ((childType == TYPE_INT)))) || ((childType == TYPE_UINT)))) || ((childType == TYPE_FUNCTION)))){
isXML = false;
isXMLString = new XML();
if (childType == TYPE_STRING){
isXMLString = new XML(object[childName]);
if (((!(isXMLString.hasSimpleContent())) && ((isXMLString.children().length() > 0)))){
isXML = true;
};
//unresolved jump
var _slot1 = error;
};
if (!isXML){
xml = (xml + createNode("node", {icon:icon, label:((((childName + " (") + childType) + ") = ") + printObject(object[childName], childType)), name:childName, type:childType, value:printObject(object[childName], childType), target:childTarget, access:variablesArr[i].access, permission:permission}, true));
} else {
xml = (xml + createNode("node", {icon:icon, label:(((childName + " (") + childType) + ")"), name:childName, type:childType, value:"", target:childTarget, access:variablesArr[i].access, permission:permission}, false));
xml = (xml + parseXML(isXMLString, ((childTarget + ".") + "cildren()"), currentDepth, maxDepth));
xml = (xml + createNode("/node"));
};
//unresolved jump
var _slot1 = error;
continue;
};
xml = (xml + createNode("node", {icon:icon, label:(((childName + " (") + childType) + ")"), name:childName, type:childType, target:childTarget, access:variablesArr[i].access, permission:permission}));
xml = (xml + parseObject(object[childName], childTarget, functions, (currentDepth + 1), maxDepth));
//unresolved jump
var _slot1 = error;
xml = (xml + createNode("node", {icon:ICON_WARNING, type:TYPE_WARNING, label:"Unreadable", name:"Unreadable"}, true));
};
if (functions){
i = 0;
while (i < methodsArr.length) {
childType = TYPE_FUNCTION;
childName = methodsArr[i].xml.@name;
childTarget = ((target + ".") + childName);
returnType = parseType(methodsArr[i].xml.@returnType);
parameters = methodsArr[i].xml..parameter;
args = new Array();
n = 0;
while (n < parameters.length()) {
args.push(parseType(parameters[n].@type));
n = (n + 1);
};
xml = (xml + createNode("node", {icon:ICON_FUNCTION, label:((((childName + "(") + args.join(", ")) + "):") + returnType), args:args.join(", "), name:childName, type:TYPE_FUNCTION, access:variablesArr[i].access, returnType:returnType, target:childTarget}, true));
i = (i + 1);
};
};
if (currentDepth == 1){
xml = (xml + createNode("/node"));
};
};
};
};
};
};
};
//unresolved jump
var _slot1 = error;
msg = "";
msg = (msg + createNode("root"));
msg = (msg + createNode("node", {icon:ICON_WARNING, type:TYPE_WARNING, label:"Not found", name:"Not found"}, true));
msg = (msg + createNode("/root"));
obj = {text:COMMAND_NOTFOUND, target:target, xml:XML(msg)};
if (isConnected){
send(obj);
} else {
sendToBuffer(obj);
};
if (currentDepth == 1){
xml = (xml + createNode("/root"));
};
};
return (xml);
}
protected function getFunctions(object, target:String=""):String{
var description:XML;
var type:String;
var childType:String;
var childName:String;
var childTarget:String;
var methods:XMLList;
var methodsArr:Array;
var returnType:String;
var parameters:XMLList;
var args:Array;
var argsString:String;
var optional:Boolean;
var double:Boolean;
var i:int;
var n:int;
var msg:String;
var obj:Object;
var object = object;
var target = target;
var xml = "";
xml = (xml + createNode("root"));
description = describeType(object);
type = parseType(description.@name);
childType = "";
childName = "";
childTarget = "";
methods = description..method;
methodsArr = new Array();
optional = false;
double = false;
i = 0;
n = 0;
xml = (xml + createNode("node", {icon:ICON_DEFAULT, label:(("(" + type) + ")"), target:target}));
i = 0;
while (i < methods.length()) {
n = 0;
while (n < methodsArr.length) {
if (methodsArr[n].name == methods[i].@name){
double = true;
break;
};
n = (n + 1);
};
if (!double){
methodsArr.push({name:methods[i].@name, xml:methods[i], access:ACCESS_METHOD});
};
i = (i + 1);
};
methodsArr.sortOn("name");
i = 0;
while (i < methodsArr.length) {
childType = TYPE_FUNCTION;
childName = methodsArr[i].xml.@name;
childTarget = ((target + ".") + childName);
returnType = parseType(methodsArr[i].xml.@returnType);
parameters = methodsArr[i].xml..parameter;
args = new Array();
argsString = "";
optional = false;
n = 0;
while (n < parameters.length()) {
if ((((parameters[n].@optional == "true")) && (!(optional)))){
optional = true;
args.push("[");
};
args.push(parseType(parameters[n].@type));
n = (n + 1);
};
if (optional){
args.push("]");
};
argsString = args.join(", ");
argsString = argsString.replace("[, ", "[");
argsString = argsString.replace(", ]", "]");
xml = (xml + createNode("node", {icon:ICON_FUNCTION, label:((((childName + "(") + argsString) + "):") + returnType), args:argsString, name:childName, type:TYPE_FUNCTION, access:ACCESS_METHOD, returnType:returnType, target:childTarget}));
n = 0;
while (n < parameters.length()) {
xml = (xml + createNode("parameter", {type:parseType(parameters[n].@type), index:parameters[n].@index, optional:parameters[n].@optional}, true));
n = (n + 1);
};
xml = (xml + createNode("/node"));
i = (i + 1);
};
xml = (xml + createNode("/node"));
//unresolved jump
var _slot1 = error;
msg = "";
msg = (msg + createNode("root"));
msg = (msg + createNode("node", {icon:ICON_WARNING, type:TYPE_WARNING, label:"Not found", name:"Not found"}, true));
msg = (msg + createNode("/root"));
obj = {text:COMMAND_NOTFOUND, target:target, xml:XML(msg)};
if (isConnected){
send(obj);
} else {
sendToBuffer(obj);
};
xml = (xml + createNode("/root"));
return (xml);
}
public static function get enabled():Boolean{
if (instance == null){
instance = new MonsterDebugger(null);
};
return (instance.isEnabled);
}
public static function snapshot(target:DisplayObject, color:uint=0x111111):void{
if (instance == null){
instance = new MonsterDebugger(null);
};
if (MonsterDebugger.enabled){
instance.snapshotInternal(target, color);
};
}
public static function trace(target:Object, object, color:uint=0x111111, functions:Boolean=false, depth:int=4):void{
if (instance == null){
instance = new MonsterDebugger(target);
};
if (MonsterDebugger.enabled){
instance.traceInternal(target, object, color, functions, depth);
};
}
public static function set enabled(value:Boolean):void{
if (instance == null){
instance = new MonsterDebugger(null);
};
instance.isEnabled = value;
}
public static function inspect(target:Object):void{
var object:*;
var xml:XML;
var obj:Object;
if (((!((instance == null))) && (!((target == null))))){
instance.root = target;
object = instance.getObject("", 0);
if (object != null){
xml = XML(instance.parseObject(object, "", false, 1, 2));
obj = {text:instance.COMMAND_INSPECT, xml:xml};
if (instance.isConnected){
instance.send(obj);
} else {
instance.sendToBuffer(obj);
};
if (instance.isDisplayObject(object)){
xml = XML(instance.parseDisplayObject(object, "", false, 1, 2));
obj = {text:instance.COMMAND_BASE, xml:xml};
if (instance.isConnected){
instance.send(obj);
} else {
instance.sendToBuffer(obj);
};
};
};
};
}
public static function clearTraces():void{
if (instance == null){
instance = new MonsterDebugger(null);
};
if (MonsterDebugger.enabled){
instance.clearTracesInternal();
};
}
}
}//package nl.demonsters.debugger
Section 199
//ExternalAdEvent (uk.co.inbox.ads.events.ExternalAdEvent)
package uk.co.inbox.ads.events {
import flash.events.*;
public class ExternalAdEvent extends Event {
public static const CLICK:String = "externalAdClick";
public static const IMPRESSION:String = "externalAdImpression";
public function ExternalAdEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
override public function toString():String{
return (formatToString("ExternalAdEvent", "type", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new ExternalAdEvent(type, bubbles, cancelable));
}
}
}//package uk.co.inbox.ads.events
Section 200
//AdTransition (uk.co.inbox.ads.AdTransition)
package uk.co.inbox.ads {
public interface AdTransition {
function completeOpen():void;
function startOpen():void;
function startClose():void;
function completeClose():void;
}
}//package uk.co.inbox.ads
Section 201
//AdViewer (uk.co.inbox.ads.AdViewer)
package uk.co.inbox.ads {
import flash.events.*;
import flash.net.*;
import flash.display.*;
import flash.errors.*;
public class AdViewer extends Sprite {
protected var displayList:Array;
protected var isAutoShow:Boolean;
protected var currentAdList:Array;
protected var _currentAd:BaseAd;
public function AdViewer(){
displayList = [];
currentAdList = [];
super();
}
protected function parseAds($xmlDoc:XML):void{
var ad:XML;
var baseAd:BaseAd;
var tag:XML;
currentAdList = [];
for each (ad in $xmlDoc.ads.*) {
baseAd = detectAdType(ad.type);
baseAd.source = XML(ad.source);
if (ad.link != undefined){
baseAd.link = XML(ad.link);
};
for each (tag in ad.tags.*) {
switch (String(tag.@type)){
case "impression":
baseAd.impressionTag = tag;
break;
case "click":
baseAd.clickTag = tag;
break;
};
};
baseAd.xml = ad;
currentAdList.push(baseAd);
};
if (isAutoShow){
showNext();
};
}
private function onXMLLoadSuccess(e:Event):void{
var loader:URLLoader = (e.target as URLLoader);
var xmlDoc:XML = new XML(loader.data);
parseAds(xmlDoc);
}
public function destroy():void{
var baseAd:BaseAd;
var i:int;
while (i < currentAdList.length) {
baseAd = currentAdList[i];
baseAd.destroy();
i++;
};
}
private function onXMLLoadFailure(e:IOErrorEvent):void{
}
public function loadFromXML($file:String="ads.xml", $isAutoShow:Boolean=true):void{
isAutoShow = $isAutoShow;
var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest($file);
loader.addEventListener(Event.COMPLETE, onXMLLoadSuccess);
loader.addEventListener(IOErrorEvent.IO_ERROR, onXMLLoadFailure);
var vars:URLVariables = new URLVariables();
vars.rnd = new Date().getTime();
req.data = vars;
loader.load(req);
}
protected function detectAdType($type:String):BaseAd{
var baseAd:BaseAd;
switch ($type){
case BaseAd.ADTYPE_IMAGE:
baseAd = new ImageAd();
break;
case BaseAd.ADTYPE_SWF:
baseAd = new SwfAd();
break;
};
return (baseAd);
}
public function showNext():void{
throw (new IllegalOperationError("AdViewer.showNext must be overridden"));
}
public function showAd():void{
_currentAd.onImpression();
addChild(_currentAd);
}
public function get currentAd():BaseAd{
return (_currentAd);
}
}
}//package uk.co.inbox.ads
Section 202
//BaseAd (uk.co.inbox.ads.BaseAd)
package uk.co.inbox.ads {
import flash.net.*;
import flash.display.*;
import gs.*;
import uk.co.inbox.tracking.*;
import flash.errors.*;
public class BaseAd extends Sprite implements AdTransition {
protected var _clickTag:XML;
protected var _impressionTag:XML;
protected var _xml:XML;
protected var _link:XML;
protected var status:int;// = 0
protected var _source:XML;
public static const ADTYPE_SWF:String = "swf";
public static const STATUS_LOADED:int = 2;
public static const STATUS_EMPTY:int = 0;
public static const ADTYPE_FLV:String = "flv";
public static const STATUS_LOADING:int = 1;
public static const ADTYPE_IMAGE:String = "image";
public function BaseAd(){
super();
}
public function destroy():void{
}
public function set source(value:XML):void{
_source = value;
}
public function completeClose():void{
}
public function onImpression():void{
if (_impressionTag != null){
InboxTag.callTag(_impressionTag.id, _impressionTag.p1, _impressionTag.p2, _impressionTag.p3, _impressionTag.p4, _impressionTag.p5, _impressionTag.i1, _impressionTag.i2, _impressionTag.i3, _impressionTag.sc);
};
}
public function get link():XML{
return (_link);
}
public function get clickTag():XML{
return (_clickTag);
}
public function startOpen():void{
alpha = 0;
TweenLite.to(this, 1, {alpha:1, onComplete:completeOpen});
}
public function get xml():XML{
return (_xml);
}
public function get source():XML{
return (_source);
}
public function get impressionTag():XML{
return (_impressionTag);
}
public function completeOpen():void{
}
public function load():void{
throw (new IllegalOperationError("BaseAd.load must be overridden"));
}
protected function onClick($target:String="_blank"):void{
if ($target != "_blank"){
$target = _link.@target;
};
if (_clickTag != null){
InboxTag.callTag(_clickTag.id, _clickTag.p1, _clickTag.p2, _clickTag.p3, _clickTag.p4, _clickTag.p5, ((_clickTag.i1 == undefined)) ? NaN : _clickTag.i1, ((_clickTag.i2 == undefined)) ? NaN : _clickTag.i2, ((_clickTag.i3 == undefined)) ? NaN : _clickTag.i3, _clickTag.sc);
};
navigateToURL(new URLRequest(link), $target);
}
public function set xml(value:XML):void{
_xml = value;
}
public function set impressionTag(value:XML):void{
_impressionTag = value;
}
public function set clickTag(value:XML):void{
_clickTag = value;
}
public function startClose():void{
trace("BaseAd.startClose");
alpha = 0;
}
public function set link(value:XML):void{
_link = value;
}
}
}//package uk.co.inbox.ads
Section 203
//ImageAd (uk.co.inbox.ads.ImageAd)
package uk.co.inbox.ads {
import flash.events.*;
import flash.net.*;
import flash.display.*;
public class ImageAd extends BaseAd {
private var loader:Loader;
public function ImageAd(){
super();
}
override public function destroy():void{
loader.unload();
removeChild(loader);
}
override public function load():void{
var url:URLRequest;
if (status == STATUS_EMPTY){
url = new URLRequest(_source);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress, false, 0, true);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
loader.x = _xml.x;
loader.x = _xml.y;
addChild(loader);
loader.load(url);
} else {
if (status == STATUS_LOADED){
dispatchEvent(new Event(Event.COMPLETE));
};
};
}
protected function onComplete(e:Event):void{
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onError);
if (_link != ""){
buttonMode = true;
mouseChildren = false;
addEventListener(MouseEvent.CLICK, onClickAd, false, 0, true);
};
dispatchEvent(e.clone());
}
protected function onError(e:IOErrorEvent):void{
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onError);
dispatchEvent(e.clone());
}
protected function onClickAd(e:MouseEvent):void{
onClick();
}
protected function onProgress(e:ProgressEvent):void{
dispatchEvent(e.clone());
}
}
}//package uk.co.inbox.ads
Section 204
//SequentialAdViewer (uk.co.inbox.ads.SequentialAdViewer)
package uk.co.inbox.ads {
import flash.events.*;
public class SequentialAdViewer extends AdViewer {
protected var _isRandomStart:Boolean;// = false
protected var currentAdId:int;// = -1
protected var _isStarted:Boolean;// = false
public function SequentialAdViewer(){
super();
}
public function get isRandomStart():Boolean{
return (_isRandomStart);
}
public function set isRandomStart(value:Boolean):void{
_isRandomStart = value;
}
private function onAdComplete(e:Event):void{
showAd();
_currentAd.startOpen();
}
override public function showNext():void{
if (!_isStarted){
if (_isRandomStart){
currentAdId = Math.floor((Math.random() * currentAdList.length));
};
};
if (currentAdId == -1){
currentAdId = 0;
} else {
currentAdId++;
if (currentAdId >= currentAdList.length){
currentAdId = 0;
};
};
if (currentAdList[currentAdId] != _currentAd){
if (_currentAd != null){
_currentAd.startClose();
};
_currentAd = currentAdList[currentAdId];
_currentAd.addEventListener(Event.COMPLETE, onAdComplete, false, 0, true);
_currentAd.load();
};
_isStarted = true;
}
}
}//package uk.co.inbox.ads
Section 205
//SwfAd (uk.co.inbox.ads.SwfAd)
package uk.co.inbox.ads {
import flash.events.*;
import flash.net.*;
import flash.display.*;
import uk.co.inbox.ads.events.*;
public class SwfAd extends BaseAd {
private var loader:Loader;
public function SwfAd(){
super();
}
override public function load():void{
var url:URLRequest = new URLRequest(_source);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress, false, 0, true);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
loader.load(url);
addChild(loader);
}
private function onComplete(e:Event):void{
loader.content.addEventListener(ExternalAdEvent.CLICK, onClickAd, false, 0, true);
dispatchEvent(e.clone());
}
private function onError(e:IOErrorEvent):void{
dispatchEvent(e.clone());
}
protected function onClickAd(e:Event):void{
onClick();
}
private function onProgress(e:ProgressEvent):void{
dispatchEvent(e.clone());
}
}
}//package uk.co.inbox.ads
Section 206
//Button2 (uk.co.inbox.buttons.Button2)
package uk.co.inbox.buttons {
import flash.events.*;
import flash.display.*;
public class Button2 extends EventDispatcher {
protected var align:String;// = ""
protected var _textId:String;
protected var contentSprite:Sprite;
protected var isEnabled:Boolean;// = false
public static const CLICK:String = "CLICK";
public function Button2($contentSprite:Sprite, $textId:String="", $align:String="left"){
contentSprite = new Sprite();
super();
contentSprite = $contentSprite;
_textId = $textId;
align = $align;
contentSprite.tabEnabled = false;
if (contentSprite != null){
contentSprite.mouseChildren = false;
};
enable();
}
public function get y():Number{
return (contentSprite.y);
}
public function enable():void{
if (!isEnabled){
isEnabled = true;
contentSprite.buttonMode = true;
contentSprite.addEventListener(MouseEvent.MOUSE_OVER, startRollOver);
contentSprite.addEventListener(MouseEvent.MOUSE_OUT, startRollOut);
contentSprite.addEventListener(MouseEvent.CLICK, submitButton);
};
}
public function get width():Number{
return (contentSprite.width);
}
public function get content():Sprite{
return (contentSprite);
}
protected function startRollOut(e:MouseEvent):void{
}
public function set textId($val:String):void{
_textId = $val;
}
public function get alpha():Number{
return (contentSprite.alpha);
}
public function set visible($val:Boolean):void{
contentSprite.visible = $val;
}
public function get height():Number{
return (contentSprite.height);
}
public function disable():void{
if (isEnabled){
isEnabled = false;
contentSprite.buttonMode = false;
contentSprite.removeEventListener(MouseEvent.MOUSE_OVER, startRollOver);
contentSprite.removeEventListener(MouseEvent.MOUSE_OUT, startRollOut);
contentSprite.removeEventListener(MouseEvent.CLICK, submitButton);
};
}
public function refreshLang():void{
}
protected function submitButton(e:MouseEvent):void{
dispatchEvent(new Event(CLICK));
}
public function get textId():String{
return (_textId);
}
public function set x($val:Number):void{
contentSprite.x = $val;
}
public function get visible():Boolean{
return (contentSprite.visible);
}
public function get x():Number{
return (contentSprite.x);
}
public function set y($val:Number):void{
contentSprite.y = $val;
}
protected function startRollOver(e:MouseEvent):void{
}
public function set alpha($val:Number):void{
contentSprite.alpha = $val;
}
}
}//package uk.co.inbox.buttons
Section 207
//DebugTypes (uk.co.inbox.debug.DebugTypes)
package uk.co.inbox.debug {
public class DebugTypes {
public static const SIMPLE_OUTPUT:String = "simpleOutPut";
public static const COMPLETE_OUTPUT:String = "completeOutPut";
public function DebugTypes(){
super();
}
}
}//package uk.co.inbox.debug
Section 208
//outPut (uk.co.inbox.debug.outPut)
package uk.co.inbox.debug {
import nl.demonsters.debugger.*;
public function outPut($msg=null, $target=null, $level:int=0, $outType:String=null):void{
MonsterDebugger.trace($target, $msg);
switch ($outType){
case DebugTypes.COMPLETE_OUTPUT:
trace(((($target)!=null) ? ($target + " - ") : "" + $msg));
printr($target);
break;
case DebugTypes.SIMPLE_OUTPUT:
trace(((($target)!=null) ? ($target + " - ") : "" + $msg));
default:
trace($msg);
break;
};
}
}//package uk.co.inbox.debug
Section 209
//printr (uk.co.inbox.debug.printr)
package uk.co.inbox.debug {
import flash.text.*;
import flash.display.*;
import flash.utils.*;
public function printr($what, $level:int=1, $key:String=null):void{
var i:*;
if ($key == null){
$key = "======= ReadObject =======";
};
var lvlSt:String = "";
var j:int;
while (j < $level) {
lvlSt = (lvlSt + " ");
j++;
};
var type:String = getQualifiedClassName($what);
if ((((type == "Array")) || ((type == "Object")))){
outPut(((((lvlSt + "[") + $key) + "] => ") + type));
for (i in $what) {
printr($what[i], ($level + 1), i);
};
} else {
if (($what is DisplayObjectContainer)){
if (($what is MovieClip)){
outPut(((((((((lvlSt + "[") + $key) + "] => ") + type) + " -- Frame: ") + $what.currentFrame) + "/") + $what.totalFrames));
} else {
outPut(((((lvlSt + "[") + $key) + "] => ") + type));
};
j = 0;
while (j < $what.numChildren) {
printr($what.getChildAt(j), ($level + 1), type);
j++;
};
} else {
if (($what is TextField)){
outPut(((((((lvlSt + "[") + $key) + "] => ") + $what) + " -- Text: ") + $what.text));
} else {
outPut(((((lvlSt + "[") + $key) + "] => ") + $what));
};
};
};
}
}//package uk.co.inbox.debug
Section 210
//TimelineEvent (uk.co.inbox.events.TimelineEvent)
package uk.co.inbox.events {
import flash.events.*;
public class TimelineEvent extends Event {
public var params:Object;
public static const START:String = "start";
public static const END:String = "end";
public function TimelineEvent(type:String, $params:Object=null){
super(type, bubbles, cancelable);
this.params = $params;
}
override public function toString():String{
return (formatToString("GlobalEvent", "type", "bubbles", "cancelable", "eventPhase", "params"));
}
override public function clone():Event{
return (new TimelineEvent(type, params));
}
}
}//package uk.co.inbox.events
Section 211
//FormEvent (uk.co.inbox.form.events.FormEvent)
package uk.co.inbox.form.events {
import flash.events.*;
import uk.co.inbox.form.*;
public class FormEvent extends Event {
public var element:IFormElement;
public static const FORM_SUBMIT_ERROR:String = "error";
public static const ELEMENT_ERROR:String = "elementError";
public static const ELEMENT_FOCUS:String = "elementFocus";
public static const FORM_SUBMIT_SUCCESS:String = "success";
public static const ELEMENT_SUBMIT:String = "elementSubmit";
public static const ELEMENT_COMPLETE:String = "elementComplete";
public function FormEvent(type:String, element:IFormElement=null, bubbles:Boolean=false, cancelable:Boolean=false){
this.element = element;
super(type, bubbles, cancelable);
}
override public function clone():Event{
return (new FormEvent(type, element, bubbles, cancelable));
}
override public function toString():String{
return (formatToString("FormEvent", "type", "element", "bubbles", "cancelable", "eventPhase"));
}
}
}//package uk.co.inbox.form.events
Section 212
//Form (uk.co.inbox.form.Form)
package uk.co.inbox.form {
import flash.events.*;
import uk.co.inbox.form.events.*;
import uk.co.inbox.debug.*;
public class Form extends EventDispatcher {
private const STATE_DISABLED:int = 0;
private const STATE_ENABLED:int = 1;
private var isDebugMode:Boolean;// = true
private var state:int;// = 1
public var breakOnInvalid:Boolean;// = true
private var elementList:Array;
public static const FOCUS_ELEMENT:String = "focusElement";
public function Form($elementList:Array):void{
var element:FormElement;
super();
elementList = $elementList;
var currentTabIndex = 1;
var i:int;
while (i < elementList.length) {
element = elementList[i];
element.addEventListener(FormEvent.ELEMENT_SUBMIT, submit);
element.addEventListener(FormEvent.ELEMENT_FOCUS, onFocus);
element.addEventListener(FormEvent.ELEMENT_COMPLETE, onComplete);
i++;
};
refreshTabIndex();
}
public function destroy():void{
var element:IFormElement;
for each (element in elementList) {
element.removeEventListener(FormEvent.ELEMENT_SUBMIT, submit);
element.removeEventListener(FormEvent.ELEMENT_FOCUS, onFocus);
element.removeEventListener(FormEvent.ELEMENT_COMPLETE, onComplete);
element.destroy();
};
}
public function enable():void{
state = STATE_ENABLED;
refreshTabIndex();
}
protected function removeTabIndexes():void{
var element:FormElement;
var i:int;
while (i < elementList.length) {
element = elementList[i];
element.setTabIndex(-1);
i++;
};
}
public function reset():void{
var element:IFormElement;
for each (element in elementList) {
element.reset();
};
}
public function addElement($newElement:FormElement, $elementBefore:FormElement=null, $isCheckDuplicate:Boolean=true):void{
var isFound:Boolean;
var i:int;
var checkElement:FormElement;
var isFoundBefore:Boolean;
var checkElement2:FormElement;
var isPush:Boolean;
if ($isCheckDuplicate){
isFound = false;
i = 0;
while (i < elementList.length) {
checkElement = elementList[i];
if (checkElement == $newElement){
isFound = true;
break;
};
i++;
};
if (!isFound){
isPush = true;
};
} else {
isPush = true;
};
if (isPush){
isFoundBefore = false;
i = 0;
while (i < elementList.length) {
checkElement2 = elementList[i];
if (checkElement2 == $elementBefore){
isFoundBefore = true;
elementList.splice(i, 0, $newElement);
$newElement.addEventListener(FormEvent.ELEMENT_SUBMIT, submit);
$newElement.addEventListener(FormEvent.ELEMENT_FOCUS, onFocus);
$newElement.addEventListener(FormEvent.ELEMENT_COMPLETE, onComplete);
break;
};
i++;
};
if (!isFoundBefore){
elementList.push($newElement);
$newElement.addEventListener(FormEvent.ELEMENT_SUBMIT, submit);
$newElement.addEventListener(FormEvent.ELEMENT_FOCUS, onFocus);
$newElement.addEventListener(FormEvent.ELEMENT_COMPLETE, onComplete);
};
};
refreshTabIndex();
}
public function submit(e:Event=null):Boolean{
var isValid:Boolean;
var element:IFormElement;
debugTrace("submit");
var success:Boolean;
if (state == STATE_ENABLED){
isValid = true;
debugTrace((" elementList.length:" + elementList.length));
for each (element in elementList) {
if (!element.validate()){
debugTrace((" bad element - element:" + element));
isValid = false;
if (breakOnInvalid){
break;
};
};
};
if (isValid){
dispatchEvent(new FormEvent(FormEvent.FORM_SUBMIT_SUCCESS));
} else {
dispatchEvent(new FormEvent(FormEvent.FORM_SUBMIT_ERROR, element));
success = false;
};
};
return (success);
}
public function removeElement($doomedElement:FormElement):void{
var checkElement:FormElement;
removeTabIndexes();
var i:int;
while (i < elementList.length) {
checkElement = elementList[i];
if (checkElement == $doomedElement){
$doomedElement.removeEventListener(FormEvent.ELEMENT_SUBMIT, submit);
$doomedElement.removeEventListener(FormEvent.ELEMENT_FOCUS, onFocus);
$doomedElement.removeEventListener(FormEvent.ELEMENT_COMPLETE, onComplete);
elementList.splice(i, 1);
break;
};
i++;
};
refreshTabIndex();
}
public function disable():void{
state = STATE_DISABLED;
removeTabIndexes();
}
public function refreshLang():void{
var i:int;
while (i < elementList.length) {
elementList[i].refreshLang();
i++;
};
}
private function debugTrace($msg):void{
if (isDebugMode){
outPut(((this + ".") + $msg));
};
}
private function onComplete(e:FormEvent):void{
var i:int;
var checkElement:IFormElement;
var targetElement:IFormElement = e.element;
if (targetElement.content.stage != null){
i = 0;
while (i < elementList.length) {
checkElement = elementList[i];
if (checkElement == targetElement){
if (i < (elementList.length - 1)){
targetElement.content.stage.focus = (elementList[(i + 1)] as IFormElement).content;
break;
} else {
targetElement.content.stage.focus = (elementList[0] as IFormElement).content;
break;
};
};
i++;
};
};
}
private function onFocus(e:Event):void{
dispatchEvent(new FormEvent(FormEvent.ELEMENT_FOCUS, (e.target as IFormElement)));
}
protected function refreshTabIndex():void{
var element:FormElement;
var currentTabIndex = 1;
var i:int;
while (i < elementList.length) {
element = elementList[i];
currentTabIndex = element.setTabIndex(currentTabIndex);
i++;
};
}
}
}//package uk.co.inbox.form
Section 213
//FormCustomCheckBox (uk.co.inbox.form.FormCustomCheckBox)
package uk.co.inbox.form {
import flash.events.*;
import uk.co.inbox.form.events.*;
import flash.text.*;
import flash.display.*;
import uk.co.inbox.debug.*;
public class FormCustomCheckBox extends FormElement implements IFormElement {
private var isDebugMode:Boolean;// = false
private var defaultState:Boolean;// = false
private var myCheckBox:MovieClip;
private var isRequired:Boolean;// = false
private var myTextLabel:TextField;
private static const FRAME_SELECTED:int = 2;
private static const FRAME_ERROR:int = 3;
private static const FRAME_UNSELECTED:int = 1;
public static const SELECTED:String = "select";
public static const DESELECTED:String = "deselect";
public function FormCustomCheckBox($checkBox:MovieClip, $textLabel:TextField=null, $defaultState:Boolean=false, $isRequired:Boolean=false):void{
super();
myCheckBox = $checkBox;
myTextLabel = $textLabel;
isRequired = $isRequired;
defaultState = $defaultState;
if ($defaultState){
myCheckBox.gotoAndStop(FRAME_SELECTED);
};
myCheckBox.buttonMode = true;
myCheckBox.addEventListener(FocusEvent.FOCUS_IN, onFocusIn, false, 0, true);
myCheckBox.addEventListener(FocusEvent.FOCUS_OUT, onFocusOut, false, 0, true);
myCheckBox.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
if (myTextLabel){
myTextLabel.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
};
myCheckBox.addEventListener(KeyboardEvent.KEY_UP, onKeyUp, false, 0, true);
}
public function get content(){
return (myCheckBox);
}
private function onKeyUp(e:KeyboardEvent):void{
if (e.keyCode == 32){
onClick();
};
}
override public function setTabIndex($tabIndex:int):int{
myCheckBox.tabIndex = $tabIndex;
return (($tabIndex + 1));
}
public function reset():void{
myCheckBox.gotoAndStop((defaultState) ? FRAME_SELECTED : FRAME_UNSELECTED);
}
private function onFocusOut(e:FocusEvent):void{
var e = e;
myCheckBox.focus.gotoAndStop(1);
//unresolved jump
var _slot1 = e;
}
public function validate():Boolean{
myCheckBox.stage.focus = null;
if (isRequired){
if (myCheckBox.currentFrame == FRAME_SELECTED){
return (true);
};
setInvalid();
dispatchEvent(new FormEvent(FormEvent.ELEMENT_ERROR));
return (false);
//unresolved jump
};
return (true);
}
private function onClick(e:MouseEvent=null):void{
if (myCheckBox.currentFrame == FRAME_SELECTED){
dispatchEvent(new Event(DESELECTED));
myCheckBox.gotoAndStop(FRAME_UNSELECTED);
} else {
dispatchEvent(new Event(SELECTED));
myCheckBox.gotoAndStop(FRAME_SELECTED);
};
}
public function get value(){
if (myCheckBox.currentFrame == FRAME_SELECTED){
return (1);
};
return (0);
}
private function debugTrace($msg):void{
if (isDebugMode){
outPut(((this + " - ") + $msg));
};
}
private function setInvalid():void{
myCheckBox.gotoAndStop(FRAME_ERROR);
}
public function destroy():void{
myCheckBox.removeEventListener(FocusEvent.FOCUS_IN, onFocusIn, false);
myCheckBox.removeEventListener(FocusEvent.FOCUS_OUT, onFocusOut, false);
myCheckBox.removeEventListener(MouseEvent.CLICK, onClick, false);
myCheckBox.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp, false);
}
private function onFocusIn(e:FocusEvent):void{
var e = e;
myCheckBox.focus.gotoAndStop(2);
//unresolved jump
var _slot1 = e;
}
}
}//package uk.co.inbox.form
Section 214
//FormElement (uk.co.inbox.form.FormElement)
package uk.co.inbox.form {
import flash.events.*;
import uk.co.inbox.form.events.*;
public class FormElement extends EventDispatcher {
public function FormElement():void{
super();
}
public function refreshLang():void{
}
protected function onGainFocus(e:FocusEvent=null):void{
dispatchEvent(new FormEvent(FormEvent.ELEMENT_FOCUS, (this as IFormElement)));
}
public function setTabIndex($tabIndex:int):int{
return ($tabIndex);
}
}
}//package uk.co.inbox.form
Section 215
//FormPasswordConfirmField (uk.co.inbox.form.FormPasswordConfirmField)
package uk.co.inbox.form {
import flash.events.*;
import flash.text.*;
import uk.co.inbox.language.*;
public class FormPasswordConfirmField extends FormTextConfirmField {
public function FormPasswordConfirmField($textField:TextField, $matchingField:FormTextField, $validationType:String, $defaultText:String="", $defaultInvalidText:String="", $fieldId:String="", $isRequired:Boolean=true, $minimumLength:int=0, $maximumLength:int=0, $invalidColour:uint=0xFF0000, $isKeyboardEnabled:Boolean=true, $isShowErrorInField:Boolean=true):void{
super($textField, $matchingField, $validationType, $defaultText, $defaultInvalidText, $fieldId, $isRequired, $minimumLength, $maximumLength, $invalidColour, $isKeyboardEnabled, $isShowErrorInField);
}
override protected function onGainFocus(e:FocusEvent=null):void{
super.onGainFocus(e);
myTextField.displayAsPassword = true;
}
override protected function onLoseFocus(e:FocusEvent):void{
super.onLoseFocus(e);
myTextField.displayAsPassword = !((myTextField.text == getText(defaultTextId)));
}
override public function validate():Boolean{
return (super.validate());
}
override public function setInvalid($errorTextId:String=""):void{
super.setInvalid($errorTextId);
myTextField.displayAsPassword = false;
}
}
}//package uk.co.inbox.form
Section 216
//FormPasswordField (uk.co.inbox.form.FormPasswordField)
package uk.co.inbox.form {
import flash.events.*;
import uk.co.inbox.form.events.*;
import flash.text.*;
import uk.co.inbox.language.*;
import uk.co.inbox.utils.*;
public class FormPasswordField extends FormTextField {
public function FormPasswordField($textField:TextField, $validationType:String, $defaultText:String="", $defaultInvalidTextId:String="", $fieldId:String="", $isRequired:Boolean=true, $minimumLength:int=0, $maximumLength:int=0, $invalidColour:uint=0xFF0000, $isKeyboardEnabled:Boolean=true, $isShowErrorInField:Boolean=true):void{
super($textField, $validationType, $defaultText, $defaultInvalidTextId, $fieldId, $isRequired, $minimumLength, $maximumLength, $invalidColour, $isKeyboardEnabled, $isShowErrorInField);
}
override protected function onGainFocus(e:FocusEvent=null):void{
super.onGainFocus(e);
myTextField.displayAsPassword = true;
}
override protected function onLoseFocus(e:FocusEvent):void{
super.onLoseFocus(e);
myTextField.displayAsPassword = !((myTextField.text == getText(defaultTextId)));
}
override public function validate():Boolean{
var validationResult:String;
myTextField.stage.focus = null;
myTextField.text = Validation.trimText(myTextField.text);
debugTrace(("validate - myTextField.text:" + myTextField.text));
if (isRequired){
if ((((myTextField.text == getText(defaultTextId))) && (!((defaultTextId == ""))))){
setInvalid(defaultTextId);
dispatchEvent(new FormEvent(FormEvent.ELEMENT_ERROR));
return (false);
};
validationResult = Validation.validateText(myTextField.text, minimumLength);
if (validationResult == Validation.RESULT_SUCCESS){
return (true);
};
if (!isRequired){
if (myTextField.text == defaultTextId){
return (true);
};
};
if (((LangContent.checkValidText(validationResult)) || ((defaultInvalidTextId == "")))){
setInvalid(validationResult);
} else {
setInvalid();
};
dispatchEvent(new FormEvent(FormEvent.ELEMENT_ERROR));
return (false);
//unresolved jump
};
return (true);
}
override public function setInvalid($errorTextId:String=""):void{
super.setInvalid($errorTextId);
myTextField.displayAsPassword = false;
}
}
}//package uk.co.inbox.form
Section 217
//FormTextConfirmField (uk.co.inbox.form.FormTextConfirmField)
package uk.co.inbox.form {
import flash.events.*;
import uk.co.inbox.form.events.*;
import flash.text.*;
import uk.co.inbox.language.*;
import uk.co.inbox.utils.*;
public class FormTextConfirmField extends FormTextField {
private var matchingField:FormTextField;
public function FormTextConfirmField($textField:TextField, $matchingField:FormTextField, $validationType:String, $defaultText:String="", $defaultInvalidText:String="", $fieldId:String="", $isRequired:Boolean=true, $minimumLength:int=0, $maximumLength:int=0, $invalidColour:uint=0xFF0000, $isKeyboardEnabled:Boolean=true, $isShowErrorInField:Boolean=true){
matchingField = $matchingField;
super($textField, $validationType, $defaultText, $defaultInvalidText, $fieldId, $isRequired, $minimumLength, $maximumLength, $invalidColour, $isKeyboardEnabled, $isShowErrorInField);
}
override protected function onLoseFocus(e:FocusEvent):void{
super.onLoseFocus(e);
}
override public function validate():Boolean{
var validationResult:String;
myTextField.stage.focus = null;
myTextField.text = Validation.trimText(myTextField.text);
if ((((myTextField.text == getText(defaultTextId))) && (!((defaultTextId == ""))))){
setInvalid(defaultTextId);
dispatchEvent(new FormEvent(FormEvent.ELEMENT_ERROR));
return (false);
};
validationResult = Validation.validateCompareText(myTextField.text, matchingField.text);
if (validationResult == Validation.RESULT_SUCCESS){
return (true);
};
if (!isRequired){
if (myTextField.text == defaultTextId){
return (true);
};
};
if (((LangContent.checkValidText(validationResult)) || ((defaultInvalidTextId == "")))){
setInvalid(validationResult);
} else {
setInvalid();
};
dispatchEvent(new FormEvent(FormEvent.ELEMENT_ERROR));
return (false);
}
override protected function onGainFocus(e:FocusEvent=null):void{
super.onGainFocus(e);
}
override public function setInvalid($errorTextId:String=""):void{
super.setInvalid($errorTextId);
}
}
}//package uk.co.inbox.form
Section 218
//FormTextField (uk.co.inbox.form.FormTextField)
package uk.co.inbox.form {
import flash.events.*;
import uk.co.inbox.form.events.*;
import flash.text.*;
import uk.co.inbox.language.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.debug.*;
import flash.ui.*;
public class FormTextField extends FormElement implements IFormElement {
protected var myTextField:TextField;
protected var isDebugMode:Boolean;// = true
protected var minimumLength:int;
public var isAutoTabOnCompletion:Boolean;// = false
protected var isShowErrorInField:Boolean;// = true
protected var oldInvalidText:String;
protected var invalidColour:uint;
protected var _currentInvalidText:String;
protected var fieldId:String;
protected var defaultInvalidTextId:String;
protected var defaultTextId:String;
protected var isKeyboardEnabled:Boolean;// = true
protected var validationType:String;
protected var _currentInvalidTextId:String;
protected var oldDefaultText:String;// = ""
protected var defaultColour:uint;
protected var isInvalid:Boolean;// = false
protected var isRequired:Boolean;
public static const VALIDATION_PASSWORD:String = "validationPassword";
public static const VALIDATION_POSTCODE:String = "validationPostcode";
public static const VALIDATION_EMAIL:String = "validationEmail";
public static const VALIDATION_TEXT:String = "validationText";
public function FormTextField($textField:TextField, $validationType:String, $defaultTextId:String="", $defaultInvalidTextId:String="", $fieldId:String="", $isRequired:Boolean=true, $minimumLength:int=0, $maximumLength:int=0, $invalidColour:uint=0xFF0000, $isKeyboardEnabled:Boolean=true, $isShowErrorInField:Boolean=true):void{
super();
myTextField = $textField;
validationType = $validationType;
defaultInvalidTextId = $defaultInvalidTextId;
defaultTextId = $defaultTextId;
fieldId = $fieldId;
isRequired = $isRequired;
isKeyboardEnabled = $isKeyboardEnabled;
isShowErrorInField = $isShowErrorInField;
minimumLength = $minimumLength;
if (isRequired){
if (minimumLength == 0){
minimumLength = 1;
};
};
if ($maximumLength != 0){
myTextField.maxChars = $maximumLength;
};
invalidColour = $invalidColour;
defaultColour = myTextField.textColor;
if (defaultTextId != ""){
oldDefaultText = (myTextField.text = getText(defaultTextId));
};
myTextField.addEventListener(FocusEvent.FOCUS_IN, onGainFocus, false, 0, true);
myTextField.addEventListener(FocusEvent.FOCUS_OUT, onLoseFocus, false, 0, true);
myTextField.addEventListener(Event.CHANGE, onChangeContent, false, 0, true);
myTextField.addEventListener(KeyboardEvent.KEY_UP, onSubmit, false, 0, true);
}
public function get currentInvalidTextId():String{
return (_currentInvalidTextId);
}
override protected function onGainFocus(e:FocusEvent=null):void{
if (myTextField.text == _currentInvalidText){
isInvalid = false;
myTextField.text = ((oldInvalidText)!=null) ? oldInvalidText : "";
};
if (defaultTextId != ""){
if (myTextField.text == getText(defaultTextId)){
myTextField.text = "";
};
};
myTextField.textColor = defaultColour;
super.onGainFocus();
}
private function onChangeContent(e:Event):void{
if (isAutoTabOnCompletion){
if (myTextField.length == myTextField.maxChars){
dispatchEvent(new FormEvent(FormEvent.ELEMENT_COMPLETE, this));
};
};
}
public function get currentInvalidText():String{
return (_currentInvalidText);
}
public function validate():Boolean{
var validationResult:String;
myTextField.stage.focus = null;
myTextField.text = Validation.trimText(myTextField.text);
debugTrace(("validate - myTextField.text:" + myTextField.text));
if (isRequired){
if ((((myTextField.text == getText(defaultTextId))) && (!((defaultTextId == ""))))){
debugTrace("invalid 1");
setInvalid(((defaultInvalidTextId)!="") ? defaultInvalidTextId : defaultTextId);
dispatchEvent(new FormEvent(FormEvent.ELEMENT_ERROR, this));
return (false);
} else {
if (isInvalid){
debugTrace("invalid 2");
dispatchEvent(new FormEvent(FormEvent.ELEMENT_ERROR, this));
return (false);
};
switch (validationType){
case VALIDATION_EMAIL:
validationResult = Validation.validateEmail(myTextField.text);
break;
case VALIDATION_POSTCODE:
validationResult = Validation.validatePostcode(myTextField.text);
break;
default:
validationResult = Validation.validateText(myTextField.text, minimumLength);
break;
};
debugTrace(("validate - validationResult:" + validationResult));
if (validationResult == Validation.RESULT_SUCCESS){
return (true);
};
if (!isRequired){
if (myTextField.text == defaultTextId){
return (true);
};
};
if (LangContent.checkValidText(validationResult)){
setInvalid(validationResult);
} else {
setInvalid();
};
dispatchEvent(new FormEvent(FormEvent.ELEMENT_ERROR, this));
return (false);
};
//unresolved jump
};
return (true);
}
protected function onLoseFocus(e:FocusEvent):void{
if (myTextField.text == ""){
if (defaultTextId != ""){
myTextField.text = getText(defaultTextId);
};
};
myTextField.textColor = defaultColour;
}
public function get text():String{
if (defaultTextId != ""){
if (myTextField.text == getText(defaultTextId)){
return ("");
};
return (myTextField.text);
//unresolved jump
};
return (myTextField.text);
}
protected function debugTrace($msg):void{
if (isDebugMode){
outPut(((this + " - ") + $msg));
};
}
public function setInvalid($errorTextId:String=""):void{
debugTrace(("setInvalid - $errorTextId:" + $errorTextId));
_currentInvalidTextId = $errorTextId;
var errStr:String = (($errorTextId)!="") ? getText($errorTextId) : getText(defaultInvalidTextId);
_currentInvalidText = errStr.split("<field>").join(getText(fieldId));
if (isShowErrorInField){
isInvalid = true;
myTextField.text = currentInvalidText;
myTextField.textColor = invalidColour;
};
}
override public function setTabIndex($tabIndex:int):int{
myTextField.tabEnabled = true;
myTextField.tabIndex = $tabIndex;
return (($tabIndex + 1));
}
public function reset():void{
myTextField.textColor = defaultColour;
if (defaultTextId != ""){
oldDefaultText = (myTextField.text = getText(defaultTextId));
} else {
myTextField.text = "";
};
}
protected function onSubmit(e:KeyboardEvent):void{
if (isKeyboardEnabled){
if (e.keyCode == Keyboard.ENTER){
dispatchEvent(new FormEvent(FormEvent.ELEMENT_SUBMIT));
};
};
}
override public function refreshLang():void{
if (defaultTextId != ""){
if (myTextField.text == oldDefaultText){
oldDefaultText = (myTextField.text = getText(defaultTextId));
};
};
}
public function setIsRequired(b:Boolean=true):void{
isRequired = false;
}
public function get value(){
if (!isRequired){
if (myTextField.text == defaultTextId){
return ("");
};
return (myTextField.text);
//unresolved jump
};
return (myTextField.text);
}
public function set text($val:String):void{
myTextField.text = $val;
}
public function get content(){
return (myTextField);
}
public function destroy():void{
myTextField.removeEventListener(FocusEvent.FOCUS_IN, onGainFocus);
myTextField.removeEventListener(FocusEvent.FOCUS_OUT, onLoseFocus);
myTextField.removeEventListener(KeyboardEvent.KEY_UP, onSubmit);
}
}
}//package uk.co.inbox.form
Section 219
//IFormElement (uk.co.inbox.form.IFormElement)
package uk.co.inbox.form {
import flash.events.*;
public interface IFormElement extends IEventDispatcher {
function get content();
function get value();
function validate():Boolean;
function refreshLang():void;
function destroy():void;
function reset():void;
function setTabIndex(uk.co.inbox.form:IFormElement/uk.co.inbox.form:IFormElement:refreshLang:int):int;
}
}//package uk.co.inbox.form
Section 220
//Level (uk.co.inbox.game.levels.Level)
package uk.co.inbox.game.levels {
import flash.events.*;
public class Level extends EventDispatcher {
private var _id:int;
public function Level(){
super();
}
public function set id(value:int):void{
_id = value;
}
public function get idLabel():int{
return ((_id + 1));
}
public function get id():int{
return (_id);
}
}
}//package uk.co.inbox.game.levels
Section 221
//LevelManager (uk.co.inbox.game.levels.LevelManager)
package uk.co.inbox.game.levels {
public class LevelManager {
protected var currentLevelId:int;// = 0
protected var _levelList:Array;
public function LevelManager(){
_levelList = [];
super();
}
public function setLevel($index:int):void{
if ($index < levelList.length){
currentLevelId = $index;
};
}
private function resetLevelIds():void{
var level:Level;
var i:int;
while (i < _levelList.length) {
level = _levelList[i];
level.id = (i + 1);
i++;
};
}
public function get isLastLevel():Boolean{
return ((currentLevelId == (_levelList.length - 1)));
}
public function get levelList():Array{
return (_levelList.slice());
}
public function addLevel($level:Level):void{
$level.id = _levelList.length;
_levelList.push($level);
}
public function get currentLevel():Level{
return (_levelList[currentLevelId]);
}
public function reset():void{
currentLevelId = 0;
}
public function decrement():void{
currentLevelId--;
if (currentLevelId < 0){
currentLevelId = 0;
};
}
public function addLevelAt($level:Level, $index:int):void{
if ($index > _levelList.length){
$index = (_levelList.length - 1);
};
_levelList.splice($index, 1, $level);
resetLevelIds();
}
public function get totalLevels():Number{
return (_levelList.length);
}
public function increment():void{
currentLevelId++;
if (currentLevelId >= _levelList.length){
currentLevelId = _levelList.length;
};
}
}
}//package uk.co.inbox.game.levels
Section 222
//GameSpriteRender (uk.co.inbox.game.render.objects.GameSpriteRender)
package uk.co.inbox.game.render.objects {
import flash.events.*;
import flash.display.*;
public class GameSpriteRender extends Sprite {
public static const DESTROY:String = "destroy";
public function GameSpriteRender(){
super();
}
public function update():void{
}
public function destroy():void{
dispatchEvent(new Event(DESTROY));
}
}
}//package uk.co.inbox.game.render.objects
Section 223
//GVector (uk.co.inbox.game.render.vector.GVector)
package uk.co.inbox.game.render.vector {
public class GVector {
public var _x:Number;
public var _y:Number;
public var _z:Number;
public function GVector(x:Number, y:Number, z:Number){
super();
_x = x;
_y = y;
_z = z;
}
public function subtractV(a:GVector):void{
_x = (_x - a._x);
_y = (_y - a._y);
_z = (_z - a._z);
}
public function getInverseV():GVector{
return (new GVector(-(_x), -(_y), -(_z)));
}
public function rotateOX(deg:Number):void{
var ay:Number = _y;
var az:Number = _z;
_y = ((ay * Math.cos(((deg * Math.PI) / 180))) - (az * Math.sin(((deg * Math.PI) / 180))));
_z = ((ay * Math.sin(((deg * Math.PI) / 180))) + (az * Math.cos(((deg * Math.PI) / 180))));
}
public function rotateOY(deg:Number):void{
var ax:Number = _x;
var az:Number = _z;
_x = ((ax * Math.cos(((deg * Math.PI) / 180))) + (az * Math.sin(((deg * Math.PI) / 180))));
_z = ((az * Math.cos(((deg * Math.PI) / 180))) - (ax * Math.sin(((deg * Math.PI) / 180))));
}
public function inverseV():void{
_x = -(_x);
_y = -(_y);
_z = -(_z);
}
public function clearV():void{
_x = 0;
_y = 0;
_z = 0;
}
public function duplicate():GVector{
return (new GVector(_x, _y, _z));
}
public function scaleV(a:Number):void{
_x = (_x * a);
_y = (_y * a);
_z = (_z * a);
}
public function normalize():void{
var amag:Number = magnitude();
if (amag <= 0){
_x = 0;
_y = 0;
_z = 0;
} else {
_x = (_x / amag);
_y = (_y / amag);
_z = (_z / amag);
};
}
public function put():void{
trace((((((("GVector( " + _x) + ", ") + _y) + ", ") + _z) + ")"));
}
public function magnitude():Number{
return (Math.sqrt((((_x * _x) + (_y * _y)) + (_z * _z))));
}
public function addV(a:GVector):void{
_x = (_x + a._x);
_y = (_y + a._y);
_z = (_z + a._z);
}
public function distanceTo(to:GVector):Number{
return (Math.sqrt(((((_x - to._x) * (_x - to._x)) + ((_y - to._y) * (_y - to._y))) + ((_z - to._z) * (_z - to._z)))));
}
public function interpolateTo(to:GVector, per:Number):void{
_x = (_x + ((per * (-(_x) + to._x)) / 100));
_y = (_y + ((per * (-(_y) + to._y)) / 100));
_z = (_z + ((per * (-(_z) + to._z)) / 100));
}
}
}//package uk.co.inbox.game.render.vector
Section 224
//GWorld (uk.co.inbox.game.render.vector.GWorld)
package uk.co.inbox.game.render.vector {
import flash.display.*;
public class GWorld {
public const XZ_RATIO:Number = 37;
private var displaceY:Number;// = -2
private var displayscale:Number;// = 34.2
private var eP:Number;// = 1.5
public var xzS:Number;// = 12
public var yzS:Number;// = 20
private var wScale:Number;// = 50
private var centreX:Number;
private var centreY:Number;
public var xyS:Number;// = 2
public function GWorld(EP:Number, $wScale:Number, $centreX:Number, $centreY:Number):void{
super();
eP = EP;
wScale = $wScale;
centreX = $centreX;
centreY = $centreY;
}
public function getX(ax:Number, vz:Number):Number{
return (((vz * ax) - ((centreX / wScale) * eP)));
}
public function getY(ay:Number, vz:Number):Number{
return (((vz * ay) - ((centreY / wScale) * eP)));
}
public function getZDist(az:Number, bx:Number):Number{
return (Math.sqrt(((az * az) + (bx * bx))));
}
public function textFrustrum(mc:Sprite, l:Number, r:Number, t:Number, b:Number, n:Number, f:Number, inter:Number, drawme:Boolean):void{
var a:int;
var spos:Object;
var npos:Object;
var apos:Object;
trace("textFrustrum");
var sx:Number = l;
var gapx:Number = ((r - l) / inter);
var sy:Number = t;
var gapy:Number = ((b - t) / inter);
var sz:Number = n;
var gapz:Number = ((f - n) / inter);
mc.graphics.clear();
mc.graphics.lineStyle(1, 39372, 30);
a = 0;
while (a < inter) {
spos = getPosition(new GVector(sx, sy, (sz + (a * gapz))));
mc.graphics.moveTo(spos._x, spos._y);
npos = getPosition(new GVector((sx + (gapx * inter)), sy, (sz + (a * gapz))));
if (drawme == true){
mc.graphics.lineTo(npos._x, npos._y);
};
a++;
};
a = 0;
while (a < inter) {
spos = getPosition(new GVector(sx, sy, (sz + (a * gapz))));
mc.graphics.moveTo(spos._x, spos._y);
apos = getPosition(new GVector(sx, (sy + (gapy * inter)), (sz + (a * gapz))));
if (drawme == true){
mc.graphics.lineTo(apos._x, apos._y);
};
a++;
};
a = 0;
while (a < inter) {
apos = getPosition(new GVector((sx + (gapx * inter)), sy, (sz + (a * gapz))));
mc.graphics.moveTo(apos._x, apos._y);
apos = getPosition(new GVector((sx + (gapx * inter)), (sy + (gapy * inter)), (sz + (a * gapz))));
if (drawme == true){
mc.graphics.lineTo(apos._x, apos._y);
};
a++;
};
}
public function getScale(az:Number):Number{
return (((wScale * eP) / az));
}
public function getZY(fy:Number, ay:Number):Number{
return (((((fy * wScale) * eP) / ay) - centreY));
}
public function getZX(fx:Number, ax:Number):Number{
return (((((fx * wScale) * eP) / ax) - centreX));
}
private function getZFromScale(sc:Number):Number{
return ((eP / (sc / wScale)));
}
public function getPosition(av:GVector):Object{
var ret:Object = new Object();
var scale:Number = getScale(av._z);
ret._x = ((av._x * scale) + centreX);
ret._y = (((av._y * scale) + centreY) - ((displaceY * scale) * displayscale));
ret._scale = (scale * displayscale);
return (ret);
}
public function drawBezier(p1:Object, a1:Object, p2:Object, a2:Object, iteration:Number, detail:Number):Object{
var x1:Number = p1._x;
var y1:Number = p1._y;
var x2:Number = a1._x;
var y2:Number = a1._y;
var x3:Number = a2._x;
var y3:Number = a2._y;
var x4:Number = p2._x;
var y4:Number = p2._y;
var cx:Number = (3 * (x2 - x1));
var cy:Number = (3 * (y2 - y1));
var bx:Number = ((3 * (x3 - x2)) - cx);
var by:Number = ((3 * (y3 - y2)) - cy);
var ax:Number = (((x4 - x1) - cx) - bx);
var ay:Number = (((y4 - y1) - cy) - by);
var i:Number = iteration;
var numspring:Number = detail;
var returnObj:Object = new Object();
var t1:Number = (i / numspring);
var t2:Number = (t1 * t1);
var t3:Number = (t2 * t1);
returnObj._x = ((((ax * t3) + (bx * t2)) + (cx * t1)) + x1);
returnObj._y = ((((ay * t3) + (by * t2)) + (cy * t1)) + y1);
return (returnObj);
}
public function getVector($mouseX:int, $mouseY:int, vectorY:Number):Object{
var sc:Number = (($mouseY - centreY) / (vectorY - (displaceY * displayscale)));
var z:Number = getZFromScale(sc);
var x:Number = (($mouseX - centreX) / sc);
return ({_x:x, _y:0, _z:z});
}
}
}//package uk.co.inbox.game.render.vector
Section 225
//GameRenderer (uk.co.inbox.game.render.GameRenderer)
package uk.co.inbox.game.render {
import flash.events.*;
import flash.display.*;
import uk.co.inbox.game.render.objects.*;
public class GameRenderer extends Sprite {
protected var spriteHolder:Sprite;
protected var spriteList:Array;
public function GameRenderer(){
spriteList = [];
super();
spriteHolder = new Sprite();
addChild(spriteHolder);
}
public function addContent($newContent:GameSpriteRender):void{
$newContent.addEventListener(GameSpriteRender.DESTROY, onObjectDestroyed, false, 0, true);
spriteHolder.addChild($newContent);
spriteList.push($newContent);
}
public function update():void{
var updateRender:GameSpriteRender;
var len:int = spriteList.length;
var i:int;
while (i < spriteList.length) {
updateRender = spriteList[i];
updateRender.update();
i++;
};
}
protected function onObjectDestroyed(e:Event):GameSpriteRender{
var doomedRender:GameSpriteRender = (e.target as GameSpriteRender);
if (spriteHolder.contains(doomedRender)){
spriteHolder.removeChild(doomedRender);
};
var i:int;
while (i < spriteList.length) {
if (spriteList[i] == doomedRender){
spriteList.splice(i, 1);
break;
};
i++;
};
return (doomedRender);
}
public function destroy():void{
var doomedRender:GameSpriteRender;
var len:int = spriteList.length;
var i:int;
while (i < len) {
doomedRender = spriteList[i];
doomedRender.destroy();
i++;
};
}
}
}//package uk.co.inbox.game.render
Section 226
//GameChangeScoreEvent (uk.co.inbox.game.score.events.GameChangeScoreEvent)
package uk.co.inbox.game.score.events {
import flash.events.*;
public class GameChangeScoreEvent extends GameScoreEvent {
public var addScore:Number;
public static const DECREASE_SCORE:String = "decreaseScore";
public static const ADD_SCORE:String = "addScore";
public function GameChangeScoreEvent(type:String, $currentScore:Number, $addScore:Number=0, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, $currentScore, bubbles, cancelable);
currentScore = $currentScore;
addScore = $addScore;
}
override public function toString():String{
return (formatToString("GameChangeScoreEvent", "type", "currentScore", "addScore", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new GameChangeScoreEvent(type, currentScore, addScore, bubbles, cancelable));
}
}
}//package uk.co.inbox.game.score.events
Section 227
//GameScoreEvent (uk.co.inbox.game.score.events.GameScoreEvent)
package uk.co.inbox.game.score.events {
import flash.events.*;
public class GameScoreEvent extends Event {
public var currentScore:Number;
public static const UPDATE:String = "update";
public function GameScoreEvent(type:String, $currentScore:Number, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
currentScore = $currentScore;
}
override public function toString():String{
return (formatToString("GameScoreEvent", "type", "currentScore", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new GameScoreEvent(type, currentScore, bubbles, cancelable));
}
}
}//package uk.co.inbox.game.score.events
Section 228
//TargetGameScoreEvent (uk.co.inbox.game.score.events.TargetGameScoreEvent)
package uk.co.inbox.game.score.events {
import flash.events.*;
public class TargetGameScoreEvent extends GameScoreEvent {
public var targetScore:Number;
public static const TARGET_OVERSHOT:String = "targetOverShot";
public static const TARGET_HIT:String = "targetHit";
public function TargetGameScoreEvent(type:String, $currentScore:Number, $targetScore:Number, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, $currentScore, bubbles, cancelable);
targetScore = $targetScore;
}
override public function toString():String{
return (formatToString("TargetGameScoreEvent", "type", "currentScore", "targetScore", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new TargetGameScoreEvent(type, currentScore, targetScore, bubbles, cancelable));
}
}
}//package uk.co.inbox.game.score.events
Section 229
//GameScore (uk.co.inbox.game.score.GameScore)
package uk.co.inbox.game.score {
import flash.events.*;
import uk.co.inbox.game.score.events.*;
public class GameScore extends EventDispatcher {
protected var _score:Number;// = 0
protected var _defaultScore:Number;// = 0
public function GameScore(){
super();
}
protected function changeScore($newScore:Number):void{
_score = $newScore;
updateScore();
}
public function incrementScore($changeAmount:Number):void{
_score = (_score + $changeAmount);
dispatchEvent(new GameChangeScoreEvent(GameChangeScoreEvent.ADD_SCORE, _score, $changeAmount));
updateScore();
}
protected function updateScore():void{
dispatchEvent(new GameScoreEvent(GameScoreEvent.UPDATE, _score));
}
public function resetScore():void{
_score = _defaultScore;
}
public function get score():Number{
return (_score);
}
public function setDefaultScore($defaultScore:Number):void{
_score = (_defaultScore = $defaultScore);
}
public function decrementScore($changeAmount:Number):void{
_score = (_score - $changeAmount);
dispatchEvent(new GameChangeScoreEvent(GameChangeScoreEvent.DECREASE_SCORE, _score, $changeAmount));
updateScore();
}
}
}//package uk.co.inbox.game.score
Section 230
//TargetGameScore (uk.co.inbox.game.score.TargetGameScore)
package uk.co.inbox.game.score {
import uk.co.inbox.game.score.events.*;
public class TargetGameScore extends GameScore {
protected var _targetScore:Number;
protected var _targetType:int;// = 0
protected var _isExact:Boolean;// = false
public static const TARGET_TYPE_POSITIVE:int = 0;
public static const TARGET_TYPE_NEGATIVE:int = 1;
public function TargetGameScore(){
super();
}
public function get targetScore():Number{
return (_targetScore);
}
override protected function updateScore():void{
super.updateScore();
if (_targetType == TARGET_TYPE_POSITIVE){
if (_isExact){
if (_score == _targetScore){
dispatchEvent(new TargetGameScoreEvent(TargetGameScoreEvent.TARGET_HIT, _score, _targetScore));
};
} else {
if (_score >= _targetScore){
dispatchEvent(new TargetGameScoreEvent(TargetGameScoreEvent.TARGET_HIT, _score, _targetScore));
};
};
if (_score > _targetScore){
dispatchEvent(new TargetGameScoreEvent(TargetGameScoreEvent.TARGET_OVERSHOT, _score, _targetScore));
};
} else {
if (_targetType == TARGET_TYPE_NEGATIVE){
if (_isExact){
if (_score == _targetScore){
dispatchEvent(new TargetGameScoreEvent(TargetGameScoreEvent.TARGET_HIT, _score, _targetScore));
};
} else {
if (_score <= _targetScore){
dispatchEvent(new TargetGameScoreEvent(TargetGameScoreEvent.TARGET_HIT, _score, _targetScore));
};
};
if (_score < _targetScore){
dispatchEvent(new TargetGameScoreEvent(TargetGameScoreEvent.TARGET_OVERSHOT, _score, _targetScore));
};
};
};
}
public function get targetType():int{
return (_targetType);
}
public function get isExact():Boolean{
return (_isExact);
}
public function setTargetScore($targetScore:Number, $targetType:int=0, $isExact:Boolean=false):void{
_targetScore = $targetScore;
_targetType = $targetType;
_isExact = $isExact;
}
}
}//package uk.co.inbox.game.score
Section 231
//PauseState (uk.co.inbox.game.states.PauseState)
package uk.co.inbox.game.states {
import uk.co.inbox.game.*;
public class PauseState implements State {
private var gameEngine:GameEngine;
public function PauseState($gameEngine:GameEngine){
super();
gameEngine = $gameEngine;
}
public function resumePlay():void{
gameEngine.setState(gameEngine.getPlayState());
gameEngine.actionResume();
}
public function stopPlay():void{
gameEngine.setState(gameEngine.getStopState());
gameEngine.actionStop();
}
public function pausePlay():void{
trace("--You're already paused");
}
public function startPlay():void{
gameEngine.setState(gameEngine.getPlayState());
gameEngine.actionStart();
}
}
}//package uk.co.inbox.game.states
Section 232
//PlayState (uk.co.inbox.game.states.PlayState)
package uk.co.inbox.game.states {
import uk.co.inbox.game.*;
public class PlayState implements State {
private var gameEngine:GameEngine;
public function PlayState($gameEngine:GameEngine){
super();
gameEngine = $gameEngine;
}
public function resumePlay():void{
trace("You're already playing");
}
public function stopPlay():void{
gameEngine.setState(gameEngine.getStopState());
gameEngine.actionStop();
}
public function pausePlay():void{
gameEngine.setState(gameEngine.getPauseState());
gameEngine.actionPause();
}
public function startPlay():void{
trace("You're already playing");
}
}
}//package uk.co.inbox.game.states
Section 233
//PreGameState (uk.co.inbox.game.states.PreGameState)
package uk.co.inbox.game.states {
import uk.co.inbox.game.*;
public class PreGameState implements State {
private var gameEngine:GameEngine;
public function PreGameState($gameEngine:GameEngine){
super();
gameEngine = $gameEngine;
}
public function resumePlay():void{
trace("You can't resume - You've not started yet");
}
public function stopPlay():void{
trace("You can't stop - You've not started yet");
}
public function pausePlay():void{
trace("You can't pause - You've not started yet");
}
public function startPlay():void{
gameEngine.setState(gameEngine.getPlayState());
gameEngine.actionStart();
}
}
}//package uk.co.inbox.game.states
Section 234
//State (uk.co.inbox.game.states.State)
package uk.co.inbox.game.states {
public interface State {
function resumePlay():void;
function pausePlay():void;
function stopPlay():void;
function startPlay():void;
}
}//package uk.co.inbox.game.states
Section 235
//StopState (uk.co.inbox.game.states.StopState)
package uk.co.inbox.game.states {
import uk.co.inbox.game.*;
public class StopState implements State {
private var gameEngine:GameEngine;
public function StopState($gameEngine:GameEngine){
super();
gameEngine = $gameEngine;
}
public function resumePlay():void{
trace("You can't resume, you've stopped");
}
public function stopPlay():void{
trace("You can't stop, you're already stopped");
}
public function pausePlay():void{
trace("You can't pause, you're already stopped");
}
public function startPlay():void{
gameEngine.setState(gameEngine.getPlayState());
gameEngine.actionStart();
}
}
}//package uk.co.inbox.game.states
Section 236
//GameCountdownEvent (uk.co.inbox.game.timer.events.GameCountdownEvent)
package uk.co.inbox.game.timer.events {
import flash.events.*;
public class GameCountdownEvent extends Event {
public var timeLeft:Number;
public var timeLimit:Number;
public static const STOP:String = "stop";
public static const UPDATE:String = "update";
public static const TIME_UP:String = "timeUp";
public function GameCountdownEvent(type:String, $timeLeft:Number, $timeLimit:Number, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
timeLeft = $timeLeft;
timeLimit = $timeLimit;
}
override public function toString():String{
return (formatToString("GameCountdownEvent", "type", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new GameCountdownEvent(type, timeLeft, timeLimit, bubbles, cancelable));
}
}
}//package uk.co.inbox.game.timer.events
Section 237
//GameCountdown (uk.co.inbox.game.timer.GameCountdown)
package uk.co.inbox.game.timer {
import flash.events.*;
import uk.co.inbox.game.timer.events.*;
import flash.utils.*;
public class GameCountdown extends EventDispatcher {
protected var timer:Timer;
protected var _timeLimit:Number;
protected var pauseMarkTime:Number;
protected var startMarkTime:Number;
public function GameCountdown($interval:Number=30){
super();
timer = new Timer($interval);
timer.addEventListener(TimerEvent.TIMER, onUpdateTimer, false, 0, true);
}
public function start():void{
startMarkTime = getTimer();
timer.start();
}
public function stop():void{
timer.stop();
var timeLeft:Number = (_timeLimit - (getTimer() - startMarkTime));
dispatchEvent(new GameCountdownEvent(GameCountdownEvent.STOP, timeLeft, _timeLimit));
}
public function setTimeLimit($timeLimit:Number):void{
_timeLimit = $timeLimit;
}
public function resume():void{
startMarkTime = (startMarkTime - (pauseMarkTime - getTimer()));
timer.start();
}
public function get timeLimit():Number{
return (_timeLimit);
}
public function get timeLeft():Number{
return ((_timeLimit - (getTimer() - startMarkTime)));
}
public function pause():void{
pauseMarkTime = getTimer();
timer.stop();
}
protected function onUpdateTimer(e:TimerEvent):void{
var timeLeft:Number = (_timeLimit - (getTimer() - startMarkTime));
if (timeLeft > 0){
dispatchEvent(new GameCountdownEvent(GameCountdownEvent.UPDATE, timeLeft, _timeLimit));
} else {
dispatchEvent(new GameCountdownEvent(GameCountdownEvent.TIME_UP, timeLeft, _timeLimit));
stop();
};
}
}
}//package uk.co.inbox.game.timer
Section 238
//GameEngine (uk.co.inbox.game.GameEngine)
package uk.co.inbox.game {
import flash.display.*;
import uk.co.inbox.game.states.*;
public class GameEngine extends Sprite implements IGameEngine {
protected var playState:State;
protected var state:State;
protected var preGameState:State;
protected var stopState:State;
protected var pauseState:State;
public function GameEngine(){
super();
}
public function getPauseState():State{
return (this.pauseState);
}
public function stop():void{
state.stopPlay();
}
public function actionResume():void{
trace("actionResume");
}
public function getPlayState():State{
return (this.playState);
}
public function actionStart():void{
trace("actionStart");
}
public function setState($state:State):void{
state = $state;
}
public function update():void{
}
public function getPreGameState():State{
return (this.preGameState);
}
public function actionStop():void{
trace("actionStop");
}
public function getState():State{
return (state);
}
public function actionPause():void{
trace("actionPause");
}
public function resume():void{
state.resumePlay();
}
public function start():void{
state.startPlay();
}
protected function initStates():void{
preGameState = new PreGameState(this);
playState = new PlayState(this);
pauseState = new PauseState(this);
stopState = new StopState(this);
state = preGameState;
}
public function pause():void{
state.pausePlay();
}
public function getStopState():State{
return (this.stopState);
}
}
}//package uk.co.inbox.game
Section 239
//IGameEngine (uk.co.inbox.game.IGameEngine)
package uk.co.inbox.game {
public interface IGameEngine {
function update():void;
function start():void;
function pause():void;
}
}//package uk.co.inbox.game
Section 240
//HubLink (uk.co.inbox.hub.HubLink)
package uk.co.inbox.hub {
import flash.events.*;
import flash.net.*;
public class HubLink {
private static var outbound:LocalConnection = new LocalConnection();
public function HubLink(){
super();
}
private static function onStatus(event:StatusEvent):void{
switch (event.level){
case "status":
trace("HubLink.send() succeeded");
break;
case "error":
trace("HubLink.send() failed");
break;
};
}
public static function showAlert($title:String, $message:String, $severity:int=2, $length:Number=5):void{
outbound.send("_inboxHub", "onShowAlert", $title, $message, $severity, $length);
}
outbound.addEventListener(StatusEvent.STATUS, onStatus);
}
}//package uk.co.inbox.hub
Section 241
//KeyBoardManager (uk.co.inbox.input.KeyBoardManager)
package uk.co.inbox.input {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import uk.co.inbox.debug.*;
public class KeyBoardManager {
public static const LEFT:String = "left";
private static const DEBUG:Boolean = false;
public static const A:String = "A";
public static const B:String = "B";
public static const C:String = "C";
public static const D:String = "D";
public static const E:String = "E";
public static const F:String = "F";
public static const G:String = "G";
public static const H:String = "H";
public static const I:String = "I";
public static const K:String = "K";
public static const L:String = "L";
public static const M:String = "M";
public static const N:String = "N";
public static const O:String = "O";
public static const P:String = "P";
public static const J:String = "J";
public static const R:String = "R";
public static const W:String = "W";
private static const keyRelations:Object = {A:65, B:66, C:67, D:68, E:69, F:70, G:71, H:72, I:73, J:74, K:75, L:76, M:77, N:78, O:79, P:80, Q:81, R:82, S:83, T:84, U:85, V:86, W:87, X:88, Y:89, Z:90, a:97, b:98, c:99, d:100, e:101, f:102, g:103, h:104, i:105, j:106, k:107, l:108, m:109, n:110, o:111, p:112, q:113, r:114, s:115, t:116, u:117, v:118, w:119, x:120, y:121, z:122, n0:48, n1:49, n2:50, n3:51, n4:52, n5:53, n6:54, n7:55, n8:56, n9:57, space:32, ctrl:17, shift:16, up:38, down:40, left:37, right:39, enter:13};
public static const Y:String = "Y";
public static const S:String = "S";
public static const T:String = "T";
public static const U:String = "U";
public static const V:String = "V";
public static const X:String = "X";
public static const Q:String = "Q";
public static const a:String = "a";
public static const b:String = "b";
public static const c:String = "c";
public static const d:String = "d";
public static const e:String = "e";
public static const g:String = "g";
public static const h:String = "h";
public static const i:String = "i";
public static const j:String = "j";
public static const k:String = "k";
public static const l:String = "l";
public static const f:String = "f";
public static const n:String = "o";
public static const o:String = "n";
public static const p:String = "p";
public static const q:String = "q";
public static const r:String = "r";
public static const s:String = "s";
public static const t:String = "t";
public static const u:String = "u";
public static const v:String = "v";
public static const w:String = "w";
public static const x:String = "x";
public static const y:String = "y";
public static const z:String = "z";
public static const m:String = "m";
public static const N_0:String = "n0";
public static const N_1:String = "n1";
public static const N_2:String = "n2";
public static const N_4:String = "n4";
public static const N_6:String = "n6";
public static const Z:String = "Z";
public static const N_3:String = "n3";
public static const N_5:String = "n5";
public static const N_7:String = "n7";
public static const N_9:String = "n9";
public static const SHIFT:String = "shift";
public static const N_8:String = "n8";
public static const CTRL:String = "strl";
public static const UP:String = "up";
public static const ENTER:String = "enter";
public static const DOWN:String = "down";
public static const SPACE:String = "space";
public static const RIGHT:String = "right";
private static var disp:EventDispatcher;
private static var sequenceEventData:Object = {};
private static var keys:Object = {};
public function KeyBoardManager(){
super();
}
public static function init($what:DisplayObject):void{
addListeners($what);
}
public static function removeListeners($what:DisplayObject):void{
$what.removeEventListener(KeyboardEvent.KEY_DOWN, keyPress);
$what.removeEventListener(KeyboardEvent.KEY_UP, keyRelease);
}
private static function keyPress(e:KeyboardEvent):void{
var value:String;
if (!keys[e.keyCode]){
value = getKeyValueByCode(e.charCode);
value = ((value == null)) ? getKeyValueByCode(e.keyCode) : value;
if (DEBUG){
outPut(((((getQualifiedClassName(KeyBoardManager) + "::keyPress() - KeyPressed: ") + e.charCode) + " ") + value));
};
dispatchEvent(new KeyEvent(KeyEvent.KEYEVENT, e.keyCode, e.charCode, value, true));
dispatchEvent(new KeyEvent(KeyEvent.KEYEVENT_DOWN, e.keyCode, e.charCode, value, true));
};
keys[e.keyCode] = true;
}
public static function checkSequenceEvent(charId:int):void{
var seq:KeySequence;
for each (seq in sequenceEventData) {
seq.checkNextChar(charId);
};
}
public static function dispatchEvent(... _args):void{
if (disp == null){
return;
};
disp.dispatchEvent.apply(null, _args);
}
public static function removeEventListener(... _args):void{
if (disp == null){
return;
};
disp.removeEventListener.apply(null, _args);
}
public static function addEventListener(... _args):void{
if (disp == null){
disp = new EventDispatcher();
};
disp.addEventListener.apply(null, _args);
}
public static function createKeySequenceEvent(str:String):KeySequence{
if (sequenceEventData[str] == null){
sequenceEventData[str] = new KeySequence(str);
};
return (sequenceEventData[str]);
}
public static function addListeners($what:DisplayObject):void{
$what.addEventListener(KeyboardEvent.KEY_DOWN, keyPress, false, 0, true);
$what.addEventListener(KeyboardEvent.KEY_UP, keyRelease, false, 0, true);
}
private static function keyRelease(e:KeyboardEvent):void{
var value:String;
if (keys[e.keyCode]){
value = getKeyValueByCode(e.charCode);
value = ((value == null)) ? getKeyValueByCode(e.keyCode) : value;
if (DEBUG){
outPut(((((getQualifiedClassName(KeyBoardManager) + "::keyRelease() - KeyReleased: ") + e.charCode) + " ") + value));
};
dispatchEvent(new KeyEvent(KeyEvent.KEYEVENT_UP, e.keyCode, e.charCode, value, false));
dispatchEvent(new KeyEvent(KeyEvent.KEYEVENT, e.keyCode, e.charCode, value, false));
checkSequenceEvent(e.charCode);
};
keys[e.keyCode] = false;
}
private static function getKeyValueByCode($key:int):String{
var i:String;
for (i in keyRelations) {
if (keyRelations[i] == $key){
return (i);
};
};
return (null);
}
public static function isDown($key:String):Boolean{
if (keyRelations[$key]){
return (((keys[keyRelations[$key]] == undefined)) ? false : keys[keyRelations[$key]]);
};
return (false);
}
}
}//package uk.co.inbox.input
Section 242
//KeyEvent (uk.co.inbox.input.KeyEvent)
package uk.co.inbox.input {
import flash.events.*;
public class KeyEvent extends Event {
public var keyValue:String;
public var charCode:int;
public var isdown:Boolean;
public var keyCode:int;
public static const KEYEVENT_DOWN:String = "KEY_EVENT_DOWN";
public static const KEYEVENT:String = "KEY_EVENT_ACTION";
public static const KEYEVENT_UP:String = "KEY_EVENT_UP";
public function KeyEvent($type:String, $keyCode:int, $charCode:int, $keyValue:String, $isdown:Boolean){
super($type);
keyCode = $keyCode;
charCode = $charCode;
keyValue = $keyValue;
isdown = $isdown;
}
}
}//package uk.co.inbox.input
Section 243
//KeySequence (uk.co.inbox.input.KeySequence)
package uk.co.inbox.input {
import flash.events.*;
public class KeySequence extends EventDispatcher {
private var targetString:String;// = ""
private var _eventId:String;// = ""
private var currentValidIndex:int;// = 0
public static const ACTIVATED:String = "activated";
public function KeySequence($targetString:String){
super();
targetString = $targetString;
_eventId = ("event" + $targetString);
}
public function checkNextChar($charId:int):Boolean{
if (targetString.charCodeAt(currentValidIndex) == $charId){
currentValidIndex++;
if (currentValidIndex >= targetString.length){
currentValidIndex = 0;
dispatchEvent(new Event(ACTIVATED));
return (true);
};
} else {
currentValidIndex = 0;
};
return (false);
}
public function get eventId():String{
return (_eventId);
}
}
}//package uk.co.inbox.input
Section 244
//getText (uk.co.inbox.language.getText)
package uk.co.inbox.language {
public function getText($id:String):String{
return (LangContent.getText($id));
}
}//package uk.co.inbox.language
Section 245
//LangContent (uk.co.inbox.language.LangContent)
package uk.co.inbox.language {
import flash.events.*;
import flash.net.*;
import flash.display.*;
import flash.utils.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.tracking.*;
import uk.co.inbox.debug.*;
import flash.system.*;
public class LangContent extends EventDispatcher {
public static const LOADED:String = "loaded";
public static const STATE_LOADED:String = "loaded";
public static const STATE_SUCCESS:String = "success";
public static const CHANGE:String = "change";
private static const keyStateList:Array = new Array(222);
public static const STATE_FAILED:String = "failed";
public static const STATE_LOADING:String = "loading";
private static const EXCEL_GENERATOR_SCRIPT:String = "http://www.timewatchshop.co.uk/test/Tests/create_excel3.php";
public static var errorCharacter:String = "!";
private static var currentLang:String = "en";
private static var _langList:Array = [];
public static var isDebugMode:Boolean = false;
private static var _status:String;
private static var isTestMode:Boolean = false;
protected static var disp:EventDispatcher;
private static var myStage:Stage;
private static var defaultLang:String = "en";
private static var myLangUI:LangUI;
private static var isInit:Boolean = false;
private static var myLangStrings:LangStrings;
private static var langContentList:Array = [];
private static var isInitLoad:Boolean = true;
private static var isErrorToDefaultLang:Boolean = false;
private static var firstLoadCount:int;
public function LangContent(){
super();
}
public static function init($myStage:Stage=null, $forceLang:String="", $isTestMode:Boolean=true):void{
var initLang:String;
var isFoundValidLanguage:Boolean;
var i:int;
var sniffLang:String;
if (!isInit){
isInit = true;
debugTrace("initialise");
debugTrace((" $forceLang:" + $forceLang));
myStage = $myStage;
myLangStrings = new LangStrings();
_langList = myLangStrings.getLangList();
isTestMode = $isTestMode;
if (myStage != null){
myStage.addEventListener(KeyboardEvent.KEY_DOWN, keyPress, false, 0, true);
myStage.addEventListener(KeyboardEvent.KEY_UP, keyRelease, false, 0, true);
};
if (isTestMode){
currentLang = defaultLang;
_status = STATE_SUCCESS;
isInitLoad = false;
dispatchEvent(new Event(LOADED));
} else {
if (((!((CustomSharedObject.get("myLang", "none") == "none"))) && (!(Settings.get("isLocal"))))){
sniffLang = CustomSharedObject.get("myLang");
} else {
if ($forceLang != null){
sniffLang = $forceLang;
} else {
sniffLang = Capabilities.language.slice(0, 2);
};
};
initLang = "";
isFoundValidLanguage = false;
i = 0;
while (((!(isFoundValidLanguage)) && ((i < _langList.length)))) {
if (_langList[i].code == sniffLang){
isFoundValidLanguage = true;
initLang = sniffLang;
} else {
i++;
};
};
debugTrace((" isFoundValidLanguage:" + isFoundValidLanguage));
debugTrace((" initLang:" + initLang));
debugTrace((" sniffLang:" + sniffLang));
if (!isFoundValidLanguage){
initLang = defaultLang;
};
if (initLang == defaultLang){
firstLoadCount = 1;
} else {
firstLoadCount = 0;
loadLang(defaultLang);
};
if (Settings.get("isLocal")){
isErrorToDefaultLang = true;
};
currentLang = initLang;
CustomSharedObject.set({myLang:currentLang});
loadLang(currentLang);
};
} else {
dispatchEvent(new Event(LOADED));
};
}
public static function get status():String{
return (_status);
}
private static function removeUI():void{
myStage.removeChild(myLangUI);
}
public static function checkValidText($id:String):Boolean{
if (myLangStrings == null){
debugTrace((("WARNING!! - You're calling checkValidText(" + $id) + ") without having called LangContent.init"));
return (false);
};
return (!((myLangStrings.getData($id, currentLang) == null)));
}
private static function keyPress(e:KeyboardEvent):void{
keyStateList[e.keyCode] = 1;
if (keyStateList[71] == 1){
if (keyStateList[76] == 1){
if (keyStateList[69] == 1){
toggleUI();
};
};
};
}
private static function keyRelease(e:KeyboardEvent):void{
keyStateList[e.keyCode] = -1;
}
public static function get langList():Array{
return (_langList.slice());
}
public static function get text():LangStrings{
return (myLangStrings);
}
public static function returnSuccess(event:Event):void{
debugTrace("- returnSuccess");
var loader:URLLoader = URLLoader(event.target);
parseLang(loader.data, currentLang);
_status = STATE_LOADED;
firstLoadCount++;
if (isInitLoad){
if (firstLoadCount == 2){
dispatchEvent(new Event(LOADED));
isInitLoad = false;
};
} else {
dispatchEvent(new Event(CHANGE));
};
}
private static function debugTrace($msg, $isForce:Boolean=false):void{
if (((isDebugMode) || ($isForce))){
outPut($msg, "LangContent");
};
}
public static function returnFailure(event:IOErrorEvent):void{
debugTrace(("returnFailure - event:" + event));
_status = STATE_FAILED;
currentLang = defaultLang;
if (isInitLoad){
isInitLoad = false;
dispatchEvent(new Event(LOADED));
} else {
dispatchEvent(new Event(CHANGE));
};
isInitLoad = false;
}
public static function getText($id:String):String{
var retText:String;
if (myLangStrings == null){
debugTrace((("WARNING!! - You're calling getText(" + $id) + ") without having called LangContent.init"));
return ($id);
};
retText = myLangStrings.getData($id, currentLang);
if (retText == null){
debugTrace(("Error - text Id not found:" + $id));
if (isErrorToDefaultLang){
retText = myLangStrings.getData($id, defaultLang);
if (retText == null){
if ($id == ""){
retText = "";
} else {
retText = (errorCharacter + $id);
};
};
} else {
if ($id == ""){
retText = "";
} else {
retText = (errorCharacter + $id);
};
};
};
return (Validation.trimText(retText));
}
public static function get isMultiLang():Boolean{
if (_langList.length <= 1){
return (false);
};
return (true);
}
private static function parseLang(dataStr:String, curLang:String):void{
var i:String;
var propList:Array;
var dataList:Array = dataStr.split("&");
langContentList[curLang] = dataStr;
var newDataStr:Object = {};
for (i in dataList) {
propList = dataList[i].split("=");
newDataStr[propList[0]] = unescape(propList[1]);
};
myLangStrings.updateStrings(newDataStr, curLang);
}
public static function changeLang(newLang:String):void{
CustomSharedObject.set({myLang:newLang});
InboxTag.callTag(InboxTagData.CHANGE_LANGUAGE, newLang, currentLang);
currentLang = newLang;
loadLang(currentLang);
}
public static function dispatchEvent(... _args):void{
if (disp == null){
return;
};
disp.dispatchEvent.apply(null, _args);
}
public static function removeEventListener(... _args):void{
if (disp == null){
return;
};
disp.removeEventListener.apply(null, _args);
}
private static function onExportComplete(e:Event):void{
debugTrace(("onExportComplete: " + e.target.data));
var loader:URLLoader = URLLoader(e.target);
var vars:URLVariables = new URLVariables(loader.data);
myLangUI.promptExportComplete(vars.excelurl);
}
public static function addEventListener(... _args):void{
if (disp == null){
disp = new EventDispatcher();
};
disp.addEventListener.apply(null, _args);
}
private static function showUI():void{
myLangUI = new LangUI();
myLangUI.addEventListener(LangUI.EXPORT, onExport, false, 0, true);
myStage.addChild(myLangUI);
}
private static function getStringList():Array{
return (myLangStrings.getDefaultStrings());
}
private static function onExportError(e:Event):void{
debugTrace(("onExportError: " + e));
}
public static function set status(newStatus:String):void{
_status = newStatus;
}
public static function get lang():String{
return (currentLang);
}
private static function onExport(e:Event):void{
debugTrace("onExport");
var req:URLRequest = new URLRequest(EXCEL_GENERATOR_SCRIPT);
var vars:URLVariables = new URLVariables();
var d:Date = new Date();
vars.rnd = d.getTime();
vars.projectid = Settings.get("projectId");
var codeStr:String = "";
var i:int;
while (i < _langList.length) {
codeStr = (codeStr + (_langList[i].code + "|"));
i++;
};
codeStr = codeStr.slice(0, -1);
vars.langcodelist = codeStr;
var strList:Array = getStringList();
debugTrace((" strList:" + strList));
var idStr:String = "";
var contentStr:String = "";
var j:int = (strList.length - 1);
while (j >= 0) {
idStr = (idStr + (escapeMultiByte(strList[j].name) + "|"));
contentStr = (contentStr + (escapeMultiByte(strList[j].content) + "|"));
j--;
};
idStr = idStr.slice(0, -1);
contentStr = contentStr.slice(0, -1);
vars.idlist = idStr;
vars.contentlist = contentStr;
req.data = vars;
req.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader(req);
loader.addEventListener(IOErrorEvent.IO_ERROR, onExportError, false, 0, true);
loader.addEventListener(Event.COMPLETE, onExportComplete, false, 0, true);
}
private static function loadLang(langToLoad:String):void{
var req:URLRequest;
var langVars:URLLoader;
var langToLoad = langToLoad;
debugTrace("loadLang");
debugTrace((" langToLoad:" + langToLoad));
langContentList[currentLang] = {};
_status = STATE_LOADING;
if (Settings.get("isLocal")){
req = new URLRequest((("langs/" + langToLoad) + ".txt"));
} else {
req = new URLRequest((((Settings.get("flashFilesPath") + "langs/") + langToLoad) + ".txt"));
};
var vars:URLVariables = new URLVariables();
langVars = new URLLoader(req);
//unresolved jump
var _slot1 = e;
returnFailure(null);
langVars.addEventListener(Event.COMPLETE, returnSuccess);
langVars.addEventListener(IOErrorEvent.IO_ERROR, returnFailure);
}
private static function toggleUI():void{
if (myLangUI == null){
showUI();
} else {
if (myStage.contains(myLangUI)){
removeUI();
} else {
showUI();
};
};
}
}
}//package uk.co.inbox.language
Section 246
//LangStrings (uk.co.inbox.language.LangStrings)
package uk.co.inbox.language {
import flash.utils.*;
import uk.co.inbox.debug.*;
import com.freekickfusion.*;
public dynamic class LangStrings {
private const LANGUAGES_LIST:Array;
private var isDebugMode:Boolean;// = true
private var dataObj:Object;
private var defaultLang:String;// = "en"
private var defaultList:Array;
public static var multiGameOverRegister:String = "Register";
public static var multiConnectingTitle:String = "Connecting...";
public static var panelRegisterPrompt:String = "Register";
public static var multiGameOverPlayAgain:String = "Play again?";
public static var singleDefaultName:String = "Player 1";
public static var multiGameOverOppLeft:String = "Opponent has left...";
public static var singleGameCompletePlayAgain:String = "Play again";
public static var singleLevel:String = "Level";
public static var singleAwardsBack:String = "Back to game";
public static var registeringTitle:String = "Registering";
public static var singleLevelCompleteContinue:String = "Continue";
public static var singleHowToPlayTitle:String = "How to play";
public static var singlePlayer:String = "Single player";
public static var singleHowToPlayStart:String = "Start";
public static var multiGameReadyMessage:String = "Game starting in <time> seconds...";
public static var multiGameOverTitle:String = "Game over";
public static var multiplayer:String = "Multiplayer";
public static var singleLevelCompleteNextLevel:String = "Next level";
public static var singleGameCompleteTitle:String = "Game complete!";
public static var registerRegister:String = "Register";
public static var multiLoginRegister:String = "Register";
public static var registerTitle:String = "Register";
public static var roomSetupCancel:String = "Cancel";
public static var singleNewLevelSkill:String = "Goalkeeper skill";
public static var multiLoginTitle:String = "Multiplayer";
public static var multiGameReadyWaiting:String = "Waiting for opponent...";
public static var multiLoginLogin:String = "Login";
public static var password:String = "Password";
public static var singleNewLevelStart:String = "Start";
public static var multiGameReadyTitle:String = "Game setup";
public static var singleLevelComleteTitle:String = "Level complete";
public static var multiConnectionFailedTitle:String = "Connection Failed";
public static var multiGameReadyStart:String = "Start";
public static var chatWritePrompt:String = "Write your chat here...";
public static var gameTest:String = "Test";
public static var singleHowToPlayBody1:String = "Click and hold mouse for direction and power";
public static var singleGameOverTitle:String = "Game Over - Level not complete";
public static var singleHowToPlayBody3:String = "Release mouse to shoot!";
public static var singleGoalkeeperLevel2:String = "Amateur";
public static var singleGoalkeeperLevel3:String = "Semi-Pro";
public static var singleGoalkeeperLevel4:String = "Pro";
public static var singleGoalkeeperLevel5:String = "World Class";
public static var singleHowToPlayBody2:String = "Then move mouse left/right to curl";
public static var singleGoalkeeperLevel1:String = "Sunday League";
public static var multiGameOverBack:String = "Back to lobby";
public static var multiLevel2:String = "Semi-Pro";
public static var multiLevel3:String = "Premiership";
public static var multiLevel4:String = "World Cup";
public static var splashPlayGame:String = "Play®";
public static var singleLevelCompleteTotal:String = "Total score";
public static var mainMenu:String = "Main menu";
public static var gameSelectionIntro:String = "<font color='#2D4C90'><font color='#FF6600'>Freekick Fusion</font> is a multi-player freekick football game. Either <font color='#FF6600'>play by yourself</font> or <font color='#FF6600'>play real-time</font> against friend or foes. Get in!</font>";
public static var splashLoading:String = "Loading";
public static var username:String = "Username";
public static var no:String = "No";
public static var singleAwardsTitle:String = "Freekick Fusion Awards";
public static var loggingInTitle:String = "Logging in";
public static var multiLevel1:String = "Sunday League";
public static var singleNewLevelPlayers:String = "Players in wall";
public static var yes:String = "Yes";
public static var roomSetupCreate:String = "Create";
public function LangStrings(){
var i:int;
LANGUAGES_LIST = [{name:"English", code:"en"}, {name:"Español", code:"es"}];
dataObj = {};
defaultList = [];
super();
dataObj[defaultLang] = {};
var varList:XMLList = describeType(LangStrings)..variable;
var tempList:Array = [];
while (i < varList.length()) {
tempList.push({name:varList[i].@name, content:LangStrings[varList[i].@name]});
i++;
};
tempList.sortOn("name", Array.DESCENDING);
var j:int;
while (j < tempList.length) {
defaultList.push({name:tempList[j].name, content:tempList[j].content});
dataObj[defaultLang][tempList[j].name] = tempList[j].content;
LangStrings[tempList[j].name] = tempList[j].name;
j++;
};
}
public function getData($id:String, $lang:String):String{
if (dataObj[$lang] != undefined){
if (dataObj[$lang][$id] != undefined){
return (findAndReplace(dataObj[$lang][$id]));
};
return (null);
//unresolved jump
};
return (null);
}
public function getLangList():Array{
return (LANGUAGES_LIST.slice());
}
private function debugTrace($msg):void{
if (isDebugMode){
outPut($msg, "LangStrings");
};
}
private function findAndReplace($str:String):String{
$str = $str.split("<orange>").join(Colours.ORANGE_STR);
$str = $str.split("<blue>").join(Colours.BLUE_STR);
return ($str);
}
public function getDefaultStrings():Array{
return (defaultList.slice());
}
public function updateStrings($newStrings:Object, $lang:String):void{
dataObj[$lang] = $newStrings;
}
}
}//package uk.co.inbox.language
Section 247
//LangUI (uk.co.inbox.language.LangUI)
package uk.co.inbox.language {
import flash.events.*;
import flash.net.*;
import flash.text.*;
import flash.display.*;
import flash.filters.*;
public class LangUI extends Sprite {
private const LEFT_INDENT:Number = 10;
private const HEIGHT:Number = 40;
private const WIDTH:Number = 500;
private var exportField:TextField;
private var holder:Sprite;
private var exportBut:Sprite;
public static const EXPORT:String = "export";
public function LangUI():void{
super();
holder = new Sprite();
addChild(holder);
drawContent();
holder.y = -24;
var glow:GlowFilter = new GlowFilter(0x333333, 1, 4, 4, 2, 2);
filters = [glow];
}
private function onClickLink(e:MouseEvent):void{
var req:URLRequest = new URLRequest(e.target.text);
navigateToURL(req);
}
public function promptExportComplete($url:String):void{
var textFormat:TextFormat = new TextFormat();
textFormat.align = "center";
textFormat.underline = true;
textFormat.color = 0xFFCC00;
textFormat.font = "Verdana";
textFormat.size = 10;
exportField.mouseEnabled = true;
exportField.selectable = true;
exportField.text = $url;
exportField.setTextFormat(textFormat);
exportField.addEventListener(MouseEvent.CLICK, onClickLink, false, 0, true);
}
private function drawContent():void{
var _local2 = holder.graphics;
with (_local2) {
lineStyle();
beginFill(0x999999, 1);
drawRoundRect(LEFT_INDENT, 0, WIDTH, HEIGHT, 20);
endFill();
};
exportBut = new Sprite();
var glow:GlowFilter = new GlowFilter(0x333333, 1, 2, 2, 2, 2);
exportBut.filters = [glow];
holder.addChild(exportBut);
_local2 = exportBut.graphics;
with (_local2) {
lineStyle();
beginFill(0xFFCC00, 1);
drawRoundRect(16, 14, 80, 20, 10);
endFill();
};
var textFormat:TextFormat = new TextFormat();
textFormat.align = "center";
textFormat.color = 0x333333;
textFormat.font = "Verdana";
textFormat.bold = true;
textFormat.size = 10;
var exportLabel:TextField = new TextField();
exportLabel.mouseEnabled = false;
exportLabel.text = "EXPORT";
exportLabel.setTextFormat(textFormat);
exportLabel.width = 80;
exportLabel.x = 16;
exportLabel.y = 16;
exportBut.addChild(exportLabel);
exportBut.buttonMode = true;
exportBut.addEventListener(MouseEvent.CLICK, onClickExport, false, 0, true);
exportField = new TextField();
exportField.width = (WIDTH - LEFT_INDENT);
exportField.x = LEFT_INDENT;
exportField.y = 16;
exportField.text = "";
exportField.mouseEnabled = false;
holder.addChild(exportField);
}
private function onClickExport(e:MouseEvent):void{
exportBut.removeEventListener(MouseEvent.CLICK, onClickExport, false);
holder.removeChild(exportBut);
dispatchEvent(new Event(EXPORT));
}
}
}//package uk.co.inbox.language
Section 248
//League (uk.co.inbox.league.League)
package uk.co.inbox.league {
import flash.events.*;
import flash.net.*;
import uk.co.inbox.score.*;
import flash.utils.*;
import uk.co.inbox.language.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.tracking.*;
import uk.co.inbox.debug.*;
public class League extends EventDispatcher {
public static const STATUS_JOIN_ERROR:String = "joinError";
public static const GET_LEAGUE_FAILED:String = "getLeagueFailure";
public static const JOIN_LEAGUE_INIT:String = "joinLeagueInit";
public static const JOIN_LEAGUE_SUCCESS:String = "joinLeagueSuccess";
public static const STATUS_GET_ERROR:String = "getError";
public static const STATUS_CREATE_ERROR:String = "createError";
public static const STATUS_LEAGUE:String = "league";
private static const GAMETYPE_LEAGUE:String = "league";
public static const CREATE_LEAGUE_FAILED:String = "createLeagueFailure";
public static const STATUS_JOIN:String = "join";
public static const STATUS_NOLEAGUE:String = "non";
public static const STATUS_GETTING:String = "getting";
public static const CREATE_LEAGUE_INIT:String = "createLeagueInit";
public static const CREATE_LEAGUE_SUCCESS:String = "createLeagueSuccess";
public static const JOIN_LEAGUE_FAILED:String = "joinLeagueFailure";
public static const GET_LEAGUE_SUCCESS:String = "getLeagueSuccess";
private static var freqUpdateScoreLimit:Number;
private static var isDebugMode:Boolean = true;
private static var _status:String = "non";
protected static var disp:EventDispatcher;
private static var leagueId:String = "";
private static var leagueOwner:String = "";
private static var freqUpdateScoreCount:Number = 0;
private static var _leagueName:String = "";
private static var myLeagueId:String;
public function League(){
super();
}
public static function get status():String{
return (_status);
}
public static function playLeague():void{
navigateToURL(new URLRequest(leagueURL), "_self");
}
public static function get playerName():String{
return (leagueOwner);
}
private static function getLeagueSuccess(event:Event):void{
debugTrace("getLeagueSuccess");
debugTrace((" event:" + event));
var loader:URLLoader = URLLoader(event.target);
var vars:URLVariables = new URLVariables(loader.data);
leagueOwner = vars.ownername;
_leagueName = vars._leagueName;
Score.setBestScore(parseInt(vars.score));
Score.setAttempts(parseInt(vars.plays));
status = STATUS_LEAGUE;
dispatchEvent(new Event(GET_LEAGUE_SUCCESS));
}
public static function init($gameType:String, $leagueId:String, $leagueName:String=""):void{
var tempList:Array;
var isFoundLeagueId:Boolean;
var i:int;
debugTrace("League - init");
if ($gameType == GAMETYPE_LEAGUE){
_leagueName = $leagueName;
leagueId = $leagueId;
debugTrace((" leagueId:" + leagueId));
debugTrace(CustomSharedObject.get("track3BestScore"));
debugTrace(CustomSharedObject.get("leagueList"));
tempList = CustomSharedObject.get("leagueList", []);
debugTrace((" tempList:" + tempList));
debugTrace((" tempList.length:" + tempList.length));
isFoundLeagueId = false;
i = 0;
while ((((i < tempList.length)) && (!(isFoundLeagueId)))) {
debugTrace((((((" tempList[" + i) + "][0]:") + tempList[i][0]) + ", leagueId:") + leagueId));
if (tempList[i][0] == leagueId){
debugTrace(" found!!");
isFoundLeagueId = true;
myLeagueId = tempList[i][1];
} else {
i++;
};
};
if (isFoundLeagueId){
status = STATUS_GETTING;
getLeague();
} else {
status = STATUS_JOIN;
};
};
debugTrace(("status:" + status));
}
public static function getLeague():void{
var sendVars:URLLoader;
var req:URLRequest = new URLRequest((Settings.get("leagueCgiPath") + "getleague.cgi"));
var vars:URLVariables = new URLVariables();
vars.rnd = new Date().getTime();
vars.unique_id = myLeagueId;
vars.campaign = Settings.get("gameName");
req.data = vars;
sendVars = new URLLoader(req);
//unresolved jump
var _slot1 = e;
getLeagueFailure(null);
sendVars.addEventListener(Event.COMPLETE, getLeagueSuccess);
sendVars.addEventListener(SecurityErrorEvent.SECURITY_ERROR, getLeagueFailure);
sendVars.addEventListener(IOErrorEvent.IO_ERROR, getLeagueFailure);
}
public static function joinLeague(playerName:String):void{
var sendVars:URLLoader;
var playerName = playerName;
var req:URLRequest = new URLRequest((Settings.get("leagueCgiPath") + "enterleague.cgi"));
var vars:URLVariables = new URLVariables();
vars.rnd = new Date().getTime();
vars.league_id = leagueId;
vars.ownername = playerName;
vars.score = Score.defaultScore;
vars.campaign = Settings.get("gameName");
req.data = vars;
sendVars = new URLLoader(req);
//unresolved jump
var _slot1 = e;
joinLeagueFailure(null);
sendVars.addEventListener(Event.COMPLETE, joinLeagueSuccess);
sendVars.addEventListener(SecurityErrorEvent.SECURITY_ERROR, joinLeagueFailure);
sendVars.addEventListener(IOErrorEvent.IO_ERROR, joinLeagueFailure);
}
private static function getLeagueFailure(event):void{
debugTrace("getLeagueFailure");
debugTrace((" event:" + event));
status = STATUS_GET_ERROR;
dispatchEvent(new Event(GET_LEAGUE_FAILED));
}
public static function get leagueStandingsURL():String{
if (LangContent.isMultiLang){
return ((((Settings.get("leagueStandingsPath") + LangContent.lang) + "/") + myLeagueId));
};
return ((Settings.get("leagueStandingsPath") + myLeagueId));
}
public static function get isLeague():Boolean{
return ((status == STATUS_LEAGUE));
}
public static function viewLeague():void{
navigateToURL(new URLRequest(leagueStandingsURL), "_blank");
}
private static function sendScoreSuccess(e:Event):void{
debugTrace("sendScoreSuccess");
}
private static function createLeagueSuccess(e:Event):void{
debugTrace("League - createLeagueSuccess");
status = STATUS_LEAGUE;
CustomSharedObject.set({track1BestScore:0});
CustomSharedObject.set({track2BestScore:0});
CustomSharedObject.set({track3BestScore:0});
CustomSharedObject.set({isTrack1Complete:0});
CustomSharedObject.set({isTrack2Complete:0});
CustomSharedObject.set({isTrack3Complete:0});
var loader:URLLoader = URLLoader(e.target);
debugTrace((" loader:" + loader));
debugTrace((" loader.data:" + loader.data));
if (loader.data.slice(-1) == "&"){
loader.data = loader.data.slice(0, (loader.data.length - 1));
};
debugTrace((" loader.data:" + loader.data));
var vars:URLVariables = new URLVariables(loader.data);
debugTrace((" vars:" + vars));
debugTrace((" vars.league_id:" + vars.league_id));
myLeagueId = vars.league_id;
var tempList:Array = CustomSharedObject.get("leagueList", []);
tempList.push([myLeagueId, myLeagueId]);
CustomSharedObject.set({leagueList:tempList});
InboxTag.callTag(InboxTagData.CREATE_LEAGUE);
dispatchEvent(new Event(CREATE_LEAGUE_SUCCESS));
}
private static function sendScoreFailure(e:Event):void{
debugTrace("sendScoreFailure");
}
private static function createLeagueFailure(e:Event):void{
debugTrace(("League - createLeagueFailure - e:" + e));
status = STATUS_CREATE_ERROR;
dispatchEvent(new Event(CREATE_LEAGUE_FAILED));
}
public static function get leagueURL():String{
if (LangContent.isMultiLang){
return (((((Settings.get("gamePath") + "game/") + LangContent.lang) + "/") + myLeagueId));
};
return (((Settings.get("gamePath") + "game/") + myLeagueId));
}
public static function cancelLeague():void{
status = STATUS_NOLEAGUE;
}
public static function addEventListener(... _args):void{
if (disp == null){
disp = new EventDispatcher();
};
disp.addEventListener.apply(null, _args);
}
private static function joinLeagueSuccess(e:Event):void{
debugTrace("League - joinLeagueSuccess");
status = STATUS_LEAGUE;
var loader:URLLoader = URLLoader(e.target);
debugTrace((" loader:" + loader));
debugTrace((" loader.data:" + loader.data));
if (loader.data.slice(-1) == "&"){
loader.data = loader.data.slice(0, (loader.data.length - 1));
};
debugTrace((" loader.data:" + loader.data));
var vars:URLVariables = new URLVariables(loader.data);
CustomSharedObject.set({track1BestScore:0});
CustomSharedObject.set({track2BestScore:0});
CustomSharedObject.set({track3BestScore:0});
CustomSharedObject.set({isTrack1Complete:0});
CustomSharedObject.set({isTrack2Complete:0});
CustomSharedObject.set({isTrack3Complete:0});
Score.setBestScore(Score.defaultScore);
myLeagueId = vars.unique_id;
var tempList:Array = CustomSharedObject.get("leagueList", []);
debugTrace((" leagueId:" + leagueId));
debugTrace((" myLeagueId:" + myLeagueId));
tempList.push([leagueId, myLeagueId]);
debugTrace((" tempList:" + tempList));
CustomSharedObject.set({leagueList:tempList});
InboxTag.callTag(InboxTagData.JOIN_LEAGUE);
dispatchEvent(new Event(JOIN_LEAGUE_SUCCESS));
}
public static function createLeague($playerName:String, $leagueName:String):void{
var sendVars:URLLoader;
var $playerName = $playerName;
var $leagueName = $leagueName;
debugTrace("League - createLeague");
debugTrace((" $playerName:" + $playerName));
debugTrace((" $leagueName:" + $leagueName));
var req:URLRequest = new URLRequest((Settings.get("leagueCgiPath") + "makeleague.cgi"));
var vars:URLVariables = new URLVariables();
vars.rnd = new Date().getTime();
_leagueName = (vars.leaguename = $leagueName);
leagueOwner = (vars.ownername = $playerName);
vars.score = Score.defaultScore;
vars.campaign = Settings.get("gameName");
req.data = vars;
sendVars = new URLLoader(req);
//unresolved jump
var _slot1 = e;
createLeagueFailure(null);
sendVars.addEventListener(Event.COMPLETE, createLeagueSuccess);
sendVars.addEventListener(SecurityErrorEvent.SECURITY_ERROR, createLeagueFailure);
sendVars.addEventListener(IOErrorEvent.IO_ERROR, createLeagueFailure);
}
private static function joinLeagueFailure(e:Event):void{
status = STATUS_JOIN_ERROR;
dispatchEvent(new Event(JOIN_LEAGUE_FAILED));
}
public static function removeEventListener(... _args):void{
if (disp == null){
return;
};
disp.removeEventListener.apply(null, _args);
}
public static function get leagueName():String{
return (_leagueName);
}
private static function debugTrace($msg):void{
if (isDebugMode){
outPut($msg, "League");
};
}
public static function sendScore(score:int, attempts:int, isNewBestScore:Boolean):void{
var req:URLRequest;
var vars:URLVariables;
var sendVars:URLLoader;
var score = score;
var attempts = attempts;
var isNewBestScore = isNewBestScore;
freqUpdateScoreCount++;
debugTrace("League - sendScore");
debugTrace((" isNewBestScore:" + isNewBestScore));
if (isNewBestScore){
req = new URLRequest((Settings.get("leagueCgiPath") + "updateleague.cgi"));
vars = new URLVariables();
vars.rnd = new Date().getTime();
vars.plays = attempts;
vars.unique_id = myLeagueId;
vars.score = MathTools.encryptScore(score);
vars.campaign = Settings.get("gameName");
req.data = vars;
sendVars = new URLLoader(req);
//unresolved jump
var _slot1 = e;
sendScoreFailure(null);
sendVars.addEventListener(Event.COMPLETE, sendScoreSuccess);
sendVars.addEventListener(SecurityErrorEvent.SECURITY_ERROR, sendScoreFailure);
sendVars.addEventListener(IOErrorEvent.IO_ERROR, sendScoreFailure);
freqUpdateScoreCount = 0;
};
}
public static function set status(newStatus:String):void{
_status = newStatus;
}
public static function dispatchEvent(... _args):void{
if (disp == null){
return;
};
disp.dispatchEvent.apply(null, _args);
}
}
}//package uk.co.inbox.league
Section 249
//ChallengeListItem (uk.co.inbox.multiplayer.lobby.render.challenge.ChallengeListItem)
package uk.co.inbox.multiplayer.lobby.render.challenge {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.lobby.*;
import uk.co.inbox.multiplayer.lobby.render.list.*;
import flash.errors.*;
public class ChallengeListItem extends ListItem {
protected var challenge:Challenge;
protected var stateGraphicList:Array;
protected var main:ChallengeListItem_Base;
protected var gameServer:GameServer;
public function ChallengeListItem(){
stateGraphicList = [];
super();
}
override public function update($data:Object):void{
var item:ChallengeListItem_Base;
challenge = ($data as Challenge);
var i:int;
while (i < stateGraphicList.length) {
item = stateGraphicList[i];
item.setChallenge(challenge);
i++;
};
refresh();
}
override public function init():void{
initSubItems();
}
protected function initSubItems():void{
stateGraphicList = [createDefaultItem()];
main = stateGraphicList[0];
addChild(main);
}
protected function createDefaultItem():ChallengeListItem_Base{
throw (new IllegalOperationError("Method must be overwritten"));
}
protected function refresh():void{
if (main != null){
if (contains(main)){
removeChild(main);
};
};
main = stateGraphicList[challenge.state];
if (main != null){
main.update();
addChild(main);
};
}
public function setGameServer($gameServer:GameServer):void{
var item:ChallengeListItem_Base;
gameServer = $gameServer;
var i:int;
while (i < stateGraphicList.length) {
item = stateGraphicList[i];
item.setGameServer($gameServer);
i++;
};
}
}
}//package uk.co.inbox.multiplayer.lobby.render.challenge
Section 250
//ChallengeListItem_Base (uk.co.inbox.multiplayer.lobby.render.challenge.ChallengeListItem_Base)
package uk.co.inbox.multiplayer.lobby.render.challenge {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.lobby.*;
import flash.display.*;
public class ChallengeListItem_Base extends Sprite {
protected var challenge:Challenge;
protected var gameServer:GameServer;
public function ChallengeListItem_Base(){
super();
}
public function setChallenge($challenge:Challenge):void{
challenge = $challenge;
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
}
public function update():void{
}
}
}//package uk.co.inbox.multiplayer.lobby.render.challenge
Section 251
//ListItem (uk.co.inbox.multiplayer.lobby.render.list.ListItem)
package uk.co.inbox.multiplayer.lobby.render.list {
import flash.display.*;
public class ListItem extends Sprite {
public function ListItem(){
super();
}
public function init():void{
}
public function update($data:Object):void{
}
}
}//package uk.co.inbox.multiplayer.lobby.render.list
Section 252
//ListViewer (uk.co.inbox.multiplayer.lobby.render.list.ListViewer)
package uk.co.inbox.multiplayer.lobby.render.list {
import flash.display.*;
public class ListViewer extends Sprite {
protected var gapX:Number;// = 0
protected var gapY:Number;// = 0
protected var offSet:int;
protected var itemClass:Object;
protected var dataList:Array;
protected var holder:Sprite;
protected var visibleItems:int;// = 10
protected var entryList:Array;
protected var startX:Number;// = 0
protected var startY:Number;// = 0
public function ListViewer(){
dataList = [];
entryList = [];
super();
holder = new Sprite();
addChild(holder);
}
protected function sortItems():void{
}
public function drawItems():void{
var newEntry:ListItem;
clearItems();
var curX:Number = startX;
var curY:Number = startY;
var i:int;
while (i < visibleItems) {
newEntry = new itemClass();
newEntry.init();
newEntry.x = curX;
newEntry.y = curY;
curX = (curX + gapX);
curY = (curY + (newEntry.height + gapY));
holder.addChild(newEntry);
entryList.push(newEntry);
i++;
};
refreshItems();
}
public function hideItems():void{
var newEntry:ListItem;
var i:int;
while (i < entryList.length) {
newEntry = entryList[i];
newEntry.visible = false;
i++;
};
}
protected function refreshItems():void{
var i:int;
var item:ListItem;
var id:int;
sortItems();
var len:int = visibleItems;
if (len > dataList.length){
len = dataList.length;
};
i = 0;
while (i < visibleItems) {
item = entryList[i];
item.visible = false;
i++;
};
i = 0;
while (i < len) {
id = (i + offSet);
item = entryList[i];
item.visible = true;
item.update(dataList[id]);
i++;
};
}
protected function clearItems():void{
while (holder.numChildren > 0) {
holder.removeChildAt(0);
};
entryList = [];
}
}
}//package uk.co.inbox.multiplayer.lobby.render.list
Section 253
//ScrollerListViewer (uk.co.inbox.multiplayer.lobby.render.list.ScrollerListViewer)
package uk.co.inbox.multiplayer.lobby.render.list {
import fl.controls.*;
import fl.events.*;
public class ScrollerListViewer extends ListViewer {
protected var scrollBar:UIScrollBar;
protected var scrollBarGapX:Number;// = 1
public function ScrollerListViewer(){
super();
}
protected function setScrollBar($scrollBar:UIScrollBar):void{
scrollBar = $scrollBar;
scrollBar.addEventListener(ScrollEvent.SCROLL, onScroll, false, 0, true);
}
protected function sizeScrollBar():void{
scrollBar.setSize(scrollBar.width, (((entryList[(entryList.length - 1)] as ListItem).y + (entryList[(entryList.length - 1)] as ListItem).height) - (entryList[0] as ListItem).y));
}
protected function onScroll(e:ScrollEvent):void{
offSet = e.position;
super.refreshItems();
}
override protected function refreshItems():void{
scrollBar.setScrollProperties(visibleItems, 0, (dataList.length - visibleItems));
if (offSet > scrollBar.maxScrollPosition){
offSet = scrollBar.maxScrollPosition;
};
if (offSet < 0){
offSet = 0;
};
super.refreshItems();
}
override public function drawItems():void{
super.drawItems();
scrollBar.x = (((entryList[0] as ListItem).x + (entryList[0] as ListItem).width) + scrollBarGapX);
scrollBar.y = (entryList[0] as ListItem).y;
sizeScrollBar();
}
}
}//package uk.co.inbox.multiplayer.lobby.render.list
Section 254
//PlayerListItem (uk.co.inbox.multiplayer.lobby.render.player.PlayerListItem)
package uk.co.inbox.multiplayer.lobby.render.player {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.player.*;
import uk.co.inbox.multiplayer.lobby.render.list.*;
import flash.errors.*;
public class PlayerListItem extends ListItem {
protected var player:Player;
protected var stateGraphicList:Array;
protected var main:PlayerListItem_Base;
protected var gameServer:GameServer;
public function PlayerListItem(){
stateGraphicList = [];
super();
}
protected function createIdleItem():PlayerListItem_Base{
throw (new IllegalOperationError("Method must be overwritten"));
}
protected function createGameItem():PlayerListItem_Base{
throw (new IllegalOperationError("Method must be overwritten"));
}
override public function update($data:Object):void{
var item:PlayerListItem_Base;
player = ($data as Player);
var i:int;
while (i < stateGraphicList.length) {
item = stateGraphicList[i];
item.setPlayer(player);
i++;
};
refresh();
}
protected function selectGraphic():void{
main = stateGraphicList[player.state];
}
override public function init():void{
initSubItems();
}
protected function initSubItems():void{
stateGraphicList = [createDefaultItem(), createIdleItem(), createGameItem()];
main = stateGraphicList[0];
addChild(main);
}
protected function createDefaultItem():PlayerListItem_Base{
throw (new IllegalOperationError("Method must be overwritten"));
}
protected function refresh():void{
if (main != null){
if (contains(main)){
removeChild(main);
};
};
selectGraphic();
if (main != null){
main.update();
addChild(main);
};
}
public function setGameServer($gameServer:GameServer):void{
var item:PlayerListItem_Base;
gameServer = $gameServer;
var i:int;
while (i < stateGraphicList.length) {
item = stateGraphicList[i];
item.setGameServer($gameServer);
i++;
};
}
}
}//package uk.co.inbox.multiplayer.lobby.render.player
Section 255
//PlayerListItem_Base (uk.co.inbox.multiplayer.lobby.render.player.PlayerListItem_Base)
package uk.co.inbox.multiplayer.lobby.render.player {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.player.*;
import flash.display.*;
public class PlayerListItem_Base extends Sprite {
protected var player:Player;
protected var gameServer:GameServer;
public function PlayerListItem_Base(){
super();
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
}
public function update():void{
}
public function setPlayer($player:Player):void{
player = $player;
}
}
}//package uk.co.inbox.multiplayer.lobby.render.player
Section 256
//Room_Setup (uk.co.inbox.multiplayer.lobby.render.room.Room_Setup)
package uk.co.inbox.multiplayer.lobby.render.room {
import uk.co.inbox.multiplayer.server.*;
import flash.display.*;
public class Room_Setup extends Sprite {
protected var gameServer:GameServer;
protected var roomId:int;
public function Room_Setup(){
super();
}
public function hide():void{
visible = false;
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
}
public function show($roomId:int):void{
roomId = $roomId;
visible = true;
}
}
}//package uk.co.inbox.multiplayer.lobby.render.room
Section 257
//RoomListItem (uk.co.inbox.multiplayer.lobby.render.room.RoomListItem)
package uk.co.inbox.multiplayer.lobby.render.room {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.lobby.*;
import uk.co.inbox.multiplayer.lobby.render.list.*;
import flash.errors.*;
public class RoomListItem extends ListItem {
protected var stateGraphicList:Array;
protected var main:RoomListItem_Base;
protected var room:GameRoom;
protected var gameServer:GameServer;
public function RoomListItem(){
stateGraphicList = [];
super();
}
protected function createJoinItem():RoomListItem_Base{
throw (new IllegalOperationError("Method must be overwritten"));
}
protected function refresh():void{
if (main != null){
if (contains(main)){
removeChild(main);
};
};
selectGraphic();
if (main != null){
main.update();
addChild(main);
};
}
public function setServer($gameServer:GameServer):void{
var item:RoomListItem_Base;
gameServer = $gameServer;
var i:int;
while (i < stateGraphicList.length) {
item = stateGraphicList[i];
item.setGameServer($gameServer);
i++;
};
}
protected function createCreatingItem():RoomListItem_Base{
throw (new IllegalOperationError("Method must be overwritten"));
}
override public function update($data:Object):void{
var item:RoomListItem_Base;
room = ($data as GameRoom);
var i:int;
while (i < stateGraphicList.length) {
item = stateGraphicList[i];
item.setGameRoom(room);
i++;
};
refresh();
}
protected function createCreateItem():RoomListItem_Base{
throw (new IllegalOperationError("Method must be overwritten"));
}
protected function selectGraphic():void{
main = stateGraphicList[room.state];
}
override public function init():void{
initSubItems();
}
protected function initSubItems():void{
stateGraphicList = [createCreateItem(), createCreatingItem(), createJoinItem(), createFullItem()];
main = stateGraphicList[0];
addChild(main);
}
protected function createFullItem():RoomListItem_Base{
throw (new IllegalOperationError("Method must be overwritten"));
}
}
}//package uk.co.inbox.multiplayer.lobby.render.room
Section 258
//RoomListItem_Base (uk.co.inbox.multiplayer.lobby.render.room.RoomListItem_Base)
package uk.co.inbox.multiplayer.lobby.render.room {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.lobby.*;
import flash.display.*;
public class RoomListItem_Base extends Sprite {
protected var gameServer:GameServer;
protected var gameRoom:GameRoom;
public function RoomListItem_Base(){
super();
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
}
public function update():void{
}
public function setGameRoom($gameRoom:GameRoom):void{
gameRoom = $gameRoom;
}
}
}//package uk.co.inbox.multiplayer.lobby.render.room
Section 259
//ChallengeList (uk.co.inbox.multiplayer.lobby.render.ChallengeList)
package uk.co.inbox.multiplayer.lobby.render {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.lobby.*;
import uk.co.inbox.multiplayer.lobby.render.challenge.*;
import uk.co.inbox.multiplayer.lobby.render.list.*;
public class ChallengeList extends ScrollerListViewer {
protected var gameServer:GameServer;
public function ChallengeList(){
visibleItems = 3;
startX = 0;
startY = 20;
super();
if (itemClass == null){
itemClass = ChallengeListItem;
};
}
protected function onCancelChallenge(e:GameServerEvent):void{
removeChallenge(e.params.challenge);
}
protected function onChallengeDestroyed(e:Event):void{
removeChallenge((e.target as Challenge));
}
protected function removeChallenge($challenge:Challenge):void{
var checkChallenge:Challenge;
var i:int;
while (i < dataList.length) {
checkChallenge = (dataList[i] as Challenge);
if (checkChallenge.creatorPlayer == $challenge.creatorPlayer){
if (checkChallenge.gameRoom.id == $challenge.gameRoom.id){
dataList.splice(i, 1);
break;
};
};
i++;
};
refreshItems();
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
gameServer.addEventListener(GameServerEvent.RECEIVE_LOBBY_CHALLENGE, onReceiveChallenge, false, 0, true);
gameServer.addEventListener(GameServerEvent.CANCEL_LOBBY_CHALLENGE, onCancelChallenge, false, 0, true);
drawItems();
}
override public function drawItems():void{
var entry:ChallengeListItem;
super.drawItems();
var i:int;
while (i < entryList.length) {
entry = (entryList[i] as ChallengeListItem);
entry.setGameServer(gameServer);
i++;
};
}
protected function onReceiveChallenge(e:GameServerEvent):void{
var challenge:Challenge = e.params.challenge;
challenge.addEventListener(Challenge.DESTROY, onChallengeDestroyed, false, 0, true);
dataList.push(challenge);
refreshItems();
}
}
}//package uk.co.inbox.multiplayer.lobby.render
Section 260
//LobbySelector (uk.co.inbox.multiplayer.lobby.render.LobbySelector)
package uk.co.inbox.multiplayer.lobby.render {
import uk.co.inbox.multiplayer.server.*;
import flash.display.*;
public class LobbySelector extends Sprite {
protected var gameServer:GameServer;
public function LobbySelector(){
super();
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
gameServer.addEventListener(GameServerEvent.LOBBY_LIST_UPDATE, onLobbyListUpdate, false, 0, true);
gameServer.addEventListener(GameServerEvent.JOIN_LOBBY, onJoinLobby, false, 0, true);
}
protected function onJoinLobby(e:GameServerEvent):void{
}
protected function onLobbyListUpdate(e:GameServerEvent):void{
}
}
}//package uk.co.inbox.multiplayer.lobby.render
Section 261
//PlayerList (uk.co.inbox.multiplayer.lobby.render.PlayerList)
package uk.co.inbox.multiplayer.lobby.render {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.player.*;
import uk.co.inbox.multiplayer.lobby.render.player.*;
import uk.co.inbox.multiplayer.lobby.render.list.*;
public class PlayerList extends ScrollerListViewer {
protected var gameServer:GameServer;
public function PlayerList(){
visibleItems = 10;
startX = 0;
startY = 20;
gapY = 1;
super();
if (itemClass == null){
itemClass = PlayerListItem;
};
}
protected function onPlayerJoin(e:GameServerEvent):void{
dataList.push(e.params.player);
refreshItems();
}
protected function onPlayerLeave(e:GameServerEvent):void{
var checkPlayer:Player;
var exitUserId:int = e.params.userId;
var i:int;
while (i < dataList.length) {
checkPlayer = (dataList[i] as Player);
if (checkPlayer.serverId == exitUserId){
dataList.splice(i, 1);
break;
};
i++;
};
refreshItems();
}
protected function onPlayerListUpdate(e:GameServerEvent):void{
var pList:Array;
var player:Player;
trace("PlayerList.onRoomListUpdate");
pList = e.params.playerList;
dataList = [];
var i:int;
while (i < pList.length) {
player = pList[i];
dataList.push(player);
i++;
};
drawItems();
}
protected function onPlayerUpdate(e:GameServerEvent):void{
var checkPlayer:Player;
var updatedPlayer:Player = (e.params.player as Player);
var len:int = dataList.length;
var i:int;
while (i < len) {
checkPlayer = (dataList[i] as Player);
if (checkPlayer.serverId == updatedPlayer.serverId){
dataList.splice(i, 1, updatedPlayer);
break;
};
i++;
};
refreshItems();
}
override public function drawItems():void{
var entry:PlayerListItem;
super.drawItems();
var i:int;
while (i < entryList.length) {
entry = (entryList[i] as PlayerListItem);
entry.setGameServer(gameServer);
i++;
};
}
override protected function refreshItems():void{
dataList.sortOn("name", Array.CASEINSENSITIVE);
super.refreshItems();
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
gameServer.addEventListener(GameServerEvent.LOBBY_PLAYER_LIST_UPDATE, onPlayerListUpdate, false, 0, true);
gameServer.addEventListener(GameServerEvent.LOBBY_PLAYER_UPDATE, onPlayerUpdate, false, 0, true);
gameServer.addEventListener(GameServerEvent.LOBBY_PLAYER_JOIN, onPlayerJoin, false, 0, true);
gameServer.addEventListener(GameServerEvent.LOBBY_PLAYER_LEAVE, onPlayerLeave, false, 0, true);
}
}
}//package uk.co.inbox.multiplayer.lobby.render
Section 262
//RoomList (uk.co.inbox.multiplayer.lobby.render.RoomList)
package uk.co.inbox.multiplayer.lobby.render {
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.multiplayer.lobby.*;
import uk.co.inbox.multiplayer.lobby.render.room.*;
import uk.co.inbox.multiplayer.lobby.render.list.*;
public class RoomList extends ScrollerListViewer {
protected var gameServer:GameServer;
public function RoomList(){
visibleItems = 10;
startX = 0;
startY = 20;
gapY = 1;
super();
if (itemClass == null){
itemClass = RoomListItem;
};
}
private function onRoomListUpdate(e:GameServerEvent):void{
var rList:Array;
var room:GameRoom;
rList = e.params.roomList;
dataList = [];
var i:int;
while (i < rList.length) {
room = rList[i];
dataList.push(room);
i++;
};
dataList.sortOn("id", Array.NUMERIC);
drawItems();
}
private function onRoomUpdate(e:GameServerEvent):void{
var checkRoom:GameRoom;
var len:int = dataList.length;
var replaceRoom:GameRoom = e.params.gameRoom;
var checkId:int = replaceRoom.id;
var i:int;
while (i < len) {
checkRoom = dataList[i];
if (checkRoom.id == checkId){
dataList.splice(i, 1, replaceRoom);
refreshItems();
break;
};
i++;
};
}
public function setGameServer($gameServer:GameServer):void{
gameServer = $gameServer;
gameServer.addEventListener(GameServerEvent.LOBBY_GAMEROOM_LIST_UPDATE, onRoomListUpdate, false, 0, true);
gameServer.addEventListener(GameServerEvent.LOBBY_GAMEROOM_UPDATE, onRoomUpdate, false, 0, true);
}
override public function drawItems():void{
var entry:RoomListItem;
super.drawItems();
var i:int;
while (i < entryList.length) {
entry = (entryList[i] as RoomListItem);
entry.setServer(gameServer);
i++;
};
}
}
}//package uk.co.inbox.multiplayer.lobby.render
Section 263
//Challenge (uk.co.inbox.multiplayer.lobby.Challenge)
package uk.co.inbox.multiplayer.lobby {
import flash.events.*;
import uk.co.inbox.multiplayer.player.*;
public class Challenge extends EventDispatcher {
protected var _gameRoom:GameRoom;
protected var _creatorPlayer:Player;
protected var _state:int;// = 0
protected var _targetPlayer:Player;
public static const STATE_GAME:int = 2;
public static const STATE_DEFAULT:int = 0;
public static const STATE_IDLE:int = 1;
public static const DESTROY:String = "destroy";
public function Challenge(){
super();
}
public function set gameRoom(value:GameRoom):void{
_gameRoom = value;
}
public function set creatorPlayer(value:Player):void{
_creatorPlayer = value;
}
public function set state(value:int):void{
_state = value;
}
public function set targetPlayer(value:Player):void{
_targetPlayer = value;
}
public function get gameRoom():GameRoom{
return (_gameRoom);
}
public function get state():int{
return (_state);
}
public function get creatorPlayer():Player{
return (_creatorPlayer);
}
public function get targetPlayer():Player{
return (_targetPlayer);
}
public function destroy():void{
dispatchEvent(new Event(DESTROY));
}
}
}//package uk.co.inbox.multiplayer.lobby
Section 264
//GameRoom (uk.co.inbox.multiplayer.lobby.GameRoom)
package uk.co.inbox.multiplayer.lobby {
public class GameRoom {
protected var _isPrivate:Boolean;
protected var _isAllowSpectators:Boolean;
protected var _playerList:Array;
protected var _id:int;// = 0
protected var _state:int;// = 0
protected var _isMembersOnly:Boolean;
protected var _serverId:int;// = 0
protected var _name:String;// = ""
public static const STATE_EMPTY:int = 0;
public static const STATE_CREATING:int = 1;
public static const STATE_OCCUPIED:int = 3;
public static const STATE_WAITING:int = 2;
public function GameRoom(){
_playerList = [];
super();
}
public function get isAllowSpectators():Boolean{
return (_isAllowSpectators);
}
public function set isAllowSpectators(value:Boolean):void{
_isAllowSpectators = value;
}
public function get name():String{
return (_name);
}
public function set playerList(value:Array):void{
_playerList = value.slice();
}
public function get state():int{
return (_state);
}
public function set name(value:String):void{
_name = value;
}
public function get idLabel():String{
return (String((_id + 1)));
}
public function get id():int{
return (_id);
}
public function set serverId(value:int):void{
_serverId = value;
}
public function get playerList():Array{
return (_playerList.slice());
}
public function get isMembersOnly():Boolean{
return (_isMembersOnly);
}
public function set state(value:int):void{
_state = value;
}
public function set isPrivate(value:Boolean):void{
_isPrivate = value;
}
public function set id(value:int):void{
_id = value;
}
public function get isPrivate():Boolean{
return (_isPrivate);
}
public function set isMembersOnly(value:Boolean):void{
_isMembersOnly = value;
}
public function get serverId():int{
return (_serverId);
}
}
}//package uk.co.inbox.multiplayer.lobby
Section 265
//Lobby (uk.co.inbox.multiplayer.lobby.Lobby)
package uk.co.inbox.multiplayer.lobby {
import uk.co.inbox.multiplayer.server.*;
import flash.display.*;
import uk.co.inbox.multiplayer.lobby.render.room.*;
import uk.co.inbox.multiplayer.lobby.render.*;
public class Lobby extends Sprite {
protected var challengeList:ChallengeList;
protected var roomSetup:Room_Setup;
protected var lobbySelector:LobbySelector;
protected var roomList:RoomList;
protected var gameServer:GameServer;
protected var playerList:PlayerList;
public function Lobby($gameServer:GameServer){
super();
gameServer = $gameServer;
gameServer.addEventListener(GameServerEvent.READY_GAME_ROOM, onReadyGame, false, 0, true);
}
protected function createLobbySelector():void{
lobbySelector = initLobbySelector();
lobbySelector.setGameServer(gameServer);
lobbySelector.x = 10;
lobbySelector.y = 10;
addChild(lobbySelector);
}
protected function createAllElements():void{
createRoomList();
createPlayerList();
createChallengeList();
createLobbySelector();
createRoomSetup();
}
protected function createChallengeList():void{
challengeList = initChallengeList();
challengeList.setGameServer(gameServer);
challengeList.x = 500;
challengeList.y = 340;
addChild(challengeList);
}
protected function createRoomSetup():void{
roomSetup = initRoomSetup();
roomSetup.setGameServer(gameServer);
roomSetup.x = 10;
roomSetup.y = 60;
addChild(roomSetup);
}
protected function initLobbySelector():LobbySelector{
return (new LobbySelector());
}
protected function createRoomList():void{
roomList = initRoomList();
roomList.setGameServer(gameServer);
roomList.x = 10;
roomList.y = 40;
addChild(roomList);
}
protected function initPlayerList():PlayerList{
return (new PlayerList());
}
protected function initRoomList():RoomList{
return (new RoomList());
}
protected function initRoomSetup():Room_Setup{
return (new Room_Setup());
}
protected function onReadyGame(e:GameServerEvent):void{
roomSetup.show(e.params.roomId);
}
protected function initChallengeList():ChallengeList{
return (new ChallengeList());
}
protected function createPlayerList():void{
playerList = initPlayerList();
playerList.setGameServer(gameServer);
playerList.x = 500;
playerList.y = 40;
addChild(playerList);
}
}
}//package uk.co.inbox.multiplayer.lobby
Section 266
//GamePlayer (uk.co.inbox.multiplayer.player.GamePlayer)
package uk.co.inbox.multiplayer.player {
public class GamePlayer {
protected var _id:int;
protected var _name:String;
protected var _isUser:Boolean;
protected var _serverId:int;
public static var me:GamePlayer;
private static var _myServerId:int;
public function GamePlayer(){
super();
}
public function set name(value:String):void{
_name = value;
}
public function get name():String{
return (_name);
}
public function get isUser():Boolean{
return (_isUser);
}
public function set id(value:int):void{
_id = value;
}
public function get id():int{
return (_id);
}
public function set serverId(value:int):void{
_serverId = value;
if (_serverId == _myServerId){
_isUser = true;
me = this;
};
}
public function get serverId():int{
return (_serverId);
}
public static function set myServerId(value:int):void{
_myServerId = value;
}
public static function get myServerId():int{
return (_myServerId);
}
}
}//package uk.co.inbox.multiplayer.player
Section 267
//Player (uk.co.inbox.multiplayer.player.Player)
package uk.co.inbox.multiplayer.player {
import flash.events.*;
public class Player extends EventDispatcher {
protected var _name:String;
protected var _isGuest:Boolean;// = true
protected var _state:int;// = 0
protected var _isUser:Boolean;// = false
protected var _serverId:int;
public static const STATE_GAME:int = 3;
public static const STATE_DEFAULT:int = 0;
public static const UPDATED:String = "updated";
public static const STATE_WAITING:int = 2;
public static const STATE_IDLE:int = 1;
public static var me:Player;
protected static var _myServerId:int;
protected static var disp:EventDispatcher;
public function Player(){
super();
}
public function updated():void{
if (_isUser){
dispatchEvent(new Event(UPDATED));
staticUpdate();
};
}
public function set state(value:int):void{
_state = value;
updated();
}
public function set isGuest(value:Boolean):void{
_isGuest = value;
updated();
}
public function get name():String{
return (_name);
}
public function get isGuest():Boolean{
return (_isGuest);
}
public function get state():int{
return (_state);
}
public function get isUser():Boolean{
return (_isUser);
}
public function set name(value:String):void{
_name = value;
updated();
}
public function set serverId(value:int):void{
_serverId = value;
if (_serverId == myServerId){
_isUser = true;
me = this;
};
}
public function get serverId():int{
return (_serverId);
}
public static function get myServerId():int{
return (_myServerId);
}
public static function addEventListener(... _args):void{
if (disp == null){
disp = new EventDispatcher();
};
disp.addEventListener.apply(null, _args);
}
public static function dispatchEvent(... _args):void{
if (disp == null){
return;
};
disp.dispatchEvent.apply(null, _args);
}
public static function set myServerId(value:int):void{
_myServerId = value;
}
private static function staticUpdate():void{
dispatchEvent(new Event(UPDATED));
}
public static function removeEventListener(... _args):void{
if (disp == null){
return;
};
disp.removeEventListener.apply(null, _args);
}
}
}//package uk.co.inbox.multiplayer.player
Section 268
//GameServer (uk.co.inbox.multiplayer.server.GameServer)
package uk.co.inbox.multiplayer.server {
import flash.events.*;
import it.gotoandplay.smartfoxserver.*;
import uk.co.inbox.multiplayer.player.*;
import uk.co.inbox.multiplayer.lobby.*;
import it.gotoandplay.smartfoxserver.data.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.debug.*;
public class GameServer extends EventDispatcher {
protected var guestPrefix:String;// = "g$"
protected var isLoggedIn:Boolean;// = false
protected var isDebugTrace:Boolean;// = false
protected var _sfs:SmartFoxClient;
protected var _gameRoom:Room;
protected var lobbyRoom:Room;
protected var extName:String;
public static const CMD_CREATING_GAME_ROOM:String = "lRGR";
public static const CMD_CREATE_GAME_ROOM:String = "lCGR";
public static const CMD_REFRESH_LOBBY:String = "lRL";
public static const CMD_WATCH_GAME_ROOM:String = "lWGR";
public static const CMD_GAME_SEND_CHALLENGE:String = "lSC";
public static const CMD_GET_PLAYER_DATA:String = "lPD";
public static const CMD_GAME_CHAT:String = "gGC";
public static const CMD_GAME_ACCEPT_CHALLENGE:String = "lAC";
public static const CMD_GAME_REJECT_CHALLENGE:String = "lRC";
public static const CMD_CHANGE_LOBBY:String = "lCL";
public static const CMD_READY_GAME:String = "gRG";
public static const CMD_JOIN_GAME_ROOM:String = "lJGR";
public static const CMD_LEAVE_GAME_ROOM:String = "lLGR";
public function GameServer($defaultZone:String, $extName:String, $_sfsDebug:Boolean=false):void{
super();
extName = $extName;
_sfs = new SmartFoxClient($_sfsDebug);
_sfs.addEventListener(SFSEvent.onConnection, onConnection);
_sfs.addEventListener(SFSEvent.onConnectionLost, onConnectionLost);
_sfs.addEventListener(SFSEvent.onLogin, onLogin);
_sfs.addEventListener(SFSEvent.onRoomListUpdate, onRoomListUpdate);
_sfs.addEventListener(SFSEvent.onExtensionResponse, onExtensionResponse);
_sfs.addEventListener(SFSEvent.onJoinRoom, onJoinRoom);
_sfs.addEventListener(SFSEvent.onDebugMessage, onDebugMessage);
_sfs.addEventListener(SFSEvent.onConfigLoadFailure, onConfigLoadError);
_sfs.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
_sfs.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
_sfs.defaultZone = $defaultZone;
}
public function get sfs():SmartFoxClient{
return (_sfs);
}
protected function onRoomListUpdate(e:SFSEvent):void{
var r:Room;
debugTrace("onRoomListUpdate");
var rList:Array = (e.params.roomList as Array);
var lobbyList:Array = [];
for each (r in rList) {
debugTrace(((("r:" + r.getName()) + ", ") + r.isLimbo()));
if (!r.isLimbo()){
if (!r.isGame()){
lobbyList.push(r);
};
};
};
dispatchEvent(new GameServerEvent(GameServerEvent.LOBBY_LIST_UPDATE, {roomList:lobbyList}));
if (isLoggedIn){
_sfs.autoJoin();
};
}
protected function onLobbyRoomData($paramList:Array):void{
var gameRoom:GameRoom;
var i:int;
var j:int;
var player:Player;
var gameRoomDataList:Array;
var gameRoomGamePlayerList:Array;
var gamePlayerDataList:Array;
var gamePlayer:GamePlayer;
var playerData:Array;
var gameRoomsDataList:Array = $paramList[0].split("|");
var roomList:Array = [];
var roomGameParamsList:Array = [];
var roomPlayerParamsList:Array = [];
i = 0;
while (i < gameRoomsDataList.length) {
gameRoomDataList = gameRoomsDataList[i].split(",");
gameRoom = populateGameRoom(gameRoomDataList[0].split("¬"));
if (((!((gameRoomDataList[1] == ""))) && (!((gameRoomDataList[1] == undefined))))){
populateGameRoomGameParams(gameRoom, gameRoomDataList[1].split("¬"));
};
gameRoomGamePlayerList = [];
if (((!((gameRoomDataList[2] == ""))) && (!((gameRoomDataList[2] == undefined))))){
gamePlayerDataList = gameRoomDataList[2].split("¬");
j = 0;
while (j < gamePlayerDataList.length) {
gamePlayer = populateGamePlayer(gamePlayerDataList[j].split("^"));
gameRoomGamePlayerList.push(gamePlayer);
j++;
};
};
gameRoom.playerList = gameRoomGamePlayerList;
roomList.push(gameRoom);
i++;
};
dispatchEvent(new GameServerEvent(GameServerEvent.LOBBY_GAMEROOM_LIST_UPDATE, {roomList:roomList}));
var playerDataList:Array = $paramList[1].split("|");
var playerList:Array = [];
i = 0;
while (i < playerDataList.length) {
playerData = playerDataList[i].split(",");
player = populatePlayer(playerData);
playerList.push(player);
i++;
};
dispatchEvent(new GameServerEvent(GameServerEvent.LOBBY_PLAYER_LIST_UPDATE, {playerList:playerList}));
}
public function get gameRoom():Room{
return (_gameRoom);
}
public function changeLobby($newLobbyId:int):void{
sendLobbyExtensionMessage(CMD_CHANGE_LOBBY, [$newLobbyId]);
}
protected function loseGameSpectator($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.LOSE_GAME_SPECTATOR));
}
protected function onPlayerUpdate($paramList:Array):Player{
return (populatePlayer($paramList));
}
public function acceptGameChallenge($playerId:int):void{
sendLobbyExtensionMessage(CMD_GAME_ACCEPT_CHALLENGE, [$playerId]);
}
public function sendReadyGame():void{
sendGameExtensionMessage(CMD_READY_GAME);
}
public function get isConnected():Boolean{
return (_sfs.isConnected);
}
protected function onExtensionResponse(e:SFSEvent):void{
var type:String = e.params.type;
debugTrace(("onExtensionResponse - type:" + type));
if (type == "str"){
processExtensionString(e.params.dataObj);
};
}
public function sendGameChat($message:String):void{
sendGameExtensionMessage(CMD_GAME_CHAT, [$message]);
}
protected function onLeaveRoom(e:SFSEvent):void{
var leftRoom:Room = e.params.room;
debugTrace((("onLeaveRoom - " + leftRoom.getName()) + " left successfully"));
}
protected function sendLobbyExtensionMessage($cmd:String, $params:Array=null):void{
debugTrace((((((" sendLobbyExtensionMessage - $cmd:" + $cmd) + ", $params:") + $params) + ", lobbyRoom.getId():") + lobbyRoom.getId()));
if ($params == null){
$params = [];
};
_sfs.sendXtMessage(extName, $cmd, $params, "str", lobbyRoom.getId());
}
protected function populateChallenge($paramList:Array):Challenge{
debugTrace(("populateChallenge - $paramList:" + $paramList));
var challenge:Challenge = initChallenge();
challenge.creatorPlayer = populatePlayer($paramList[0].split(","));
var gameRoomDataList:Array = $paramList[1].split(",");
challenge.gameRoom = populateGameRoom(gameRoomDataList[0].split("¬"));
if (((!((gameRoomDataList[1] == ""))) && (!((gameRoomDataList[1] == undefined))))){
populateGameRoomGameParams(challenge.gameRoom, gameRoomDataList[1].split("¬"));
};
return (challenge);
}
protected function populatePlayerFull($paramList:Array):Player{
return (populatePlayer($paramList));
}
public function disconnect(e:Event=null):void{
if (_sfs.isConnected){
_sfs.disconnect();
};
}
public function loginAsGuest($username:String, $zone:String=""):void{
_sfs.login((($zone == "")) ? _sfs.defaultZone : $zone, (guestPrefix + $username), "");
}
protected function onReadyGameRoom($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.READY_GAME_ROOM, {roomId:int($paramList[0])}));
}
protected function onInitGame($paramList:Array):void{
var player:GamePlayer;
var playerDataList:Array = $paramList[0].split("|");
var playerList:Array = [];
var i:int;
while (i < playerDataList.length) {
player = populateGamePlayer(playerDataList[i].split("^"));
playerList.push(player);
i++;
};
dispatchEvent(new GameServerEvent(GameServerEvent.INIT_GAME, {playerList:playerList}));
}
protected function initGamePlayer():GamePlayer{
return (new GamePlayer());
}
protected function onJoinRoom(e:SFSEvent):void{
var joinedRoom:Room = e.params.room;
debugTrace((("onJoinRoom - " + joinedRoom.getName()) + " joined successfully"));
if (!joinedRoom.isLimbo()){
if (joinedRoom.isGame()){
_gameRoom = joinedRoom;
} else {
lobbyRoom = joinedRoom;
_gameRoom = null;
};
};
dispatchEvent(new GameServerEvent(GameServerEvent.JOIN_LOBBY, {lobbyRoom:lobbyRoom, playerList:_sfs.getActiveRoom().getUserList()}));
}
protected function onAbandonGame($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.ABANDON_GAME));
}
protected function onSecurityError(e:SecurityErrorEvent):void{
debugTrace(("onSecurityError - e:" + SecurityErrorEvent));
}
protected function onConnection(e:SFSEvent):void{
var success:Boolean = e.params.success;
if (success){
debugTrace("onConnection - Connection successful!");
dispatchEvent(new GameServerEvent(GameServerEvent.CONNECT_SUCCESS));
} else {
debugTrace(("onConnection - Connection failed! - error:" + e.params.error));
dispatchEvent(new GameServerEvent(GameServerEvent.CONNECT_FAILED, {success:false, error:e.params.error}));
};
}
protected function sendGameExtensionMessage($cmd:String, $params:Array=null):void{
debugTrace((((" sendGameExtensionMessage - $cmd:" + $cmd) + ", $params:") + $params));
if ($params == null){
$params = [];
};
if (gameRoom != null){
_sfs.sendXtMessage(extName, $cmd, $params, "str", gameRoom.getId());
};
}
public function getPlayerData($playerId:int):void{
sendLobbyExtensionMessage(CMD_GET_PLAYER_DATA, [$playerId]);
}
public function rejectGameChallenge($playerId:int):void{
sendLobbyExtensionMessage(CMD_GAME_REJECT_CHALLENGE, [$playerId]);
}
protected function initGameRoom():GameRoom{
return (new GameRoom());
}
protected function onJoinGameRoom($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.JOIN_GAME_ROOM));
}
public function joinGameRoom($roomId:int):void{
sendLobbyExtensionMessage(CMD_JOIN_GAME_ROOM, [$roomId]);
}
protected function debugTrace($msg:String):void{
if (isDebugTrace){
outPut(("GameServer." + $msg));
};
}
protected function onDebugMessage(e:SFSEvent):void{
debugTrace(("_sfs - e.params.message:" + e.params.message));
}
public function refreshLobby():void{
sendLobbyExtensionMessage(CMD_REFRESH_LOBBY);
}
protected function onWatchGameRoom($paramList:Array):void{
var playerData:Array;
var player:Player;
var playerDataList:Array = $paramList[0].split("|");
var playerList:Array = [];
var i:int;
while (i < playerDataList.length) {
playerData = playerDataList[i].split("^");
player = new Player();
player.serverId = playerData[0];
player.name = playerData[1];
playerList.push(player);
i++;
};
dispatchEvent(new GameServerEvent(GameServerEvent.WATCH_GAME, {gameParams:$paramList[1], playerList:playerList}));
}
protected function initPlayer():Player{
return (new Player());
}
protected function initChallenge():Challenge{
return (new Challenge());
}
protected function onIOError(e:IOErrorEvent):void{
debugTrace(("onSecurityError - e:" + IOErrorEvent));
}
public function leaveGameRoom():void{
sendLobbyExtensionMessage(CMD_LEAVE_GAME_ROOM);
}
public function creatingGameRoom($roomId:int):void{
sendLobbyExtensionMessage(CMD_CREATING_GAME_ROOM, [$roomId]);
}
protected function onPlayerLeft($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.LOBBY_PLAYER_LEAVE, {userId:Number($paramList[0])}));
}
protected function onConfigLoadError(e:SFSEvent):void{
debugTrace(("onConfigLoadError - e:" + e));
}
protected function onLogin(e:SFSEvent):void{
debugTrace(("onLogin:" + e.params.success));
if (e.params.success){
isLoggedIn = true;
dispatchEvent(new GameServerEvent(GameServerEvent.LOGIN_SUCCESS));
} else {
isLoggedIn = false;
trace((" server login error:" + e.params.error));
dispatchEvent(new GameServerEvent(GameServerEvent.LOGIN_FAILED, {error:e.params.error}));
};
}
protected function cancelLobbyChallenge($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.CANCEL_LOBBY_CHALLENGE));
}
public function createGameRoom($roomId:int, $isPrivate:Boolean=false, $isMembersOnly:Boolean=false, $isAllowSpectators:Boolean=true):void{
sendLobbyExtensionMessage(CMD_CREATE_GAME_ROOM, [$roomId, ($isPrivate) ? 1 : 0, $isMembersOnly, ($isAllowSpectators) ? 1 : 0]);
}
protected function processExtensionString($allParamList:Array):void{
var remParams:Array;
var _local4:GameRoom;
var _local5:Player;
var _local6:Player;
var _local7:Player;
var _local8:Challenge;
debugTrace(((((((((((((("processExtensionString $allParamList[0]:" + $allParamList[0]) + ", $allParamList[1]:") + $allParamList[1]) + ", $allParamList[2]:") + $allParamList[2]) + ", $allParamList[3]:") + $allParamList[3]) + ", $allParamList[4]:") + $allParamList[4]) + ", $allParamList[5]:") + $allParamList[5]) + ", $allParamList[6]:") + $allParamList[6]));
var method:String = $allParamList[0];
remParams = $allParamList.slice(2);
switch (method){
case "logOK":
onLoginSuccess(remParams);
break;
case "logKO":
isLoggedIn = false;
dispatchEvent(new GameServerEvent(GameServerEvent.LOGIN_FAILED, {error:remParams[0]}));
break;
case "oLRD":
onLobbyRoomData(remParams);
break;
case "uGR":
_local4 = updateGameRoom(remParams);
dispatchEvent(new GameServerEvent(GameServerEvent.LOBBY_GAMEROOM_UPDATE, {gameRoom:_local4}));
break;
case "oGRA":
break;
case "oGRR":
break;
case "uP":
_local5 = onPlayerUpdate(remParams[0].split(","));
dispatchEvent(new GameServerEvent(GameServerEvent.LOBBY_PLAYER_UPDATE, {player:_local5}));
break;
case "oPJ":
_local6 = onPlayerJoin(remParams[0].split(","));
dispatchEvent(new GameServerEvent(GameServerEvent.LOBBY_PLAYER_JOIN, {player:_local6}));
break;
case "oPL":
onPlayerLeft(remParams);
break;
case "oRGR":
onReadyGameRoom(remParams);
break;
case "oJGR":
onJoinGameRoom(remParams);
break;
case "oWGR":
onWatchGameRoom(remParams);
break;
case "lPD":
_local7 = receivePlayerData(remParams[0].split(","));
dispatchEvent(new GameServerEvent(GameServerEvent.RECEIVE_PLAYER_DATA, {player:_local7}));
break;
case "lRC":
_local8 = receiveLobbyChallenge(remParams[0].split("|"));
dispatchEvent(new GameServerEvent(GameServerEvent.RECEIVE_LOBBY_CHALLENGE, {challenge:_local8}));
break;
case "gIG":
onInitGame(remParams);
break;
case "gSG":
onStartGame(remParams);
break;
case "gCG":
onCompleteGame(remParams);
break;
case "gAG":
onAbandonGame(remParams);
break;
case "gAP":
addGamePlayer(remParams);
break;
case "gLP":
loseGamePlayer(remParams);
break;
case "gAS":
addGameSpectator(remParams);
break;
case "gLS":
loseGameSpectator(remParams);
break;
case "gC":
receiveGameChat(remParams);
break;
};
}
protected function onStartGame($paramList:Array):void{
var player:GamePlayer;
var playerDataList:Array = $paramList[0].split("|");
var playerList:Array = [];
var i:int;
while (i < playerDataList.length) {
player = populateGamePlayer(playerDataList[i].split("^"));
playerList.push(player);
i++;
};
dispatchEvent(new GameServerEvent(GameServerEvent.START_GAME, {playerList:playerList}));
}
protected function updateGameRoom($paramList:Array):GameRoom{
var j:int;
var gamePlayerDataList:Array;
var gamePlayer:GamePlayer;
var gameRoomDataList:Array = $paramList[0].split(",");
var gameRoom:GameRoom = populateGameRoom(gameRoomDataList[0].split("¬"));
if (((!((gameRoomDataList[1] == ""))) && (!((gameRoomDataList[1] == undefined))))){
populateGameRoomGameParams(gameRoom, gameRoomDataList[1].split("¬"));
};
var gameRoomGamePlayerList:Array = [];
if (((!((gameRoomDataList[2] == ""))) && (!((gameRoomDataList[2] == undefined))))){
gamePlayerDataList = gameRoomDataList[2].split("¬");
j = 0;
while (j < gamePlayerDataList.length) {
gamePlayer = populateGamePlayer(gamePlayerDataList[j].split("^"));
gameRoomGamePlayerList.push(gamePlayer);
j++;
};
};
gameRoom.playerList = gameRoomGamePlayerList;
return (gameRoom);
}
protected function onLoginSuccess($paramList:Array):Player{
isLoggedIn = true;
_sfs.myUserId = int($paramList[0]);
_sfs.myUserName = $paramList[1];
Player.myServerId = _sfs.myUserId;
GamePlayer.myServerId = _sfs.myUserId;
var player:Player = populatePlayerFull($paramList[2].split(","));
dispatchEvent(new GameServerEvent(GameServerEvent.LOGIN_SUCCESS, {player:player}));
return (player);
}
public function watchGameRoom($roomId:int):void{
sendLobbyExtensionMessage(CMD_WATCH_GAME_ROOM, [$roomId]);
}
protected function onConnectionLost(e:SFSEvent):void{
debugTrace("onConnectionLost");
var params:Object = {};
if (e.params != null){
params.error = e.params.error;
};
dispatchEvent(new GameServerEvent(GameServerEvent.DISCONNECTED, params));
}
protected function onCompleteGame($paramList:Array):void{
var player:GamePlayer;
var playerDataList:Array = $paramList[1].split("|");
var playerList:Array = [];
var i:int;
while (i < playerDataList.length) {
player = populateGamePlayer(playerDataList[i].split("^"));
playerList.push(player);
i++;
};
dispatchEvent(new GameServerEvent(GameServerEvent.COMPLETE_GAME, {winnerId:$paramList[0], playerList:playerList}));
}
protected function loseGamePlayer($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.LOSE_GAME_PLAYER));
}
public function login($username:String, $password:String="", $zone:String=""):void{
_sfs.login((($zone == "")) ? _sfs.defaultZone : $zone, $username, $password);
}
public function connect():void{
debugTrace("connect - connecting...");
if (!_sfs.isConnected){
_sfs.connect(Settings.get("multiplayerIP"), Settings.get("multiplayerPort"));
} else {
debugTrace("connect - You are already connected!");
dispatchEvent(new GameServerEvent(GameServerEvent.CONNECT_SUCCESS));
};
}
protected function populatePlayer($paramList:Array):Player{
debugTrace(("populatePlayer - $paramList:" + $paramList));
var player:Player = initPlayer();
player.serverId = Number($paramList[0]);
player.name = $paramList[1];
player.isGuest = ($paramList[2] == "1");
player.state = $paramList[3];
return (player);
}
protected function receiveGameChat($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.RECEIVE_GAME_CHAT, {fromId:$paramList[0], from:$paramList[1], message:$paramList[2]}));
}
protected function receivePlayerData($paramList:Array):Player{
return (populatePlayerFull($paramList));
}
protected function populateGameRoomGameParams($gameRoom:GameRoom, $paramList:Array):void{
}
protected function receiveLobbyChallenge($paramList:Array):Challenge{
return (populateChallenge($paramList));
}
protected function onPlayerJoin($paramList:Array):Player{
return (populatePlayer($paramList));
}
protected function onGameRoomAdded():GameRoom{
return (null);
}
protected function populateGameRoom($paramList:Array):GameRoom{
var gameRoom:GameRoom = initGameRoom();
gameRoom.id = Number($paramList[0]);
gameRoom.serverId = Number($paramList[1]);
gameRoom.name = $paramList[2];
gameRoom.state = Number($paramList[3]);
gameRoom.isPrivate = ($paramList[4] == "1");
gameRoom.isMembersOnly = ($paramList[5] == "1");
gameRoom.isAllowSpectators = ($paramList[6] == "1");
return (gameRoom);
}
public function sendGameChallenge($playerId:int):void{
sendLobbyExtensionMessage(CMD_GAME_SEND_CHALLENGE, [$playerId]);
}
public function destroy():void{
_sfs.removeEventListener(SFSEvent.onConnection, onConnection);
_sfs.removeEventListener(SFSEvent.onConnectionLost, onConnectionLost);
_sfs.removeEventListener(SFSEvent.onLogin, onLogin);
_sfs.removeEventListener(SFSEvent.onRoomListUpdate, onRoomListUpdate);
_sfs.removeEventListener(SFSEvent.onExtensionResponse, onExtensionResponse);
_sfs.removeEventListener(SFSEvent.onJoinRoom, onJoinRoom);
_sfs.removeEventListener(SFSEvent.onDebugMessage, onDebugMessage);
_sfs.removeEventListener(SFSEvent.onConfigLoadFailure, onConfigLoadError);
_sfs.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
_sfs.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
}
protected function addGamePlayer($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.ADD_GAME_PLAYER));
}
protected function addGameSpectator($paramList:Array):void{
dispatchEvent(new GameServerEvent(GameServerEvent.ADD_GAME_SPECTATOR));
}
protected function populateGamePlayer($paramList:Array):GamePlayer{
debugTrace(("populateGamePlayer - $paramList:" + $paramList));
var player:GamePlayer = initGamePlayer();
player.serverId = Number($paramList[0]);
player.id = Number($paramList[1]);
player.name = $paramList[2];
return (player);
}
}
}//package uk.co.inbox.multiplayer.server
Section 269
//GameServerEvent (uk.co.inbox.multiplayer.server.GameServerEvent)
package uk.co.inbox.multiplayer.server {
import flash.events.*;
public class GameServerEvent extends Event {
public var params:Object;
public static const LOBBY_LIST_UPDATE:String = "lobbyListUpdate";
public static const RECEIVE_LOBBY_CHALLENGE:String = "receiveLobbyChallenge";
public static const LOBBY_GAMEROOM_LIST_UPDATE:String = "lobbyGameRoomListUpdate";
public static const ADD_GAME_PLAYER:String = "addGameUser";
public static const WATCH_GAME:String = "watchGame";
public static const LOBBY_GAMEROOM_ADDED:String = "lobbyGameRoomAdded";
public static const ABANDON_GAME:String = "abandonGame";
public static const LOBBY_PLAYER_UPDATE:String = "lobbyPlayerUpdate";
public static const RECEIVE_GAME_CHAT:String = "receiveGameChat";
public static const LOSE_GAME_PLAYER:String = "loseGameUser";
public static const LOBBY_PLAYER_LEAVE:String = "lobbyPlayerLeave";
public static const LOSE_GAME_SPECTATOR:String = "loseGameSpectator";
public static const JOIN_GAME_ROOM:String = "joinGameRoom";
public static const CANCEL_LOBBY_CHALLENGE:String = "cancelLobbyChallenge";
public static const LOBBY_GAMEROOM_REMOVED:String = "lobbyGameRoomRemoved";
public static const DISCONNECTED:String = "disconnected";
public static const COMPLETE_GAME:String = "completeGame";
public static const ADD_GAME_SPECTATOR:String = "addGameSpectator";
public static const INIT_GAME:String = "initGame";
public static const LOBBY_PLAYER_JOIN:String = "lobbyPlayerJoin";
public static const READY_GAME_ROOM:String = "readyGameRoom";
public static const START_GAME:String = "startGame";
public static const CONNECT_FAILED:String = "connectFailed";
public static const RECEIVE_PLAYER_DATA:String = "receivePlayerData";
public static const LOBBY_PLAYER_LIST_UPDATE:String = "lobbyPlayerListUpdate";
public static const JOIN_LOBBY:String = "joinLobby";
public static const LOGIN_SUCCESS:String = "loginSuccess";
public static const CONNECT_SUCCESS:String = "connectSuccess";
public static const LOBBY_GAMEROOM_UPDATE:String = "lobbyGameRoomUpdate";
public static const LOGIN_FAILED:String = "loginFailed";
public function GameServerEvent(type:String, params:Object=null){
super(type);
this.params = params;
}
override public function toString():String{
return (formatToString("GameServerEvent", "type", "bubbles", "cancelable", "eventPhase", "params"));
}
override public function clone():Event{
return (new GameServerEvent(type, params));
}
}
}//package uk.co.inbox.multiplayer.server
Section 270
//ScoreEvent (uk.co.inbox.score.events.ScoreEvent)
package uk.co.inbox.score.events {
import flash.events.*;
public class ScoreEvent extends Event {
public static const BEST_SCORE_UPDATED:String = "bestScoreUpdated";
public static const GLOBAL_RANKING_UPDATED:String = "globalRankingUpdated";
public static const GLOBAL_RANKING_LOADED:String = "globalRankingLoaded";
public function ScoreEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
override public function toString():String{
return (formatToString("ScoreEvent", "type", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new ScoreEvent(type, bubbles, cancelable));
}
}
}//package uk.co.inbox.score.events
Section 271
//GlobalRanking (uk.co.inbox.score.GlobalRanking)
package uk.co.inbox.score {
import flash.events.*;
import flash.net.*;
import uk.co.inbox.score.*;
import uk.co.inbox.score.events.*;
import flash.utils.*;
import uk.co.inbox.debug.*;
class GlobalRanking extends EventDispatcher {
private var filePath:String;// = "http://www.inboxtag.com/rankings/"
private var _status:int;// = 0
private var rankingList:Array;
private var ranking:int;// = 0
private var isDebugMode:Boolean;// = false
private var fileTitle:String;// = ""
public static const STATUS_LOADED:int = 1;
public static const STATUS_ERROR:int = 2;
public static const STATUS_LOADING:int = 0;
protected static var disp:EventDispatcher;
function GlobalRanking($fileTitle:String):void{
rankingList = [];
super();
fileTitle = $fileTitle;
retrieveRanking();
}
public function set status($newStatus:int):void{
_status = $newStatus;
}
private function retrieveSuccess(event:Event):void{
var j:int;
var loader:URLLoader = URLLoader(event.target);
var vars:URLVariables = new URLVariables(loader.data);
rankingList = vars.rankings.split("|");
var i:int;
while (i < rankingList.length) {
rankingList[i] = rankingList[i].split(",");
j = 0;
while (j < rankingList[i].length) {
rankingList[i][j] = parseInt(rankingList[i][j]);
j++;
};
i++;
};
status = STATUS_LOADED;
dispatchEvent(new ScoreEvent(ScoreEvent.GLOBAL_RANKING_LOADED));
}
private function debugTrace($msg):void{
if (isDebugMode){
outPut($msg, "GlobalRanking");
};
}
public function calculateRanking(bestScore:int, isPositive:Boolean, defaultScore:int):int{
var isFound:Boolean;
var i:int;
var perc:Number;
debugTrace("calculateRanking");
debugTrace((" bestScore:" + bestScore));
debugTrace((" isPositive:" + isPositive));
debugTrace((" defaultScore:" + defaultScore));
if (status == STATUS_LOADED){
if (isPositive){
isFound = false;
i = 0;
while (((!(isFound)) && ((i < rankingList.length)))) {
if (bestScore >= rankingList[i][1]){
ranking = rankingList[i][0];
isFound = true;
} else {
if ((((bestScore < rankingList[i][1])) && ((bestScore >= rankingList[i][3])))){
isFound = true;
perc = ((bestScore - rankingList[i][3]) / (rankingList[i][1] - rankingList[i][3]));
ranking = Math.floor((rankingList[i][2] + (1 - ((rankingList[i][2] - rankingList[i][0]) * perc))));
} else {
i++;
};
};
};
if (!isFound){
if (bestScore >= rankingList[0][1]){
ranking = 1;
} else {
ranking = int((rankingList[(i - 1)][2] + 1));
};
};
if (bestScore == defaultScore){
ranking = 0;
};
} else {
isFound = false;
i = 0;
while (((!(isFound)) && ((i < rankingList.length)))) {
if (bestScore <= rankingList[i][1]){
ranking = rankingList[i][0];
isFound = true;
} else {
if ((((bestScore > rankingList[i][1])) && ((bestScore <= rankingList[i][3])))){
isFound = true;
perc = ((bestScore - rankingList[i][3]) / (rankingList[i][1] - rankingList[i][3]));
ranking = Math.floor((rankingList[i][2] - (1 - ((rankingList[i][2] - rankingList[i][0]) * perc))));
} else {
i++;
};
};
};
if (!isFound){
if (bestScore < rankingList[0][1]){
ranking = 1;
} else {
ranking = int((rankingList[(i - 1)][2] + 1));
};
};
if (bestScore == defaultScore){
ranking = 0;
};
};
dispatchEvent(new ScoreEvent(ScoreEvent.GLOBAL_RANKING_UPDATED));
return (ranking);
//unresolved jump
};
dispatchEvent(new ScoreEvent(ScoreEvent.GLOBAL_RANKING_UPDATED));
return (-1);
}
public function get status():int{
return (_status);
}
private function retrieveFailed(ioEvent:IOErrorEvent):void{
status = STATUS_ERROR;
throw (new Error(("Couldn't load GlobalRanking file - ioEvent:" + ioEvent)));
}
private function retrieveRanking():void{
var sendVars:URLLoader;
var req:URLRequest = new URLRequest(((filePath + fileTitle) + ".txt"));
req.data = {rnd:new Date().getTime()};
sendVars = new URLLoader(req);
//unresolved jump
var _slot1 = e;
retrieveFailed(null);
sendVars.addEventListener(Event.COMPLETE, retrieveSuccess);
sendVars.addEventListener(IOErrorEvent.IO_ERROR, retrieveFailed);
}
}
}//package uk.co.inbox.score
Section 272
//Score (uk.co.inbox.score.Score)
package uk.co.inbox.score {
import flash.events.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.tracking.*;
import uk.co.inbox.league.*;
import uk.co.inbox.debug.*;
public class Score extends EventDispatcher {
private static var scoreList:Array = [];
private static var isDebugMode:Boolean = false;
private static var isMultiScore:Boolean = false;
protected static var disp:EventDispatcher;
public function Score(){
super();
}
public static function dispatchEvent(... _args):void{
if (disp == null){
return;
};
disp.dispatchEvent.apply(null, _args);
}
public static function getDefaultScore(scoreListInd:int=0):int{
if (scoreList[scoreListInd] == null){
return (-1);
};
return (scoreList[scoreListInd].defaultScore);
}
public static function setAttempts(newAttempts:int, scoreListInd:int=0):void{
if (scoreListInd > scoreList.length){
throw (new Error(((("Score - setAttempts - scoreListInd:" + scoreListInd) + " is outside scoreList length:") + scoreList.length)));
};
scoreList[scoreListInd].attempts = newAttempts;
}
public static function updateScore(newScore:int, scoreListInd:int=0):int{
var obj:Object;
var scoreObj:Object = scoreList[scoreListInd];
scoreObj.attempts++;
var isNewBest:Boolean;
if (scoreObj.isPositive){
if (newScore > scoreObj.bestScore){
scoreObj.bestScore = newScore;
isNewBest = true;
};
} else {
if (newScore < scoreObj.bestScore){
scoreObj.bestScore = newScore;
isNewBest = true;
};
};
if (isNewBest){
if (isMultiScore){
InboxTag.callTag(InboxTagData[("SUBMIT_SCORE" + scoreListInd)], "", "", "", "", "", scoreObj.bestScore);
} else {
InboxTag.callTag(InboxTagData.SUBMIT_SCORE, "", "", "", "", "", scoreObj.bestScore);
};
if (!League.isLeague){
obj = {};
obj[("ScoreBestScore" + scoreListInd)] = scoreObj.bestScore;
CustomSharedObject.set(obj);
};
};
var obj2:Object = {};
obj2[("ScoreAttempts" + scoreListInd)] = scoreObj.attempts;
CustomSharedObject.set(obj2);
if (League.isLeague){
League.sendScore(scoreObj.bestScore, scoreObj.attempts, isNewBest);
};
return (getGlobalRanking(scoreListInd));
}
public static function removeEventListener(... _args):void{
if (disp == null){
return;
};
disp.removeEventListener.apply(null, _args);
}
public static function setBestScore(newScore:int, scoreListInd:int=0):void{
if (scoreListInd > scoreList.length){
throw (new Error(((("Score - setBestScore - scoreListInd:" + scoreListInd) + " is outside scoreList length:") + scoreList.length)));
};
scoreList[scoreListInd].bestScore = newScore;
}
public static function get bestScore():int{
return (getBestScore());
}
public static function get defaultScore():int{
return (getDefaultScore());
}
public static function get globalRanking():int{
return (getGlobalRanking());
}
public static function addEventListener(... _args):void{
if (disp == null){
disp = new EventDispatcher();
};
disp.addEventListener.apply(null, _args);
}
public static function get attempts():int{
return (getAttempts());
}
public static function init($scoreList:Array=null):void{
scoreList = $scoreList;
isMultiScore = ((scoreList.length > 1)) ? true : false;
var i:int;
while (i < scoreList.length) {
scoreList[i].bestScore = CustomSharedObject.get(("ScoreBestScore" + i), scoreList[i].defaultScore);
scoreList[i].attempts = CustomSharedObject.get(("ScoreAttempts" + i), 0);
if (scoreList[i].isGlobalRanking){
if (isMultiScore){
scoreList[i].globalRanking = new GlobalRanking((Settings.get("gameName") + i));
} else {
scoreList[i].globalRanking = new GlobalRanking(Settings.get("gameName"));
};
};
i++;
};
}
public static function getBestScore(scoreListInd:int=0):int{
if (scoreList[scoreListInd] == null){
return (-1);
};
return (scoreList[scoreListInd].bestScore);
}
public static function getScoreList():Array{
return (scoreList);
}
public static function getGlobalRanking(scoreListInd:int=0):int{
if (scoreList[scoreListInd] == null){
return (-1);
};
if (scoreList[scoreListInd].isGlobalRanking){
return (scoreList[scoreListInd].globalRanking.calculateRanking(scoreList[scoreListInd].bestScore, scoreList[scoreListInd].isPositive, scoreList[scoreListInd].defaultScore));
};
return (-1);
}
private static function debugTrace($msg):void{
if (isDebugMode){
outPut($msg, "Score");
};
}
public static function getAttempts(scoreListInd:int=0):int{
return (scoreList[scoreListInd].attempts);
}
}
}//package uk.co.inbox.score
Section 273
//ScoreItem (uk.co.inbox.score.ScoreItem)
package uk.co.inbox.score {
import flash.events.*;
import uk.co.inbox.score.events.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.tracking.*;
import uk.co.inbox.league.*;
public class ScoreItem extends EventDispatcher {
private var isPositive:Boolean;
private var _attempts:int;
private var inboxTagId:Number;// = -1
private var _defaultScore:Number;
private var _globalRanking:GlobalRanking;
private var _bestScore:Number;
private var uniqueSOId:String;
public function ScoreItem($isPositive:Boolean=true, $defaultScore:Number=0, $uniqueSOId:String=""){
super();
isPositive = $isPositive;
_defaultScore = $defaultScore;
uniqueSOId = $uniqueSOId;
_bestScore = CustomSharedObject.get(("ScoreBestScore" + uniqueSOId), _defaultScore);
_attempts = CustomSharedObject.get(("ScoreAttempts" + uniqueSOId), 0);
}
public function update($newScore:Number):void{
var obj:Object;
_attempts++;
var isNewBest:Boolean;
if (isPositive){
if ($newScore > bestScore){
_bestScore = $newScore;
isNewBest = true;
};
} else {
if ($newScore < bestScore){
_bestScore = $newScore;
isNewBest = true;
};
};
if (isNewBest){
if (inboxTagId != -1){
InboxTag.callTag(inboxTagId, "", "", "", "", "", bestScore);
};
if (!League.isLeague){
obj = {};
obj[("ScoreBestScore" + uniqueSOId)] = bestScore;
CustomSharedObject.set(obj);
};
};
var obj2:Object = {};
obj2[("ScoreAttempts" + uniqueSOId)] = attempts;
CustomSharedObject.set(obj2);
if (League.isLeague){
League.sendScore(_bestScore, _attempts, isNewBest);
};
if (isNewBest){
dispatchEvent(new ScoreEvent(ScoreEvent.BEST_SCORE_UPDATED));
};
}
public function get bestScore():Number{
return (_bestScore);
}
public function setGlobalRanking($name:String, $tagId:Number):void{
inboxTagId = $tagId;
_globalRanking = new GlobalRanking($name);
}
public function get attempts():int{
return (_attempts);
}
public function get defaultScore():Number{
return (_defaultScore);
}
public function get globalRanking():GlobalRanking{
return (_globalRanking);
}
public function get ranking():int{
return (((_globalRanking == null)) ? -1 : _globalRanking.calculateRanking(bestScore, isPositive, defaultScore));
}
}
}//package uk.co.inbox.score
Section 274
//InboxTag (uk.co.inbox.tracking.InboxTag)
package uk.co.inbox.tracking {
import flash.events.*;
import flash.net.*;
import flash.display.*;
import uk.co.inbox.hub.*;
import uk.co.inbox.debug.*;
import flash.system.*;
public class InboxTag {
private static var timeOut:int = 600;
public static var hubDebugLength:Number = 7;
private static var tagHolder:Sprite;
public static var isHubDebug:Boolean = true;
public static var isDebugMode:Boolean = true;
private static var overrideClientId:int = -1;
private static var isInit:Boolean = false;
private static var tagPath:String = "http://www.inboxtag.com/";
public function InboxTag(){
super();
}
public static function setClientId($clientId:int):void{
overrideClientId = $clientId;
}
public static function init($myHolder:DisplayObjectContainer):void{
Security.allowDomain(tagPath);
if (!isInit){
tagHolder = new Sprite();
$myHolder.addChild(tagHolder);
};
isInit = true;
}
private static function debugTrace(msg):void{
if (isDebugMode){
outPut(("InboxTag - " + msg));
};
}
public static function callTag($id:int, $stringParam1:String="", $stringParam2:String="", $stringParam3:String="", $stringParam4:String="", $stringParam5:String="", $numberParam1:Number=NaN, $numberParam2:Number=NaN, $numberParam3:Number=NaN, $sourceId:int=0, $altClientId:int=-1):void{
var clientId:int;
var debugHubText:String;
var tagName:String;
var i:int;
var loader:Loader;
var request:URLRequest;
var variables:URLVariables;
if (!isInit){
if (isHubDebug){
HubLink.showAlert("InboxTag Error", ("Couldn't find id: " + $id), 0, hubDebugLength);
};
debugTrace("callTag error. Check that InboxTag.init() has been called");
} else {
debugTrace("callTag start---------------------");
clientId = ((overrideClientId == -1)) ? InboxTagData.clientId : overrideClientId;
debugHubText = (((("<b>" + InboxTagData.getTagNameById($id)) + "</b> (") + $id) + ")");
debugTrace((((" ID:" + $id) + " - ") + InboxTagData.getTagNameById($id)));
tagName = InboxTagData.getTagNameById($id);
i = 1;
while (i <= 5) {
if (arguments[i] != undefined){
if (arguments[i] != ""){
debugHubText = (debugHubText + ((("<br> <b>P" + i) + "</b>: ") + arguments[i]));
debugTrace((((" P" + i) + ": ") + arguments[i]));
};
};
i++;
};
i = 1;
while (i <= 3) {
if (arguments[(i + 5)] != undefined){
if (!isNaN(arguments[(i + 5)])){
debugHubText = (debugHubText + ((("<br> <b>I" + i) + "</b>: ") + arguments[(i + 5)]));
debugTrace((((" I" + i) + ": ") + arguments[(i + 5)]));
};
};
i++;
};
if (isHubDebug){
HubLink.showAlert((("InboxTag (Client ID: " + clientId) + ")"), debugHubText, 2, hubDebugLength);
};
debugTrace("callTag end---------------------------------");
loader = new Loader();
request = new URLRequest((tagPath + "tag.swf"));
variables = new URLVariables();
variables.js = "yes";
variables.isFlashCall = true;
variables.ti = timeOut;
variables.cl = clientId;
variables.pg = $id;
if ($sourceId != 0){
variables.sc = $sourceId;
};
i = 1;
while (i <= 5) {
if (arguments[i] != undefined){
variables[("p" + i)] = arguments[i];
};
i++;
};
i = 1;
while (i <= 3) {
if (arguments[(i + 5)] != undefined){
if (!isNaN(arguments[(i + 5)])){
variables[("i" + i)] = arguments[(i + 5)];
};
};
i++;
};
variables.rnd = new Date().getTime();
request.data = variables;
loader.load(request);
tagHolder.addChild(loader);
};
}
}
}//package uk.co.inbox.tracking
Section 275
//InboxTagData (uk.co.inbox.tracking.InboxTagData)
package uk.co.inbox.tracking {
import flash.utils.*;
public class InboxTagData {
public static const INIT_FLASH_LOAD:int = 4265;
public static const PLAY_MEMBER:int = 4286;
public static const CHANGE_LANGUAGE:int = 0;
public static const LOGIN:int = 4266;
public static const SUBMIT_SCORE:int = 0;
public static const CREATE_LEAGUE:int = 0;
public static const SERVER_ERROR:int = 4287;
public static const PLAY_GUEST:int = 4285;
public static const LOGIN_ERROR:int = 4288;
public static const JOIN_LEAGUE:int = 0;
public static const SINGLE_PLAYER:int = 4267;
public static const MULTIPLAYER:int = 4268;
private static var _clientId:int = 249;
public function InboxTagData(){
super();
}
public static function getTagNameById($id:int):String{
var i:int;
var varList:XMLList = describeType(InboxTagData)..constant;
while (i < varList.length()) {
if (InboxTagData[varList[i].@name] == $id){
return (varList[i].@name);
};
i++;
};
return ("");
}
public static function get clientId():int{
return (_clientId);
}
}
}//package uk.co.inbox.tracking
Section 276
//BlackholeCommandCache (uk.co.inbox.users.cache.BlackholeCommandCache)
package uk.co.inbox.users.cache {
import uk.co.inbox.users.commands.*;
public class BlackholeCommandCache implements ICommandCache {
public function BlackholeCommandCache(){
super();
}
public function addSavedData(time:Number, bytes:Number):void{
}
public function getBytesSaved():Number{
return (0);
}
public function getTimeSaved():Number{
return (0);
}
public function hasSignature(str:String):UserCommand{
return (null);
}
public function addSignature(cmd:UserCommand, str:String):void{
}
}
}//package uk.co.inbox.users.cache
Section 277
//CachedItem (uk.co.inbox.users.cache.CachedItem)
package uk.co.inbox.users.cache {
import uk.co.inbox.users.commands.*;
import flash.utils.*;
public class CachedItem {
public var sig:String;
public var cachedAt:Number;
public var cmd:UserCommand;
public function CachedItem(cmd:UserCommand, sig:String){
super();
this.sig = sig;
this.cachedAt = getTimer();
this.cmd = cmd;
}
}
}//package uk.co.inbox.users.cache
Section 278
//ICommandCache (uk.co.inbox.users.cache.ICommandCache)
package uk.co.inbox.users.cache {
import uk.co.inbox.users.commands.*;
public interface ICommandCache {
function addSavedData(_arg1:Number, _arg2:Number):void;
function getBytesSaved():Number;
function getTimeSaved():Number;
function addSignature(_arg1:UserCommand, _arg2:String):void;
function hasSignature(:String):UserCommand;
}
}//package uk.co.inbox.users.cache
Section 279
//SimpleCommandCache (uk.co.inbox.users.cache.SimpleCommandCache)
package uk.co.inbox.users.cache {
import uk.co.inbox.users.commands.*;
import flash.utils.*;
import uk.co.inbox.debug.*;
public class SimpleCommandCache implements ICommandCache {
private var cache:Array;
private var cacheSavedBytes:Number;// = 0
public var cacheTime:int;// = 60
private var cacheSavedTime:Number;// = 0
public function SimpleCommandCache(){
cache = [];
super();
}
public function getBytesSaved():Number{
return (cacheSavedBytes);
}
public function addSavedData(time:Number, bytes:Number):void{
cacheSavedTime = (cacheSavedTime + time);
cacheSavedBytes = (cacheSavedBytes + bytes);
}
public function addSignature(cmd:UserCommand, str:String):void{
outPut((getQualifiedClassName(this) + "::addSignature() - Added Sig"));
cache[str] = new CachedItem(cmd, str);
}
public function purge():void{
cache = [];
}
public function getTimeSaved():Number{
return (cacheSavedTime);
}
public function hasSignature(str:String):UserCommand{
var item:CachedItem;
var currentTime:Number = getTimer();
for each (item in cache) {
if ((currentTime - item.cachedAt) > (cacheTime * 1000)){
outPut((getQualifiedClassName(this) + "::addSignature() - Old item cleared from cache"));
cache[item.sig] = null;
delete cache[item.sig];
};
};
return (((cache[str])!=null) ? CachedItem(cache[str]).cmd : null);
}
}
}//package uk.co.inbox.users.cache
Section 280
//AddScoreCommand (uk.co.inbox.users.commands.concrete.AddScoreCommand)
package uk.co.inbox.users.commands.concrete {
import uk.co.inbox.users.commands.*;
import flash.utils.*;
import uk.co.inbox.debug.*;
public class AddScoreCommand extends UserCommand {
private var scoreb:String;// = null
private var scorec:String;// = null
private var score:String;
private var mode:String;// = null
public function AddScoreCommand($score:String, $scoreb:String=null, $scorec:String=null, $mode:String=null){
super();
requiresLogin = true;
queueable = true;
score = $score;
scoreb = $scoreb;
scorec = $scorec;
mode = $mode;
cmdName = "addScore";
}
override public function compare(comparision:UserCommand):int{
var compareWith:AddScoreCommand;
var comparision = comparision;
compareWith = (comparision as AddScoreCommand);
if (int(compareWith.score) < int(score)){
return (1);
};
if (int(compareWith.score) > int(score)){
return (-1);
};
//unresolved jump
var _slot1 = e;
outPut((((getQualifiedClassName(this) + "::compare( ") + comparision) + " ) - Invalid comparison type"));
return (0);
}
override public function returnPOSTVars():Object{
var post:Object = {};
post.score = score;
if (scoreb){
post.scoreb = scoreb;
};
if (scorec){
post.scorec = scorec;
};
if (mode){
post.mode = mode;
};
return (post);
}
}
}//package uk.co.inbox.users.commands.concrete
Section 281
//GetAffiliationScoresCommand (uk.co.inbox.users.commands.concrete.GetAffiliationScoresCommand)
package uk.co.inbox.users.commands.concrete {
import uk.co.inbox.users.commands.*;
import uk.co.inbox.users.items.*;
public class GetAffiliationScoresCommand extends UserCommand {
public var scores:Array;
public var total:int;// = 0
private var selectFrom:String;
private var leagueId:String;
private var selectAmount:String;
private var scoreMode:String;
private var type:String;
public function GetAffiliationScoresCommand(leagueId:String, type:String, selectFrom:int=0, selectAmount:int=30, scoreMode:String=null){
scores = [];
super();
cmdName = "getAffiliationScores";
this.leagueId = leagueId;
this.selectFrom = selectFrom.toString();
this.selectAmount = selectAmount.toString();
this.type = type;
this.scoreMode = scoreMode;
}
override public function returnPOSTVars():Object{
var post:Object = {};
post.leagueId = leagueId;
post.selectFrom = selectFrom;
post.selectAmount = selectAmount;
post.type = type;
if (scoreMode != null){
post.scoreMode = scoreMode;
};
return (post);
}
override protected function onSuccess():void{
var score:XML;
var item:ScoreInfo;
total = ((xmlReturned.totalScores) || (0));
scores = [];
var i:int;
while (i < xmlReturned.scores.score.length()) {
score = xmlReturned.scores.score[i];
item = new ScoreInfo();
item.loadXML(score);
scores.push(item);
i++;
};
super.onSuccess();
}
}
}//package uk.co.inbox.users.commands.concrete
Section 282
//LoginCommand (uk.co.inbox.users.commands.concrete.LoginCommand)
package uk.co.inbox.users.commands.concrete {
import uk.co.inbox.users.*;
import uk.co.inbox.users.commands.*;
import uk.co.inbox.users.commands.events.*;
public class LoginCommand extends UserCommand {
private var keyAsPass:Boolean;
private var remember:Boolean;
private var password:String;
private var username:String;
public function LoginCommand($username:String="", $password:String="", $keyAsPass:Boolean=false, $remember:Boolean=false){
super();
cmdName = "login";
relatesLogin = true;
triggersQueue = true;
username = $username;
password = $password;
keyAsPass = $keyAsPass;
remember = $remember;
}
override public function returnPOSTVars():Object{
var post:Object = {};
post.username = username;
if (!keyAsPass){
post.password = password;
} else {
post.key = password;
};
return (post);
}
override protected function onError():void{
var _local1 = handle;
_local1.userspace::applyLoginFromResult(xmlReturned, remember);
super.onError();
handle.dispatchEvent(new UserEvent(UserEvent.EVENT_LOGIN_FAIL));
}
override protected function onSuccess():void{
var _local1 = handle;
_local1.userspace::applyLoginFromResult(xmlReturned, remember);
super.onSuccess();
handle.dispatchEvent(new UserEvent(UserEvent.EVENT_LOGIN_SUCCESS));
}
}
}//package uk.co.inbox.users.commands.concrete
Section 283
//LogoutCommand (uk.co.inbox.users.commands.concrete.LogoutCommand)
package uk.co.inbox.users.commands.concrete {
import uk.co.inbox.users.*;
import uk.co.inbox.users.commands.*;
public class LogoutCommand extends UserCommand {
public function LogoutCommand(){
super();
cmdName = "logout";
}
override protected function onSuccess():void{
super.onSuccess();
var _local1 = handle;
_local1.userspace::applyLogout();
}
}
}//package uk.co.inbox.users.commands.concrete
Section 284
//RegisterCommand (uk.co.inbox.users.commands.concrete.RegisterCommand)
package uk.co.inbox.users.commands.concrete {
import uk.co.inbox.users.*;
import uk.co.inbox.users.commands.*;
import uk.co.inbox.users.commands.events.*;
public class RegisterCommand extends UserCommand {
private var username:String;
private var data:Object;
private var remember:Boolean;
public var awards:Array;
private var password:String;
private var email:String;
public function RegisterCommand($username:String, $password:String, $email:String, $data:Object=null, $remember:Boolean=false){
awards = [];
super();
cmdName = "register";
relatesLogin = true;
triggersQueue = true;
username = $username;
password = $password;
email = $email;
data = $data;
remember = $remember;
}
override public function returnPOSTVars():Object{
var i:String;
var post:Object = {};
post.username = username;
post.password = password;
post.email = email;
for (i in data) {
post[i] = data[i];
};
return (post);
}
override protected function onSuccess():void{
var _local1 = handle;
_local1.userspace::applyLoginFromResult(xmlReturned, remember);
super.onSuccess();
handle.dispatchEvent(new UserEvent(UserEvent.EVENT_REGISTER_SUCCESS));
}
override protected function begin():void{
if (handle.usernameFilter.isSafe(username)){
super.begin();
} else {
setError("Bad username");
onError();
};
}
override protected function onError():void{
var _local1 = handle;
_local1.userspace::applyLoginFromResult(xmlReturned, remember);
super.onError();
handle.dispatchEvent(new UserEvent(UserEvent.EVENT_REGISTER_FAIL));
}
}
}//package uk.co.inbox.users.commands.concrete
Section 285
//SetAffiliationCommand (uk.co.inbox.users.commands.concrete.SetAffiliationCommand)
package uk.co.inbox.users.commands.concrete {
import uk.co.inbox.users.commands.*;
import uk.co.inbox.users.items.*;
import flash.utils.*;
import uk.co.inbox.debug.*;
import uk.co.inbox.users.commands.events.commands.*;
public class SetAffiliationCommand extends UserCommand {
private var type:String;
private var affiliationId:String;
public function SetAffiliationCommand($affiliationId:String, $type:String=null){
super();
cmdName = "setAffiliation";
affiliationId = $affiliationId;
type = $type;
requiresLogin = true;
}
override protected function onSuccess():void{
var affiliationInfo:XML;
var affiliationInfoItem:AffiliationInfo;
if (handle.loggedIn){
affiliationInfo = xmlReturned.affiliation[0];
affiliationInfoItem = new AffiliationInfo(affiliationInfo.id, affiliationInfo.type, affiliationInfo.owner, affiliationInfo.name);
affiliationInfoItem.loadXML(affiliationInfo);
handle.userDetails.affiliations.push(affiliationInfoItem);
handle.dispatchEvent(new SetAffiliationEvent(affiliationInfoItem));
outPut(((((getQualifiedClassName(this) + "::onSuccess() - Affilation added to current user. ") + affiliationInfoItem.aid) + ":") + affiliationInfoItem.name));
};
super.onSuccess();
}
override public function returnPOSTVars():Object{
var post:Object = {};
post.affiliationId = affiliationId;
post.type = type;
return (post);
}
}
}//package uk.co.inbox.users.commands.concrete
Section 286
//SetAffiliationEvent (uk.co.inbox.users.commands.events.commands.SetAffiliationEvent)
package uk.co.inbox.users.commands.events.commands {
import flash.events.*;
import uk.co.inbox.users.items.*;
import flash.utils.*;
import uk.co.inbox.debug.*;
public class SetAffiliationEvent extends Event {
public var affiliation:AffiliationInfo;
public static const SET_AFFILIATION_EVENT:String = "setAffiliationEvent";
public function SetAffiliationEvent(affiliation:AffiliationInfo){
this.affiliation = affiliation;
super(SET_AFFILIATION_EVENT);
outPut((getQualifiedClassName(this) + " SetAffiliationEvent() - "));
}
}
}//package uk.co.inbox.users.commands.events.commands
Section 287
//CommandEvent (uk.co.inbox.users.commands.events.CommandEvent)
package uk.co.inbox.users.commands.events {
import flash.events.*;
public class CommandEvent extends Event {
public var message:String;// = ""
public static const EVENT_COMMAND_COMPLETE:String = "EventCommandComplete";
public static const EVENT_COMMAND_FAIL:String = "EventCommandFail";
public static const EVENT_COMMAND_QUEUED:String = "EventCommandQueued";
public function CommandEvent(type:String, message:String=""){
this.message = message;
super(type);
}
override public function toString():String{
return (formatToString("CommandEvent", "type", "message", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new CommandEvent(type, message));
}
}
}//package uk.co.inbox.users.commands.events
Section 288
//CommandProgressEvent (uk.co.inbox.users.commands.events.CommandProgressEvent)
package uk.co.inbox.users.commands.events {
public class CommandProgressEvent extends CommandEvent {
public var bytesLoaded:int;
public var bytesTotal:int;
public static const COMMAND_PROGRESS_EVENT:String = "CommandProgressEvent";
public function CommandProgressEvent(message:String="", bytesLoaded:int=-1, bytesTotal:int=-1){
this.bytesLoaded = bytesLoaded;
this.bytesTotal = bytesTotal;
super(COMMAND_PROGRESS_EVENT, message);
}
}
}//package uk.co.inbox.users.commands.events
Section 289
//CommandSyncEvent (uk.co.inbox.users.commands.events.CommandSyncEvent)
package uk.co.inbox.users.commands.events {
import flash.events.*;
public class CommandSyncEvent extends Event {
public static const EVENT_LOSE_SYNC:String = "eventLoseSync";
public function CommandSyncEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
override public function toString():String{
return (formatToString("CommandSyncEvent", "type", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new CommandSyncEvent(type, bubbles, cancelable));
}
}
}//package uk.co.inbox.users.commands.events
Section 290
//UserEvent (uk.co.inbox.users.commands.events.UserEvent)
package uk.co.inbox.users.commands.events {
public class UserEvent extends CommandEvent {
public static const EVENT_REGISTER_FAIL:String = "UserEventRegisterFail";
public static const EVENT_LOGIN_SUCCESS:String = "UserEventLoginSuccess";
public static const EVENT_LOGIN_FAIL:String = "UserEventLoginFail";
public static const EVENT_REGISTER_SUCCESS:String = "UserEventRegisterSuccess";
public static const EVENT_LOGOUT:String = "UserEventLogout";
public function UserEvent(type:String, message:String=""){
super(type, message);
}
}
}//package uk.co.inbox.users.commands.events
Section 291
//BadWordFilter (uk.co.inbox.users.commands.filters.BadWordFilter)
package uk.co.inbox.users.commands.filters {
import flash.utils.*;
import uk.co.inbox.debug.*;
public class BadWordFilter implements IStringFilter {
private var badWords:Array;
public function BadWordFilter(){
badWords = ["cunt", "fuck", "cock", "nigger", "wank", "shit", "motherfuckingbaker", "penis", "sexation"];
super();
}
public function getSafe($string:String):String{
var orginal:String = $string;
var i:int;
while (i < badWords.length) {
if ($string.toLowerCase() != $string.replace(badWords[i], "").toLowerCase()){
$string = $string.replace(badWords[i], "");
};
i++;
};
if (orginal != $string){
outPut((getQualifiedClassName(this) + " getSafe() - Variable was filtered:"));
outPut(("\t\twas: " + orginal));
outPut(("\t\tnow: " + $string));
};
return ($string);
}
public function addBadWord($string:String):void{
badWords.push($string);
}
public function isSafe($string:String):Boolean{
return (($string == getSafe($string)));
}
public function addBadWordArray($array:Array):void{
badWords.concat($array);
}
}
}//package uk.co.inbox.users.commands.filters
Section 292
//BlankStringFilter (uk.co.inbox.users.commands.filters.BlankStringFilter)
package uk.co.inbox.users.commands.filters {
public class BlankStringFilter implements IStringFilter {
public function BlankStringFilter(){
super();
}
public function getSafe($string:String):String{
return ($string);
}
public function isSafe($string:String):Boolean{
return (($string == getSafe($string)));
}
}
}//package uk.co.inbox.users.commands.filters
Section 293
//IStringFilter (uk.co.inbox.users.commands.filters.IStringFilter)
package uk.co.inbox.users.commands.filters {
public interface IStringFilter {
function getSafe(:String):String;
function isSafe(C:\Documents and Settings\rwallis\My Documents\FreeKickFusion\src;uk\co\inbox\users\commands\filters;IStringFilter.as:String):Boolean;
}
}//package uk.co.inbox.users.commands.filters
Section 294
//UsernameFilter (uk.co.inbox.users.commands.filters.UsernameFilter)
package uk.co.inbox.users.commands.filters {
public class UsernameFilter extends BadWordFilter {
private var badPrefix:String;
public function UsernameFilter($dissallowPrefix:String=""){
super();
badPrefix = $dissallowPrefix;
}
override public function isSafe($string:String):Boolean{
if (badPrefix == ""){
return (super.isSafe($string));
};
return ((($string.substr(0, badPrefix.length).toLowerCase())!=badPrefix.toLowerCase()) ? super.isSafe($string) : false);
}
}
}//package uk.co.inbox.users.commands.filters
Section 295
//CommandQueue (uk.co.inbox.users.commands.queue.CommandQueue)
package uk.co.inbox.users.commands.queue {
import flash.events.*;
import flash.display.*;
public class CommandQueue extends Sprite {
private var queue:Array;
private var processing:Boolean;// = false
public function CommandQueue(){
queue = [];
super();
addEventListener(Event.ENTER_FRAME, runMe, false, 0, true);
}
private function runMe(e:Event):void{
if (!processing){
startNext();
};
}
public function addItem($item:CommandQueueItem):void{
queue.push($item);
startNext();
}
private function startNext():void{
if (((!(processing)) && ((queue.length >= 1)))){
CommandQueueItem(queue[0]).addEventListener(CommandQueueItem.EVENT_COMMANDQUEUE_COMPLETE, itemComplete, false, 0, true);
processing = true;
CommandQueueItem(queue[0]).startItem();
};
}
private function itemComplete(e:Event):void{
var item:CommandQueueItem = queue.shift();
item.removeEventListener(CommandQueueItem.EVENT_COMMANDQUEUE_COMPLETE, itemComplete);
processing = false;
startNext();
}
}
}//package uk.co.inbox.users.commands.queue
Section 296
//CommandQueueItem (uk.co.inbox.users.commands.queue.CommandQueueItem)
package uk.co.inbox.users.commands.queue {
import flash.events.*;
public class CommandQueueItem extends EventDispatcher {
public static const EVENT_COMMANDQUEUE_COMPLETE:String = "EventCommandQueueComplete";
public function CommandQueueItem(){
super();
}
protected function complete():void{
dispatchEvent(new Event(EVENT_COMMANDQUEUE_COMPLETE));
}
protected function begin():void{
}
function startItem():void{
begin();
}
}
}//package uk.co.inbox.users.commands.queue
Section 297
//Base64 (uk.co.inbox.users.commands.Base64)
package uk.co.inbox.users.commands {
import flash.utils.*;
public class Base64 {
public static const version:String = "1.1.0";
private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
public function Base64(){
super();
throw (new Error("Base64 class is static container only"));
}
public static function encode(data:String):String{
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes(data);
return (encodeByteArray(bytes));
}
public static function encodeByteArray(data:ByteArray):String{
var dataBuffer:Array;
var i:uint;
var j:uint;
var k:uint;
var output:String = "";
var outputBuffer:Array = new Array(4);
data.position = 0;
while (data.bytesAvailable > 0) {
dataBuffer = new Array();
i = 0;
while ((((i < 3)) && ((data.bytesAvailable > 0)))) {
dataBuffer[i] = data.readUnsignedByte();
i++;
};
outputBuffer[0] = ((dataBuffer[0] & 252) >> 2);
outputBuffer[1] = (((dataBuffer[0] & 3) << 4) | (dataBuffer[1] >> 4));
outputBuffer[2] = (((dataBuffer[1] & 15) << 2) | (dataBuffer[2] >> 6));
outputBuffer[3] = (dataBuffer[2] & 63);
j = dataBuffer.length;
while (j < 3) {
outputBuffer[(j + 1)] = 64;
j++;
};
k = 0;
while (k < outputBuffer.length) {
output = (output + BASE64_CHARS.charAt(outputBuffer[k]));
k++;
};
};
return (output);
}
public static function decode(data:String):String{
var bytes:ByteArray = decodeToByteArray(data);
return (bytes.readUTFBytes(bytes.length));
}
public static function decodeToByteArray(data:String):ByteArray{
var j:uint;
var k:uint;
var output:ByteArray = new ByteArray();
var dataBuffer:Array = new Array(4);
var outputBuffer:Array = new Array(3);
var i:uint;
while (i < data.length) {
j = 0;
while ((((j < 4)) && (((i + j) < data.length)))) {
dataBuffer[j] = BASE64_CHARS.indexOf(data.charAt((i + j)));
j++;
};
outputBuffer[0] = ((dataBuffer[0] << 2) + ((dataBuffer[1] & 48) >> 4));
outputBuffer[1] = (((dataBuffer[1] & 15) << 4) + ((dataBuffer[2] & 60) >> 2));
outputBuffer[2] = (((dataBuffer[2] & 3) << 6) + dataBuffer[3]);
k = 0;
while (k < outputBuffer.length) {
if (dataBuffer[(k + 1)] == 64){
break;
};
output.writeByte(outputBuffer[k]);
k++;
};
i = (i + 4);
};
output.position = 0;
return (output);
}
}
}//package uk.co.inbox.users.commands
Section 298
//CommandItem (uk.co.inbox.users.commands.CommandItem)
package uk.co.inbox.users.commands {
import uk.co.inbox.users.commands.events.*;
public class CommandItem {
private var _cmd:UserCommand;
public function CommandItem($cmd:UserCommand){
super();
_cmd = $cmd;
}
private function removeListeners():void{
}
protected function onComplete(e:CommandEvent):void{
removeListeners();
}
protected function onFail(e:CommandEvent):void{
removeListeners();
}
public function get userCmd():UserCommand{
return (_cmd);
}
}
}//package uk.co.inbox.users.commands
Section 299
//IAPICommand (uk.co.inbox.users.commands.IAPICommand)
package uk.co.inbox.users.commands {
public interface IAPICommand {
function returnFileVars():Object;
function returnGETVars():String;
function returnPOSTVars():Object;
}
}//package uk.co.inbox.users.commands
Section 300
//PluginCommand (uk.co.inbox.users.commands.PluginCommand)
package uk.co.inbox.users.commands {
public class PluginCommand extends UserCommand {
public function PluginCommand(commandName:String){
super();
cmdName = commandName;
}
protected function appendPOSTData(data:Object):Object{
return (data);
}
final override public function returnPOSTVars():Object{
var post:Object = appendPOSTData({});
if (!post){
setError("Invalid post data");
onError();
return (new Object());
};
post.isPlugin = true;
post.commandName = cmdName;
return (post);
}
}
}//package uk.co.inbox.users.commands
Section 301
//UserCommand (uk.co.inbox.users.commands.UserCommand)
package uk.co.inbox.users.commands {
import flash.events.*;
import uk.co.inbox.users.*;
import flash.net.*;
import uk.co.inbox.users.commands.events.*;
import flash.utils.*;
import uk.co.inbox.users.commands.queue.*;
import com.adobe.crypto.*;
import uk.co.inbox.debug.*;
public class UserCommand extends CommandQueueItem implements IAPICommand {
private var thisTime:Number;
private var request:URLRequest;
private var loader:URLLoader;
public var triggersQueue:Boolean;// = false
private var fileLoader:FileReference;
private var signature:String;// = null
private var thisSize:Number;
protected var _handle:UserHandle;
private var retrys:int;// = 0
private var _xmlReturned:XML;// = null
public var relatesLogin:Boolean;// = false
public var willCache:Boolean;// = true
public var requiresLogin:Boolean;// = false
public var cmdName:String;// = "none"
public var queueable:Boolean;// = false
private static const FILE_UPLOAD_DATA_NAME:String = "FileRefData";
private static const MAX_RETRYS:int = 1;
public static var timeWasted:Number = 0;
public static var bytesTransfered:Number = 0;
public function UserCommand(){
super();
}
private function onCommandReturnData(e:DataEvent):void{
if (!fileLoader){
return;
};
handleReturnedData(e.data);
}
private function onSecurityError(e:SecurityErrorEvent):void{
onError();
}
public function get xmlReturned():XML{
return (_xmlReturned);
}
private function addLoaderListeners(loader:EventDispatcher):EventDispatcher{
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError, false, 0, true);
loader.addEventListener(Event.COMPLETE, onCommandReturn, false, 0, true);
loader.addEventListener(ProgressEvent.PROGRESS, onCommandProgress, false, 0, true);
loader.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, onCommandReturnData, false, 0, true);
return (loader);
}
public function returnFileVars():Object{
return ({});
}
public function returnPOSTVars():Object{
return ({});
}
protected function onSuccess():void{
if (willCache){
if (((handle.commandCache) && (!((signature == null))))){
if (handle.commandCache.hasSignature(signature) == null){
handle.commandCache.addSignature(this, signature);
};
};
};
super.complete();
var thisSizeTotal:Number = (Math.round(((bytesTransfered / 0x0400) * 100)) / 100);
var size:Number = (Math.round(((thisSize / 0x0400) * 100)) / 100);
outPut((((((((((getQualifiedClassName(this) + " onSuccess() - Server spent ") + (xmlReturned.time) ? (Math.round((xmlReturned.time * 100000)) / 100000) : "?") + " ms / ") + (Math.round((timeWasted * 100000)) / 100000)) + " ms and returned ") + size) + " kb / ") + thisSizeTotal) + " kb"), this);
if (handle.debugMode){
outPut(xmlReturned, this);
};
dispatchEvent(new CommandEvent(CommandEvent.EVENT_COMMAND_COMPLETE, ((xmlReturned.message == undefined)) ? "" : xmlReturned.message));
if (handle.commandLogger){
handle.commandLogger.logCommand(this, xmlReturned.time, thisSize, true);
};
}
public function get handle():UserHandle{
return (_handle);
}
override protected function begin():void{
var identicalCommand:UserCommand;
super.begin();
outPut((getQualifiedClassName(this) + "::begin()"), this);
if (((!(_handle.loggedIn)) && (requiresLogin))){
outPut((getQualifiedClassName(this) + " begin()- MUST BE LOGGED IN TO USE THIS COMMAND"), this);
setError("Must be logged in");
onError();
} else {
if (willCache){
generateSignature();
if (((handle.commandCache) && (!((signature == null))))){
identicalCommand = handle.commandCache.hasSignature(signature);
if (identicalCommand != null){
outPut((getQualifiedClassName(this) + "::begin() - Signature was found in the cache."), this);
_xmlReturned = identicalCommand.xmlReturned;
thisSize = 0;
thisTime = (_xmlReturned.time = 0);
willCache = false;
handle.commandCache.addSavedData(identicalCommand.commandServerTimeUsed, identicalCommand.commandBytesTransfered);
onSuccess();
return;
};
};
};
request.data.securitykey = handle.userspace::getSecurityKey();
if (((!(loader)) && (fileLoader))){
addLoaderListeners(fileLoader);
fileLoader.upload(request, FILE_UPLOAD_DATA_NAME);
} else {
addLoaderListeners(loader);
loader.load(request);
};
};
}
protected function hasError($xml:XML):String{
if (!$xml){
return ("No xml set");
};
return ((($xml.error)!=undefined) ? xmlReturned.error[0].code : null);
}
private function onCommandProgress(e:ProgressEvent):void{
dispatchEvent(new CommandProgressEvent("", e.bytesLoaded, e.bytesTotal));
}
private function onCommandReturn(e:Event):void{
if ((e.target is FileReference)){
return;
};
handleReturnedData(URLLoader(e.target).data);
}
private function onIOError(e:IOErrorEvent):void{
onError();
}
protected function setError($string:String):XML{
_xmlReturned = new XML((("<root><error><code>" + $string) + "</code></error></root>"));
return (_xmlReturned);
}
public function get commandBytesTransfered():Number{
return (thisSize);
}
public function returnGETVars():String{
return (("cmd=" + escape(cmdName)));
}
userspace function set handle(value:UserHandle):void{
if (!_handle){
_handle = value;
};
}
public function get commandServerTimeUsed():Number{
return (thisTime);
}
protected function returnFileReference():FileReference{
return (null);
}
private function handleReturnedData(data:String):void{
var data = data;
var byteArray:ByteArray = new ByteArray();
byteArray.writeObject(data);
byteArray.position = 0;
bytesTransfered = (bytesTransfered + byteArray.bytesAvailable);
thisSize = byteArray.bytesAvailable;
_xmlReturned = XML(data);
//unresolved jump
var _slot1 = er;
_xmlReturned = setError("Server Error");
outPut((getQualifiedClassName(this) + " onCommandReturn() - SERVER ERROR, SERVER RETURNED:"), this);
outPut(data, this);
thisTime = ((xmlReturned.time == undefined)) ? 0 : Number(xmlReturned.time);
timeWasted = (timeWasted + thisTime);
var oldKey:String = handle.userspace::getSecurityKey();
var _local3 = handle;
_local3.userspace::setSecurityKey(((_xmlReturned.keyinc)!=undefined) ? _xmlReturned.keyinc : handle.userspace::getSecurityKey());
if (_xmlReturned.keyinc != undefined){
_local3 = handle;
_local3.userspace::setSecurityKey(MD5.hash((handle.getDefaultSecurityKeyUNMD() + handle.userspace::getSecurityKey())));
};
var endCommand:Boolean;
if (xmlReturned.security != undefined){
outPut((getQualifiedClassName(this) + " onCommandReturn() - SECURITY ERROR, KEYS DID NOT MATCH, SESSION DESTROYED, Server returned:"), this);
outPut(_xmlReturned, this);
_local3 = handle;
_local3.userspace::setSecurityKey(handle.getDefaultSecurityKey());
retrys++;
if (retrys <= MAX_RETRYS){
if (((!(loader)) && (fileLoader))){
setError("File uploads cannot be retryed (Due to a flash security restriction)");
} else {
outPut((getQualifiedClassName(this) + " onCommandReturn() - Retrying"), this);
endCommand = false;
begin();
};
} else {
dispatchEvent(new CommandSyncEvent(CommandSyncEvent.EVENT_LOSE_SYNC));
};
};
if (endCommand){
if (hasError(xmlReturned)){
onError();
} else {
onSuccess();
};
};
}
public function canIHazVinegar():String{
return (((xmlReturned.vinegar) || ("no cus you sux")));
}
public function acceptRequest($loader:URLLoader, $request:URLRequest):void{
request = $request;
fileLoader = returnFileReference();
if (!fileLoader){
loader = $loader;
};
}
protected function onError():void{
super.complete();
outPut((getQualifiedClassName(this) + "::onError()"), this);
if (handle.debugMode){
outPut(xmlReturned);
};
dispatchEvent(new CommandEvent(CommandEvent.EVENT_COMMAND_FAIL, ((hasError(xmlReturned))!=null) ? hasError(xmlReturned) : ""));
if (handle.commandLogger){
handle.commandLogger.logCommand(this, (xmlReturned) ? (xmlReturned.time) ? xmlReturned.time : 0 : 0, thisSize, false);
};
}
public function compare(comparision:UserCommand):int{
return (0);
}
private function generateSignature():void{
var str:String;
if (request){
signature = "";
for (str in request.data) {
if (str != "sessionId"){
signature = (signature + ("_" + request.data[str]));
};
};
signature = (signature + ("_" + cmdName));
signature = MD5.hash(signature);
};
}
}
}//package uk.co.inbox.users.commands
Section 302
//AffiliationInfo (uk.co.inbox.users.items.AffiliationInfo)
package uk.co.inbox.users.items {
public class AffiliationInfo {
public var regionRank:int;// = 0
public var owner:String;
public var region:String;
public var name:String;
public var country:String;
public var countryRank:int;// = 0
public var totalUsers:int;
public var totalScore:int;
public var globalRank:int;// = 0
public var isPublic:Boolean;
public var type:String;
public var rank:int;// = 0
public var aid:String;
public static const TYPE_GROUP:String = "Group";
public static const TYPE_LEAGUE:String = "League";
public function AffiliationInfo(aid:String, type:String, owner:String, name:String=null){
super();
this.aid = aid;
this.type = type;
this.owner = owner;
this.name = name;
this.name = this.name.replace("\\\\", "'");
}
public function loadXML(xml:XML):void{
isPublic = ((xml.isPublic)!=undefined) ? ((xml.isPublic == "1")) ? true : false : true;
country = ((xml.country) || (null));
region = ((xml.region) || (null));
totalUsers = ((int(xml.totalUsers)) || (0));
rank = ((xml.rank) || (0));
totalScore = ((xml.totalScore) || (0));
globalRank = ((xml.globalRank) || (0));
countryRank = ((xml.countryRank) || (0));
regionRank = ((xml.regionRank) || (0));
}
}
}//package uk.co.inbox.users.items
Section 303
//AwardInfo (uk.co.inbox.users.items.AwardInfo)
package uk.co.inbox.users.items {
public class AwardInfo {
public var id:String;// = null
public var imagePath:String;// = null
public var awardName:String;// = null
public var awardLongDesc:String;// = null
public var awardShortDesc:String;// = null
public var achieved:String;// = null
public var amount:int;// = 0
public var incremental:Boolean;// = false
public function AwardInfo(id:String=null, awardName:String=null, shortDesc:String=null){
super();
this.id = id;
this.awardName = awardName;
this.awardShortDesc = shortDesc;
}
public function loadXML($xml:XML):void{
id = (($xml.id)!=undefined) ? $xml.id : null;
awardName = (($xml.awardName)!=undefined) ? $xml.awardName : null;
awardShortDesc = (($xml.awardShortDesc)!=undefined) ? $xml.awardShortDesc : null;
awardLongDesc = (($xml.awardLongDesc)!=undefined) ? $xml.awardLongDesc : null;
incremental = (($xml.incremental)!=undefined) ? (($xml.incremental == 1)) ? true : false : false;
achieved = (($xml.achieved)!=undefined) ? $xml.achieved : null;
imagePath = (($xml.imagePath)!=undefined) ? $xml.imagePath : null;
amount = (($xml.amount)!=undefined) ? $xml.amount : 0;
}
}
}//package uk.co.inbox.users.items
Section 304
//ScoreInfo (uk.co.inbox.users.items.ScoreInfo)
package uk.co.inbox.users.items {
import flash.utils.*;
public class ScoreInfo {
public var mode:String;// = null
public var name:String;// = null
public var rank:int;// = 0
public var uid:String;// = null
public var scorec:String;// = null
public var score:String;// = null
public var scoreb:String;// = null
public var dateAdded:String;// = null
public var id:String;// = null
public function ScoreInfo(){
super();
}
public function loadXML($xml:XML):void{
id = (($xml.id)!=undefined) ? $xml.id : id;
uid = (($xml.uid)!=undefined) ? $xml.uid : uid;
name = (($xml.name)!=undefined) ? $xml.name : name;
score = (($xml.score)!=undefined) ? $xml.score : score;
scoreb = (($xml.scoreb)!=undefined) ? $xml.scoreb : scoreb;
scorec = (($xml.scorec)!=undefined) ? $xml.scorec : scorec;
mode = (($xml.mode)!=undefined) ? $xml.mode : mode;
dateAdded = (($xml.dateAdded)!=undefined) ? $xml.dateAdded : dateAdded;
rank = (($xml.rank)!=undefined) ? int($xml.rank) : rank;
}
public function toString():String{
return (((((((((getQualifiedClassName(this) + "\n\tid:") + id) + "\n\tuid:") + uid) + "\n\tname:") + name) + "\n\tscore:") + score));
}
}
}//package uk.co.inbox.users.items
Section 305
//UserInfo (uk.co.inbox.users.items.UserInfo)
package uk.co.inbox.users.items {
import flash.utils.*;
import uk.co.inbox.debug.*;
public class UserInfo {
public var lastName:String;// = null
public var affiliations:Array;
public var countryShort:String;// = null
public var isGuest:Boolean;// = false
public var friends:Array;
public var username:String;// = null
public var firstName:String;// = null
public var email:String;// = null
public var key:String;// = null
public var scores:Array;
private var _online:Boolean;// = false
public var lastLogin:Date;// = null
public var region:String;// = null
public var awards:Array;
public var countryLong:String;// = null
private var _id:String;// = null
public function UserInfo($username:String=null, $key:String=null){
friends = [];
awards = [];
affiliations = [];
scores = [];
super();
username = $username;
key = $key;
}
public function hasAward($id:String):AwardInfo{
var i:int;
while (i < numAwards) {
if ((awards[i] as AwardInfo).id == $id){
return (awards[i]);
};
i++;
};
return (null);
}
public function setGuestName($username:String):void{
isGuest = true;
username = $username;
}
public function loadDetailsXML($xml:XML):void{
var temp:ScoreInfo;
_id = (($xml.id)!=undefined) ? $xml.id : (($xml.UserId)!=undefined) ? $xml.UserId : null;
key = (($xml.key)!=undefined) ? $xml.key : null;
username = (($xml.username)!=undefined) ? $xml.username : null;
email = (($xml.email)!=undefined) ? $xml.email : null;
firstName = (($xml.firstName)!=undefined) ? $xml.firstName : null;
lastName = (($xml.lastName)!=undefined) ? $xml.lastName : null;
countryLong = (($xml.countryLong)!=undefined) ? $xml.countryLong : null;
countryShort = (($xml.countryShort)!=undefined) ? $xml.countryShort : null;
region = (($xml.region)!=undefined) ? $xml.region : null;
lastLogin = (($xml.lastLogin)!=undefined) ? new Date(Date.parse($xml.lastLogin.split("-").join("/"))) : null;
_online = (($xml.online)!=undefined) ? ($xml.online == "1") : false;
if ($xml.affiliations != undefined){
loadAffiliationsXML($xml.affiliations.*);
};
if ($xml.scores != undefined){
loadScoresXML($xml.scores.*);
};
if (scores.length == 0){
temp = new ScoreInfo();
scores.push(temp);
temp.name = username;
temp.score = "0";
temp.scoreb = "0";
};
}
public function getAffiliation(aid:String):AffiliationInfo{
var info:AffiliationInfo;
var il:int = affiliations.length;
var i:int;
while (i < il) {
info = affiliations[i];
if (info.aid == aid){
return (info);
};
i++;
};
return (null);
}
public function get online():Boolean{
return (_online);
}
public function getFriend($id:String):UserInfo{
return (hasFriend($id));
}
public function hasFriend($id:String):UserInfo{
var i:int;
while (i < numFriends) {
if ((friends[i] as UserInfo).id == $id){
return (friends[i]);
};
i++;
};
return (null);
}
public function toString():String{
return (((((((((((getQualifiedClassName(this) + "\n\tid:") + id) + "\tusername:") + username) + "\n\tnumFriends:") + numFriends) + "\tnumAwards:") + numAwards) + "\n\tOnline:") + online));
}
protected function loadAffiliationsXML($xml:XMLList):void{
var affiliation:XML;
var affiliationInfo:AffiliationInfo;
for each (affiliation in $xml) {
if (affiliation.aid == undefined){
} else {
affiliationInfo = new AffiliationInfo(affiliation.aid, affiliation.type, affiliation.owner, affiliation.name);
affiliationInfo.loadXML(affiliation);
affiliations.push(affiliationInfo);
};
};
}
public function get id():String{
return (_id);
}
public function getAward($id:String):AwardInfo{
return (hasAward($id));
}
public function loginXML($xml:XML):void{
loadDetailsXML(XML($xml.user));
}
public function get numFriends():int{
return (friends.length);
}
protected function loadScoresXML($xml:XMLList):void{
var scoreXML:XML;
var scoreInfo:ScoreInfo;
outPut((getQualifiedClassName(this) + "::loadScoresXML"));
for each (scoreXML in $xml) {
scoreInfo = new ScoreInfo();
scoreInfo.uid = id;
scoreInfo.name = username;
scoreInfo.loadXML(scoreXML);
scores.push(scoreInfo);
};
}
public function addFriend($friend:UserInfo):void{
if (hasFriend($friend.id)){
return;
};
friends.push($friend);
}
public function addAward($award:AwardInfo):void{
if (hasAward($award.id)){
return;
};
awards.push($award);
}
public function get numAwards():int{
return (awards.length);
}
}
}//package uk.co.inbox.users.items
Section 306
//LogEvent (uk.co.inbox.users.logging.LogEvent)
package uk.co.inbox.users.logging {
public class LogEvent {
public var serverTime:Number;
public var bandwidth:Number;
public var success:Boolean;
public var cmd:String;
public var timeAdded:String;
public function LogEvent(cmd:String, serverTime:Number, bandwidth:Number, success:Boolean=true){
super();
this.cmd = cmd;
this.serverTime = serverTime;
this.bandwidth = bandwidth;
this.success = success;
this.timeAdded = new Date().toTimeString();
}
public function output():String{
return (((((((((((("timeAdded: " + timeAdded.split(" ")[0]) + " cmd: ") + cmd) + " - Success: ") + success) + " - ") + (Math.round(((bandwidth / 0x0400) * 100)) / 100)) + " Kb ") + (Math.round((serverTime * 100000)) / 100000)) + " Sec - Cached: ") + ((serverTime == 0)) ? "true" : "false"));
}
}
}//package uk.co.inbox.users.logging
Section 307
//UserLogger (uk.co.inbox.users.logging.UserLogger)
package uk.co.inbox.users.logging {
import uk.co.inbox.users.*;
import uk.co.inbox.users.commands.*;
import flash.utils.*;
import uk.co.inbox.debug.*;
public class UserLogger {
public var userHandle:UserHandle;
public var logs:Array;
public function UserLogger(){
logs = [];
super();
}
public function traceLogs():String{
var log:LogEvent;
outPut((getQualifiedClassName(this) + "::traceLogs()"), this);
var str:String = "";
for each (log in logs) {
str = (str + (log.output() + "\n"));
outPut(log.output(), log);
};
return (str);
}
public function logCommand(cmd:UserCommand, serverTime:Number, bandwidth:Number, success:Boolean=true):void{
if (userHandle == null){
return;
};
logs.push(new LogEvent(cmd.cmdName, serverTime, bandwidth, success));
if (logs.length > 50){
logs.shift();
};
}
}
}//package uk.co.inbox.users.logging
Section 308
//UserOverlay (uk.co.inbox.users.overlay.UserOverlay)
package uk.co.inbox.users.overlay {
import flash.events.*;
import uk.co.inbox.users.*;
import uk.co.inbox.users.commands.*;
import uk.co.inbox.input.*;
import flash.text.*;
import flash.display.*;
import flash.filters.*;
public class UserOverlay extends Sprite {
private var myStage:Stage;
private var userHandle:UserHandle;
private var textField:TextField;
public function UserOverlay(userHandle:UserHandle){
super();
this.userHandle = userHandle;
if (stage){
init();
} else {
addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
};
KeyBoardManager.addEventListener(KeyEvent.KEYEVENT_DOWN, onKeyDown, false, 0, true);
var keySequence:KeySequence = KeyBoardManager.createKeySequenceEvent("upgazsmum");
keySequence.addEventListener(KeySequence.ACTIVATED, onUPmumActivated, false, 0, true);
visible = false;
}
private function onKeyDown(e:KeyEvent):void{
if (((userHandle.debugMode) && (visible))){
visible = false;
};
}
public function get defaultTextFormat():TextFormat{
return (new TextFormat("Courier New", 12, 0xEEEEEE, false, false, false, null, null, "center"));
}
private function onUPmumActivated(e:Event):void{
if (!userHandle.debugMode){
return;
};
visible = !(visible);
if (visible){
reset();
};
}
private function reset():void{
myStage.addChild(this);
textField.text = "";
textField.appendText(("" + "----- Current Project -----"));
textField.appendText(("\n" + userHandle.getProjectId()));
textField.appendText(("\n\n" + "----- Current Useage -----"));
textField.appendText(((((("\n" + "Server time: ") + UserCommand.timeWasted) + " ms / ") + (Math.round((UserCommand.timeWasted * 100000)) / 100000)) + " sec"));
textField.appendText(((((("\n" + "Bytes transfered: ") + UserCommand.bytesTransfered) + " bytes / ") + (Math.round(((UserCommand.bytesTransfered / 0x0400) * 100)) / 100)) + " Kb"));
textField.appendText(("\n\n" + "----- Current User -----"));
if (userHandle.loggedIn){
textField.appendText((("\n" + "ID: ") + userHandle.userDetails.id));
textField.appendText((("\n" + "Username: ") + userHandle.userDetails.username));
} else {
textField.appendText(("\n" + "User is not logged in"));
};
textField.appendText(("\n\n" + "----- Current cache system -----"));
textField.appendText(("\n" + userHandle.commandCache));
textField.appendText(((((("\n" + "Server time saved: ") + userHandle.commandCache.getTimeSaved()) + " ms / ") + (Math.round((userHandle.commandCache.getTimeSaved() * 100000)) / 100000)) + " sec"));
textField.appendText(((((("\n" + "Transfer bytes saved: ") + userHandle.commandCache.getBytesSaved()) + " bytes / ") + (Math.round(((userHandle.commandCache.getBytesSaved() / 0x0400) * 100)) / 100)) + " Kb"));
textField.appendText(("\n\n" + "----- Current logging system -----"));
textField.appendText(("\n" + userHandle.commandLogger));
textField.appendText(("\n\n" + "----- Current username filter -----"));
textField.appendText(("\n" + userHandle.usernameFilter));
textField.appendText(("\n\n" + "----- Current variable filter -----"));
textField.appendText(("\n" + userHandle.variableStringFilter));
textField.appendText(("\n\n" + "----- Tracing Logs -----"));
textField.appendText(("\n" + userHandle.commandLogger.traceLogs()));
textField.appendText(("" + "----- END Logs -----"));
textField.setSelection(0, int.MAX_VALUE);
}
private function init(e:Event=null):void{
if (e){
removeEventListener(Event.ADDED_TO_STAGE, init);
};
myStage = stage;
textField = new TextField();
textField.setTextFormat(defaultTextFormat);
textField.defaultTextFormat = defaultTextFormat;
graphics.beginFill(0, 0.6);
graphics.lineStyle(2, 0xFFFFFF, 0.7);
graphics.drawRoundRect(20, 20, (stage.stageWidth - 40), (stage.stageHeight - 40), 10, 10);
addChild(textField);
textField.x = (textField.y = 30);
textField.width = (stage.stageWidth - 60);
textField.height = (stage.stageHeight - 60);
textField.embedFonts = false;
filters = [new DropShadowFilter(4, 45, 0, 0.6)];
}
public function get headerTextFormat():TextFormat{
return (new TextFormat("Courier New", 12, 16768477, true, false, false, null, null, "center"));
}
}
}//package uk.co.inbox.users.overlay
Section 309
//GuestUserHandle (uk.co.inbox.users.GuestUserHandle)
package uk.co.inbox.users {
import flash.events.*;
import uk.co.inbox.users.commands.*;
import uk.co.inbox.users.commands.events.*;
import flash.utils.*;
import uk.co.inbox.debug.*;
public class GuestUserHandle extends UserHandle {
private var storedCommands:Array;
public function GuestUserHandle(){
storedCommands = [];
super();
userDetails = getBlankUser();
userDetails.isGuest = true;
}
public function removeCommandFromQueue($cmd:CommandItem):Boolean{
var index:int = storedCommands.indexOf($cmd);
if (index != -1){
storedCommands.splice(index, 1);
return (true);
};
return (false);
}
override public function runCommandItem($cmd:CommandItem):CommandItem{
if ((((($cmd.userCmd.requiresLogin) || ($cmd.userCmd.relatesLogin))) && (!(loggedIn)))){
if ($cmd.userCmd.requiresLogin){
if ($cmd.userCmd.queueable){
storeCommand($cmd);
};
} else {
if ($cmd.userCmd.triggersQueue){
$cmd.userCmd.addEventListener(CommandEvent.EVENT_COMMAND_COMPLETE, userActivated, false, 0, true);
};
super.runCommandItem($cmd);
};
} else {
super.runCommandItem($cmd);
};
return ($cmd);
}
public function removeQueuedCommandsByType(type:Class):int{
var command:UserCommand;
var removed:int;
var i:int;
while (i < storedCommands.length) {
command = CommandItem(storedCommands[i]).userCmd;
if ((command is type)){
storedCommands.splice(i, 1);
i--;
removed++;
};
i++;
};
return (removed);
}
private function storeCommand($cmd:CommandItem):void{
var compareCommand:CommandItem;
var storedClass:Class;
var comparisonCode:int;
var store:Boolean;
var i:int;
while (i < storedCommands.length) {
compareCommand = storedCommands[i];
storedClass = Object(compareCommand.userCmd).constructor;
if (($cmd.userCmd is storedClass)){
outPut((((getQualifiedClassName(this) + "::storeCommand(") + $cmd.userCmd) + ") - A similar command was found in the queue"), this);
comparisonCode = $cmd.userCmd.compare(compareCommand.userCmd);
if (comparisonCode == -1){
outPut((((getQualifiedClassName(this) + "::storeCommand(") + $cmd.userCmd) + ") - Command rejected, the command was considered old"), this);
store = false;
break;
} else {
if (comparisonCode == 1){
outPut((((getQualifiedClassName(this) + "::storeCommand(") + $cmd.userCmd) + ") - Command accepted, the command was considered newer, an old command was removed"), this);
storedCommands.splice(storedCommands.indexOf(compareCommand), 1);
i--;
} else {
if (comparisonCode == 0){
outPut((((getQualifiedClassName(this) + "::storeCommand(") + $cmd.userCmd) + ") - Command accepted, the command was considered different but valid"), this);
};
};
};
};
i++;
};
if (store){
storedCommands.push($cmd);
$cmd.userCmd.dispatchEvent(new CommandEvent(CommandEvent.EVENT_COMMAND_QUEUED));
};
}
private function userActivated(e:Event):void{
var i:int;
if (loggedIn){
i = 0;
while (i < storedCommands.length) {
runCommandItem(CommandItem(storedCommands[i]));
i++;
};
storedCommands = [];
};
}
}
}//package uk.co.inbox.users
Section 310
//PHPHandle (uk.co.inbox.users.PHPHandle)
package uk.co.inbox.users {
import flash.events.*;
import flash.net.*;
import uk.co.inbox.users.commands.*;
import flash.utils.*;
import uk.co.inbox.users.commands.filters.*;
import uk.co.inbox.debug.*;
public class PHPHandle extends EventDispatcher {
public var variableStringFilter:IStringFilter;
private static const PHP_FILE:String = "api.php";
public static const DELIMITER:String = "||";
private static const PHP_LOCATION:String = "http://www.inboxwork.co.uk/badger/";
public function PHPHandle(){
variableStringFilter = new BlankStringFilter();
super();
}
private function onIOError(e:IOErrorEvent):void{
outPut((((getQualifiedClassName(PHPHandle) + " onIOError()") + "\n\t") + e));
}
protected function parseXML($loader:URLLoader):XML{
var xml:XML = XML($loader.data);
return (xml);
}
protected function createURLLoader():URLLoader{
var loader:URLLoader = new URLLoader();
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError, false, 0, true);
return (loader);
}
protected function constructRequest($command:IAPICommand):URLRequest{
var key:String;
var request:URLRequest = new URLRequest();
var url:String = (PHP_LOCATION + PHP_FILE);
request.method = URLRequestMethod.POST;
request.data = new URLVariables();
var postVars:Object = $command.returnPOSTVars();
if (postVars){
for (key in postVars) {
request.data[key] = variableStringFilter.getSafe(postVars[key]);
};
};
var fileVars:Object = $command.returnFileVars();
if (fileVars){
for (key in fileVars) {
request.data[key] = Base64.encodeByteArray(fileVars[key]);
};
};
var getVars:String = variableStringFilter.getSafe($command.returnGETVars());
request.url = ((((url + "?") + getVars) + "&cache=") + (Math.random() * 10000));
return (request);
}
private function onSecurityError(e:SecurityErrorEvent):void{
outPut((((getQualifiedClassName(PHPHandle) + " onSecurityError()") + "\n\t") + e));
}
protected function hasError($xml:XML):String{
if (!$xml){
return ("No xml set");
};
return ((($xml.error)!=undefined) ? $xml.error : null);
}
}
}//package uk.co.inbox.users
Section 311
//UserHandle (uk.co.inbox.users.UserHandle)
package uk.co.inbox.users {
import flash.net.*;
import uk.co.inbox.users.commands.*;
import uk.co.inbox.users.commands.events.*;
import uk.co.inbox.users.commands.concrete.*;
import uk.co.inbox.users.items.*;
import flash.utils.*;
import uk.co.inbox.users.commands.queue.*;
import uk.co.inbox.users.commands.filters.*;
import uk.co.inbox.users.logging.*;
import uk.co.inbox.users.cache.*;
import uk.co.inbox.utils.*;
import com.adobe.crypto.*;
import uk.co.inbox.debug.*;
public class UserHandle extends PHPHandle {
private var knownUsers:Object;
private var default_key_unmd:String;// = ""
private var queue:CommandQueue;
private var projectId:String;// = "global"
public var debugMode:Boolean;// = false
public var commandLogger:UserLogger;
private var sessionId:String;
private var security_key:String;
private var default_key:String;// = ""
private var commandsRun:int;// = 0
public var previousKey:String;// = null
public var previousUsername:String;// = null
public var userDetails:UserInfo;// = null
public var usernameFilter:UsernameFilter;
public var commandCache:ICommandCache;
public function UserHandle(){
security_key = default_key;
queue = new CommandQueue();
knownUsers = {};
usernameFilter = new UsernameFilter("Guest_");
commandCache = new SimpleCommandCache();
commandLogger = new UserLogger();
sessionId = MD5.hash(((((Math.random() + "-") + new Date().time) + "_") + (Math.random() * 100000)));
super();
commandLogger.userHandle = this;
setDefaultSecurityKey("9239391247b1jb4");
}
public function setDefaultSecurityKey(key:String):void{
default_key_unmd = key;
default_key = MD5.hash((default_key_unmd + MD5.hash(default_key_unmd)));
userspace::setSecurityKey(getDefaultSecurityKey());
}
public function getBlankUser():UserInfo{
return (new UserInfo());
}
userspace function addUser($user:UserInfo):void{
knownUsers[$user.id] = $user;
}
public function init($isAutoLogin:Boolean=true):LoginCommand{
if (!CustomSharedObject.inited){
CustomSharedObject.init("userhandle");
};
previousKey = CustomSharedObject.get("userhandle_Key", "");
previousUsername = CustomSharedObject.get("userhandle_Username", "");
outPut(((((getQualifiedClassName(this) + " init()\n\tpreviousKey:") + previousKey) + ", previousUsername:") + previousUsername), this);
if (((!((previousKey === ""))) && (!((previousUsername === ""))))){
userDetails = getBlankUser();
userDetails.isGuest = true;
userDetails.username = previousUsername;
userDetails.key = previousKey;
outPut(((getQualifiedClassName(this) + " init()\n\t") + "Previous login detected, attempting key based login"), this);
return (login(userDetails.username, userDetails.key, true, true, $isAutoLogin));
};
return (null);
}
userspace function applyLogout():void{
userDetails = null;
clearSavedLogin();
dispatchEvent(new UserEvent(UserEvent.EVENT_LOGOUT));
}
public function logout():void{
runCommand(new LogoutCommand());
}
public function register($username:String, $password:String, $email:String, $data:Object=null):CommandItem{
return (runCommand(new RegisterCommand($username, $password, $email, $data)));
}
override protected function constructRequest($command:IAPICommand):URLRequest{
var request:URLRequest = super.constructRequest($command);
request.data.projectId = projectId;
request.data.sessionId = sessionId;
if (commandsRun == 0){
outPut((getQualifiedClassName(this) + "::constructRequest() - Request is coming from a new handle, session will be reset"));
request.data.commandReset = true;
};
commandsRun++;
return (request);
}
userspace function setSecurityKey(key:String):void{
security_key = key;
}
public function getUser($id:String):UserInfo{
return ((knownUsers[$id]) ? knownUsers[$id] : null);
}
public function runCommand($cmd:UserCommand):CommandItem{
return (runCommandItem(new CommandItem($cmd)));
}
userspace function getSecurityKey():String{
return (security_key);
}
public function get loggedIn():Boolean{
if (userDetails !== null){
return (!(userDetails.isGuest));
};
return (false);
}
private function clearSavedLogin():void{
CustomSharedObject.set({userhandle_Key:"", userhandle_Username:""});
}
public function setProjectId($value:String):void{
projectId = $value;
}
public function getUsers():Object{
return (knownUsers);
}
public function getProjectId():String{
return (projectId);
}
userspace function applyLoginFromResult($xml:XML, $remember:Boolean=false):void{
if (hasError($xml)){
outPut((getQualifiedClassName(this) + " applyLoginFromResult() - Cannot apply login, login data has an error"), this);
userspace::applyLogout();
} else {
userDetails = getBlankUser();
userDetails.loginXML(XML($xml));
outPut(((((getQualifiedClassName(this) + " userDetails.key:") + userDetails.key) + ", userDetails.username:") + userDetails.username), this);
if ($remember){
CustomSharedObject.set({userhandle_Key:userDetails.key, userhandle_Username:userDetails.username});
};
userspace::addUser(userDetails);
};
}
public function getDefaultSecurityKeyUNMD():String{
return (default_key_unmd);
}
public function login($username:String="", $password:String="", $keyAsPass:Boolean=false, $remember:Boolean=false, $isAutoRun:Boolean=true):LoginCommand{
var cmd:LoginCommand = new LoginCommand($username, $password, $keyAsPass, $remember);
if ($isAutoRun){
runCommand(cmd);
};
return (cmd);
}
private function onCommandLoseSync(e:CommandSyncEvent):void{
e.target.removeEventListener(CommandSyncEvent.EVENT_LOSE_SYNC, onCommandLoseSync);
dispatchEvent(e.clone());
}
public function runCommandItem($cmd:CommandItem):CommandItem{
$cmd.userCmd.userspace::handle = this;
var urlLoader:URLLoader = createURLLoader();
var request:URLRequest = constructRequest($cmd.userCmd);
$cmd.userCmd.acceptRequest(urlLoader, request);
queue.addItem($cmd.userCmd);
$cmd.userCmd.addEventListener(CommandSyncEvent.EVENT_LOSE_SYNC, onCommandLoseSync, false, 0, true);
return ($cmd);
}
public function getDefaultSecurityKey():String{
return (default_key);
}
}
}//package uk.co.inbox.users
Section 312
//userspace (uk.co.inbox.users.userspace)
package uk.co.inbox.users {
public namespace userspace = "user";
}//package uk.co.inbox.users
Section 313
//CustomSharedObject (uk.co.inbox.utils.CustomSharedObject)
package uk.co.inbox.utils {
import flash.net.*;
import uk.co.inbox.debug.*;
public class CustomSharedObject {
private static var so:SharedObject;
public static var data:Object;
private static var isDebugMode:Boolean = true;
private static var _inited:Boolean = false;
public function CustomSharedObject(){
super();
}
public static function wipe($idList:Array):void{
var i:int;
var $idList = $idList;
i = 0;
while (i < $idList.length) {
delete so.data[$idList[i]];
i = (i + 1);
};
so.flush();
data = so.data;
//unresolved jump
var _slot1 = e;
throwNonInitError("wipe()");
}
public static function set($obj:Object):void{
var i:String;
var $obj = $obj;
for (i in $obj) {
so.data[i] = $obj[i];
};
so.flush();
data = so.data;
//unresolved jump
var _slot1 = e;
throwNonInitError("set()");
}
public static function clear():void{
so.clear();
so.flush();
data = so.data;
}
public static function get inited():Boolean{
return (_inited);
}
public static function init($name:String, $folder:String="/"):void{
so = SharedObject.getLocal($name, $folder);
data = so.data;
_inited = true;
}
private static function throwNonInitError($sourceFunction:String=""):void{
throw (new Error(("Error: CustomSharedObject.init() has not been called - when you were trying to call CustomSharedObject." + $sourceFunction)));
}
private static function debugTrace($msg):void{
if (isDebugMode){
outPut($msg, "CustomSharedObject");
};
}
public static function get($propertyName:String, $defaultValue=null){
var $propertyName = $propertyName;
var $defaultValue = $defaultValue;
if (so.data[$propertyName] != undefined){
return (so.data[$propertyName]);
} else {
if ($defaultValue != null){
so.data[$propertyName] = $defaultValue;
};
return ($defaultValue);
};
//unresolved jump
var _slot1 = e;
throwNonInitError("get()");
return (null);
}
}
}//package uk.co.inbox.utils
Section 314
//MathTools (uk.co.inbox.utils.MathTools)
package uk.co.inbox.utils {
public class MathTools {
public function MathTools(){
super();
}
public static function formatNumber($number:Number, $thousandSeparator:String=","):String{
var str:String = String($number);
var strList:Array = [];
while (str.length > 3) {
strList.push(str.slice((str.length - 3), str.length));
str = str.slice(0, (str.length - 3));
};
strList.push(str);
var retStr:String = "";
var i:int;
while (i < strList.length) {
if (i != (strList.length - 1)){
retStr = (($thousandSeparator + strList[i]) + retStr);
} else {
retStr = (strList[i] + retStr);
};
i++;
};
return (retStr);
}
public static function formatPrice(num:Number):String{
var len:int;
var numS:String = num.toString();
var numR:Number = num;
var decP:int = numS.indexOf(".");
if (decP == -1){
numS = (numS + ".00");
} else {
numR = Number(numS.slice(0, (decP + 4)));
numR = (numR * 100);
numR = Math.round(numR);
numR = (numR / 100);
numS = String(numR);
len = (numS.length - 1);
decP = numS.indexOf(".");
if (decP == -1){
numS = (numS + ".00");
} else {
if ((len - decP) == 1){
numS = (numS + "0");
};
};
};
return (numS);
}
public static function formatTime($time:uint, $matchStr:String):String{
var ind:int;
var before:String;
var after:String;
var data:String;
var ms:String = addLeadingZeros(($time % 1000), 3);
var safetyCount:int;
while (((!(($matchStr.indexOf("ms") == -1))) && ((safetyCount < 10)))) {
$matchStr = $matchStr.replace("ms", ms.slice(0, 1));
ms = ms.slice(1);
safetyCount++;
};
var seconds:int = Math.floor(($time / 1000));
var minutes:int = Math.floor((seconds / 60));
var hours:int = Math.floor((minutes / 60));
var days:int = Math.floor((hours / 24));
var dataList:Array = [days, (hours % 24), (minutes % 60), (seconds % 60)];
var repList:Array = ["d", "h", "m", "s"];
var i:int;
while (i < repList.length) {
safetyCount = 0;
data = addLeadingZeros(dataList[i], 2);
while (((!(($matchStr.lastIndexOf(repList[i]) == -1))) && ((safetyCount < 10)))) {
ind = $matchStr.lastIndexOf(repList[i]);
before = $matchStr.slice(0, ind);
after = $matchStr.slice((ind + 1), $matchStr.length);
$matchStr = ((before + data.slice(-1)) + after);
data = data.slice(0, -1);
safetyCount++;
};
i++;
};
return ($matchStr);
}
public static function roundToPrecision(number:Number, precision:int=0):Number{
var decimalPlaces:Number = Math.pow(10, precision);
return ((Math.round((decimalPlaces * number)) / decimalPlaces));
}
public static function addLeadingZeros($number:Number, $totalDigits:int):String{
var str:String = String($number).split(".")[0];
var fraction:String = String($number).split(".")[1];
var len:int = ($totalDigits - str.length);
var i:int;
while (i < len) {
str = ("0" + str);
i++;
};
return ((str + ((fraction)!=null) ? ("." + fraction) : ""));
}
public static function genRandomInt(lowerB:Number, higherB:Number):int{
return ((Math.floor((Math.random() * (higherB - lowerB))) + lowerB));
}
public static function encryptScore(ascore:Number=0):String{
var as1:String = "";
ascore = ((ascore * 1000000) + 9876543210);
as1 = ascore.toString();
var code:Number = 0;
var i = 1;
while (i <= as1.length) {
code = ((code + i) + int(as1.charAt((i - 1))));
i++;
};
var cs:String = code.toString();
return (((cs.length.toString() + as1) + cs));
}
}
}//package uk.co.inbox.utils
Section 315
//Settings (uk.co.inbox.utils.Settings)
package uk.co.inbox.utils {
import flash.display.*;
public class Settings {
private static var isInit:Boolean = false;
private static var propertyData:Object = {};
public function Settings(){
super();
}
public static function init(loaderInfo:LoaderInfo):void{
var settingsData:Object;
if (!isInit){
isInit = true;
settingsData = {};
settingsData.projectId = 3;
settingsData.gameVersion = "0_2_0";
settingsData.gameName = "freeKickFusion2";
settingsData.gamePath = "http://www.freekickfusion.com/";
settingsData.leagueCgiPath = "http://shapetrace.lv.com/cgi-bin/shapetrace/";
settingsData.leagueStandingsPath = "http://www.viewstandings.com/shapetrace/stand.php?lid=";
settingsData.gameName = "discoveryMoonMiner";
settingsData.cgiPath = "http://www.hyperblastgame.com/cgi-bin/hyperblastgame/";
settingsData.scriptPath = "http://www.inboxwork.co.uk/discovery/scripts/";
settingsData.xmlPath = "http://www.inboxwork.co.uk/discovery/xml/";
settingsData.registrationURL = (settingsData.scriptPath + "register.php");
settingsData.loginURL = (settingsData.scriptPath + "login.php");
settingsData.updateProfileURL = (settingsData.scriptPath + "updateprofile.php");
settingsData.getGamesPlayedURL = (settingsData.scriptPath + "getusergames.php");
settingsData.globalRankingsXML = (settingsData.xmlPath + "globalrankings.xml");
settingsData.countryRankingsXML = (settingsData.xmlPath + "countryrankings.xml");
settingsData.termsURL = "http://www.lumixworldgolf.co.uk/terms.html";
settingsData.gameName = "freekickfusion";
settingsData.cgiPath = "http://www.hyperblastgame.com/cgi-bin/hyperblastgame/";
settingsData.scriptPath = "http://www.inboxwork.co.uk/discovery/scripts/";
settingsData.xmlPath = "http://www.inboxwork.co.uk/discovery/xml/";
settingsData.registrationURL = (settingsData.scriptPath + "register.php");
settingsData.loginURL = (settingsData.scriptPath + "login.php");
settingsData.updateProfileURL = (settingsData.scriptPath + "updateprofile.php");
settingsData.getGamesPlayedURL = (settingsData.scriptPath + "getusergames.php");
settingsData.globalRankingsXML = (settingsData.xmlPath + "globalrankings.xml");
settingsData.countryRankingsXML = (settingsData.xmlPath + "countryrankings.xml");
settingsData.termsURL = "http://www.lumixworldgolf.co.uk/terms.html";
settingsData.inboxURL = "http://www.inboxgames.co.uk/";
settingsData.isLocal = ((loaderInfo.url.slice(0, 4) == "file")) ? true : false;
settingsData.flashVars = loaderInfo.parameters;
settingsData.gameTitle = "Free Kick Fusion";
settingsData.gameFacebookAPIKey = "f3adc5c7b829fc17044babf6d2c5f440";
settingsData.isShell = false;
if (settingsData.isLocal){
settingsData.flashFilesPath = "";
} else {
settingsData.flashFilesPath = (settingsData.flashFilesPath = ((settingsData.flashVars.flashFilesPath)!=undefined) ? settingsData.flashVars.flashFilesPath : "http://shapetrace.lv.com/");
};
settingsData.versionNumber = ((settingsData.flashVars.gameVersion == undefined)) ? "1.0.0" : settingsData.flashVars.gameVersion;
settingsData.multiplayerIP = "192.168.1.86";
settingsData.multiplayerPort = "1935";
set(settingsData);
};
}
public static function get(prop:String, $defaultValue=null){
if (propertyData[prop] == null){
if ($defaultValue == null){
throw (new Error((("Settings property:" + prop) + " not found")));
};
propertyData[prop] = $defaultValue;
return ($defaultValue);
//unresolved jump
};
return (propertyData[prop]);
}
public static function set(propObj:Object):void{
var i:String;
for (i in propObj) {
propertyData[i] = propObj[i];
};
}
}
}//package uk.co.inbox.utils
Section 316
//TextTools (uk.co.inbox.utils.TextTools)
package uk.co.inbox.utils {
import flash.net.*;
import flash.text.*;
import flash.utils.*;
import uk.co.inbox.league.*;
import uk.co.inbox.debug.*;
import flash.external.*;
public class TextTools {
protected static const WINDOW_OPEN_FUNCTION:String = "window.open";
private static var resizeOrigPositionList:Dictionary = new Dictionary();
private static var isDebugMode:Boolean = true;
public function TextTools(){
super();
}
public static function squashTextField($targetTextField:TextField, $maxDimension:Number, $defaultLetterSpacing:Number, $align:String, $content:String, $isHTMLText:Boolean=false, $letterSpacingInc:Number=0.5):void{
var newWidth:Number;
var my_fmt:TextFormat = new TextFormat();
my_fmt.letterSpacing = $defaultLetterSpacing;
if ($isHTMLText){
$targetTextField.htmlText = $content;
} else {
$targetTextField.text = $content;
};
$targetTextField.autoSize = $align;
$targetTextField.setTextFormat(my_fmt);
if ($targetTextField.multiline){
newWidth = $targetTextField.textHeight;
} else {
newWidth = $targetTextField.textWidth;
};
if (newWidth > $maxDimension){
squashTextField($targetTextField, $maxDimension, ($defaultLetterSpacing - $letterSpacingInc), $align, $content, $isHTMLText);
} else {
if ($align == TextFieldAutoSize.CENTER){
$targetTextField.autoSize = TextFieldAutoSize.LEFT;
$targetTextField.x = Math.round((($targetTextField.x + ($targetTextField.textWidth / 2)) - ($targetTextField.textWidth / 2)));
};
};
}
public static function popupEmail(subject:String, body:String, targetEmail:String=""):void{
trace("TextTools - popupEmail");
body = body.split("<br>").join("%0D %0A");
if (League.status == "league"){
body = body.split("<url>").join(League.leagueURL);
body = body.split("<URL>").join(League.leagueURL);
} else {
body = body.split("<url>").join(Settings.get("gamePath"));
body = body.split("<URL>").join(Settings.get("gamePath"));
};
var req:URLRequest = new URLRequest(((((("mailto:" + targetEmail) + "?subject=") + subject) + "&body=") + body));
navigateToURL(req, "_self");
}
private static function debugTrace($msg):void{
if (isDebugMode){
outPut($msg, "TextTools");
};
}
public static function resizeTextField($targetTextField:TextField, $maxDimension:Number, $maxFontSize:Number, $align:String, $content:String, $yInc:Number=0.6, $isHTMLText:Boolean=false, countNum:Number=0):void{
var newWidth:Number;
if (countNum == 0){
if (resizeOrigPositionList[$targetTextField] == undefined){
resizeOrigPositionList[$targetTextField] = $targetTextField.y;
};
$targetTextField.y = resizeOrigPositionList[$targetTextField];
};
var my_fmt:TextFormat = new TextFormat();
my_fmt.size = $maxFontSize;
if ($isHTMLText){
$targetTextField.htmlText = $content;
} else {
$targetTextField.text = $content;
};
$targetTextField.autoSize = $align;
$targetTextField.setTextFormat(my_fmt);
if ($targetTextField.multiline){
newWidth = $targetTextField.textHeight;
} else {
newWidth = $targetTextField.textWidth;
};
if ((((newWidth > $maxDimension)) && (($maxFontSize > 8)))){
$targetTextField.y = ($targetTextField.y + $yInc);
resizeTextField($targetTextField, $maxDimension, ($maxFontSize - 1), $align, $content, $yInc, $isHTMLText, 1);
} else {
$targetTextField.y = Math.round($targetTextField.y);
};
}
public static function openWindow(url:String, window:String="_blank", features:String=""):void{
if (Settings.get("isHosted")){
ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features);
} else {
navigateToURL(new URLRequest(url), window);
};
}
public static function realignTextField(ref:TextField, targetX:Number, textContent:String, refAlign:String):void{
ref.autoSize = TextFieldAutoSize.LEFT;
ref.text = textContent;
if (refAlign == TextFieldAutoSize.RIGHT){
ref.x = Math.round((targetX - ref.textWidth));
} else {
if (refAlign == TextFieldAutoSize.CENTER){
ref.x = Math.round((targetX - (ref.textWidth / 2)));
};
};
}
}
}//package uk.co.inbox.utils
Section 317
//Validation (uk.co.inbox.utils.Validation)
package uk.co.inbox.utils {
public class Validation {
public static const RESULT_SUCCESS:String = "resultSuccess";
public static const RESULT_TOO_LONG:String = "resultTooLong";
public static const RESULT_EMPTY:String = "resultEmpty";
public static const RESULT_TOO_SHORT:String = "resultTooShort";
public static const RESULT_NO_MATCH:String = "resultNoMatch";
public static const RESULT_INVALID_EMAIL:String = "resultInvalidEmail";
public static const RESULT_INVALID:String = "resultInvalid";
public function Validation(){
super();
}
public static function validateText(str:String, minLen:Number=0):String{
if (str.length < minLen){
if (str.length == 0){
return (RESULT_EMPTY);
};
return (RESULT_TOO_SHORT);
//unresolved jump
};
return (RESULT_SUCCESS);
}
public static function validateEmail(email:String):String{
var xES:String = email.toLowerCase();
var xVE:Boolean;
var xA:int = xES.indexOf("@");
var xB:String = xES.substring(0, xA);
var xD:int = (xES.length - 1);
var xE:int = xES.lastIndexOf(".");
var xC:String = xES.substring((xA + 1), xE);
var xF:int = (xD - (xE + 1));
if (xA == -1){
xVE = false;
};
if (xE == -1){
xVE = false;
};
if (xA != xES.lastIndexOf("@")){
xVE = false;
};
if (xCheckSUVC(xB) != true){
xVE = false;
};
if (xB.length < 1){
xVE = false;
};
if (xCheckSUVC(xC) != true){
xVE = false;
};
if (xC.length < 2){
xVE = false;
};
if (xCheckSUVC(xES.substr((xE + 1), xD)) != true){
xVE = false;
};
if ((((xF < 1)) || ((xF > 3)))){
xVE = false;
};
if (xVE){
return (RESULT_SUCCESS);
};
return (RESULT_INVALID_EMAIL);
}
public static function trimText(str:String):String{
var i:int;
while ((((((str.charCodeAt(i) == 32)) || ((str.charCodeAt(i) == 10)))) || ((str.charCodeAt(i) == 13)))) {
str = str.slice(1, str.length);
};
i = (str.length - 1);
while ((((((str.charCodeAt(i) == 32)) || ((str.charCodeAt(i) == 10)))) || ((str.charCodeAt(i) == 13)))) {
str = str.slice(0, (str.length - 1));
i = (str.length - 1);
};
return (str);
}
public static function validatePostcode($postcode:String):String{
var postcodeExpression:RegExp = /^(GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])[0-9][ABD-HJLNP-UW-Z]{2})$/i;
var isValid:Boolean = postcodeExpression.test($postcode.split(" ").join(""));
if (isValid){
return (RESULT_SUCCESS);
};
return (RESULT_INVALID);
}
public static function validateCompareText(str1:String, str2:String, minLen:Number=0):String{
if (str1.length < minLen){
return (RESULT_TOO_SHORT);
};
if (str1 != str2){
return (RESULT_NO_MATCH);
};
return (RESULT_SUCCESS);
}
private static function xCheckSUVC(xESS:String):Boolean{
var xV:Boolean;
var xUC:Array = new Array("!", "£", "$", "%", "^", "&", "*", "+", "=", "?", ":", ";", "'", "\t", " ", "\"", "~", "#", "/");
var i:int;
while (i <= (xUC.length - 1)) {
if (xESS.indexOf(xUC[i], 0) != -1){
xV = false;
break;
};
i++;
};
return (xV);
}
}
}//package uk.co.inbox.utils
Section 318
//AnimWindow (uk.co.inbox.windows.AnimWindow)
package uk.co.inbox.windows {
import gs.*;
public class AnimWindow extends Window {
protected var tweenLength:Number;// = 0.3
public function AnimWindow(){
super();
alpha = 0;
}
protected function startClose():void{
TweenLite.to(this, tweenLength, {alpha:0, onComplete:completeClose});
}
override public function close():void{
disable();
dispatchEvent(new WindowEvent(WindowEvent.CLOSE_START));
startClose();
}
override public function open():void{
isOpen = true;
refreshLang();
dispatchEvent(new WindowEvent(WindowEvent.OPEN_START));
startOpen();
}
protected function completeOpen():void{
enable();
dispatchEvent(new WindowEvent(WindowEvent.OPEN_COMPLETE));
}
protected function startOpen():void{
TweenLite.to(this, tweenLength, {alpha:1, onComplete:completeOpen});
}
protected function completeClose():void{
isOpen = false;
dispatchEvent(new WindowEvent(WindowEvent.CLOSE_COMPLETE));
}
}
}//package uk.co.inbox.windows
Section 319
//QueueWindowData (uk.co.inbox.windows.QueueWindowData)
package uk.co.inbox.windows {
public class QueueWindowData {
private var _id:String;
private var _args:Array;
public function QueueWindowData($id:String, $args:Array){
super();
_id = $id;
_args = $args;
}
public function get id():String{
return (_id);
}
public function get args():Array{
return (_args.slice());
}
}
}//package uk.co.inbox.windows
Section 320
//Window (uk.co.inbox.windows.Window)
package uk.co.inbox.windows {
import flash.display.*;
import uk.co.inbox.debug.*;
public class Window extends MovieClip {
protected var isDebugMode:Boolean;// = true
protected var isOpen:Boolean;// = false
protected var windowManager:WindowManager;
public function Window():void{
super();
}
public function enable():void{
mouseChildren = true;
}
public function refreshLang():void{
}
public function open():void{
isOpen = true;
refreshLang();
enable();
dispatchEvent(new WindowEvent(WindowEvent.OPEN_COMPLETE));
}
public function disable():void{
mouseChildren = false;
}
public function init():void{
}
protected function debugTrace($msg):void{
if (isDebugMode){
outPut(((("Window:" + this) + " - ") + $msg));
};
}
public function close():void{
isOpen = false;
disable();
dispatchEvent(new WindowEvent(WindowEvent.CLOSE_COMPLETE));
}
public function setWindowManager($windowManager:WindowManager):void{
windowManager = $windowManager;
}
}
}//package uk.co.inbox.windows
Section 321
//WindowEvent (uk.co.inbox.windows.WindowEvent)
package uk.co.inbox.windows {
import flash.events.*;
public class WindowEvent extends Event {
public static const CLOSE_COMPLETE:String = "closeComplete";
public static const CLOSE_START:String = "closeStart";
public static const OPEN_START:String = "openStart";
public static const OPEN_COMPLETE:String = "openComplete";
public function WindowEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
override public function clone():Event{
return (new WindowEvent(type, bubbles, cancelable));
}
}
}//package uk.co.inbox.windows
Section 322
//WindowManager (uk.co.inbox.windows.WindowManager)
package uk.co.inbox.windows {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import uk.co.inbox.language.*;
import uk.co.inbox.debug.*;
public class WindowManager extends EventDispatcher {
protected var displayList:Array;
protected var nextWindowParentCount:int;// = 0
protected var currentWindowList:Array;
protected var isDebugMode:Boolean;// = true
protected var queueList:Array;
private var _state:int;// = 0
private var _prevWindow:Window;
protected var windowList:Array;
protected var nextWindowObj:Object;
protected var windowHolder:Sprite;
public static const NO_WINDOWS_LEFT:String = "noWindowsLeft";
public static const STATE_OPENING_WINDOW:int = 1;
public static const STATE_CLOSING_WINDOW:int = 2;
public static const STATE_IDLE:int = 0;
private static var _inst:WindowManager;
public function WindowManager($windowHolder:Sprite, $initWindowList:Array):void{
var window:Window;
var className:String;
displayList = [];
currentWindowList = [];
queueList = [];
super();
_inst = this;
windowHolder = $windowHolder;
windowList = [];
var i:int;
while (i < $initWindowList.length) {
window = $initWindowList[i];
className = getQualifiedClassName(window).split("::")[1];
windowList[className] = window;
i++;
};
initWindows();
LangContent.addEventListener(LangContent.CHANGE, refreshLang, false, 0, true);
}
protected function displayWindowOpen($newWindow:Window, $args:Array):void{
($newWindow as MovieClip).openDisplay.apply(null, $args);
}
public function openWindowByInstance($window:Window, ... _args):void{
_args.unshift(getQualifiedClassName($window).split("::")[1]);
openWindow.apply(null, _args);
}
public function get currentWindow():Window{
if (currentWindowList.length > 0){
return (currentWindowList[0]);
};
return (null);
}
public function get prevWindow():Window{
return (_prevWindow);
}
private function onWindowClosing(e:WindowEvent):void{
var targetWindow:Window = (e.target as Window);
targetWindow.removeEventListener(WindowEvent.CLOSE_START, onWindowClosing);
_state = STATE_CLOSING_WINDOW;
}
private function displayWindow($nextWindowData:QueueWindowData):void{
debugTrace("displayWindow");
var newWindow:Window = windowList[$nextWindowData.id];
debugTrace((" newWindow:" + newWindow));
displayWindowOpen(newWindow, $nextWindowData.args);
newWindow.addEventListener(WindowEvent.OPEN_COMPLETE, onWindowOpened, false, 0, true);
newWindow.addEventListener(WindowEvent.CLOSE_START, onWindowClosing, false, 0, true);
newWindow.addEventListener(WindowEvent.CLOSE_COMPLETE, onWindowClosed, false, 0, true);
windowHolder.addChild(newWindow);
currentWindowList.push(newWindow);
displayList.push($nextWindowData);
debugTrace((" displayList:" + displayList));
}
protected function initWindows():void{
var win:Window;
for each (win in windowList) {
win.setWindowManager(this);
win.init();
};
}
public function openWindow($windowId:String, ... _args):void{
debugTrace("openWindow");
debugTrace((" $windowId:" + $windowId));
if (windowList[$windowId] != null){
queueList.push(new QueueWindowData($windowId, _args));
checkCurrentWindows();
} else {
throw (new Error((("WindowManager - Window:" + $windowId) + " not initialised")));
};
}
public function closeCurrentWindows():void{
var window:Window;
var i:int;
while (i < currentWindowList.length) {
window = currentWindowList[i];
window.close();
i++;
};
if (displayList.length > 0){
nextWindowObj = null;
displayList = [];
currentWindow.close();
};
}
public function refreshLang():void{
var window:Window;
var i:int;
while (i < currentWindowList.length) {
window = currentWindowList[i];
window.refreshLang();
i++;
};
}
public function removeAndOpenWindow($windowId:String, ... _args):void{
}
public function closeCurrentWindow():void{
debugTrace("closeCurrentWindow");
debugTrace((" currentWindow:" + currentWindow));
if (currentWindow != null){
currentWindow.close();
};
}
private function checkCurrentWindows():void{
debugTrace(("checkCurrentWindows - displayList.length:" + displayList.length));
if (displayList.length == 0){
displayWindow(queueList.shift());
} else {
currentWindow.close();
};
}
private function doNoWindowProcedure():void{
dispatchEvent(new Event(NO_WINDOWS_LEFT));
}
protected function debugTrace(msg, $isForced:Boolean=false):void{
if (((isDebugMode) || ($isForced))){
outPut(msg, this);
};
}
public function closeAllWindows():void{
queueList = [];
displayList = [];
closeCurrentWindows();
}
protected function onWindowClosed(e:WindowEvent):void{
var checkWindow:Window;
var checkWindow2:String;
debugTrace("onWindowClosed");
var targetWindow:Window = (e.target as Window);
debugTrace((" targetWindow:" + targetWindow));
targetWindow.removeEventListener(WindowEvent.CLOSE_COMPLETE, onWindowClosed);
var i:int;
while (i < currentWindowList.length) {
checkWindow = currentWindowList[i];
if (checkWindow == targetWindow){
windowHolder.removeChild(checkWindow);
_prevWindow = currentWindowList.splice(i, 1)[0];
break;
};
i++;
};
i = 0;
while (i < displayList.length) {
checkWindow2 = (displayList[i] as QueueWindowData).id;
if (checkWindow2 == getQualifiedClassName(targetWindow).split("::")[1]){
displayList.splice(i, 1);
break;
};
i++;
};
if (queueList.length > 0){
displayWindow(queueList.shift());
} else {
if (displayList.length > 0){
displayWindow(displayList.pop());
} else {
dispatchEvent(new Event(NO_WINDOWS_LEFT));
};
};
}
protected function onWindowOpened(e:WindowEvent):void{
var targetWindow:Window = (e.target as Window);
targetWindow.removeEventListener(WindowEvent.OPEN_COMPLETE, onWindowOpened);
_state = STATE_IDLE;
}
public static function get currentWindow():Window{
return (_inst.currentWindow);
}
public static function openWindow($windowId:String, ... _args):void{
_args.unshift($windowId);
if (_inst == null){
throw (new Error("You haven't instantiated WindowManager yet!"));
};
_inst.openWindow.apply(null, _args);
}
}
}//package uk.co.inbox.windows
Section 323
//_HandelGothic (_HandelGothic)
package {
import flash.text.*;
public dynamic class _HandelGothic extends Font {
}
}//package
Section 324
//AdPanel_Graphic (AdPanel_Graphic)
package {
import flash.display.*;
public dynamic class AdPanel_Graphic extends MovieClip {
public var outline:MovieClip;
public var adMask:MovieClip;
}
}//package
Section 325
//AimArrow_Ball_Graphic (AimArrow_Ball_Graphic)
package {
import flash.display.*;
public dynamic class AimArrow_Ball_Graphic extends MovieClip {
public var shadow_mc:MovieClip;
public var ball_mc:MovieClip;
}
}//package
Section 326
//Ball_Graphic (Ball_Graphic)
package {
import flash.display.*;
public dynamic class Ball_Graphic extends MovieClip {
public var ball_mc:MovieClip;
}
}//package
Section 327
//Ball_Shadow_Graphic (Ball_Shadow_Graphic)
package {
import flash.display.*;
public dynamic class Ball_Shadow_Graphic extends MovieClip {
}
}//package
Section 328
//Button_Main_Graphic (Button_Main_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Button_Main_Graphic extends MovieClip {
public var icon:MovieClip;
public var hit:MovieClip;
public var label_txt:TextField;
}
}//package
Section 329
//ButtonLobby_Graphic (ButtonLobby_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class ButtonLobby_Graphic extends MovieClip {
public var label_txt:TextField;
}
}//package
Section 330
//ButtonLobby2_Graphic (ButtonLobby2_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class ButtonLobby2_Graphic extends MovieClip {
public var icon:MovieClip;
public var hit:MovieClip;
public var label_txt:TextField;
}
}//package
Section 331
//ButtonLobby2White_Graphic (ButtonLobby2White_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class ButtonLobby2White_Graphic extends MovieClip {
public var icon:MovieClip;
public var hit:MovieClip;
public var label_txt:TextField;
}
}//package
Section 332
//ButtonLobbySmall_Graphic (ButtonLobbySmall_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class ButtonLobbySmall_Graphic extends MovieClip {
public var label_txt:TextField;
}
}//package
Section 333
//ButtonLogout_Graphic (ButtonLogout_Graphic)
package {
import flash.display.*;
public dynamic class ButtonLogout_Graphic extends MovieClip {
public var icon:MovieClip;
public var hit:MovieClip;
}
}//package
Section 334
//CellRenderer_disabledSkin (CellRenderer_disabledSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_disabledSkin extends MovieClip {
}
}//package
Section 335
//CellRenderer_downSkin (CellRenderer_downSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_downSkin extends MovieClip {
}
}//package
Section 336
//CellRenderer_overSkin (CellRenderer_overSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_overSkin extends MovieClip {
}
}//package
Section 337
//CellRenderer_selectedDisabledSkin (CellRenderer_selectedDisabledSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_selectedDisabledSkin extends MovieClip {
}
}//package
Section 338
//CellRenderer_selectedDownSkin (CellRenderer_selectedDownSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_selectedDownSkin extends MovieClip {
}
}//package
Section 339
//CellRenderer_selectedOverSkin (CellRenderer_selectedOverSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_selectedOverSkin extends MovieClip {
}
}//package
Section 340
//CellRenderer_selectedUpSkin (CellRenderer_selectedUpSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_selectedUpSkin extends MovieClip {
}
}//package
Section 341
//CellRenderer_upSkin (CellRenderer_upSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_upSkin extends MovieClip {
}
}//package
Section 342
//ChallengeList_Graphic (ChallengeList_Graphic)
package {
import flash.display.*;
import fl.controls.*;
public dynamic class ChallengeList_Graphic extends MovieClip {
public var list_scr:UIScrollBar;
}
}//package
Section 343
//ChatWindow_Graphic (ChatWindow_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class ChatWindow_Graphic extends MovieClip {
public var player2_chat_txt:TextField;
public var player1_txt:TextField;
public var send_but:SimpleButton;
public var input_txt:TextField;
public var player2_txt:TextField;
}
}//package
Section 344
//ComboBox_disabledSkin (ComboBox_disabledSkin)
package {
import flash.display.*;
public dynamic class ComboBox_disabledSkin extends MovieClip {
}
}//package
Section 345
//ComboBox_downSkin (ComboBox_downSkin)
package {
import flash.display.*;
public dynamic class ComboBox_downSkin extends MovieClip {
}
}//package
Section 346
//ComboBox_overSkin (ComboBox_overSkin)
package {
import flash.display.*;
public dynamic class ComboBox_overSkin extends MovieClip {
}
}//package
Section 347
//ComboBox_upSkin (ComboBox_upSkin)
package {
import flash.display.*;
public dynamic class ComboBox_upSkin extends MovieClip {
}
}//package
Section 348
//focusRectSkin (focusRectSkin)
package {
import flash.display.*;
public dynamic class focusRectSkin extends MovieClip {
}
}//package
Section 349
//FreeKickChallenge_Default_Graphic (FreeKickChallenge_Default_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class FreeKickChallenge_Default_Graphic extends MovieClip {
public var no_but:ButtonLobbySmall_Graphic;
public var yes_but:ButtonLobbySmall_Graphic;
public var bg:MovieClip;
public var name_txt:TextField;
}
}//package
Section 350
//FreeKickLobbyPlayerInfo_Graphic (FreeKickLobbyPlayerInfo_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class FreeKickLobbyPlayerInfo_Graphic extends MovieClip {
public var played_txt:TextField;
public var won_txt:TextField;
public var invite_but:ButtonLobby2_Graphic;
public var preloader:MovieClip;
public var close_but:SimpleButton;
public var name_txt:TextField;
public var rating_txt:TextField;
public var lost_txt:TextField;
}
}//package
Section 351
//FreeKickLobbySelector_Graphic (FreeKickLobbySelector_Graphic)
package {
import flash.text.*;
import flash.display.*;
import fl.controls.*;
public dynamic class FreeKickLobbySelector_Graphic extends MovieClip {
public var lobbies_cmb:ComboBox;
public var label_txt:TextField;
}
}//package
Section 352
//FreeKickPlayer_Default_Graphic (FreeKickPlayer_Default_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class FreeKickPlayer_Default_Graphic extends MovieClip {
public var bg:MovieClip;
public var star:MovieClip;
public var name_txt:TextField;
public var rating_txt:TextField;
}
}//package
Section 353
//FreeKickPlayer_Guest_Graphic (FreeKickPlayer_Guest_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class FreeKickPlayer_Guest_Graphic extends MovieClip {
public var bg:MovieClip;
public var name_txt:TextField;
public var rating_txt:TextField;
}
}//package
Section 354
//FreeKickRoom_Create_Graphic (FreeKickRoom_Create_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class FreeKickRoom_Create_Graphic extends MovieClip {
public var num_txt:TextField;
public var bg:MovieClip;
public var num_mc:MovieClip;
}
}//package
Section 355
//FreeKickRoom_Creating_Graphic (FreeKickRoom_Creating_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class FreeKickRoom_Creating_Graphic extends MovieClip {
public var num_txt:TextField;
public var num_mc:MovieClip;
public function FreeKickRoom_Creating_Graphic(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 356
//FreeKickRoom_Full_Graphic (FreeKickRoom_Full_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class FreeKickRoom_Full_Graphic extends MovieClip {
public var player1_txt:TextField;
public var num_txt:TextField;
public var score_mc:MovieClip;
public var player2_txt:TextField;
public var num_mc:MovieClip;
public var player1_rating_txt:TextField;
}
}//package
Section 357
//FreeKickRoom_Join_Graphic (FreeKickRoom_Join_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class FreeKickRoom_Join_Graphic extends MovieClip {
public var join_but:ButtonLobby_Graphic;
public var player1_txt:TextField;
public var num_txt:TextField;
public var score_mc:MovieClip;
public var members_txt:TextField;
public var private_txt:TextField;
public var num_mc:MovieClip;
public var player1_rating_txt:TextField;
}
}//package
Section 358
//FreeKickRoom_Setup_Graphic (FreeKickRoom_Setup_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class FreeKickRoom_Setup_Graphic extends MovieClip {
public var ball1:MovieClip;
public var ball2:MovieClip;
public var ball3:MovieClip;
public var ball4:MovieClip;
public var level_txt:TextField;
public var cancel_but:ButtonLobby2_Graphic;
public var member_chk:MovieClip;
public var membersBlocker:MovieClip;
public var create_but:ButtonLobby2_Graphic;
public var private_chk:MovieClip;
}
}//package
Section 359
//GameMessage_Graphic (GameMessage_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class GameMessage_Graphic extends MovieClip {
public var label_txt:TextField;
}
}//package
Section 360
//Goalie_DiveCrouch_Graphic (Goalie_DiveCrouch_Graphic)
package {
import flash.display.*;
import uk.co.inbox.events.*;
public dynamic class Goalie_DiveCrouch_Graphic extends MovieClip {
public function Goalie_DiveCrouch_Graphic(){
addFrameScript(0, frame1, 25, frame26);
}
function frame1(){
stop();
}
function frame26(){
dispatchEvent(new TimelineEvent(TimelineEvent.END));
}
}
}//package
Section 361
//Goalie_DiveHigh_Graphic (Goalie_DiveHigh_Graphic)
package {
import flash.display.*;
import uk.co.inbox.events.*;
public dynamic class Goalie_DiveHigh_Graphic extends MovieClip {
public var startPosY:Number;
public var ySpeed;
public var isSuperSave;
public var supersave_mc:MovieClip;
public function Goalie_DiveHigh_Graphic(){
addFrameScript(0, frame1, 3, frame4, 4, frame5, 5, frame6, 6, frame7, 7, frame8, 9, frame10, 10, frame11, 11, frame12, 12, frame13, 13, frame14, 14, frame15, 59, frame60);
}
function frame10(){
y = (y - ySpeed);
}
function frame14(){
y = (y - ySpeed);
}
function frame12(){
y = (y - ySpeed);
}
function frame6(){
y = (y + ySpeed);
}
function frame7(){
y = (y + ySpeed);
}
function frame1(){
startPosY = y;
stop();
}
function frame13(){
y = (y - ySpeed);
}
function frame4(){
y = (y + ySpeed);
}
function frame5(){
y = (y + ySpeed);
}
function frame8(){
if (isSuperSave){
supersave_mc.visible = true;
} else {
supersave_mc.visible = false;
};
y = (y + ySpeed);
}
function frame15(){
y = startPosY;
}
function frame11(){
y = (y - ySpeed);
}
function frame60(){
dispatchEvent(new TimelineEvent(TimelineEvent.END));
}
}
}//package
Section 362
//Goalie_DiveJump_Graphic (Goalie_DiveJump_Graphic)
package {
import flash.display.*;
import uk.co.inbox.events.*;
public dynamic class Goalie_DiveJump_Graphic extends MovieClip {
public var isSuperSave;
public var supersave_mc:MovieClip;
public function Goalie_DiveJump_Graphic(){
addFrameScript(0, frame1, 7, frame8, 22, frame23);
}
function frame1(){
stop();
}
function frame23(){
dispatchEvent(new TimelineEvent(TimelineEvent.END));
}
function frame8(){
if (isSuperSave){
supersave_mc.visible = true;
} else {
supersave_mc.visible = false;
};
}
}
}//package
Section 363
//Goalie_DiveLow_Graphic (Goalie_DiveLow_Graphic)
package {
import flash.display.*;
import uk.co.inbox.events.*;
public dynamic class Goalie_DiveLow_Graphic extends MovieClip {
public var isSuperSave;
public var supersave_mc:MovieClip;
public function Goalie_DiveLow_Graphic(){
addFrameScript(0, frame1, 7, frame8, 51, frame52);
}
function frame1(){
stop();
}
function frame8(){
if (isSuperSave){
supersave_mc.visible = true;
} else {
supersave_mc.visible = false;
};
}
function frame52(){
dispatchEvent(new TimelineEvent(TimelineEvent.END));
}
}
}//package
Section 364
//Goalie_Idle_Graphic (Goalie_Idle_Graphic)
package {
import flash.display.*;
public dynamic class Goalie_Idle_Graphic extends MovieClip {
}
}//package
Section 365
//GoalSound (GoalSound)
package {
import flash.media.*;
public dynamic class GoalSound extends Sound {
}
}//package
Section 366
//Header_Graphic (Header_Graphic)
package {
import flash.display.*;
public dynamic class Header_Graphic extends MovieClip {
public var logo_but:SimpleButton;
}
}//package
Section 367
//KickSound (KickSound)
package {
import flash.media.*;
public dynamic class KickSound extends Sound {
}
}//package
Section 368
//LeagueList_Graphic (LeagueList_Graphic)
package {
import flash.display.*;
import fl.controls.*;
public dynamic class LeagueList_Graphic extends MovieClip {
public var list_scr:UIScrollBar;
}
}//package
Section 369
//LeagueListItem_Graphic (LeagueListItem_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class LeagueListItem_Graphic extends MovieClip {
public var num_txt:TextField;
public var bg:MovieClip;
public var star:MovieClip;
public var name_txt:TextField;
public var rating_txt:TextField;
}
}//package
Section 370
//List_skin (List_skin)
package {
import flash.display.*;
public dynamic class List_skin extends MovieClip {
}
}//package
Section 371
//MainGame (MainGame)
package {
import flash.events.*;
import uk.co.inbox.multiplayer.server.*;
import uk.co.inbox.windows.*;
import com.freekickfusion.game.*;
import com.freekickfusion.ui.uiframe.*;
import uk.co.inbox.users.*;
import uk.co.inbox.input.*;
import flash.display.*;
import uk.co.inbox.score.*;
import uk.co.inbox.users.commands.concrete.*;
import com.freekickfusion.multiplayer.server.*;
import com.freekickfusion.ui.windows.*;
import uk.co.inbox.users.overlay.*;
import uk.co.inbox.users.cache.*;
import uk.co.inbox.utils.*;
import uk.co.inbox.tracking.*;
import flash.system.*;
public class MainGame extends Sprite {
private var singleGame:FreeKickGameSingleEngine;
private var testLoader:Loader;
private var multiGame:FreeKickGameMultiEngine;
private var mainScoreItem:ScoreItem;
private var userHandle:GuestUserHandle;
private var gameServer:FreeKickGameServer;
private var windowHolder:Sprite;
private var windowManager:WindowManager;
public function MainGame():void{
super();
if (stage){
init();
} else {
addEventListener(Event.ADDED_TO_STAGE, init);
};
}
private function onMouseDown(e:MouseEvent):void{
}
private function setupWindows():void{
var loginCmd:LoginCommand;
var uiFrame:UIFrame = new UIFrame();
uiFrame.setVersion(Settings.get("version"));
uiFrame.setSingleGame(singleGame);
uiFrame.setMultiGame(multiGame);
uiFrame.setGameServer(gameServer);
uiFrame.setUserHandle(userHandle);
addChild(uiFrame);
var windowMask:WindowMask_Graphic = new WindowMask_Graphic();
windowHolder = new Sprite();
windowHolder.mask = windowMask;
addChild(windowHolder);
var windowList:Array = [];
windowList.push(new GameSelection());
windowList.push(new SingleHowToPlay());
windowList.push(new SingleNewLevel());
windowList.push(new SingleGameHolder());
windowList.push(new SingleLevelComplete());
windowList.push(new SingleGameComplete());
windowList.push(new SingleGameOver());
windowList.push(new Register());
windowList.push(new Registering());
windowList.push(new MultiLogin());
windowList.push(new MultiLoggingIn());
windowList.push(new MultiGuestLogin());
windowList.push(new MultiConnecting());
windowList.push(new MultiConnectionFailed());
windowList.push(new MultiConnectionLost());
windowList.push(new MultiLobbyView());
windowList.push(new MultiGameReady());
windowList.push(new MultiGameHolder());
windowList.push(new MultiGameOver());
windowList.push(new LoginCompetition());
windowList.push(new LoggingIn());
windowList.push(new RegisterCompetition());
windowList.push(new RegisteringCompetition());
windowList.push(new SingleViewStandingsCompetition());
windowManager = new FreeKickWindowManager(windowHolder, windowList, uiFrame, gameServer, userHandle, singleGame, multiGame);
Settings.set({isCompetition:false});
trace((" Settings.get(isCompetition):" + Settings.get("isCompetition")));
if (Settings.get("isCompetition", false)){
loginCmd = userHandle.init(false);
if (loginCmd == null){
windowManager.openWindow("RegisterCompetition");
} else {
windowManager.openWindow("LoggingIn", loginCmd);
};
} else {
windowManager.openWindow("GameSelection");
};
}
private function init(e:Event=null):void{
removeEventListener(Event.ADDED_TO_STAGE, init);
Settings.init(loaderInfo);
Settings.set({stage:parent});
Settings.set({version:"2.0.4"});
var flashVars:Object = Settings.get("flashVars");
Settings.set({isCompetition:(flashVars.isCompetition == "yes"), competitionId:flashVars.competitionId});
if (Settings.get("isLocal")){
Settings.set({multiplayerIP:"127.0.0.1"});
} else {
Settings.set({multiplayerIP:"94.236.7.117"});
};
Settings.set({multiplayerIP:"94.236.7.117"});
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.stageFocusRect = false;
Security.allowDomain("*.cdn.cloudfiles.rackspacecloud.com");
Security.allowDomain("freekickfusion.com");
Security.allowDomain("inboxwork.co.uk");
Security.allowDomain("*");
InboxTag.init(stage);
CustomSharedObject.init(Settings.get("gameName"));
KeyBoardManager.init(stage);
userHandle = new GuestUserHandle();
userHandle.debugMode = true;
userHandle.commandCache = new BlackholeCommandCache();
userHandle.setProjectId("freekick");
var overlay:UserOverlay = new UserOverlay(userHandle);
addChild(overlay);
gameServer = new FreeKickGameServer("freekick", "fk", true);
gameServer.addEventListener(GameServerEvent.DISCONNECTED, onServerDisconnection, false, 0, true);
gameServer.addEventListener(GameServerEvent.COMPLETE_GAME, onCompleteGame, false, 0, true);
singleGame = new FreeKickGameSingleEngine();
multiGame = new FreeKickGameMultiEngine();
multiGame.setGameServer(gameServer);
setupWindows();
}
private function onCompleteGame(e:GameServerEvent):void{
trace("OPEN MultiGameOver");
windowManager.openWindow("MultiGameOver", false);
}
private function onServerDisconnection(e:GameServerEvent):void{
trace("MainGame.onServerDisconnection");
if (!Settings.get("isUserDisconnect", false)){
trace((" isUserDisconnect:" + Settings.get("isUserDisconnect")));
windowManager.openWindow("MultiConnectionLost");
};
}
}
}//package
Section 372
//MultiScorePanel_Graphic (MultiScorePanel_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class MultiScorePanel_Graphic extends MovieClip {
public var played_txt:TextField;
public var title_txt:TextField;
public var logout_but:ButtonLogout_Graphic;
public var won_txt:TextField;
public var ratinglabel_txt:TextField;
public var rating_txt:TextField;
public var lost_txt:TextField;
public var registerPrompt:MovieClip;
}
}//package
Section 373
//Player_Graphic (Player_Graphic)
package {
import flash.display.*;
public dynamic class Player_Graphic extends MovieClip {
public var body:MovieClip;
}
}//package
Section 374
//PlayerList_Graphic (PlayerList_Graphic)
package {
import flash.display.*;
import fl.controls.*;
public dynamic class PlayerList_Graphic extends MovieClip {
public var list_scr:UIScrollBar;
}
}//package
Section 375
//RightPanel_Graphic (RightPanel_Graphic)
package {
import flash.display.*;
public dynamic class RightPanel_Graphic extends MovieClip {
public var singleScore:SingleScorePanel_Graphic;
public var singleScoreCompetition:SingleScoreCompetitionPanel_Graphic;
public var singleScoreCompetitionLogin:SingleScoreCompetitionLoginPanel_Graphic;
public var singleScore2:SingleScorePanel2_Graphic;
public var adPanel1:AdPanel_Graphic;
public var adPanel2:AdPanel_Graphic;
public var multiScore:MultiScorePanel_Graphic;
}
}//package
Section 376
//RoomList_Graphic (RoomList_Graphic)
package {
import flash.display.*;
import fl.controls.*;
public dynamic class RoomList_Graphic extends MovieClip {
public var list_scr:UIScrollBar;
}
}//package
Section 377
//ScrollArrowDown_disabledSkin (ScrollArrowDown_disabledSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowDown_disabledSkin extends MovieClip {
public var face_mc:MovieClip;
}
}//package
Section 378
//ScrollArrowDown_downSkin (ScrollArrowDown_downSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowDown_downSkin extends MovieClip {
public var face_mc:MovieClip;
}
}//package
Section 379
//ScrollArrowDown_overSkin (ScrollArrowDown_overSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowDown_overSkin extends MovieClip {
public var face_mc:MovieClip;
}
}//package
Section 380
//ScrollArrowDown_upSkin (ScrollArrowDown_upSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowDown_upSkin extends MovieClip {
public var face_mc:MovieClip;
}
}//package
Section 381
//ScrollArrowUp_disabledSkin (ScrollArrowUp_disabledSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowUp_disabledSkin extends MovieClip {
public var face_mc:MovieClip;
}
}//package
Section 382
//ScrollArrowUp_downSkin (ScrollArrowUp_downSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowUp_downSkin extends MovieClip {
public var face_mc:MovieClip;
}
}//package
Section 383
//ScrollArrowUp_overSkin (ScrollArrowUp_overSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowUp_overSkin extends MovieClip {
public var face_mc:MovieClip;
}
}//package
Section 384
//ScrollArrowUp_upSkin (ScrollArrowUp_upSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowUp_upSkin extends MovieClip {
public var face_mc:MovieClip;
}
}//package
Section 385
//ScrollBar_thumbIcon (ScrollBar_thumbIcon)
package {
import flash.display.*;
public dynamic class ScrollBar_thumbIcon extends MovieClip {
}
}//package
Section 386
//ScrollThumb_downSkin (ScrollThumb_downSkin)
package {
import flash.display.*;
public dynamic class ScrollThumb_downSkin extends MovieClip {
}
}//package
Section 387
//ScrollThumb_overSkin (ScrollThumb_overSkin)
package {
import flash.display.*;
public dynamic class ScrollThumb_overSkin extends MovieClip {
}
}//package
Section 388
//ScrollThumb_upSkin (ScrollThumb_upSkin)
package {
import flash.display.*;
public dynamic class ScrollThumb_upSkin extends MovieClip {
}
}//package
Section 389
//ScrollTrack_skin (ScrollTrack_skin)
package {
import flash.display.*;
public dynamic class ScrollTrack_skin extends MovieClip {
}
}//package
Section 390
//SingleScoreCompetitionLoginPanel_Graphic (SingleScoreCompetitionLoginPanel_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class SingleScoreCompetitionLoginPanel_Graphic extends MovieClip {
public var title_txt:TextField;
public var message_txt:TextField;
public var login_but:ButtonLobby2_Graphic;
}
}//package
Section 391
//SingleScoreCompetitionPanel_Graphic (SingleScoreCompetitionPanel_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class SingleScoreCompetitionPanel_Graphic extends MovieClip {
public var title_txt:TextField;
public var viewstandings_but:ButtonLobby2_Graphic;
public var bestscore_txt:TextField;
public var ranking_txt:TextField;
}
}//package
Section 392
//SingleScorePanel_Graphic (SingleScorePanel_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class SingleScorePanel_Graphic extends MovieClip {
public var bestscore_txt:TextField;
public var ranking_txt:TextField;
}
}//package
Section 393
//SingleScorePanel2_Graphic (SingleScorePanel2_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class SingleScorePanel2_Graphic extends MovieClip {
public var title_txt:TextField;
public var logout_but:ButtonLogout_Graphic;
public var awards_txt:TextField;
public var ratinglabel_txt:TextField;
public var bestscore_txt:TextField;
public var ranking_txt:TextField;
public var registerPrompt:MovieClip;
}
}//package
Section 394
//SuperSave_Graphic (SuperSave_Graphic)
package {
import flash.display.*;
public dynamic class SuperSave_Graphic extends MovieClip {
public var main_mc:MovieClip;
}
}//package
Section 395
//TextInput_disabledSkin (TextInput_disabledSkin)
package {
import flash.display.*;
public dynamic class TextInput_disabledSkin extends MovieClip {
}
}//package
Section 396
//TextInput_upSkin (TextInput_upSkin)
package {
import flash.display.*;
public dynamic class TextInput_upSkin extends MovieClip {
}
}//package
Section 397
//UIFrame_Graphic (UIFrame_Graphic)
package {
import flash.text.*;
import flash.display.*;
public dynamic class UIFrame_Graphic extends MovieClip {
public var rightPanel:RightPanel_Graphic;
public var chat:ChatWindow_Graphic;
public var mainmenu_but:MovieClip;
public var sound_txt:TextField;
public var sound_but:SimpleButton;
public var version_txt:TextField;
public var header:Header_Graphic;
public var feedback_txt:TextField;
public var feedback_but:SimpleButton;
}
}//package
Section 398
//WhistleSound (WhistleSound)
package {
import flash.media.*;
public dynamic class WhistleSound extends Sound {
}
}//package
Section 399
//Window_GameSelection (Window_GameSelection)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_GameSelection extends MovieClip {
public var title_txt:TextField;
public var multiplayer_but:MovieClip;
public var single_but:MovieClip;
}
}//package
Section 400
//Window_LoggingIn (Window_LoggingIn)
package {
import flash.display.*;
public dynamic class Window_LoggingIn extends MovieClip {
public var title:MovieClip;
}
}//package
Section 401
//Window_LoginCompetition (Window_LoginCompetition)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_LoginCompetition extends MovieClip {
public var user_login_but:ButtonLobby2_Graphic;
public var user_error_txt:TextField;
public var title:MovieClip;
public var rem_chk:MovieClip;
public var user_name_txt:TextField;
public var user_password_txt:TextField;
public var register_but:ButtonLobby2_Graphic;
}
}//package
Section 402
//Window_MultiConnecting (Window_MultiConnecting)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_MultiConnecting extends MovieClip {
public var title:MovieClip;
public var body_txt:TextField;
}
}//package
Section 403
//Window_MultiConnectionFailed (Window_MultiConnectionFailed)
package {
import flash.display.*;
public dynamic class Window_MultiConnectionFailed extends MovieClip {
public var title:MovieClip;
}
}//package
Section 404
//Window_MultiConnectionLost (Window_MultiConnectionLost)
package {
import flash.display.*;
public dynamic class Window_MultiConnectionLost extends MovieClip {
public var title:MovieClip;
public var mainmenu_but:Button_Main_Graphic;
}
}//package
Section 405
//Window_MultiGameHolder (Window_MultiGameHolder)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_MultiGameHolder extends MovieClip {
public var time_txt:TextField;
public var player1_txt:TextField;
public var scores2:MovieClip;
public var player1rating_txt:TextField;
public var scores1:MovieClip;
public var toggleTimerBut:SimpleButton;
public var lobby_but:MovieClip;
public var player2_txt:TextField;
public var player2rating_txt:TextField;
}
}//package
Section 406
//Window_MultiGameOver (Window_MultiGameOver)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_MultiGameOver extends MovieClip {
public var no_but:Button_Main_Graphic;
public var yes_but:Button_Main_Graphic;
public var backtolobby_but:Button_Main_Graphic;
public var newranking_label_txt:TextField;
public var playagain_txt:TextField;
public var title:MovieClip;
public var subtitle_txt:TextField;
public var new_ranking_txt:TextField;
public var register_but:Button_Main_Graphic;
}
}//package
Section 407
//Window_MultiGameReady (Window_MultiGameReady)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_MultiGameReady extends MovieClip {
public var start_but:Button_Main_Graphic;
public var title:MovieClip;
public var body_txt:TextField;
public var waiting_txt:TextField;
}
}//package
Section 408
//Window_MultiGuestLogin (Window_MultiGuestLogin)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_MultiGuestLogin extends MovieClip {
public var title:MovieClip;
public var enter_but:SimpleButton;
public var error_txt:TextField;
public var name_txt:TextField;
}
}//package
Section 409
//Window_MultiLobbyView (Window_MultiLobbyView)
package {
import flash.display.*;
public dynamic class Window_MultiLobbyView extends MovieClip {
public var mainmenu_but:ButtonLobby2White_Graphic;
}
}//package
Section 410
//Window_MultiLoggingIn (Window_MultiLoggingIn)
package {
import flash.display.*;
public dynamic class Window_MultiLoggingIn extends MovieClip {
public var title:MovieClip;
}
}//package
Section 411
//Window_MultiLogin (Window_MultiLogin)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_MultiLogin extends MovieClip {
public var guest_login_but:ButtonLobby2_Graphic;
public var guest_error_txt:TextField;
public var user_login_but:ButtonLobby2_Graphic;
public var guest_name_txt:TextField;
public var user_error_txt:TextField;
public var title:MovieClip;
public var rem_chk:MovieClip;
public var user_name_txt:TextField;
public var user_password_txt:TextField;
public var register_but:ButtonLobby2_Graphic;
}
}//package
Section 412
//Window_Register (Window_Register)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_Register extends MovieClip {
public var title:MovieClip;
public var password2_txt:TextField;
public var email_txt:TextField;
public var password1_txt:TextField;
public var error_txt:TextField;
public var name_txt:TextField;
public var gamenet_chk:MovieClip;
public var register_but:ButtonLobby2_Graphic;
}
}//package
Section 413
//Window_RegisterCompetition (Window_RegisterCompetition)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_RegisterCompetition extends MovieClip {
public var mainmenu_but:ButtonLobby2White_Graphic;
public var password2_txt:TextField;
public var email_txt:TextField;
public var password1_txt:TextField;
public var error_txt:TextField;
public var name_txt:TextField;
public var terms_but:SimpleButton;
public var gamenet_chk:MovieClip;
public var register_but:ButtonLobby2_Graphic;
}
}//package
Section 414
//Window_Registering (Window_Registering)
package {
import flash.display.*;
public dynamic class Window_Registering extends MovieClip {
public var title:MovieClip;
}
}//package
Section 415
//Window_SingleGameComplete (Window_SingleGameComplete)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_SingleGameComplete extends MovieClip {
public var multiplayer_but:MovieClip;
public var score_txt:TextField;
public var title:MovieClip;
public var playagain_but:MovieClip;
public var playmoregames_but:MovieClip;
}
}//package
Section 416
//Window_SingleGameHolder (Window_SingleGameHolder)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_SingleGameHolder extends MovieClip {
public var ball1:MovieClip;
public var ball2:MovieClip;
public var ball3:MovieClip;
public var bar:MovieClip;
public var level_txt:TextField;
public var name_txt:TextField;
}
}//package
Section 417
//Window_SingleGameOver (Window_SingleGameOver)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_SingleGameOver extends MovieClip {
public var multiplayer_but:MovieClip;
public var score_txt:TextField;
public var title:MovieClip;
public var viewstandings_but:MovieClip;
public var playagain_but:MovieClip;
public var playmoregames_but:MovieClip;
}
}//package
Section 418
//Window_SingleHowToPlay (Window_SingleHowToPlay)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_SingleHowToPlay extends MovieClip {
public var play_but:Button_Main_Graphic;
public var title:MovieClip;
public var instr2_txt:TextField;
public var instr1_txt:TextField;
public var instr3_txt:TextField;
}
}//package
Section 419
//Window_SingleLevelComplete (Window_SingleLevelComplete)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_SingleLevelComplete extends MovieClip {
public var total_score_txt:TextField;
public var score_txt:TextField;
public var title:MovieClip;
public var total_label_txt:TextField;
public var elements_txt:TextField;
public var nextlevel_but:Button_Main_Graphic;
public var multiplier_txt:TextField;
}
}//package
Section 420
//Window_SingleNewLevel (Window_SingleNewLevel)
package {
import flash.text.*;
import flash.display.*;
public dynamic class Window_SingleNewLevel extends MovieClip {
public var label_skill_txt:TextField;
public var title:MovieClip;
public var players_txt:TextField;
public var skill_txt:TextField;
public var label_players_txt:TextField;
public var play_but:Button_Main_Graphic;
}
}//package
Section 421
//Window_SingleViewStandingsCompetition (Window_SingleViewStandingsCompetition)
package {
import flash.display.*;
public dynamic class Window_SingleViewStandingsCompetition extends MovieClip {
public var mainmenu_but:ButtonLobby2White_Graphic;
public var terms_but:SimpleButton;
}
}//package
Section 422
//WindowMask_Graphic (WindowMask_Graphic)
package {
import flash.display.*;
public dynamic class WindowMask_Graphic extends MovieClip {
public var contentMask:MovieClip;
}
}//package