Section 1
//Tea (com.VectorFlash.crypto.Tea)
package com.VectorFlash.crypto {
public class Tea {
private var encrypted:String;
private var b2a:Object;
private var b2c:Object;
private var a2b:Object;
private var c2b:Object;
private var keystr:String;
public var plaintext:String;
public function Tea(... _args){
initConversionTables();
if (_args[0]){
plaintext = _args[0];
};
if (_args[1]){
keystr = _args[1];
};
if (((_args[0]) && (_args[1]))){
encrypt();
};
}
private function binary2str(_arg1){
return (bytes2str(blocks2bytes(_arg1)));
}
private function ascii2binary(_arg1){
return (bytes2blocks(ascii2bytes(_arg1)));
}
private function binarydigest(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
_local2 = new Array();
_local2[0] = 1633837924;
_local2[1] = 1650680933;
_local2[2] = 1667523942;
_local2[3] = 1684366951;
_local3 = new Array();
_local3[0] = 1633837924;
_local3[1] = 1650680933;
_local4 = new Array();
_local4 = _local3;
_local5 = new Array();
_local6 = new Array();
_local8 = new Array();
_local8 = bytes2blocks(digest_pad(str2bytes(_arg1)));
_local9 = 0;
_local10 = _local8.length;
while (1) {
if (_local9 >= _local10){
break;
};
_local5[0] = _local8[_local9];
_local9++;
_local5[1] = _local8[_local9];
_local9++;
_local6[0] = _local8[_local9];
_local9++;
_local6[1] = _local8[_local9];
_local9++;
_local3 = tea_code(xor_blocks(_local5, _local3), _local2);
_local4 = tea_code(xor_blocks(_local6, _local4), _local2);
_local7 = _local3[0];
_local3[0] = _local3[1];
_local3[1] = _local4[0];
_local4[0] = _local4[1];
_local4[1] = _local7;
};
_local11 = new Array();
_local11[0] = _local3[0];
_local11[1] = _local3[1];
_local11[2] = _local4[0];
_local11[3] = _local4[1];
return (_local11);
}
private function ascii2bytes(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
_local2 = -1;
_local3 = _arg1.length;
_local4 = 0;
_local5 = new Array();
while (1) {
while (1) {
_local2++;
if (_local2 >= _local3){
return (_local5);
};
if (a2b[_arg1.charAt(_local2)] != null){
break;
};
};
_local5[_local4] = (a2b[_arg1.charAt(_local2)] << 2);
while (1) {
_local2++;
if (_local2 >= _local3){
return (_local5);
};
if (a2b[_arg1.charAt(_local2)] != null){
break;
};
};
_local6 = a2b[_arg1.charAt(_local2)];
_local5[_local4] = (_local5[_local4] | (_local6 >>> 4));
_local4++;
_local6 = (15 & _local6);
if ((((_local6 == 0)) && ((_local2 == (_local3 - 1))))){
return (_local5);
};
_local5[_local4] = (_local6 << 4);
while (1) {
_local2++;
if (_local2 >= _local3){
return (_local5);
};
if (a2b[_arg1.charAt(_local2)] != null){
break;
};
};
_local6 = a2b[_arg1.charAt(_local2)];
_local5[_local4] = (_local5[_local4] | (_local6 >>> 2));
_local4++;
_local6 = (3 & _local6);
if ((((_local6 == 0)) && ((_local2 == (_local3 - 1))))){
return (_local5);
};
_local5[_local4] = (_local6 << 6);
while (1) {
_local2++;
if (_local2 >= _local3){
return (_local5);
};
if (a2b[_arg1.charAt(_local2)] != null){
break;
};
};
_local5[_local4] = (_local5[_local4] | a2b[_arg1.charAt(_local2)]);
_local4++;
};
return (_local5);
}
private function initConversionTables():void{
var _local1:*;
c2b = new Object();
c2b["\x00"] = 0;
c2b["\x01"] = 1;
c2b["\x02"] = 2;
c2b["\x03"] = 3;
c2b["\x04"] = 4;
c2b["\x05"] = 5;
c2b["\x06"] = 6;
c2b["\x07"] = 7;
c2b["\b"] = 8;
c2b["\t"] = 9;
c2b["\n"] = 10;
c2b["\x0B"] = 11;
c2b["\f"] = 12;
c2b["\r"] = 13;
c2b["\x0E"] = 14;
c2b["\x0F"] = 15;
c2b["\x10"] = 16;
c2b["\x11"] = 17;
c2b["\x12"] = 18;
c2b["\x13"] = 19;
c2b["\x14"] = 20;
c2b["\x15"] = 21;
c2b["\x16"] = 22;
c2b["\x17"] = 23;
c2b["\x18"] = 24;
c2b["\x19"] = 25;
c2b["\x1A"] = 26;
c2b["\x1B"] = 27;
c2b["\x1C"] = 28;
c2b["\x1D"] = 29;
c2b["\x1E"] = 30;
c2b["\x1F"] = 31;
c2b[" "] = 32;
c2b["!"] = 33;
c2b["\""] = 34;
c2b["#"] = 35;
c2b["$"] = 36;
c2b["%"] = 37;
c2b["&"] = 38;
c2b["'"] = 39;
c2b["("] = 40;
c2b[")"] = 41;
c2b["*"] = 42;
c2b["+"] = 43;
c2b[","] = 44;
c2b["-"] = 45;
c2b["."] = 46;
c2b["/"] = 47;
c2b["0"] = 48;
c2b["1"] = 49;
c2b["2"] = 50;
c2b["3"] = 51;
c2b["4"] = 52;
c2b["5"] = 53;
c2b["6"] = 54;
c2b["7"] = 55;
c2b["8"] = 56;
c2b["9"] = 57;
c2b[":"] = 58;
c2b[";"] = 59;
c2b["<"] = 60;
c2b["="] = 61;
c2b[">"] = 62;
c2b["?"] = 63;
c2b["@"] = 64;
c2b["A"] = 65;
c2b["B"] = 66;
c2b["C"] = 67;
c2b["D"] = 68;
c2b["E"] = 69;
c2b["F"] = 70;
c2b["G"] = 71;
c2b["H"] = 72;
c2b["I"] = 73;
c2b["J"] = 74;
c2b["K"] = 75;
c2b["L"] = 76;
c2b["M"] = 77;
c2b["N"] = 78;
c2b["O"] = 79;
c2b["P"] = 80;
c2b["Q"] = 81;
c2b["R"] = 82;
c2b["S"] = 83;
c2b["T"] = 84;
c2b["U"] = 85;
c2b["V"] = 86;
c2b["W"] = 87;
c2b["X"] = 88;
c2b["Y"] = 89;
c2b["Z"] = 90;
c2b["["] = 91;
c2b["\\"] = 92;
c2b["]"] = 93;
c2b["^"] = 94;
c2b["_"] = 95;
c2b["`"] = 96;
c2b["a"] = 97;
c2b["b"] = 98;
c2b["c"] = 99;
c2b["d"] = 100;
c2b["e"] = 101;
c2b["f"] = 102;
c2b["g"] = 103;
c2b["h"] = 104;
c2b["i"] = 105;
c2b["j"] = 106;
c2b["k"] = 107;
c2b["l"] = 108;
c2b["m"] = 109;
c2b["n"] = 110;
c2b["o"] = 111;
c2b["p"] = 112;
c2b["q"] = 113;
c2b["r"] = 114;
c2b["s"] = 115;
c2b["t"] = 116;
c2b["u"] = 117;
c2b["v"] = 118;
c2b["w"] = 119;
c2b["x"] = 120;
c2b["y"] = 121;
c2b["z"] = 122;
c2b["{"] = 123;
c2b["|"] = 124;
c2b["}"] = 125;
c2b["~"] = 126;
c2b[""] = 127;
c2b[""] = 128;
c2b[""] = 129;
c2b[""] = 130;
c2b[""] = 131;
c2b[""] = 132;
c2b["
"] = 133;
c2b[""] = 134;
c2b[""] = 135;
c2b[""] = 136;
c2b[""] = 137;
c2b[""] = 138;
c2b[""] = 139;
c2b[""] = 140;
c2b[""] = 141;
c2b[""] = 142;
c2b[""] = 143;
c2b[""] = 144;
c2b[""] = 145;
c2b[""] = 146;
c2b[""] = 147;
c2b[""] = 148;
c2b[""] = 149;
c2b[""] = 150;
c2b[""] = 151;
c2b[""] = 152;
c2b[""] = 153;
c2b[""] = 154;
c2b[""] = 155;
c2b[""] = 156;
c2b[""] = 157;
c2b[""] = 158;
c2b[""] = 159;
c2b[" "] = 160;
c2b["¡"] = 161;
c2b["¢"] = 162;
c2b["£"] = 163;
c2b["¤"] = 164;
c2b["¥"] = 165;
c2b["¦"] = 166;
c2b["§"] = 167;
c2b["¨"] = 168;
c2b["©"] = 169;
c2b["ª"] = 170;
c2b["«"] = 171;
c2b["¬"] = 172;
c2b[""] = 173;
c2b["®"] = 174;
c2b["¯"] = 175;
c2b["°"] = 176;
c2b["±"] = 177;
c2b["²"] = 178;
c2b["³"] = 179;
c2b["´"] = 180;
c2b["µ"] = 181;
c2b["¶"] = 182;
c2b["·"] = 183;
c2b["¸"] = 184;
c2b["¹"] = 185;
c2b["º"] = 186;
c2b["»"] = 187;
c2b["¼"] = 188;
c2b["½"] = 189;
c2b["¾"] = 190;
c2b["¿"] = 191;
c2b["À"] = 192;
c2b["Á"] = 193;
c2b["Â"] = 194;
c2b["Ã"] = 195;
c2b["Ä"] = 196;
c2b["Å"] = 197;
c2b["Æ"] = 198;
c2b["Ç"] = 199;
c2b["È"] = 200;
c2b["É"] = 201;
c2b["Ê"] = 202;
c2b["Ë"] = 203;
c2b["Ì"] = 204;
c2b["Í"] = 205;
c2b["Î"] = 206;
c2b["Ï"] = 207;
c2b["Ð"] = 208;
c2b["Ñ"] = 209;
c2b["Ò"] = 210;
c2b["Ó"] = 211;
c2b["Ô"] = 212;
c2b["Õ"] = 213;
c2b["Ö"] = 214;
c2b["×"] = 215;
c2b["Ø"] = 216;
c2b["Ù"] = 217;
c2b["Ú"] = 218;
c2b["Û"] = 219;
c2b["Ü"] = 220;
c2b["Ý"] = 221;
c2b["Þ"] = 222;
c2b["ß"] = 223;
c2b["à"] = 224;
c2b["á"] = 225;
c2b["â"] = 226;
c2b["ã"] = 227;
c2b["ä"] = 228;
c2b["å"] = 229;
c2b["æ"] = 230;
c2b["ç"] = 231;
c2b["è"] = 232;
c2b["é"] = 233;
c2b["ê"] = 234;
c2b["ë"] = 235;
c2b["ì"] = 236;
c2b["í"] = 237;
c2b["î"] = 238;
c2b["ï"] = 239;
c2b["ð"] = 240;
c2b["ñ"] = 241;
c2b["ò"] = 242;
c2b["ó"] = 243;
c2b["ô"] = 244;
c2b["õ"] = 245;
c2b["ö"] = 246;
c2b["÷"] = 247;
c2b["ø"] = 248;
c2b["ù"] = 249;
c2b["ú"] = 250;
c2b["û"] = 251;
c2b["ü"] = 252;
c2b["ý"] = 253;
c2b["þ"] = 254;
c2b["ÿ"] = 0xFF;
b2c = new Object();
for (_local1 in c2b) {
b2c[c2b[_local1]] = _local1;
};
a2b = new Object();
a2b["A"] = 0;
a2b["B"] = 1;
a2b["C"] = 2;
a2b["D"] = 3;
a2b["E"] = 4;
a2b["F"] = 5;
a2b["G"] = 6;
a2b["H"] = 7;
a2b["I"] = 8;
a2b["J"] = 9;
a2b["K"] = 10;
a2b["L"] = 11;
a2b["M"] = 12;
a2b["N"] = 13;
a2b["O"] = 14;
a2b["P"] = 15;
a2b["Q"] = 16;
a2b["R"] = 17;
a2b["S"] = 18;
a2b["T"] = 19;
a2b["U"] = 20;
a2b["V"] = 21;
a2b["W"] = 22;
a2b["X"] = 23;
a2b["Y"] = 24;
a2b["Z"] = 25;
a2b["a"] = 26;
a2b["b"] = 27;
a2b["c"] = 28;
a2b["d"] = 29;
a2b["e"] = 30;
a2b["f"] = 31;
a2b["g"] = 32;
a2b["h"] = 33;
a2b["i"] = 34;
a2b["j"] = 35;
a2b["k"] = 36;
a2b["l"] = 37;
a2b["m"] = 38;
a2b["n"] = 39;
a2b["o"] = 40;
a2b["p"] = 41;
a2b["q"] = 42;
a2b["r"] = 43;
a2b["s"] = 44;
a2b["t"] = 45;
a2b["u"] = 46;
a2b["v"] = 47;
a2b["w"] = 48;
a2b["x"] = 49;
a2b["y"] = 50;
a2b["z"] = 51;
a2b["0"] = 52;
a2b["1"] = 53;
a2b["2"] = 54;
a2b["3"] = 55;
a2b["4"] = 56;
a2b["5"] = 57;
a2b["6"] = 58;
a2b["7"] = 59;
a2b["8"] = 60;
a2b["9"] = 61;
a2b["-"] = 62;
a2b["_"] = 63;
b2a = new Object();
for (_local1 in a2b) {
b2a[a2b[_local1]] = ("" + _local1);
};
}
private function xor_blocks(_arg1, _arg2){
var _local3:*;
_local3 = new Array();
_local3[0] = (_arg1[0] ^ _arg2[0]);
_local3[1] = (_arg1[1] ^ _arg2[1]);
return (_local3);
}
public function decrypt(... _args){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
if (_args[0]){
_args[0];
};
if (_args[1]){
_local2 = _args[1];
} else {
_local2 = getEncrypted();
};
if (!keystr){
trace("decrypt: no key");
return (false);
};
_local3 = new Array();
_local3 = binarydigest(keystr);
if (!_local2){
return ("");
};
_local4 = new Array();
_local4 = ascii2binary(_local2);
_local5 = 0;
_local6 = _local4.length;
_local7 = new Array();
_local7[0] = 1633837924;
_local7[1] = 1650680933;
_local8 = new Array();
_local9 = new Array();
_local10 = new Array();
_local11 = 0;
while (1) {
if (_local5 >= _local6){
break;
};
_local9[0] = _local4[_local5];
_local5++;
_local9[1] = _local4[_local5];
_local5++;
_local8 = xor_blocks(_local7, tea_decode(_local9, _local3));
_local10[_local11] = _local8[0];
_local11++;
_local10[_local11] = _local8[1];
_local11++;
_local7[0] = _local9[0];
_local7[1] = _local9[1];
};
return (bytes2str(unpad(blocks2bytes(_local10))));
}
public function getEncrypted():String{
return (encrypted);
}
private function asciidigest(_arg1){
return (binary2ascii(binarydigest(_arg1)));
}
private function bytes2ascii(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
_local2 = 0;
_local3 = _arg1.length;
_local4 = "";
while (1) {
if (_local2 >= _local3){
break;
};
_local5 = (0xFF & _arg1[_local2]);
_local4 = (_local4 + b2a[(63 & (_local5 >>> 2))]);
_local8 = (3 & _local5);
_local2++;
if (_local2 >= _local3){
_local4 = (_local4 + b2a[(_local8 << 4)]);
break;
};
_local6 = (0xFF & _arg1[_local2]);
_local4 = (_local4 + b2a[((240 & (_local8 << 4)) | (_local6 >>> 4))]);
_local8 = (15 & _local6);
_local2++;
if (_local2 >= _local3){
_local4 = (_local4 + b2a[(_local8 << 2)]);
break;
};
_local7 = (0xFF & _arg1[_local2]);
_local4 = (_local4 + (b2a[((60 & (_local8 << 2)) | (_local7 >>> 6))] + b2a[(63 & _local7)]));
_local2++;
if ((_local2 % 36) == 0){
_local4 = (_local4 + "\n");
};
};
return (_local4);
}
public function setKey(_arg1:String):void{
keystr = _arg1;
}
private function digest_pad(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
_local2 = new Array();
_local3 = 0;
_local4 = 0;
_local5 = _arg1.length;
_local6 = (15 - (_local5 % 16));
_local2[_local3] = _local6;
_local3++;
while (_local4 < _local5) {
_local2[_local3] = _arg1[_local4];
_local3++;
_local4++;
};
_local7 = _local6;
while (_local7 > 0) {
_local2[_local3] = 0;
_local3++;
_local7--;
};
return (_local2);
}
private function binary2ascii(_arg1){
return (bytes2ascii(blocks2bytes(_arg1)));
}
private function unpad(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
_local2 = 0;
_local3 = new Array();
_local4 = 0;
_local5 = (7 & _arg1[_local2]);
_local2++;
_local6 = (_arg1.length - _local5);
while (_local2 < _local6) {
_local3[_local4] = _arg1[_local2];
_local4++;
_local2++;
};
return (_local3);
}
public function encrypt(... _args){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
if (_args[0]){
plaintext = _args[0];
};
if (_args[1]){
keystr = _args[1];
};
if (!keystr){
trace("encrypt: no key");
return (false);
};
_local2 = new Array();
_local2 = binarydigest(keystr);
if (!plaintext){
return ("");
};
_local3 = new Array();
_local3 = bytes2blocks(pad(str2bytes(plaintext)));
_local4 = 0;
_local5 = _local3.length;
_local6 = new Array();
_local6[0] = 1633837924;
_local6[1] = 1650680933;
_local7 = new Array();
_local8 = new Array();
_local9 = 0;
while (1) {
if (_local4 >= _local5){
break;
};
_local7[0] = _local3[_local4];
_local4++;
_local7[1] = _local3[_local4];
_local4++;
_local6 = tea_code(xor_blocks(_local7, _local6), _local2);
_local8[_local9] = _local6[0];
_local9++;
_local8[_local9] = _local6[1];
_local9++;
};
encrypted = binary2ascii(_local8);
return (encrypted);
}
private function str2bytes(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
_local2 = 0;
_local3 = _arg1.length;
_local4 = new Array();
while (1) {
if (_local2 >= _local3){
break;
};
if (c2b[_arg1.charAt(_local2)] == null){
_local4[_local2] = 247;
trace(((((("is_ = " + _local2) + "\nchar = ") + _arg1.charAt(_local2)) + "\nls = ") + _local3));
} else {
_local4[_local2] = c2b[_arg1.charAt(_local2)];
};
_local2++;
};
return (_local4);
}
private function pad(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
_local2 = new Array();
_local3 = 0;
_local4 = 0;
_local5 = _arg1.length;
_local6 = (7 - (_local5 % 8));
_local2[_local3] = ((248 & rand_byte()) | (7 & _local6));
_local3++;
while (_local4 < _local5) {
_local2[_local3] = _arg1[_local4];
_local3++;
_local4++;
};
_local7 = _local6;
while (_local7 > 0) {
_local2[_local3] = rand_byte();
_local3++;
_local7--;
};
return (_local2);
}
private function str2binary(_arg1){
return (bytes2blocks(str2bytes(_arg1)));
}
private function bytes2blocks(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local2 = new Array();
_local3 = 0;
_local4 = 0;
_local5 = _arg1.length;
while (1) {
_local2[_local3] = ((0xFF & _arg1[_local4]) << 24);
++_local4;
if (_local4 >= _local5){
break;
};
_local2[_local3] = (_local2[_local3] | ((0xFF & _arg1[_local4]) << 16));
++_local4;
if (_local4 >= _local5){
break;
};
_local2[_local3] = (_local2[_local3] | ((0xFF & _arg1[_local4]) << 8));
++_local4;
if (_local4 >= _local5){
break;
};
_local2[_local3] = (_local2[_local3] | (0xFF & _arg1[_local4]));
++_local4;
if (_local4 >= _local5){
break;
};
_local3++;
};
return (_local2);
}
private function bytes2str(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
_local2 = 0;
_local3 = _arg1.length;
_local4 = "";
while (1) {
if (_local2 >= _local3){
break;
};
_local4 = (_local4 + b2c[(0xFF & _arg1[_local2])]);
_local2++;
};
return (_local4);
}
private function rand_byte(){
var _local1:*;
return (Math.floor((0x0100 * Math.random())));
}
private function tea_code(_arg1, _arg2){
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
_local3 = _arg1[0];
_local4 = _arg1[1];
_local5 = _arg2[0];
_local6 = _arg2[1];
_local7 = _arg2[2];
_local8 = _arg2[3];
_local9 = 0;
_local10 = 32;
while (_local10-- > 0) {
_local9 = (_local9 - 1640531527);
_local9 = (_local9 | 0);
_local3 = (_local3 + ((((_local4 << 4) + _local5) ^ (_local4 + _local9)) ^ ((_local4 >>> 5) + _local6)));
_local3 = (_local3 | 0);
_local4 = (_local4 + ((((_local3 << 4) + _local7) ^ (_local3 + _local9)) ^ ((_local3 >>> 5) + _local8)));
_local4 = (_local4 | 0);
};
_local11 = new Array();
_local11[0] = _local3;
_local11[1] = _local4;
return (_local11);
}
private function tea_decode(_arg1, _arg2){
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
_local3 = _arg1[0];
_local4 = _arg1[1];
_local5 = _arg2[0];
_local6 = _arg2[1];
_local7 = _arg2[2];
_local8 = _arg2[3];
_local9 = 0;
_local10 = 32;
_local9 = -957401312;
while (_local10-- > 0) {
_local4 = (_local4 - ((((_local3 << 4) + _local7) ^ (_local3 + _local9)) ^ ((_local3 >>> 5) + _local8)));
_local4 = (_local4 | 0);
_local3 = (_local3 - ((((_local4 << 4) + _local5) ^ (_local4 + _local9)) ^ ((_local4 >>> 5) + _local6)));
_local3 = (_local3 | 0);
_local9 = (_local9 + 1640531527);
_local9 = (_local9 | 0);
};
_local11 = new Array();
_local11[0] = _local3;
_local11[1] = _local4;
return (_local11);
}
private function blocks2bytes(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local2 = new Array();
_local3 = 0;
_local4 = 0;
_local5 = _arg1.length;
while (1) {
if (_local4 >= _local5){
break;
};
_local2[_local3] = (0xFF & (_arg1[_local4] >>> 24));
_local3++;
_local2[_local3] = (0xFF & (_arg1[_local4] >>> 16));
_local3++;
_local2[_local3] = (0xFF & (_arg1[_local4] >>> 8));
_local3++;
_local2[_local3] = (0xFF & _arg1[_local4]);
_local3++;
_local4++;
};
return (_local2);
}
}
}//package com.VectorFlash.crypto
Section 2
//Authenticate (com.VectorFlash.net.Authenticate)
package com.VectorFlash.net {
import flash.utils.*;
import com.VectorFlash.*;
import com.VectorFlash.crypto.*;
public class Authenticate {
private var username:String;// = null
private var passwordHash:String;// = null
private var authStatus:String;// = null
public function Authenticate(_arg1:Object, _arg2:String, _arg3:String){
var _local4:*;
username = null;
passwordHash = null;
authStatus = null;
super();
_local4 = new CGI(Global.urls.login.live);
if (((!((_arg2 == null))) && (!((_arg3 == null))))){
username = _arg2;
passwordHash = encryptPassword(_arg3);
_local4.sendValues.username = username;
_local4.sendValues.loginParams = passwordHash;
} else {
username = new FlashCookie("com.VectorFlash.login").getCookie("username");
passwordHash = new FlashCookie("com.VectorFlash.login").getCookie("passwordHash");
_local4.sendValues.username = username;
_local4.sendValues.loginParams = passwordHash;
};
_local4.onReply(_arg1);
_local4.send();
}
private function encryptPassword(_arg1:String):String{
var _local2:*;
_local2 = (Math.random() * 100000000);
_local2 = _local2.toString().substring(1, 6);
return (new Tea(_arg1, _arg1).getEncrypted());
}
public function getStatus():String{
return (authStatus);
}
}
}//package com.VectorFlash.net
Section 3
//CGI (com.VectorFlash.net.CGI)
package com.VectorFlash.net {
import flash.events.*;
import flash.net.*;
public class CGI {
private var onReplyFunction:Object;// = null
public var recvValues:Object;
public var sendValues:URLVariables;
private var request:URLRequest;
private var method:String;// = "GET"
private var url:String;
public function CGI(... _args){
var _local2:*;
method = "GET";
sendValues = new URLVariables();
onReplyFunction = null;
super();
if (_args[0]){
url = _args[0];
};
if (_args[1]){
setMethod(_args[1]);
};
if (_args[2]){
onReply(_args[2]);
};
_local2 = 3;
while (_local2 < _args.length) {
var _temp1 = _args[_local2];
_local2 = (_local2 + 1);
sendValues[_temp1] = _args[_local2];
_local2++;
};
}
public function send():void{
var _local1:URLLoader;
request = new URLRequest(url);
_local1 = new URLLoader();
_local1.dataFormat = URLLoaderDataFormat.VARIABLES;
request.data = sendValues;
request.method = ((method)=="POST") ? URLRequestMethod.POST : URLRequestMethod.GET;
_local1.addEventListener(Event.COMPLETE, handleComplete);
_local1.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
_local1.load(request);
}
public function onReply(_arg1:Object){
onReplyFunction = _arg1;
}
public function setUrl(_arg1:String){
url = _arg1;
}
public function setMethod(_arg1:String){
switch (_arg1){
case "POST":
case "Post":
case "post":
method = "POST";
break;
default:
method = "GET";
break;
};
}
private function handleComplete(_arg1:Event):void{
var _local2:URLLoader;
_local2 = URLLoader(_arg1.target);
recvValues = _local2.data;
if (onReplyFunction){
onReplyFunction(recvValues);
};
}
private function onIOError(_arg1:IOErrorEvent):void{
trace("Error loading URL.");
}
}
}//package com.VectorFlash.net
Section 4
//FlashCookie (com.VectorFlash.net.FlashCookie)
package com.VectorFlash.net {
import flash.net.*;
public class FlashCookie {
private var synchUrl:String;// = "http://vectorflash.com/browserCookieSynch.cgi"
private var so:SharedObject;
public function FlashCookie(... _args){
synchUrl = "http://vectorflash.com/browserCookieSynch.cgi";
super();
if (_args[0]){
useNameSpace(_args[0]);
};
if (_args[1] != null){
setCookie(_args[1], _args[2]);
};
}
public function setCookie(_arg1:String, _arg2:String):void{
so.data[_arg1] = _arg2;
so.flush();
}
public function deleteCookie(_arg1:String):void{
delete so.data[_arg1];
}
public function deleteNameSpace(_arg1:String):void{
var _local2:*;
for (_local2 in so.data) {
deleteCookie(_local2);
so.flush();
};
}
public function useNameSpace(_arg1:String):void{
so = SharedObject.getLocal(_arg1);
}
public function getCookie(_arg1:String):String{
return (so.data[_arg1]);
}
}
}//package com.VectorFlash.net
Section 5
//Button (com.VectorFlash.userInterface.core.Button)
package com.VectorFlash.userInterface.core {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.geom.*;
public class Button extends MovieClip {
private var borderWidth:int;// = 2
private var backgroundHeight:int;// = 20
private var backgroundEllipseHeight:int;// = 7
private var onClickHandler:Object;// = null
private var backgroundWidth:int;// = 50
private var buttonTextColor:uint;// = 0
private var backgroundHighlight:uint;// = 11259375
private var buttonTextFormat:TextFormat;// = null
private var buttonText:String;// = "Button"
private var backgroundLowlight:uint;// = 7903932
private var borderColor:uint;// = 0x777777
private var borderAlpha:int;// = 1
private var backgroundSprite:Sprite;
private var buttonTextPadding:int;// = 5
private var buttonTextField:TextField;
private var backgroundEllipseWidth:int;// = 7
public function Button(){
borderWidth = 2;
borderColor = 0x777777;
borderAlpha = 1;
backgroundWidth = 50;
backgroundHeight = 20;
backgroundEllipseWidth = 7;
backgroundEllipseHeight = 7;
backgroundHighlight = 11259375;
backgroundLowlight = 7903932;
buttonText = "Button";
buttonTextField = new TextField();
buttonTextPadding = 5;
buttonTextColor = 0;
buttonTextFormat = null;
onClickHandler = null;
super();
backgroundSprite = new Sprite();
addChild(backgroundSprite);
buttonTextField.text = buttonText;
addChild(buttonTextField);
buttonTextField.width = backgroundWidth;
buttonTextField.height = backgroundHeight;
buttonTextFormat = new TextFormat();
buttonTextFormat.font = "Verdana";
buttonTextFormat.align = "center";
buttonTextFormat.color = buttonTextColor;
buttonTextFormat.size = 11;
buttonTextFormat.bold = true;
resetMouseEvents();
setState("mouseOut");
}
private function setState_mouseDown(_arg1:MouseEvent):void{
backgroundHighlight = 16567145;
backgroundLowlight = 13211702;
redrawButton();
}
public function redrawButton():void{
redrawText();
redrawBackground();
}
private function setState_mouseOver(_arg1:MouseEvent):void{
removeEventListener(MouseEvent.MOUSE_OVER, setState_mouseOver);
borderColor = 0xCCCCCC;
backgroundHighlight = 14544639;
backgroundLowlight = 7903932;
redrawButton();
}
private function handleMouseClick(_arg1:MouseEvent):void{
removeEventListeners();
setState_mouseDown(null);
if (onClickHandler){
onClickHandler();
};
}
private function setState_mouseUp(_arg1:MouseEvent):void{
setState_mouseOver(null);
}
public function setTextSize(_arg1:int):void{
buttonTextFormat.size = _arg1;
redrawButton();
}
public function setTextPadding(_arg1:int):void{
buttonTextPadding = _arg1;
redrawButton();
}
private function resetMouseEvents():void{
removeEventListeners();
addEventListeners();
}
public function setState(_arg1:String):void{
switch (_arg1){
case "mouseOut":
setState_mouseOut(null);
break;
case "mouseOver":
setState_mouseOver(null);
break;
case "mouseDown":
setState_mouseDown(null);
break;
case "mouseUp":
setState_mouseUp(null);
break;
};
}
private function redrawBackground():void{
var _local1:int;
var _local2:Array;
var _local3:Array;
var _local4:Array;
var _local5:String;
var _local6:String;
var _local7:String;
var _local8:Number;
var _local9:Matrix;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local1 = getChildIndex(backgroundSprite);
removeChild(backgroundSprite);
backgroundSprite = new Sprite();
_local2 = new Array(backgroundHighlight, backgroundLowlight);
_local3 = new Array(1, 1);
_local4 = new Array(100, 0xFF);
_local5 = GradientType.LINEAR;
_local6 = SpreadMethod.PAD;
_local7 = InterpolationMethod.LINEAR_RGB;
_local8 = 0;
_local9 = new Matrix();
_local10 = backgroundWidth;
_local11 = backgroundHeight;
_local12 = (Math.PI / 2);
_local13 = 25;
_local14 = 0;
_local9.createGradientBox(_local10, _local11, _local12, _local13, _local14);
backgroundSprite.graphics.lineStyle(borderWidth, borderColor, borderAlpha);
backgroundSprite.graphics.beginGradientFill(_local5, _local2, _local3, _local4, _local9, _local6, _local7, _local8);
backgroundSprite.graphics.drawRoundRect(2, 2, backgroundWidth, backgroundHeight, backgroundEllipseWidth, backgroundEllipseHeight);
addChild(backgroundSprite);
setChildIndex(backgroundSprite, _local1);
}
private function setState_mouseOut(_arg1:MouseEvent):void{
addEventListener(MouseEvent.MOUSE_OVER, setState_mouseOver);
borderColor = 0x777777;
backgroundHighlight = 11259375;
backgroundLowlight = 7903932;
buttonTextColor = 0;
redrawButton();
}
public function setText(_arg1:String):void{
buttonText = _arg1;
redrawButton();
}
public function removeEventListeners():void{
removeEventListener(MouseEvent.MOUSE_OUT, setState_mouseOut);
removeEventListener(MouseEvent.MOUSE_OVER, setState_mouseOver);
removeEventListener(MouseEvent.CLICK, handleMouseClick);
}
public function addEventListeners():void{
addEventListener(MouseEvent.MOUSE_OUT, setState_mouseOut);
addEventListener(MouseEvent.MOUSE_OVER, setState_mouseOver);
addEventListener(MouseEvent.CLICK, handleMouseClick);
}
public function redrawText():void{
buttonTextField.defaultTextFormat = buttonTextFormat;
buttonTextField.text = buttonText;
buttonTextField.selectable = false;
buttonTextField.autoSize = "center";
buttonTextField.x = buttonTextPadding;
buttonTextField.y = buttonTextPadding;
backgroundWidth = (buttonTextField.width + buttonTextPadding);
backgroundHeight = (buttonTextField.height + buttonTextPadding);
}
public function onClick(_arg1:Object):Boolean{
if (typeof(_arg1) != "function"){
return (false);
};
onClickHandler = _arg1;
return (true);
}
}
}//package com.VectorFlash.userInterface.core
Section 6
//DisplayPanel (com.VectorFlash.userInterface.core.DisplayPanel)
package com.VectorFlash.userInterface.core {
import flash.display.*;
import flash.filters.*;
import flash.geom.*;
public class DisplayPanel extends Sprite {
protected var backgroundHeight:int;// = 90
private var backgroundEllipseHeight:int;// = 7
protected var backgroundWidth:int;// = 180
private var fillType:String;// = "solid"
private var borderColor:uint;// = 0xFFFFFF
private var borderAlpha:Number;// = 1
private var backgroundSprite:Sprite;
private var backgroundAlpha:int;// = 1
private var backgroundColor:uint;// = 16702650
private var backgroundEllipseWidth:int;// = 7
private var borderWidth:int;// = 2
public function DisplayPanel(){
backgroundColor = 16702650;
backgroundWidth = 180;
backgroundHeight = 90;
backgroundEllipseWidth = 7;
backgroundEllipseHeight = 7;
backgroundAlpha = 1;
fillType = "solid";
borderWidth = 2;
borderColor = 0xFFFFFF;
borderAlpha = 1;
super();
backgroundSprite = new Sprite();
addChild(backgroundSprite);
setColor("grey");
}
public function setBackgroundAlpha(_arg1:Number):void{
backgroundAlpha = _arg1;
borderAlpha = _arg1;
redraw();
}
public function setBackgroundColor(_arg1:uint):void{
backgroundColor = _arg1;
redraw();
}
public function emboss(_arg1:String):void{
var _local2:Array;
var _local3:ConvolutionFilter;
if (_arg1 == "down"){
_local2 = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
} else {
_local2 = [2, 1, 0, 1, 1, -1, 0, -1, -2];
};
_local3 = new ConvolutionFilter();
_local3.matrixX = 3;
_local3.matrixY = 3;
_local3.matrix = _local2;
_local3.divisor = 1;
backgroundSprite.filters = [_local3];
}
public function setHeight(_arg1:int):void{
backgroundHeight = _arg1;
redraw();
}
public function setBorderWidth(_arg1:int):void{
borderWidth = _arg1;
redraw();
}
public function setColor(_arg1:String):void{
switch (_arg1){
case "red":
backgroundColor = 16768477;
break;
case "green":
backgroundColor = 14548957;
break;
case "blue":
backgroundColor = 14540287;
break;
case "black":
backgroundColor = 0;
break;
case "grey":
default:
backgroundColor = 0xDDDDDD;
break;
};
redraw();
}
public function blur():void{
var _local1:Array;
var _local2:ConvolutionFilter;
_local1 = [0, 1, 0, 1, 1, 1, 0, 1, 0];
_local2 = new ConvolutionFilter();
_local2.matrixX = 3;
_local2.matrixY = 3;
_local2.matrix = _local1;
_local2.divisor = 1;
backgroundSprite.filters = [_local2];
}
public function setWidth(_arg1:int):void{
backgroundWidth = _arg1;
redraw();
}
public function drawGradient():void{
var _local1:int;
var _local2:Array;
var _local3:Array;
var _local4:Array;
var _local5:String;
var _local6:String;
var _local7:String;
var _local8:Number;
var _local9:Matrix;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local1 = getChildIndex(backgroundSprite);
removeChild(backgroundSprite);
backgroundSprite = new Sprite();
_local2 = new Array();
switch (backgroundColor){
case 16768477:
_local2.push(0x660000, 7803153, 10040115, 10040115, 0x660000, 10040115, 7803153, 7803153, 0x660000);
break;
case 14548957:
_local2.push(0x6600, 1144593, 3381555, 3381555, 0x6600, 3381555, 1144593, 1144593, 0x6600);
break;
case 14540287:
_local2.push(102, 1118583, 3355545, 3355545, 102, 3355545, 1118583, 1118583, 102);
break;
case 0:
_local2.push(0, 0x111111, 0x333333, 0x333333, 0, 0x333333, 0x111111, 0x111111, 0);
break;
case 0xDDDDDD:
default:
_local2.push(0, 0x111111, 0x333333, 0x333333, 0, 0x333333, 0x111111, 0x111111, 0);
break;
};
_local3 = new Array();
_local3.push(backgroundAlpha, backgroundAlpha, backgroundAlpha, backgroundAlpha, backgroundAlpha, backgroundAlpha, backgroundAlpha, backgroundAlpha, backgroundAlpha);
_local4 = new Array();
_local4.push(0, 70, 90, 100, 180, 200, 230, 235, 0xFF);
_local5 = GradientType.LINEAR;
_local6 = SpreadMethod.PAD;
_local7 = InterpolationMethod.LINEAR_RGB;
_local8 = 0;
_local9 = new Matrix();
_local10 = 50;
_local11 = 100;
_local12 = (Math.PI / 3);
_local13 = 25;
_local14 = 0;
_local9.createGradientBox(_local10, _local11, _local12, _local13, _local14);
backgroundSprite.graphics.lineStyle(borderWidth, borderColor, borderAlpha);
backgroundSprite.graphics.beginGradientFill(_local5, _local2, _local3, _local4, _local9, _local6, _local7, _local8);
backgroundSprite.graphics.drawRoundRect(2, 2, backgroundWidth, backgroundHeight, backgroundEllipseWidth, backgroundEllipseHeight);
addChild(backgroundSprite);
setChildIndex(backgroundSprite, _local1);
}
public function drawSolid():void{
var _local1:int;
_local1 = getChildIndex(backgroundSprite);
removeChild(backgroundSprite);
backgroundSprite = new Sprite();
backgroundSprite.graphics.lineStyle(borderWidth, borderColor, borderAlpha);
backgroundSprite.graphics.beginFill(backgroundColor);
backgroundSprite.graphics.drawRoundRect(2, 2, backgroundWidth, backgroundHeight, backgroundEllipseWidth, backgroundEllipseHeight);
backgroundSprite.alpha = backgroundAlpha;
addChild(backgroundSprite);
setChildIndex(backgroundSprite, _local1);
}
public function setFillType(_arg1:String):void{
switch (_arg1){
case "gradient":
fillType = "gradient";
break;
case "solid":
default:
fillType = "solid";
break;
};
redraw();
}
public function setBorderColor(_arg1:uint):void{
borderColor = _arg1;
redraw();
}
public function redraw():void{
switch (fillType){
case "gradient":
drawGradient();
break;
case "solid":
default:
drawSolid();
break;
};
}
}
}//package com.VectorFlash.userInterface.core
Section 7
//SubmitScore (com.VectorFlash.userInterface.net.SubmitScore)
package com.VectorFlash.userInterface.net {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.net.*;
import com.VectorFlash.*;
import com.VectorFlash.crypto.*;
import com.VectorFlash.net.*;
import com.VectorFlash.userInterface.core.*;
public class SubmitScore extends DisplayPanel {
private var authAttempt:int;// = 0
private var dataFields:Array;// = null
private var currentPanel:Sprite;
private var credentials:TextField;
private var passwordLabel:TextField;
private var gameUrl:String;// = "http://vectorflash.com/"
private var changeUserLink:TextField;
private var submit:Button;
private var title:TextField;
private var score:Number;// = 0
private var groupInput:TextInput;
private var gameName:String;// = ""
private var playAgain:Button;
private var gameId:int;// = 0
private var groupLabel:TextField;
private var usernameLabel:TextField;
private var usernameInput:TextInput;
private var coverSheet:DisplayPanel;
private var passwordInput:TextInput;
public function SubmitScore(_arg1:Number, _arg2:String, ... _args){
var _local4:*;
score = 0;
gameName = "";
gameId = 0;
gameUrl = "http://vectorflash.com/";
dataFields = null;
authAttempt = 0;
currentPanel = new Sprite();
super();
addChild(currentPanel);
score = _arg1;
gameName = _arg2;
trace(("Game Name: " + _arg2));
gameId = Global.games[_arg2].id;
gameUrl = Global.games[_arg2].url;
if (_args.length){
dataFields = new Array();
_local4 = 0;
while (_local4 < _args.length) {
dataFields.push(_args[_local4]);
_local4++;
};
};
showSubmitForm();
}
private function handleServerResponse(_arg1:Object):void{
var _local2:URLRequest;
trace(_arg1.submitStatus);
_local2 = new URLRequest(gameUrl);
navigateToURL(_local2, "_self");
}
private function addPasswordField(){
var _local1:TextFormat;
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 0xFFFFFF;
_local1.size = 12;
_local1.bold = false;
passwordLabel = new TextField();
passwordLabel.defaultTextFormat = _local1;
passwordLabel.text = "Password";
passwordLabel.selectable = false;
passwordLabel.x = 10;
passwordLabel.y = 225;
addChild(passwordLabel);
passwordInput = new TextInput();
passwordInput.move(90, 225);
passwordInput.displayAsPassword = true;
addChild(passwordInput);
}
private function clearCurrentPanel(){
removeChild(currentPanel);
currentPanel = null;
currentPanel = new Sprite();
addChild(currentPanel);
}
private function sendDataToServer():void{
var _local1:String;
var _local2:String;
var _local3:*;
var _local4:String;
var _local5:*;
var _local6:*;
clearCoverSheet();
applyCoverSheet("Submitting score ...");
if (groupInput.text){
_local1 = groupInput.text;
} else {
_local1 = "noScoreGroupData";
};
_local2 = usernameInput.text;
_local3 = "nopassword";
_local4 = ((((((((("game=" + gameId) + "&score=") + score) + "&password=") + _local3) + "&scoreGroup=") + _local1) + "&extraData=") + dataFields[0]);
trace(Global.urls.scoreboard);
trace(Global.urls.scoreboard.live);
trace(Global.urls.scoreboard.dev);
_local5 = new CGI(Global.urls.scoreboard.live);
_local6 = new Tea(_local4, _local3).getEncrypted();
trace(_local6);
_local5.sendValues.action = "submit";
_local5.sendValues.username = _local2;
_local5.sendValues.scoreData = _local6;
_local5.onReply(handleServerResponse);
_local5.send();
}
private function authStatus_ERROR(_arg1:Object){
}
private function clearCoverSheet():void{
if (coverSheet){
removeChild(coverSheet);
};
coverSheet = null;
}
private function addGroupField(){
var _local1:TextFormat;
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 0xFFFFFF;
_local1.size = 12;
_local1.bold = false;
groupLabel = new TextField();
groupLabel.defaultTextFormat = _local1;
groupLabel.text = "Group";
groupLabel.selectable = false;
groupLabel.x = 10;
groupLabel.y = 140;
addChild(groupLabel);
groupInput = new TextInput();
groupInput.move(90, 140);
addChild(groupInput);
}
private function addExtraData(){
var _local1:TextFormat;
var _local2:*;
var _local3:TextFormat;
var _local4:*;
if (!dataFields[0]){
return;
};
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 0xFFFFFF;
_local1.size = 12;
_local1.bold = true;
_local2 = new TextField();
_local2.defaultTextFormat = _local1;
_local2.text = "Difficulty:";
_local2.selectable = true;
_local2.x = 10;
_local2.y = 80;
_local2.width = 300;
currentPanel.addChild(_local2);
_local3 = new TextFormat();
_local3.font = "Verdana";
_local3.color = 6724095;
_local3.size = 14;
_local3.bold = true;
_local4 = new TextField();
_local4.defaultTextFormat = _local3;
_local4.text = dataFields[0];
_local4.selectable = true;
_local4.x = 90;
_local4.y = 78;
_local4.width = 300;
currentPanel.addChild(_local4);
}
private function add_score():void{
var _local1:TextFormat;
var _local2:TextField;
var _local3:TextFormat;
var _local4:TextField;
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 0xFFFFFF;
_local1.size = 12;
_local1.bold = false;
_local2 = new TextField();
_local2.defaultTextFormat = _local1;
_local2.text = "Final Score: ";
_local2.selectable = false;
_local2.x = 10;
_local2.y = 10;
currentPanel.addChild(_local2);
_local3 = new TextFormat();
_local3.font = "Verdana";
_local3.color = 11206502;
_local3.size = 12;
_local3.bold = true;
_local4 = new TextField();
_local4.defaultTextFormat = _local3;
_local4.text = score.toString();
_local4.selectable = false;
_local4.x = 90;
_local4.y = 10;
currentPanel.addChild(_local4);
}
private function addPasswordInstructions(){
var _local1:TextFormat;
var _local2:*;
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 16567145;
_local1.size = 12;
_local1.bold = false;
_local2 = new TextField();
_local2.defaultTextFormat = _local1;
_local2.text = "If you are submitting your score as a\n";
_local2.text = (_local2.text + "registered user, enter your password\n");
_local2.text = (_local2.text + "here; if not, just leave it blank!\n");
_local2.selectable = true;
_local2.x = 10;
_local2.y = 170;
_local2.width = 300;
currentPanel.addChild(_local2);
}
private function addGameName(){
var _local1:TextFormat;
var _local2:*;
var _local3:TextFormat;
var _local4:*;
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 0xFFFFFF;
_local1.size = 12;
_local1.bold = true;
_local2 = new TextField();
_local2.defaultTextFormat = _local1;
_local2.text = "Game:";
_local2.selectable = true;
_local2.x = 10;
_local2.y = 40;
_local2.width = 300;
currentPanel.addChild(_local2);
_local3 = new TextFormat();
_local3.font = "Verdana";
_local3.color = 0xFF0000;
_local3.size = 14;
_local3.bold = true;
_local4 = new TextField();
_local4.defaultTextFormat = _local3;
_local4.text = gameName;
_local4.selectable = true;
_local4.x = 90;
_local4.y = 38;
_local4.width = 300;
currentPanel.addChild(_local4);
}
private function authStatus_FAIL(_arg1:Object){
title.text = "Bad Login";
usernameInput.opaqueBackground = 0xFF0000;
usernameInput.alpha = 0.65;
removeChild(submit);
submit = null;
addSubmitButton();
clearCoverSheet();
usernameInput.text = "";
}
private function authStatus_PASS(_arg1:Object){
sendDataToServer();
}
private function applyCoverSheet(_arg1:String){
var _local2:TextFormat;
var _local3:*;
clearCoverSheet();
coverSheet = new DisplayPanel();
coverSheet.setHeight(300);
coverSheet.setWidth(300);
coverSheet.setFillType("gradient");
coverSheet.setColor("grey");
coverSheet.setBackgroundAlpha(1);
coverSheet.alpha = 0.7;
_local2 = new TextFormat();
_local2.font = "Verdana";
_local2.color = 0xFFFFFF;
_local2.size = 14;
_local2.bold = true;
_local3 = new TextField();
_local3.defaultTextFormat = _local2;
_local3.text = _arg1;
_local3.width = 300;
_local3.selectable = false;
_local3.x = 50;
_local3.y = 50;
coverSheet.addChild(_local3);
addChild(coverSheet);
}
private function addSubmitButton(){
submit = new Button();
submit.x = 170;
submit.y = 270;
submit.setText("Submit My Score!");
submit.addEventListener(MouseEvent.CLICK, authenticateCredentials);
addChild(submit);
}
private function addScoreData(){
var _local1:TextFormat;
var _local2:*;
var _local3:TextFormat;
var _local4:*;
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 0xFFFFFF;
_local1.size = 12;
_local1.bold = true;
_local2 = new TextField();
_local2.defaultTextFormat = _local1;
_local2.text = "Score:";
_local2.selectable = true;
_local2.x = 10;
_local2.y = 60;
_local2.width = 300;
currentPanel.addChild(_local2);
_local3 = new TextFormat();
_local3.font = "Verdana";
_local3.color = 0xFF00;
_local3.size = 14;
_local3.bold = true;
_local4 = new TextField();
_local4.defaultTextFormat = _local3;
_local4.text = score.toString();
_local4.selectable = true;
_local4.x = 90;
_local4.y = 58;
_local4.width = 300;
currentPanel.addChild(_local4);
}
private function addUsernameField(){
var _local1:TextFormat;
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 0xFFFFFF;
_local1.size = 12;
_local1.bold = false;
usernameLabel = new TextField();
usernameLabel.defaultTextFormat = _local1;
usernameLabel.text = "Username";
usernameLabel.selectable = false;
usernameLabel.x = 10;
usernameLabel.y = 110;
addChild(usernameLabel);
usernameInput = new TextInput();
usernameInput.move(90, 110);
addChild(usernameInput);
}
private function handleAuthentication(_arg1:Object):void{
if (((!(_arg1)) || (!(_arg1.authStatus)))){
authStatus_ERROR(_arg1);
} else {
if (_arg1.authStatus == "fail"){
authStatus_FAIL(_arg1);
} else {
if (_arg1.authStatus == "pass"){
authStatus_PASS(_arg1);
} else {
authStatus_ERROR(_arg1);
};
};
};
}
private function showSubmitForm():void{
clearCurrentPanel();
setHeight(300);
setWidth(300);
setFillType("gradient");
setColor("black");
addSubmitFormTitle();
addGameName();
addScoreData();
addExtraData();
addUsernameField();
addGroupField();
addSubmitButton();
addPlayAgainButton();
}
private function addSubmitFormTitle(){
var _local1:TextFormat;
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 16567145;
_local1.size = 18;
_local1.bold = true;
title = new TextField();
title.defaultTextFormat = _local1;
title.text = "Submit Your Score!";
title.selectable = true;
title.x = 10;
title.y = 10;
title.width = 300;
currentPanel.addChild(title);
}
private function authenticateCredentials(_arg1:MouseEvent):void{
if (!usernameInput.text){
title.text = "Invalid Username";
usernameInput.opaqueBackground = 0xFF0000;
usernameInput.alpha = 0.65;
removeChild(submit);
submit = null;
addSubmitButton();
return;
};
sendDataToServer();
}
private function add_saveOrPlay():void{
var _local1:TextFormat;
var _local2:Button;
var _local3:Button;
clearCurrentPanel();
setHeight(92);
setWidth(250);
setFillType("gradient");
setColor("black");
add_score();
_local1 = new TextFormat();
_local1.font = "Verdana";
_local1.color = 0xDDDDDD;
_local1.size = 10;
_local1.bold = true;
credentials = new TextField();
credentials.defaultTextFormat = _local1;
credentials.text = "";
credentials.selectable = true;
credentials.x = 10;
credentials.y = 97;
credentials.width = 1000;
currentPanel.addChild(credentials);
_local2 = new Button();
_local2.setText("Play Again");
_local2.x = 10;
_local2.y = 60;
currentPanel.addChild(_local2);
_local3 = new Button();
_local3.setText("Submit Score?");
_local3.x = 137;
_local3.y = 60;
_local3.onClick(showSubmitForm);
currentPanel.addChild(_local3);
}
private function addPlayAgainButton(){
playAgain = new Button();
playAgain.x = 10;
playAgain.y = 270;
playAgain.setText("Play Again");
addChild(playAgain);
}
}
}//package com.VectorFlash.userInterface.net
Section 8
//Global (com.VectorFlash.Global)
package com.VectorFlash {
public class Global {
public static var games:Object = [];
public static var urls:Object = [];
public static var vars:Object = [];
urls.login = new Object();
urls.login.live = "http://vectorflash.com/login.cgi";
urls.login.dev = "http://vectorflash.com/dev/login.cgi";
urls.scoreboard = new Object();
urls.scoreboard.live = "http://vectorflash.com/scoreboard.cgi";
urls.scoreboard.dev = "http://vectorflash.com/dev/scoreboard.cgi";
games["Keep the Keep: alpha"] = new Object();
games["Keep the Keep: alpha"].id = 1;
games["Keep the Keep: alpha"].url = "http://vectorflash.com/keepthekeep";
games["Keep the Keep: beta"] = new Object();
games["Keep the Keep: beta"].id = 2;
games["Keep the Keep: beta"].url = "http://vectorflash.com/keepthekeep/beta";
}
}//package com.VectorFlash
Section 9
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import fl.events.*;
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 10
//Button (fl.controls.Button)
package fl.controls {
import flash.display.*;
import fl.core.*;
import fl.managers.*;
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 11
//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 12
//Label (fl.controls.Label)
package fl.controls {
import fl.core.*;
import flash.text.*;
import fl.events.*;
public class Label extends UIComponent {
protected var actualHeight:Number;
protected var _html:Boolean;// = false
protected var actualWidth:Number;
protected var defaultLabel:String;// = "Label"
protected var _savedHTML:String;
public var textField:TextField;
private static var defaultStyles:Object = {textFormat:null, embedFonts:false};
public function Label(){
defaultLabel = "Label";
_html = false;
super();
text = defaultLabel;
actualWidth = _width;
actualHeight = _height;
}
public function get autoSize():String{
return (textField.autoSize);
}
public function get selectable():Boolean{
return (textField.selectable);
}
public function set text(_arg1:String):void{
if (_arg1 == text){
return;
};
if (((componentInspectorSetting) && ((_arg1 == defaultLabel)))){
return;
};
_html = false;
textField.text = _arg1;
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE);
};
}
public function get wordWrap():Boolean{
return (textField.wordWrap);
}
public function set condenseWhite(_arg1:Boolean):void{
textField.condenseWhite = _arg1;
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE);
};
}
public function set selectable(_arg1:Boolean):void{
textField.selectable = _arg1;
}
public function set autoSize(_arg1:String):void{
textField.autoSize = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set wordWrap(_arg1:Boolean):void{
textField.wordWrap = _arg1;
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE);
};
}
override public function get height():Number{
if (((!((textField.autoSize == TextFieldAutoSize.NONE))) && (wordWrap))){
return (_height);
};
return (actualHeight);
}
public function set htmlText(_arg1:String):void{
if (_arg1 == htmlText){
return;
};
if (((componentInspectorSetting) && ((_arg1 == "")))){
return;
};
_html = true;
_savedHTML = _arg1;
textField.htmlText = _arg1;
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE);
};
}
public function get text():String{
return (textField.text);
}
public function get condenseWhite():Boolean{
return (textField.condenseWhite);
}
override protected function draw():void{
var _local1:Object;
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawTextFormat();
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE, false);
};
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
addChild(textField);
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
textField.wordWrap = false;
}
public function get htmlText():String{
return (textField.htmlText);
}
override public function setSize(_arg1:Number, _arg2:Number):void{
actualWidth = _arg1;
actualHeight = _arg2;
super.setSize(_arg1, _arg2);
}
override public function set width(_arg1:Number):void{
actualWidth = _arg1;
super.width = _arg1;
}
protected function drawLayout():void{
var _local1:Boolean;
var _local2:Number;
var _local3:Number;
_local1 = false;
textField.width = width;
textField.height = height;
if (textField.autoSize != TextFieldAutoSize.NONE){
_local2 = textField.width;
_local3 = textField.height;
_local1 = ((!((_width == _local2))) || (!((_height == _local3))));
_width = _local2;
_height = _local3;
switch (textField.autoSize){
case TextFieldAutoSize.CENTER:
textField.x = ((actualWidth / 2) - (textField.width / 2));
break;
case TextFieldAutoSize.LEFT:
textField.x = 0;
break;
case TextFieldAutoSize.RIGHT:
textField.x = -((textField.width - actualWidth));
break;
};
} else {
textField.width = actualWidth;
textField.height = actualHeight;
textField.x = 0;
};
if (_local1){
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, true));
};
}
override public function get width():Number{
if (((!((textField.autoSize == TextFieldAutoSize.NONE))) && (!(wordWrap)))){
return (_width);
};
return (actualWidth);
}
protected function drawTextFormat():void{
var _local1:TextFormat;
var _local2:Object;
_local1 = (getStyleValue("textFormat") as TextFormat);
if (_local1 == null){
_local2 = UIComponent.getStyleDefinition();
_local1 = (enabled) ? (_local2.defaultTextFormat as TextFormat) : (_local2.defaultDisabledTextFormat as TextFormat);
};
textField.defaultTextFormat = _local1;
textField.setTextFormat(_local1);
if (((_html) && (!((_savedHTML == null))))){
htmlText = _savedHTML;
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 13
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import fl.events.*;
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 14
//TextInput (fl.controls.TextInput)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import fl.events.*;
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 15
//ComponentShim (fl.core.ComponentShim)
package fl.core {
import flash.display.*;
public dynamic class ComponentShim extends MovieClip {
}
}//package fl.core
Section 16
//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 17
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.display.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import flash.utils.*;
import fl.events.*;
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 18
//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 19
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
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 20
//IFocusManager (fl.managers.IFocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
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 21
//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 22
//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 23
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import fl.core.*;
import flash.text.*;
import flash.utils.*;
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 24
//None (fl.transitions.easing.None)
package fl.transitions.easing {
public class None {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeNone(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
}
}//package fl.transitions.easing
Section 25
//Tween (fl.transitions.Tween)
package fl.transitions {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
public class Tween extends EventDispatcher {
private var _position:Number;// = NAN
public var prevTime:Number;// = NAN
public var prevPos:Number;// = NAN
public var isPlaying:Boolean;// = false
public var begin:Number;// = NAN
private var _fps:Number;// = NAN
private var _time:Number;// = NAN
public var change:Number;// = NAN
private var _finish:Number;// = NAN
public var looping:Boolean;// = false
private var _intervalID:uint;// = 0
public var func:Function;
private var _timer:Timer;// = null
private var _startTime:Number;// = NAN
public var prop:String;// = ""
private var _duration:Number;// = NAN
public var obj:Object;// = null
public var useSeconds:Boolean;// = false
protected static var _mc:MovieClip = new MovieClip();
public function Tween(_arg1:Object, _arg2:String, _arg3:Function, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean=false){
isPlaying = false;
obj = null;
prop = "";
func = function (_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
};
begin = NaN;
change = NaN;
useSeconds = false;
prevTime = NaN;
prevPos = NaN;
looping = false;
_duration = NaN;
_time = NaN;
_fps = NaN;
_position = NaN;
_startTime = NaN;
_intervalID = 0;
_finish = NaN;
_timer = null;
super();
if (!arguments.length){
return;
};
this.obj = _arg1;
this.prop = _arg2;
this.begin = _arg4;
this.position = _arg4;
this.duration = _arg6;
this.useSeconds = _arg7;
if ((_arg3 is Function)){
this.func = _arg3;
};
this.finish = _arg5;
this._timer = new Timer(100);
this.start();
}
public function continueTo(_arg1:Number, _arg2:Number):void{
this.begin = this.position;
this.finish = _arg1;
if (!isNaN(_arg2)){
this.duration = _arg2;
};
this.start();
}
public function stop():void{
this.stopEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_STOP, this._time, this._position));
}
private function fixTime():void{
if (this.useSeconds){
this._startTime = (getTimer() - (this._time * 1000));
};
}
public function set FPS(_arg1:Number):void{
var _local2:Boolean;
_local2 = this.isPlaying;
this.stopEnterFrame();
this._fps = _arg1;
if (_local2){
this.startEnterFrame();
};
}
public function get finish():Number{
return ((this.begin + this.change));
}
public function get duration():Number{
return (this._duration);
}
protected function startEnterFrame():void{
var _local1:Number;
if (isNaN(this._fps)){
_mc.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, false, 0, true);
} else {
_local1 = (1000 / this._fps);
this._timer.delay = _local1;
this._timer.addEventListener(TimerEvent.TIMER, this.timerHandler, false, 0, true);
this._timer.start();
};
this.isPlaying = true;
}
public function set time(_arg1:Number):void{
this.prevTime = this._time;
if (_arg1 > this.duration){
if (this.looping){
this.rewind((_arg1 - this._duration));
this.update();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_LOOP, this._time, this._position));
} else {
if (this.useSeconds){
this._time = this._duration;
this.update();
};
this.stop();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_FINISH, this._time, this._position));
};
} else {
if (_arg1 < 0){
this.rewind();
this.update();
} else {
this._time = _arg1;
this.update();
};
};
}
protected function stopEnterFrame():void{
if (isNaN(this._fps)){
_mc.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
} else {
this._timer.stop();
};
this.isPlaying = false;
}
public function getPosition(_arg1:Number=NaN):Number{
if (isNaN(_arg1)){
_arg1 = this._time;
};
return (this.func(_arg1, this.begin, this.change, this._duration));
}
public function set finish(_arg1:Number):void{
this.change = (_arg1 - this.begin);
}
public function set duration(_arg1:Number):void{
this._duration = ((_arg1)<=0) ? Infinity : _arg1;
}
public function setPosition(_arg1:Number):void{
this.prevPos = this._position;
if (this.prop.length){
this.obj[this.prop] = (this._position = _arg1);
};
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_CHANGE, this._time, this._position));
}
public function resume():void{
this.fixTime();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_RESUME, this._time, this._position));
}
public function fforward():void{
this.time = this._duration;
this.fixTime();
}
protected function onEnterFrame(_arg1:Event):void{
this.nextFrame();
}
public function get position():Number{
return (this.getPosition(this._time));
}
public function yoyo():void{
this.continueTo(this.begin, this.time);
}
public function nextFrame():void{
if (this.useSeconds){
this.time = ((getTimer() - this._startTime) / 1000);
} else {
this.time = (this._time + 1);
};
}
protected function timerHandler(_arg1:TimerEvent):void{
this.nextFrame();
_arg1.updateAfterEvent();
}
public function get FPS():Number{
return (this._fps);
}
public function rewind(_arg1:Number=0):void{
this._time = _arg1;
this.fixTime();
this.update();
}
public function set position(_arg1:Number):void{
this.setPosition(_arg1);
}
public function get time():Number{
return (this._time);
}
private function update():void{
this.setPosition(this.getPosition(this._time));
}
public function start():void{
this.rewind();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_START, this._time, this._position));
}
public function prevFrame():void{
if (!this.useSeconds){
this.time = (this._time - 1);
};
}
}
}//package fl.transitions
Section 26
//TweenEvent (fl.transitions.TweenEvent)
package fl.transitions {
import flash.events.*;
public class TweenEvent extends Event {
public var time:Number;// = NAN
public var position:Number;// = NAN
public static const MOTION_START:String = "motionStart";
public static const MOTION_STOP:String = "motionStop";
public static const MOTION_LOOP:String = "motionLoop";
public static const MOTION_CHANGE:String = "motionChange";
public static const MOTION_FINISH:String = "motionFinish";
public static const MOTION_RESUME:String = "motionResume";
public function TweenEvent(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Boolean=false){
time = NaN;
position = NaN;
super(_arg1, _arg4, _arg5);
this.time = _arg2;
this.position = _arg3;
}
override public function clone():Event{
return (new TweenEvent(this.type, this.time, this.position, this.bubbles, this.cancelable));
}
}
}//package fl.transitions
Section 27
//Bullet (Bullet)
package {
import flash.display.*;
import flash.events.*;
import fl.transitions.*;
import flash.utils.*;
import fl.transitions.easing.*;
dynamic class Bullet extends MovieClip {
var XTween:Tween;
var NoMoreTarget:Boolean;
var offsetX:int;
var offsetY:int;
var startX:int;
var startY:int;
var bulletTimer:Timer;
var Type:int;
var DamageIWillDo:int;
var BulletColor:uint;
var ImThere:Boolean;
var WhatMadeMe:MovieClip;
var YTween:Tween;
var mm:MapManager;
var nextX:Number;
var nextY:Number;
var WhatIWillHit:MovieClip;
var SplashDamage:int;
var endX:int;
var endY:int;
function Bullet(_arg1:MapManager, _arg2:MovieClip, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:MovieClip, _arg8:int, _arg9:int, _arg10:int, _arg11:uint){
var _local12:Number;
super();
this.WhatMadeMe = _arg2;
this.startX = _arg3;
this.startY = _arg4;
this.WhatIWillHit = _arg7;
this.offsetX = _arg5;
this.offsetY = _arg6;
this.endX = (WhatIWillHit.x + _arg5);
this.endY = (WhatIWillHit.y + _arg6);
this.SplashDamage = _arg9;
this.DamageIWillDo = _arg8;
NoMoreTarget = false;
this.mm = _arg1;
this.Type = _arg10;
this.BulletColor = _arg11;
this.x = this.startX;
this.y = this.startY;
if (this.Type == 1){
this.graphics.lineStyle(1, 0);
this.graphics.beginFill(BulletColor, 0.2);
this.graphics.drawCircle(0, 0, 2.5);
};
if (this.Type == 2){
this.graphics.beginFill(BulletColor, 0.1);
this.graphics.drawCircle(0, 0, 10);
this.graphics.beginFill(BulletColor, 0.2);
this.graphics.drawCircle(0, 0, 5);
this.graphics.beginFill(BulletColor, 0.4);
this.graphics.drawCircle(0, 0, 2);
};
if (this.Type == 3){
this.graphics.lineStyle(1, BulletColor);
this.graphics.moveTo(0, -10);
this.graphics.lineTo(0, 0);
this.graphics.lineTo(1, -2);
this.graphics.moveTo(0, 0);
this.graphics.lineTo(-1, -2);
};
this.rotation = (((Math.atan2(((WhatIWillHit.y + _arg6) - this.y), ((WhatIWillHit.x + _arg5) - this.x)) * 180) / Math.PI) - 90);
this.mm.sky.addChild(this);
bulletTimer = new Timer(200, 0);
bulletTimer.addEventListener("timer", bTimer);
bulletTimer.start();
_local12 = (Math.sqrt((Math.pow((endX - _arg3), 2) + Math.pow((endY - _arg4), 2))) / 10);
XTween = new Tween(this, "x", None.easeIn, this.startX, this.endX, _local12, false);
YTween = new Tween(this, "y", None.easeIn, this.startY, this.endY, _local12, false);
XTween.addEventListener("motionFinish", TweenTimer);
YTween.addEventListener("motionFinish", TweenTimer);
}
function bTimer(_arg1:TimerEvent):void{
this.rotation = (((Math.atan2(((WhatIWillHit.y + offsetY) - this.y), ((WhatIWillHit.x + offsetX) - this.x)) * 180) / Math.PI) - 90);
if (WhatIWillHit != null){
if (NoMoreTarget == false){
XTween.finish = (WhatIWillHit.x + offsetX);
YTween.finish = (WhatIWillHit.y + offsetY);
};
};
}
function Stop(){
var _local1:*;
if (((!((this == null))) && (!((this.parent == null))))){
this.mm.sky.removeChild(this);
};
bulletTimer.removeEventListener("timer", bTimer);
this.mm.allBullets.splice(this.mm.allBullets.indexOf(this), 1);
for each (_local1 in this) {
_local1 = null;
};
}
function ReachedTarget(){
var _local1:*;
var _local2:Array;
var _local3:Array;
var _local4:Tile;
var _local5:Enemy;
CheckEnemyNotifyBullets(this.WhatIWillHit);
if (this.WhatIWillHit != null){
this.WhatIWillHit.TakeDamage(DamageIWillDo);
if ((((SplashDamage > 0)) && ((WhatIWillHit is Enemy)))){
_local2 = new Array();
_local3 = new Array();
_local3.push(WhatIWillHit.WhichTileAmIOn());
if (SplashDamage > 1){
_local3.push(WhatIWillHit.WhichTileAmIOn().nTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().sTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().eTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().wTile);
};
if (SplashDamage > 2){
_local3.push(WhatIWillHit.WhichTileAmIOn().sTile.sTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().sTile.eTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().sTile.wTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().nTile.nTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().nTile.eTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().nTile.wTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().eTile.eTile);
_local3.push(WhatIWillHit.WhichTileAmIOn().wTile.wTile);
};
for each (_local4 in _local3) {
for each (_local5 in this.mm.gm.npem.allEnemies) {
if ((((_local4 == _local5.WhichTileAmIOn())) && (!((_local5 == WhatIWillHit))))){
_local2.push(_local5);
};
};
};
for each (_local5 in _local2) {
CheckEnemyNotifyBullets(_local5);
_local5.TakeDamage(DamageIWillDo);
};
};
this.mm.gm.sounds.PlaySound(4);
};
if (((!((this == null))) && (!((this.parent == null))))){
this.mm.sky.removeChild(this);
};
bulletTimer.removeEventListener("timer", bTimer);
bulletTimer = null;
this.mm.allBullets.splice(this.mm.allBullets.indexOf(this), 1);
for each (_local1 in this) {
_local1 = null;
};
}
function CheckEnemyNotifyBullets(_arg1:MovieClip){
var _local2:Bullet;
if (this.DamageIWillDo >= _arg1.hp){
for each (_local2 in this.mm.allBullets) {
if (_local2 != null){
if ((((_arg1 == _local2.WhatIWillHit)) && (!((_local2 == this))))){
_local2.NoMoreTarget = true;
};
};
};
};
}
function TweenTimer(_arg1:TweenEvent):void{
if (ImThere == false){
ImThere = true;
if (NoMoreTarget == false){
ReachedTarget();
} else {
Stop();
};
};
}
function CutOutDuplicates(_arg1:Array):Array{
var _local2:int;
var _local3:int;
_local2 = 0;
while (_local2 < _arg1.length) {
_local3 = (_local2 + 1);
while (_local3 < _arg1.length) {
if (_arg1[_local2] === _arg1[_local3]){
_arg1.splice(_local3, 1);
_local3--;
};
_local3++;
};
_local2++;
};
return (_arg1);
}
}
}//package
Section 28
//ClickThroughImage (ClickThroughImage)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
class ClickThroughImage extends MovieClip {
var gm:GameManager;
function ClickThroughImage(_arg1:GameManager){
this.gm = _arg1;
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
var _local2:Array;
var _local3:Object;
var _local4:Boolean;
var _local5:Object;
var _local6:MouseEvent;
_local2 = this.gm.ktk.getObjectsUnderPoint(new Point(_arg1.stageX, _arg1.stageY));
for each (_local3 in _local2) {
if (((!((_local3 == this))) && ((_local3.hitTestPoint(_arg1.stageX, _arg1.stageY, true) == true)))){
_local4 = false;
for each (_local5 in _local2) {
if (_local5.parent == _local3){
_local4 = true;
};
};
if (_local4 == false){
_local6 = new MouseEvent(MouseEvent.MOUSE_DOWN);
_local3.dispatchEvent(_local6);
};
};
};
}
}
}//package
Section 29
//CrossWall (CrossWall)
package {
import flash.display.*;
public dynamic class CrossWall extends MovieClip {
}
}//package
Section 30
//DeadEnemyImage (DeadEnemyImage)
package {
import flash.display.*;
public dynamic class DeadEnemyImage extends MovieClip {
}
}//package
Section 31
//EasyButton (EasyButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
class EasyButton extends SimpleButton {
var buttonDown:MovieClip;
var buttonOver:MovieClip;
var buttonHitTest:Shape;
var ss:SplashScreen;
var buttonUp:MovieClip;
function EasyButton(_arg1){
var _local2:TextFormat;
var _local3:TextField;
super();
this.ss = _arg1;
this.x = 427;
this.y = 195;
_local2 = new TextFormat();
_local2.bold = false;
_local2.size = 35;
_local2.font = "Tahoma";
_local3 = new TextField();
_local3.x = 27;
_local3.y = 1;
_local3.textColor = 0xFFFFFF;
_local3.text = "Easy";
_local3.width = 126;
_local3.height = 48;
buttonOver = new MovieClip();
buttonOver.graphics.beginFill(13260);
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.drawRect(0, 0, 130, 50);
buttonOver.addChild(_local3);
buttonHitTest = new Shape();
buttonHitTest.graphics.beginFill(0x999999);
buttonHitTest.graphics.drawRect(0, 0, 130, 50);
this.upState = buttonOver;
this.downState = buttonOver;
this.overState = buttonOver;
this.hitTestState = buttonHitTest;
_local3.setTextFormat(_local2);
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
this.ss.gm.DifficultyMode = 0;
this.ss.gm.DoAfterSettingsLoaded();
this.ss.gm.RemoveSplashScreen();
this.ss.gm.uim.Explain("Click here to select the keep ----->", 5, 90, 120, 20);
}
}
}//package
Section 32
//Enemy (Enemy)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
dynamic class Enemy extends MovieClip {
var hp:int;
var Points:int;
var TilesUntilKeep:int;
var endTile:Tile;
var DamageIWillDo:int;
var deadTimer:Timer;
var speed:Number;
var Type:int;
var HPMeter:MovieClip;
var maxhp:int;
var movingTimerInterval:int;
var shootingTimerInterval:int;
var movingTimer:Timer;
var gold:int;
var IAmNextToTheKeep:Boolean;
var ICannotMove:Boolean;
var FollowFlow:Boolean;
var MyPlaceInTheArray:int;
var shootingTimer:Timer;
var ISentICantMove:Boolean;
var ei:MovieClip;
var enemycolor:uint;
var endX:Number;
var endY:Number;
var gm:GameManager;
var npem:NonPlayerElementManager;
var HPMeterInSky:Boolean;
function Enemy(_arg1:NonPlayerElementManager, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:Number, _arg7:uint, _arg8:int, _arg9:int){
ei = new MovieClip();
HPMeter = new MovieClip();
super();
this.npem = _arg1;
this.gm = _arg1.gm;
ICannotMove = false;
IAmNextToTheKeep = false;
this.hp = _arg4;
maxhp = _arg4;
this.speed = _arg6;
this.gold = _arg5;
this.x = _arg2;
this.y = _arg3;
this.DamageIWillDo = 1;
this.enemycolor = _arg7;
this.Type = _arg8;
this.Points = _arg9;
this.ISentICantMove = false;
HPMeterInSky = false;
movingTimerInterval = this.npem.movingTimerInterval;
shootingTimerInterval = this.npem.shootingTimerInterval;
movingTimer = new Timer(movingTimerInterval, 0);
movingTimer.addEventListener("timer", mTimer);
movingTimer.start();
shootingTimer = new Timer(shootingTimerInterval, 0);
shootingTimer.addEventListener("timer", sTimer);
shootingTimer.start();
if (this.Type == 1){
ei.graphics.beginFill(this.enemycolor);
ei.graphics.lineStyle(1, 0);
ei.graphics.drawCircle(0, 0, 5);
ei.graphics.beginFill(0xFFFFFF);
ei.graphics.drawCircle(-2.5, 2.5, 2.5);
ei.graphics.drawCircle(2.5, 2.5, 2.5);
ei.graphics.beginFill(0);
ei.graphics.drawCircle(-2.5, 3.9, 0.7);
ei.graphics.drawCircle(2.5, 3.9, 0.7);
};
if (this.Type == 2){
ei.graphics.beginFill(this.enemycolor);
ei.graphics.lineStyle(1, 0);
ei.graphics.drawCircle(0, 0, 7);
ei.graphics.beginFill(0xFFFFFF);
ei.graphics.drawCircle(-3, 3.5, 3.2);
ei.graphics.drawCircle(3, 3.5, 3.2);
ei.graphics.beginFill(0);
ei.graphics.drawCircle(-3, 4.9, 0.7);
ei.graphics.drawCircle(3, 4.9, 0.7);
};
if (this.Type == 3){
ei.graphics.beginFill(this.enemycolor);
ei.graphics.lineStyle(1, 0);
ei.graphics.drawCircle(0, 0, 3);
ei.graphics.beginFill(0xFFFFFF);
ei.graphics.drawCircle(-2, 2, 2);
ei.graphics.drawCircle(2, 2, 2);
ei.graphics.beginFill(0);
ei.graphics.drawCircle(-2, 3.4, 0.7);
ei.graphics.drawCircle(2, 3.4, 0.7);
};
this.addChild(ei);
FollowFlow = false;
SetEnd();
}
function ICantMove(){
this.WhichTileAmIOn().TryChangingMyFlow();
}
function TakeDamage(_arg1:int){
this.hp = (this.hp - _arg1);
if (this.hp < 1){
this.KillMe(true);
} else {
if (HPMeterInSky == false){
this.npem.gm.mm.sky.addChild(HPMeter);
HPMeterInSky = true;
};
HPMeter.graphics.clear();
HPMeter.graphics.moveTo(-10, -7);
HPMeter.graphics.lineStyle(4, 0);
HPMeter.graphics.lineTo(10, -7);
HPMeter.graphics.moveTo(-10, -7);
HPMeter.graphics.lineStyle(2, 0xFFFF);
HPMeter.graphics.lineTo((-10 + ((this.hp * 20) / this.maxhp)), -7);
};
}
function ShootKeep(){
this.npem.gm.mm.MakeBullet(this.npem.gm.mm, this, this.x, this.y, 20, 20, this.npem.gm.pem.theKeep, DamageIWillDo, 0, 2, this.enemycolor);
this.npem.gm.sounds.PlaySound(2);
}
function mTimer(_arg1:TimerEvent):void{
moveTowardKeep();
}
function Unpause(){
if (shootingTimer != null){
shootingTimer.start();
};
if (movingTimer != null){
movingTimer.start();
};
}
function SnapTo(_arg1:int):int{
return ((_arg1 - (_arg1 % 10)));
}
function HowManyTilesLeft():int{
var _local1:int;
var _local2:Tile;
_local1 = 1;
_local2 = this.WhichTileAmIOn().IFlowTo;
while (_local2.HasKeep == false) {
_local2 = _local2.IFlowTo;
_local1++;
if (_local1 >= 1600){
_local2.IAmFlowingBadly();
return (_local1);
};
};
return (_local1);
}
function SetEnd(){
var _local1:Tile;
var _local2:Boolean;
var _local3:int;
_local1 = this.WhichTileAmIOn();
_local2 = false;
if (((!((_local1 == null))) && ((_local1.CardinalNearbyTiles().length > 0)))){
while (_local2 == false) {
_local3 = 0;
while (_local3 <= 6) {
if (_local1.NearbyTiles[_local3] != null){
if (_local1.NearbyTiles[_local3].isTraversable() == false){
_local2 = true;
};
};
_local3 = (_local3 + 1);
};
if (_local2 == false){
_local1 = _local1.IFlowTo;
};
};
if (_local1 == this.WhichTileAmIOn()){
_local1 = _local1.IFlowTo;
};
endTile = _local1;
if (_local1.HasWall == true){
trace("I'm on a tile with a wall!");
};
if (endTile != null){
endX = ((endTile.TilePosX * 10) + 5);
endY = ((endTile.TilePosY * 10) + 5);
};
};
}
function dTimer(_arg1:TimerEvent):void{
KillMeFinish();
deadTimer.removeEventListener("timer", dTimer);
}
function DecideWhetherToShoot(){
var _local1:Tile;
for each (_local1 in this.WhichTileAmIOn().CardinalNearbyTiles()) {
if (_local1 != null){
if (_local1.HasKeep == true){
ShootKeep();
IAmNextToTheKeep = true;
};
};
};
}
function sTimer(_arg1:TimerEvent):void{
DecideWhetherToShoot();
if (this.npem.allEnemies.indexOf(this) == -1){
this.npem.allEnemies.push(this);
};
}
function KillMeStart(){
deadTimer = new Timer(80, 1);
deadTimer.addEventListener("timer", dTimer);
deadTimer.start();
if (((!((HPMeter == null))) && (!((HPMeter.parent == null))))){
HPMeter.parent.removeChild(HPMeter);
};
if (this.numChildren > 0){
this.removeChild(ei);
};
if (((!((this == null))) && ((this.parent == this.npem.gm.ktk)))){
this.npem.gm.ktk.removeChild(this);
};
this.graphics.clear();
this.rotation = 0;
this.graphics.lineStyle(1, 0xFF0000, 0.75);
this.graphics.moveTo(0, -6);
this.graphics.lineTo(0, 6);
this.graphics.moveTo(6, 0);
this.graphics.lineTo(-6, 0);
this.graphics.moveTo(2, 2);
this.graphics.lineTo(-2, -2);
this.graphics.moveTo(-2, 2);
this.graphics.lineTo(2, -2);
this.npem.gm.mm.sky.addChild(this);
}
function moveTowardKeep(){
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Tile;
var _local10:Number;
_local1 = this.speed;
_local2 = this.x;
_local3 = this.y;
if (endTile == this.WhichTileAmIOn()){
SetEnd();
};
_local4 = Math.sqrt((Math.pow((endX - this.x), 2) + Math.pow((endY - this.y), 2)));
_local5 = this.x;
_local6 = this.y;
_local7 = (this.x + ((_local1 * (endX - this.x)) / _local4));
_local8 = (this.y - ((_local1 * (this.y - endY)) / _local4));
_local9 = this.npem.gm.mm.theMap.allTiles[(SnapTo(_local7) / 10)][(SnapTo(this.y) / 10)];
if ((((((_local9.HasWall == true)) || ((_local9.HasKeep == true)))) || ((_local9.HasTower == true)))){
_local7 = this.x;
this.SetEnd();
};
_local9 = this.npem.gm.mm.theMap.allTiles[(SnapTo(this.x) / 10)][(SnapTo(_local8) / 10)];
if ((((((_local9.HasWall == true)) || ((_local9.HasKeep == true)))) || ((_local9.HasTower == true)))){
_local8 = this.y;
this.SetEnd();
};
_local10 = Math.atan2((_local8 - this.y), (_local7 - this.x));
if (this.numChildren > 0){
this.getChildAt((this.numChildren - 1)).rotation = (((_local10 * 180) / Math.PI) - 90);
};
this.x = _local7;
this.y = _local8;
if ((((this.x == _local5)) && ((this.y == _local6)))){
if (IAmNextToTheKeep == false){
trace("I cannot move!");
trace(((("Position x" + this.x) + " y") + this.y));
trace(((("End tile: " + endTile.TilePosX) + ", ") + endTile.TilePosY));
this.SetEnd();
};
};
HPMeter.x = this.x;
HPMeter.y = this.y;
}
function ChangeTimerIntervals(_arg1:Number){
movingTimer.stop();
movingTimer.removeEventListener("timer", mTimer);
shootingTimer.stop();
shootingTimer.removeEventListener("timer", sTimer);
movingTimerInterval = Math.round((movingTimerInterval * _arg1));
shootingTimerInterval = Math.round((shootingTimerInterval * _arg1));
movingTimer = new Timer(movingTimerInterval, 0);
movingTimer.addEventListener("timer", mTimer);
movingTimer.start();
shootingTimer = new Timer(shootingTimerInterval, 0);
shootingTimer.addEventListener("timer", sTimer);
shootingTimer.start();
}
function KillMe(_arg1:Boolean){
if (_arg1 == true){
this.npem.gm.sounds.PlaySound(1);
this.npem.gm.Gold = (this.npem.gm.Gold + this.gold);
this.npem.gm.Score = (this.npem.gm.Score + this.Points);
KillMeStart();
} else {
KillMeFinish();
};
}
function WhichTileAmIOn():Tile{
return (this.npem.gm.mm.theMap.allTiles[(SnapTo(this.x) / 10)][(SnapTo(this.y) / 10)]);
}
function Pause(){
if (shootingTimer != null){
shootingTimer.stop();
};
if (movingTimer != null){
movingTimer.stop();
};
}
function PickClearNeighbor(_arg1:Tile):Tile{
var _local2:int;
_local2 = 0;
while (_local2 <= 6) {
if (_arg1.NearbyTiles[_local2].isTraversable() == true){
return (_arg1.NearbyTiles[_local2]);
};
_local2 = (_local2 + 2);
};
return (_arg1);
}
function KillMeFinish(){
var _local1:*;
shootingTimer.removeEventListener("timer", sTimer);
movingTimer.removeEventListener("timer", mTimer);
if (((!((HPMeter == null))) && (!((HPMeter.parent == null))))){
HPMeter.parent.removeChild(HPMeter);
};
if (((!((this == null))) && (!((this.parent == null))))){
this.parent.removeChild(this);
};
this.npem.allEnemies.splice(this.npem.allEnemies.indexOf(this), 1);
for each (_local1 in this) {
_local1 = null;
};
}
}
}//package
Section 33
//EnemyImage (EnemyImage)
package {
import flash.display.*;
public dynamic class EnemyImage extends MovieClip {
}
}//package
Section 34
//EWWall (EWWall)
package {
import flash.display.*;
public dynamic class EWWall extends MovieClip {
}
}//package
Section 35
//focusRectSkin (focusRectSkin)
package {
import flash.display.*;
public dynamic class focusRectSkin extends MovieClip {
}
}//package
Section 36
//GameManager (GameManager)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import com.VectorFlash.userInterface.net.*;
public class GameManager extends Sprite {
var NumberOfSecondsSinceLastWave:int;
var DifficultyMode:int;
var ktk:KeepTheKeep;
var LengthOfWave:int;
var GhostImage:ClickThroughImage;
var TimeBonus:int;
var SettingsLoader:URLLoader;
var Settings:XML;
var pem:PlayerElementManager;
var SettingsReq:URLRequest;
var TowerCost:int;
var sounds:Sounds;
var ss:SplashScreen;
var uim:UserInterfaceManager;
var KeepHP:int;
var GoldBonus:int;
var wavesNumber:int;
var Gold:int;
var Score:int;
var WallHP:int;
var mm:MapManager;
var TowerHP:int;
var Version:String;// = "Build 0.07.09.04.0"
var WallCost:int;
var StopwatchInterval:int;
var wavesTimer:Timer;
var TheGameIsOver:Boolean;
var SendScores:Boolean;
var Stopwatch:Timer;
var NumberOfSecondsSinceStart:int;
var npem:NonPlayerElementManager;
var HPBonus:int;
public function GameManager(_arg1:KeepTheKeep){
Version = "Build 0.07.09.04.0";
super();
ktk = _arg1;
this.SendScores = true;
StopwatchInterval = 1000;
this.GhostImage = new ClickThroughImage(this);
this.pem = new PlayerElementManager(this);
this.npem = new NonPlayerElementManager(this);
this.mm = new MapManager(this);
this.uim = new UserInterfaceManager(this);
ss = new SplashScreen(this);
ss.x = 0;
ss.y = 0;
this.mm.sky.addChild(ss);
SettingsLoader = new URLLoader();
SettingsReq = new URLRequest("settings.xml");
SettingsLoader.load(SettingsReq);
SettingsLoader.addEventListener(Event.COMPLETE, SettingsLoaded);
TimeBonus = 2;
HPBonus = 100;
GoldBonus = 2;
}
function SnapTo(_arg1:int):int{
return ((_arg1 - (_arg1 % 10)));
}
function GameOver(){
TheGameIsOver = true;
this.pem.PlacingElement = false;
this.GhostImage = null;
this.uim.InfoArea.text = "";
this.ktk.CursorDisappear();
Score = (Score + (this.GoldBonus * Gold));
if ((((NumberOfSecondsSinceStart < this.Settings.StartingSettings.PenaltyTime)) && ((this.wavesNumber >= this.Settings.StartingSettings.PenaltyTime)))){
Score = (Score + this.Settings.StartingSettings.Penalty);
};
if (((!((this.GhostImage == null))) && (!((this.GhostImage.parent == null))))){
this.GhostImage.parent.removeChild(this.GhostImage);
};
trace("GAME OVER");
this.uim.pb.PauseEverything();
this.SendScoreToServer();
this.mm.sky.addChild(ss);
this.mm.PutSkyOnTop();
ss.AfterGame();
}
function StopwatchTick(_arg1:TimerEvent):void{
NumberOfSecondsSinceStart++;
if ((LengthOfWave - NumberOfSecondsSinceLastWave) > -1){
NumberOfSecondsSinceLastWave++;
} else {
if (this.npem.allEnemies.every(IsEnemyNull) == true){
YouWin();
};
};
if ((((NumberOfSecondsSinceLastWave > LengthOfWave)) && ((TheGameIsOver == false)))){
SendNextWave();
};
}
function IsEnemyNull(_arg1, _arg2:int, _arg3:Array):Boolean{
return ((_arg1 == null));
}
function SendNextWave(){
var _local1:XML;
var _local2:int;
if (Settings.waves.wave[wavesNumber] != null){
this.sounds.PlayAnything(Settings.waves.wave[wavesNumber].WaveSound);
if ((LengthOfWave - NumberOfSecondsSinceLastWave) > 0){
Score = (Score + (this.TimeBonus * (LengthOfWave - NumberOfSecondsSinceLastWave)));
};
NumberOfSecondsSinceLastWave = 0;
for each (_local1 in Settings.waves.wave[wavesNumber].enemy) {
_local2 = 0;
while (_local2 < _local1.HowMany) {
if (_local1.Start == "Top"){
this.npem.createNewEnemy((Math.round((Math.random() * 100)) * 4), 5, _local1.HP, _local1.Gold, _local1.Speed, _local1.Color, _local1.Type, _local1.Points);
};
if (_local1.Start == "Bottom"){
this.npem.createNewEnemy((Math.round((Math.random() * 100)) * 4), 405, _local1.HP, _local1.Gold, _local1.Speed, _local1.Color, _local1.Type, _local1.Points);
};
if (_local1.Start == "Left"){
this.npem.createNewEnemy(5, (Math.round((Math.random() * 100)) * 4), _local1.HP, _local1.Gold, _local1.Speed, _local1.Color, _local1.Type, _local1.Points);
};
if (_local1.Start == "Right"){
this.npem.createNewEnemy(405, (Math.round((Math.random() * 100)) * 4), _local1.HP, _local1.Gold, _local1.Speed, _local1.Color, _local1.Type, _local1.Points);
};
if (_local1.Start == "Specific"){
this.npem.createNewEnemy(_local1.PositionX, _local1.PositionY, _local1.HP, _local1.Gold, _local1.Speed, _local1.Color, _local1.Type, _local1.Points);
};
_local2++;
};
};
LengthOfWave = Settings.waves.wave[wavesNumber].Duration;
wavesNumber = (wavesNumber + 1);
} else {
if (this.npem.allEnemies.every(IsEnemyNull) == true){
NumberOfSecondsSinceLastWave = (LengthOfWave + 1);
};
};
}
function SettingsLoaded(_arg1:Event):void{
if (SettingsLoader != null){
if (SettingsLoader.bytesTotal != 3234){
};
Settings = new XML(SettingsLoader.data);
};
}
function WhichTileIsTheMouseOn():Tile{
return (this.mm.theMap.allTiles[(SnapTo((ktk.stage.mouseX - 10)) / 10)][(SnapTo((ktk.stage.mouseY - 10)) / 10)]);
}
function YouWin(){
TheGameIsOver = true;
this.ktk.CursorDisappear();
this.pem.PlacingElement = false;
this.GhostImage = null;
this.uim.InfoArea.text = "";
Score = ((Score + (this.pem.theKeep.hp * this.HPBonus)) + (this.GoldBonus * this.Gold));
Stopwatch.removeEventListener("timer", StopwatchTick);
if (((!((this.GhostImage == null))) && (!((this.GhostImage.parent == null))))){
this.GhostImage.parent.removeChild(this.GhostImage);
};
this.uim.pb.PauseEverything();
this.mm.sky.addChild(ss);
ss.YouWin();
this.SendScoreToServer();
}
function RemoveSplashScreen(){
this.mm.sky.removeChild(ss);
}
function ChangeTimerIntervals(_arg1:Number){
StopwatchInterval = Math.round((StopwatchInterval * _arg1));
Stopwatch.stop();
Stopwatch.removeEventListener("timer", StopwatchTick);
Stopwatch = new Timer(StopwatchInterval, 0);
Stopwatch.addEventListener("timer", StopwatchTick);
Stopwatch.start();
}
function ChangeAllTimerIntervals(_arg1:Number){
var _local2:Enemy;
var _local3:Tower;
trace("How many times is this running?");
this.npem.movingTimerInterval = Math.round((this.npem.movingTimerInterval * _arg1));
this.npem.shootingTimerInterval = Math.round((this.npem.shootingTimerInterval * _arg1));
this.pem.HowOftenDoIShootMultiplier = Math.round((this.pem.HowOftenDoIShootMultiplier * _arg1));
this.ChangeTimerIntervals(_arg1);
for each (_local2 in this.uim.gm.npem.allEnemies) {
if (_local2 != null){
_local2.ChangeTimerIntervals(_arg1);
};
};
for each (_local3 in this.uim.gm.pem.allTowers) {
if (_local3 != null){
_local3.ChangeTimerIntervals(_arg1);
};
};
}
function PutUpVersion(){
var _local1:TextField;
_local1 = new TextField();
_local1.text = this.Version;
_local1.x = 315;
_local1.y = 396.5;
this.ktk.addChild(_local1);
}
function FirstWave(){
Stopwatch = new Timer(StopwatchInterval, 0);
Stopwatch.addEventListener("timer", StopwatchTick);
Stopwatch.start();
ChangeAllTimerIntervals(Settings.StartingSettings.TimerMultiplier);
SendNextWave();
}
function DoAfterSettingsLoaded(){
if (this.Settings != null){
trace(("Difficulty mode is " + this.DifficultyMode));
this.Settings = this.Settings.modes.mode[this.DifficultyMode];
Gold = this.Settings.StartingSettings.StartingGold;
WallCost = this.Settings.wallSettings.Cost;
TowerCost = this.Settings.towerSettings.Cost;
WallHP = this.Settings.wallSettings.HP;
TowerHP = this.Settings.towerSettings.HP;
KeepHP = this.Settings.StartingSettings.KeepHP;
TimeBonus = this.Settings.StartingSettings.TimeBonus;
HPBonus = this.Settings.StartingSettings.HPBonus;
GoldBonus = this.Settings.StartingSettings.GoldBonus;
PutUpVersion();
this.sounds = new Sounds(this);
} else {
throw (new Error("The settings xml file failed to load."));
};
TheGameIsOver = false;
Score = 0;
NumberOfSecondsSinceLastWave = 0;
LengthOfWave = 0;
this.addEventListener(Event.ENTER_FRAME, runsOncePerFrame);
wavesNumber = this.Settings.StartingSettings.StartOnWave;
}
function SendScoreToServer(){
var _local1:String;
var _local2:SubmitScore;
switch (DifficultyMode){
case 0:
_local1 = "Easy";
break;
case 1:
_local1 = "Medium";
break;
case 2:
_local1 = "Hard";
break;
default:
_local1 = "Error";
break;
};
_local2 = new SubmitScore(this.Score, "Keep the Keep: alpha", _local1);
_local2.x = 100;
_local2.y = 100;
this.ktk.addChild(_local2);
}
function runsOncePerFrame(_arg1:Event):void{
var _local2:int;
if (this.ktk.JustPlacedTower == true){
this.ktk.JustPlacedTower = false;
};
this.uim.MessageBoard.text = ((("Score: " + Score) + "\rGold: ") + Gold);
if ((((this.pem.KeepHasBeenPlaced == true)) && (!((this.pem.theKeep == null))))){
this.uim.MessageBoard.text = ((((("Score: " + Score) + "\rGold: ") + Gold) + "\rKeep HP: ") + this.pem.theKeep.hp);
};
this.uim.MessageBoard.text = ((((this.uim.MessageBoard.text + "\rWave: ") + wavesNumber) + "/") + this.Settings.waves.wave.length());
if ((LengthOfWave - NumberOfSecondsSinceLastWave) > -1){
this.uim.MessageBoard.text = ((this.uim.MessageBoard.text + "\rTime to next wave: ") + (LengthOfWave - NumberOfSecondsSinceLastWave));
};
this.uim.SetTFForMessages();
if (GhostImage != null){
this.mm.theMap.DrawGhost(GhostImage);
_local2 = 0;
if (this.pem.WhichElement == 0){
_local2 = 31;
};
if (this.pem.WhichElement == 1){
_local2 = 1;
};
if (this.pem.WhichElement == 2){
_local2 = 11;
};
if ((((((((this.ktk.mouseX > (400 - _local2))) || ((this.ktk.mouseY > (400 - _local2))))) || ((this.ktk.mouseX < 20)))) || ((this.ktk.mouseY < 20)))){
GhostImage.alpha = 0;
} else {
GhostImage.alpha = 0.25;
};
};
}
function Pause(){
if (Stopwatch != null){
Stopwatch.stop();
};
}
function Unpause(){
if (Stopwatch != null){
Stopwatch.start();
};
}
}
}//package
Section 37
//GhostlyBubble (GhostlyBubble)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.geom.*;
class GhostlyBubble extends MovieClip {
var uim:UserInterfaceManager;
var MessageFormat:TextFormat;
var Message:TextField;
function GhostlyBubble(_arg1:UserInterfaceManager, _arg2:String, _arg3:int, _arg4:int){
var _local5:Number;
super();
this.uim = _arg1;
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
MessageFormat = new TextFormat();
MessageFormat.font = "Tahoma";
MessageFormat.bold = true;
MessageFormat.size = 12;
MessageFormat.color = 13175;
Message = new TextField();
Message.text = _arg2;
Message.setTextFormat(MessageFormat);
Message.width = (Message.textWidth + 3);
Message.height = (Message.textHeight + 3);
this.addChild(Message);
this.x = _arg3;
this.y = _arg4;
_local5 = 0;
while (_local5 < 1) {
this.graphics.beginFill(119, 0.03);
this.graphics.drawCircle((Message.width / 2), (Message.height / 2), ((Message.width * _local5) + (Message.width / 2)));
_local5 = (_local5 + 0.1);
};
this.uim.gm.mm.sky.addChild(this);
}
function mouseDown(_arg1:MouseEvent):void{
var _local2:Array;
var _local3:Object;
var _local4:Boolean;
var _local5:Object;
var _local6:MouseEvent;
trace("ghostlybubble click");
_local2 = this.uim.gm.ktk.getObjectsUnderPoint(new Point(_arg1.stageX, _arg1.stageY));
trace(_local2.length);
for each (_local3 in _local2) {
if (((!((_local3 == this))) && ((_local3.hitTestPoint(_arg1.stageX, _arg1.stageY, true) == true)))){
_local4 = false;
for each (_local5 in _local2) {
if (_local5.parent == _local3){
_local4 = true;
};
};
if (_local4 == false){
_local6 = new MouseEvent(MouseEvent.MOUSE_DOWN);
_local3.dispatchEvent(_local6);
};
};
};
}
}
}//package
Section 38
//HardButton (HardButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
class HardButton extends SimpleButton {
var buttonDown:MovieClip;
var buttonOver:MovieClip;
var buttonHitTest:Shape;
var ss:SplashScreen;
var buttonUp:MovieClip;
function HardButton(_arg1){
var _local2:TextFormat;
var _local3:TextField;
super();
this.ss = _arg1;
this.x = 427;
this.y = 195;
_local2 = new TextFormat();
_local2.bold = false;
_local2.size = 35;
_local2.font = "Tahoma";
_local3 = new TextField();
_local3.x = 24;
_local3.y = 1;
_local3.textColor = 0xFFFFFF;
_local3.text = "Hard";
_local3.width = 126;
_local3.height = 48;
buttonOver = new MovieClip();
buttonOver.graphics.beginFill(13260);
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.drawRect(0, 0, 130, 50);
buttonOver.addChild(_local3);
buttonHitTest = new Shape();
buttonHitTest.graphics.beginFill(0x999999);
buttonHitTest.graphics.drawRect(0, 0, 130, 50);
this.upState = buttonOver;
this.downState = buttonOver;
this.overState = buttonOver;
this.hitTestState = buttonHitTest;
_local3.setTextFormat(_local2);
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
this.ss.gm.DifficultyMode = 2;
this.ss.gm.DoAfterSettingsLoaded();
this.ss.gm.RemoveSplashScreen();
this.ss.gm.uim.Explain("Click here to select the keep ----->", 5, 90, 120, 20);
}
}
}//package
Section 39
//Keep (Keep)
package {
import flash.display.*;
class Keep extends MovieClip {
var hp:int;
var pem:PlayerElementManager;
var speed:int;
var t:Array;
public var posX:int;
var TilePosX:int;
var score:int;
public var posY:int;
var TilePosY:int;
function Keep(_arg1:PlayerElementManager, _arg2:int, _arg3:int, _arg4:int){
var _local5:int;
var _local6:KeepImage;
var _local7:int;
super();
this.t = new Array();
this.pem = _arg1;
this.x = _arg2;
this.y = _arg3;
this.posX = this.x;
this.posY = this.y;
this.hp = _arg4;
this.speed = 0;
TilePosX = (this.x / 10);
TilePosY = (this.y / 10);
_local5 = 0;
while (_local5 < 4) {
_local7 = 0;
while (_local7 < 4) {
this.pem.gm.mm.theMap.allTiles[(TilePosX + _local5)][(TilePosY + _local7)].k = this;
this.pem.gm.mm.theMap.allTiles[(TilePosX + _local5)][(TilePosY + _local7)].HasKeep = true;
this.t[(_local5 + _local7)] = this.pem.gm.mm.theMap.allTiles[(TilePosX + _local5)][(TilePosY + _local7)];
_local7++;
};
_local5++;
};
_local6 = new KeepImage();
this.addChild(_local6);
}
function KillMe(_arg1:Boolean){
var _local2:*;
var _local3:*;
for each (_local2 in t) {
_local2.HasKeep = false;
_local2.k = null;
};
if (this != null){
this.pem.gm.ktk.removeChild(this);
};
this.pem.theKeep = null;
for each (_local3 in this) {
_local3 = null;
};
this.pem.gm.GameOver();
}
function Update(){
}
function RedrawMyself(){
if (((!((this == null))) && ((this.parent == this.pem.gm.ktk)))){
this.pem.gm.ktk.removeChild(this);
};
this.pem.gm.ktk.addChild(this);
}
function TakeDamage(_arg1:int){
this.hp = (this.hp - _arg1);
if (this.hp < 1){
this.KillMe(false);
};
}
}
}//package
Section 40
//KeepButton (KeepButton)
package {
import flash.display.*;
import flash.events.*;
class KeepButton extends SimpleButton {
var buttonDown:Shape;
var buttonOver:Shape;
var buttonHitTest:Shape;
var buttonUp:Shape;
var me:MapEdit;
function KeepButton(_arg1){
this.me = _arg1;
this.x = 465;
this.y = 130;
buttonUp = new Shape();
buttonUp.graphics.beginFill(11259375);
buttonUp.graphics.drawRect(0, 0, 50, 25);
buttonDown = new Shape();
buttonDown.graphics.beginFill(0x333333);
buttonDown.graphics.drawRect(0, 0, 50, 25);
buttonOver = new Shape();
buttonOver.graphics.beginFill(6636321);
buttonOver.graphics.drawRect(0, 0, 50, 25);
buttonHitTest = new Shape();
buttonHitTest.graphics.beginFill(0x999999);
buttonHitTest.graphics.drawRect(0, 0, 50, 25);
this.upState = new KeepImage();
this.downState = new KeepImage();
this.overState = new KeepImage();
this.hitTestState = new KeepImage();
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Pause(){
this.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Unpause(){
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
var _local2:KeepImage;
if (this.me.mm.gm.pem.KeepHasBeenPlaced == false){
this.me.mm.gm.pem.PlacingElement = true;
this.me.mm.gm.pem.WhichElement = 0;
this.me.mm.gm.uim.Explain("Place it somewhere on the map.", 5, 50, 120, 20);
trace(!((this.me.mm.gm.GhostImage == null)));
if (this.me.mm.gm.GhostImage != null){
this.me.mm.gm.GhostImage.graphics.clear();
while (this.me.mm.gm.GhostImage.numChildren > 0) {
this.me.mm.gm.GhostImage.removeChildAt((this.me.mm.gm.GhostImage.numChildren - 1));
};
_local2 = new KeepImage();
_local2.x = 10;
_local2.y = 10;
this.me.mm.gm.GhostImage.addChild(_local2);
};
this.me.mm.gm.uim.InfoArea.text = "The Keep\r\rDon't let the enemies get\rto it!\r\rNo Cost.";
};
}
}
}//package
Section 41
//KeepImage (KeepImage)
package {
import flash.display.*;
public dynamic class KeepImage extends MovieClip {
}
}//package
Section 42
//KeepTheKeep (KeepTheKeep)
package {
import flash.display.*;
import flash.events.*;
public class KeepTheKeep extends MovieClip {
var JustPlacedTower:Boolean;// = false
var Paused:Boolean;
var Cursor:MovieClip;
var WasSelected:MovieClip;
var IJustTookItDown:Boolean;
var Selected:MovieClip;
var gm:GameManager;
var TowerJustUpgradedAllTheWay:Boolean;
public function KeepTheKeep(){
JustPlacedTower = false;
super();
gm = new GameManager(this);
Cursor = new MovieClip();
TowerJustUpgradedAllTheWay = false;
this.Paused = false;
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function SnapTo(_arg1:int):int{
return ((_arg1 - (_arg1 % 10)));
}
function PlacementModeGoAway(){
this.gm.pem.PlacingElement = false;
if (this.gm.GhostImage != null){
while (this.gm.GhostImage.numChildren > 0) {
this.gm.GhostImage.removeChildAt((this.gm.GhostImage.numChildren - 1));
};
this.gm.GhostImage.graphics.clear();
trace("InfoArea text set to nothing at PlaceMentGoAway");
if (TowerJustUpgradedAllTheWay == false){
this.gm.uim.InfoArea.text = "";
} else {
TowerJustUpgradedAllTheWay = false;
};
};
}
function ClickedOnMap(_arg1:Tile){
var _local2:Tile;
if (JustPlacedTower == false){
if (_arg1 == null){
_local2 = WhichTileIsMouseOn();
} else {
_local2 = _arg1;
};
if (_local2.HasKeep == true){
};
if (_local2.HasTower == true){
PlacementModeGoAway();
Selected = _local2.tower;
Cursor.x = _local2.tower.x;
Cursor.y = _local2.tower.y;
Cursor.graphics.clear();
if (_local2.tower.Type == 0){
Cursor.graphics.lineStyle(2, 0xFF0000);
Cursor.graphics.moveTo(0, 0);
Cursor.graphics.lineTo(0, 5);
Cursor.graphics.moveTo(0, 0);
Cursor.graphics.lineTo(5, 0);
Cursor.graphics.moveTo(0, 20);
Cursor.graphics.lineTo(0, 15);
Cursor.graphics.moveTo(0, 20);
Cursor.graphics.lineTo(5, 20);
Cursor.graphics.moveTo(20, 0);
Cursor.graphics.lineTo(15, 0);
Cursor.graphics.moveTo(20, 0);
Cursor.graphics.lineTo(20, 5);
Cursor.graphics.moveTo(20, 20);
Cursor.graphics.lineTo(15, 20);
Cursor.graphics.moveTo(20, 20);
Cursor.graphics.lineTo(20, 15);
Cursor.graphics.lineStyle(2, 0, 0.25);
Cursor.graphics.drawCircle(10, 10, _local2.tower.HowFarDoIShoot);
};
if (_local2.tower.Type == 1){
Cursor.graphics.lineStyle(2, 0xFF0000);
Cursor.graphics.drawCircle(0, 0, 7);
Cursor.graphics.lineStyle(2, 0, 0.25);
Cursor.graphics.drawCircle(0, 0, _local2.tower.HowFarDoIShoot);
};
this.gm.mm.sky.addChild(Cursor);
Selected.ShowInfo();
};
if (_local2.HasWall == true){
};
};
}
function CursorDisappear(){
if (Cursor.parent == this.gm.mm.sky){
trace("Clear the infoarea at CursorDisappear");
if (TowerJustUpgradedAllTheWay == false){
Cursor.graphics.clear();
this.gm.mm.sky.removeChild(Cursor);
WasSelected = Selected;
IJustTookItDown = true;
Selected = null;
this.gm.uim.InfoArea.text = "";
};
this.gm.uim.ub.Disappear();
};
}
function WhichTileIsMouseOn():Tile{
return (this.gm.mm.theMap.allTiles[(SnapTo(this.stage.mouseX) / 10)][(SnapTo(this.stage.mouseY) / 10)]);
}
function Pause(){
this.Paused = true;
}
function Unpause(){
this.Paused = false;
}
function mouseDown(_arg1:MouseEvent):void{
if (this.Paused == false){
trace(((("A click comes in at " + this.stage.mouseX) + " ") + this.stage.mouseY));
if (this.gm.TheGameIsOver == false){
trace("This happens");
if ((((this.gm.pem.KeepHasBeenPlaced == true)) || ((((this.gm.pem.KeepHasBeenPlaced == false)) && ((((((((this.stage.mouseX > this.gm.mm.me.kb.x)) && ((this.stage.mouseX < (this.gm.mm.me.kb.x + 50))))) && ((this.stage.mouseY > this.gm.mm.me.kb.y)))) && ((this.stage.mouseY < (this.gm.mm.me.kb.y + 50))))))))){
IJustTookItDown = false;
if (!(((((((((this.stage.mouseX > (this.gm.uim.ub.x - 2))) && ((this.stage.mouseX < ((this.gm.uim.ub.x + 70) + 4))))) && ((this.stage.mouseY > (this.gm.uim.ub.y - 2))))) && ((this.stage.mouseY < ((this.gm.uim.ub.y + 25) + 4))))) && (!((this.gm.uim.ub.parent == null))))){
CursorDisappear();
};
if ((((((((this.stage.mouseX < 410)) && ((this.stage.mouseX > 10)))) && ((this.stage.mouseY < 410)))) && ((this.stage.mouseY > 10)))){
ClickedOnMap(null);
};
trace((!((this.gm.mm.me.wwb == null)) + ": wwb exists"));
if (((((((((((((((((((!((((((((this.stage.mouseX < (this.gm.mm.theMap.x + (this.gm.mm.theMap.gridNumberOfSquaresPerSide * this.gm.mm.theMap.gridPixelsBetween)))) && ((this.stage.mouseX > this.gm.mm.theMap.x)))) && ((this.stage.mouseY < (this.gm.mm.theMap.y + (this.gm.mm.theMap.gridNumberOfSquaresPerSide * this.gm.mm.theMap.gridPixelsBetween)))))) && ((this.stage.mouseY > this.gm.mm.theMap.y))))) && (!((((((((((this.stage.mouseX > this.gm.mm.me.kb.x)) && ((this.stage.mouseX < (this.gm.mm.me.kb.x + 50))))) && ((this.stage.mouseY > this.gm.mm.me.kb.y)))) && ((this.stage.mouseY < (this.gm.mm.me.kb.y + 50))))) && ((this.gm.pem.KeepHasBeenPlaced == false))))))) && (!((((((((this.stage.mouseX > (this.gm.mm.me.tb.x - 2))) && ((this.stage.mouseX < ((this.gm.mm.me.tb.x + 20) + 4))))) && ((this.stage.mouseY > (this.gm.mm.me.tb.y - 2))))) && ((this.stage.mouseY < ((this.gm.mm.me.tb.y + 20) + 4)))))))) && (!((((((((this.stage.mouseX > (this.gm.mm.me.wb.x - 2))) && ((this.stage.mouseX < ((this.gm.mm.me.wb.x + 10) + 4))))) && ((this.stage.mouseY > (this.gm.mm.me.wb.y - 2))))) && ((this.stage.mouseY < ((this.gm.mm.me.wb.y + 10) + 4)))))))) && (!((((((((this.stage.mouseX > ((this.gm.mm.me.wwb.x - 5) - 2))) && ((this.stage.mouseX < (((this.gm.mm.me.wwb.x - 5) + 10) + 4))))) && ((this.stage.mouseY > ((this.gm.mm.me.wwb.y - 5) - 2))))) && ((this.stage.mouseY < (((this.gm.mm.me.wwb.y - 5) + 10) + 4)))))))) && (!((((((((((this.stage.mouseX > (this.gm.uim.ub.x - 2))) && ((this.stage.mouseX < ((this.gm.uim.ub.x + 70) + 4))))) && ((this.stage.mouseY > (this.gm.uim.ub.y - 2))))) && ((this.stage.mouseY < ((this.gm.uim.ub.y + 25) + 4))))) && (!((this.gm.uim.ub.parent == null)))))))) && (!((((((((this.stage.mouseX > (this.gm.uim.sb.x - 2))) && ((this.stage.mouseX < ((this.gm.uim.sb.x + 130) + 4))))) && ((this.stage.mouseY > (this.gm.uim.sb.y - 2))))) && ((this.stage.mouseY < ((this.gm.uim.sb.y + 30) + 4)))))))) && (!((((((((this.stage.mouseX > (this.gm.uim.pb.x - 2))) && ((this.stage.mouseX < ((this.gm.uim.pb.x + 35) + 4))))) && ((this.stage.mouseY > (this.gm.uim.pb.y - 2))))) && ((this.stage.mouseY < ((this.gm.uim.pb.y + 20) + 4)))))))) && (!((((((((this.stage.mouseX > (this.gm.uim.mb.x - 2))) && ((this.stage.mouseX < ((this.gm.uim.mb.x + 35) + 4))))) && ((this.stage.mouseY > (this.gm.uim.mb.y - 2))))) && ((this.stage.mouseY < ((this.gm.uim.mb.y + 20) + 4)))))))) && (!((((((((this.stage.mouseX > (this.gm.uim.rb.x - 2))) && ((this.stage.mouseX < ((this.gm.uim.rb.x + 35) + 4))))) && ((this.stage.mouseY > (this.gm.uim.rb.y - 2))))) && ((this.stage.mouseY < ((this.gm.uim.rb.y + 20) + 4)))))))){
PlacementModeGoAway();
};
};
};
};
}
}
}//package
Section 43
//LWall (LWall)
package {
import flash.display.*;
public dynamic class LWall extends MovieClip {
}
}//package
Section 44
//Map (Map)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
class Map extends Sprite {
var gridPixelsBetween:int;// = 10
var SomeDoNotConsiderMeExist:Boolean;
var PHowManyHaveReportedIn:int;
var gridLineColor:uint;// = 7842559
var gridLineColorDark:uint;// = 0xFF0000
var FarDown:int;
var PFarLeft:int;
var PHowManyInCurrentLayer:int;
var gridNumberOfSquaresPerSide:int;// = 40
var ShouldIDisplayFlow:Boolean;
var allTiles:Array;
var Paused:Boolean;
var FarRight:int;
var U:Array;
var PHowManyInNextLayer:int;
var FlowTimer:Timer;
var mm:MapManager;
var PFarUp:int;
var FarLeft:int;
var PFarRight:int;
var PCurrentLayer:int;
var PFarDown:int;
var FarUp:int;
function Map(_arg1:MapManager){
gridLineColor = 7842559;
gridLineColorDark = 0xFF0000;
gridPixelsBetween = 10;
gridNumberOfSquaresPerSide = 40;
super();
this.mm = _arg1;
ShouldIDisplayFlow = true;
this.x = 10;
this.y = 10;
DrawMap();
DrawCrosses();
U = new Array();
SomeDoNotConsiderMeExist = false;
this.Paused = false;
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
FlowTimer = new Timer(50, 0);
FlowTimer.addEventListener("timer", fTimer);
DoTiles();
}
function TilePropagationReport(){
PHowManyHaveReportedIn++;
if (PHowManyHaveReportedIn == PHowManyInCurrentLayer){
PCurrentLayer++;
PHowManyInCurrentLayer = 0;
PHowManyHaveReportedIn = 0;
TellNextLayerToCalculatePropagation();
};
}
function SnapTo(_arg1:int):int{
return ((_arg1 - (_arg1 % 10)));
}
function OpenAllTiles(){
var _local1:int;
var _local2:int;
_local1 = 0;
while (_local1 < 41) {
_local2 = 0;
while (_local2 < 41) {
allTiles[_local1][_local2].Layer = 0;
_local2++;
};
_local1++;
};
}
function TellNextLayerToCalculatePropagation(){
var _local1:Array;
var _local2:int;
var _local3:Tile;
var _local4:int;
_local1 = new Array();
_local2 = 0;
while (_local2 <= 40) {
_local4 = 0;
while (_local4 <= 40) {
if (allTiles[_local2][_local4] != null){
if (allTiles[_local2][_local4].Layer == PCurrentLayer){
_local1.push(allTiles[_local2][_local4]);
PHowManyInCurrentLayer++;
};
};
_local4++;
};
_local2++;
};
for each (_local3 in _local1) {
_local3.CalculatePropagation();
};
}
function FlowConsiderOneTile(_arg1:Tile):Boolean{
var _local2:Array;
var _local3:Array;
var _local4:Array;
var _local5:Array;
var _local6:int;
var _local7:Enemy;
var _local8:int;
var _local9:Tile;
var _local10:Tile;
var _local11:int;
var _local12:Number;
var _local13:Tile;
var _local14:Boolean;
var _local15:int;
var _local16:int;
this.mm.sky.graphics.clear();
_local2 = new Array();
_local3 = new Array();
_local4 = new Array();
_local3.push(_arg1);
while (_local3.length > 0) {
for each (_local9 in _local3) {
_local4.push(_local9);
};
while (_local3.length > 0) {
_local3.pop();
};
for each (_local9 in _local4) {
for each (_local10 in _local9.FlowsToMe) {
if (_local10.isTraversable() == true){
_local3.push(_local10);
};
};
};
for each (_local9 in _local4) {
_local2.push(_local9);
};
while (_local4.length > 0) {
_local4.pop();
};
};
for each (_local9 in _local2) {
_local9.HaveIBeenConsidered = false;
_local9.IFlowTo = null;
while (_local9.FlowsToMe.length > 0) {
_local9.FlowsToMe.pop();
};
};
_local5 = FillDoNextFromU(_local2);
_local6 = _local5.length;
if (_local5.length > 0){
while (_local5.length > 0) {
trace(_local5.length);
_local5.sortOn("HowFarAmI", Array.NUMERIC);
_local11 = 0;
while (_local11 < _local5.length) {
_local12 = 10000;
_local14 = false;
_local15 = 0;
while (_local15 <= 6) {
if (_local5[_local11].NearbyTiles[_local15] != null){
if ((((_local5[_local11].NearbyTiles[_local15].isTraversable() == true)) && ((_local5[_local11].NearbyTiles[_local15].HowFarAmI < _local12)))){
_local12 = _local5[_local11].NearbyTiles[_local15].HowFarAmI;
_local13 = _local5[_local11].NearbyTiles[_local15];
_local14 = true;
};
};
_local15 = (_local15 + 2);
};
if (_local14 == true){
_local5[_local11].HaveIBeenConsidered = true;
_local5[_local11].IFlowTo = _local13;
_local13.FlowsToMe.push(_local5[_local11]);
};
_local11++;
};
while (_local5.length > 0) {
_local5.pop();
};
_local5 = FillDoNextFromU(_local2);
if (_local6 == _local5.length){
trace("OOPS - this placement has blocked off a section of tiles");
if (this.mm.gm.pem.ElementsPlacedInOrder[(this.mm.gm.pem.ElementsPlacedInOrder.length - 1)] != null){
this.mm.gm.pem.ElementsPlacedInOrder[(this.mm.gm.pem.ElementsPlacedInOrder.length - 1)].KillMe(true);
this.mm.gm.pem.ElementsPlacedInOrder.pop();
SetUnconsideredAllTiles();
} else {
this.mm.gm.GameOver();
};
return (false);
};
};
};
for each (_local7 in this.mm.gm.npem.allEnemies) {
if (_local7 != null){
_local7.SetEnd();
};
};
_local8 = 0;
while (_local8 < 41) {
_local16 = 0;
while (_local16 < 41) {
this.mm.sky.graphics.beginFill(0x222222);
this.mm.sky.graphics.drawCircle(((allTiles[_local8][_local16].TilePosX * 10) + 5), ((allTiles[_local8][_local16].TilePosY * 10) + 5), 2);
this.mm.sky.graphics.beginFill(3407769);
if (allTiles[_local8][_local16].IFlowTo != null){
this.mm.sky.graphics.drawCircle((((allTiles[_local8][_local16].TilePosX * 10) + 5) + (0.25 * (((allTiles[_local8][_local16].IFlowTo.TilePosX * 10) + 5) - ((allTiles[_local8][_local16].TilePosX * 10) + 5)))), (((allTiles[_local8][_local16].TilePosY * 10) + 5) + (0.25 * (((allTiles[_local8][_local16].IFlowTo.TilePosY * 10) + 5) - ((allTiles[_local8][_local16].TilePosY * 10) + 5)))), 2);
};
_local16++;
};
_local8++;
};
return (true);
}
function IsSomethingNextToThisTile(_arg1:Tile):Boolean{
var _local2:Tile;
for each (_local2 in _arg1.NearbyTiles) {
if (_local2.isTraversable() == false){
return (true);
};
};
return (false);
}
function DrawCrosses(){
this.graphics.lineStyle(1, gridLineColorDark);
this.graphics.moveTo(200, 180);
this.graphics.lineTo(200, 220);
this.graphics.moveTo(180, 200);
this.graphics.lineTo(220, 200);
this.graphics.moveTo(100, 90);
this.graphics.lineTo(100, 110);
this.graphics.moveTo(90, 100);
this.graphics.lineTo(110, 100);
this.graphics.moveTo(300, 290);
this.graphics.lineTo(300, 310);
this.graphics.moveTo(290, 300);
this.graphics.lineTo(310, 300);
this.graphics.moveTo(100, 290);
this.graphics.lineTo(100, 310);
this.graphics.moveTo(90, 300);
this.graphics.lineTo(110, 300);
this.graphics.moveTo(300, 90);
this.graphics.lineTo(300, 110);
this.graphics.moveTo(290, 100);
this.graphics.lineTo(310, 100);
}
function CanIGetToTheKeep(_arg1:Tile):Boolean{
var _local2:Tile;
var _local3:int;
_local2 = _arg1;
_local3 = 0;
while (_local2.IFlowTo.HasKeep == false) {
_local3 = (_local3 + 1);
if (_local2.IFlowTo != null){
if (_local2.IFlowTo.isTraversable() == true){
_local2 = _local2.IFlowTo;
if (_local3 > 1000){
trace("Howmany > 1000");
return (false);
};
} else {
if (_local2.IFlowTo.HasKeep == false){
trace("I flow to something nontraversable");
return (false);
};
trace("I flow to the keep");
return (true);
};
} else {
trace("I flow to something null");
return (false);
};
};
trace("I don't know how I got here");
return (true);
}
function ClearDoNotConsiderMeByFlowsToMe(_arg1:Tile){
var _local2:Tile;
_arg1.DoNotConsiderMe = false;
for each (_local2 in _arg1.FlowsToMe) {
if (_local2.DoNotConsiderMe == true){
ClearDoNotConsiderMeByFlowsToMe(_local2);
};
};
}
function FlowConsider():Boolean{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:Enemy;
var _local5:int;
var _local6:Tile;
var _local7:int;
var _local8:Number;
var _local9:Tile;
var _local10:Boolean;
_local1 = 0;
while (_local1 < 41) {
_local5 = 0;
while (_local5 < 41) {
if ((((allTiles[_local1][_local5].isTraversable() == true)) && ((allTiles[_local1][_local5].HaveIBeenConsidered == false)))){
U.push(allTiles[_local1][_local5]);
};
_local5++;
};
_local1++;
};
U.sortOn("HowFarAmI", Array.NUMERIC);
_local2 = 0;
while (_local2 < U.length) {
_local6 = U[_local2];
_local7 = 0;
while (_local7 <= 6) {
if (_local6.NearbyTiles[_local7] != null){
if (_local6.NearbyTiles[_local7].HasKeep == true){
_local6.HaveIBeenConsidered = true;
_local6.IFlowTo = _local6.NearbyTiles[_local7];
};
};
_local7 = (_local7 + 2);
};
_local2++;
};
while (U.length > 0) {
_local3 = U.length;
U.sortOn("HowFarAmI", Array.NUMERIC);
_local2 = 0;
while (_local2 < U.length) {
_local6 = U[_local2];
if (_local6.HaveIBeenConsidered == false){
_local8 = 10000;
_local10 = false;
_local7 = 0;
while (_local7 <= 6) {
if (_local6.NearbyTiles[_local7] != null){
if ((((_local6.NearbyTiles[_local7].HaveIBeenConsidered == true)) && ((_local6.NearbyTiles[_local7].isTraversable() == true)))){
if (_local6.NearbyTiles[_local7].HowFarAmI < _local8){
_local8 = _local6.NearbyTiles[_local7].HowFarAmI;
_local9 = _local6.NearbyTiles[_local7];
_local10 = true;
};
};
};
_local7 = (_local7 + 2);
};
if (_local10 == true){
_local6.HaveIBeenConsidered = true;
_local6.IFlowTo = _local9;
_local9.FlowsToMe.push(_local6);
};
};
_local2++;
};
while (U.length > 0) {
U.pop();
};
_local1 = 0;
while (_local1 < 41) {
_local5 = 0;
while (_local5 < 41) {
if ((((allTiles[_local1][_local5].isTraversable() == true)) && ((allTiles[_local1][_local5].HaveIBeenConsidered == false)))){
U.push(allTiles[_local1][_local5]);
};
_local5++;
};
_local1++;
};
if (_local3 == U.length){
trace("OOPS - this placement has blocked off a section of tiles");
if (this.mm.gm.pem.ElementsPlacedInOrder[(this.mm.gm.pem.ElementsPlacedInOrder.length - 1)] != null){
this.mm.gm.pem.ElementsPlacedInOrder[(this.mm.gm.pem.ElementsPlacedInOrder.length - 1)].KillMe(true);
this.mm.gm.pem.ElementsPlacedInOrder.pop();
SetUnconsideredAllTiles();
} else {
this.mm.gm.GameOver();
};
return (false);
};
};
for each (_local4 in this.mm.gm.npem.allEnemies) {
if (_local4 != null){
_local4.SetEnd();
};
};
return (true);
}
function SetUnconsideredByIFlowTo(_arg1:Tile){
_arg1.HaveIBeenConsidered = false;
if (_arg1.IFlowTo != null){
if (_arg1.IFlowTo.isTraversable() == true){
SetUnconsideredByIFlowTo(_arg1.IFlowTo);
};
};
}
function UndoChanges(){
var _local1:int;
var _local2:int;
_local1 = 0;
while (_local1 < 41) {
_local2 = 0;
while (_local2 < 41) {
if (allTiles[_local1][_local2].possibleHasWall == true){
allTiles[_local1][_local2].possibleHasWall = false;
};
_local2++;
};
_local1++;
};
}
function DrawCross(_arg1:int, _arg2:int, _arg3:int){
this.graphics.moveTo(_arg1, (_arg2 - _arg3));
this.graphics.lineTo(_arg1, (_arg2 + _arg3));
this.graphics.moveTo((_arg1 - _arg3), _arg2);
this.graphics.lineTo((_arg1 + _arg3), _arg2);
}
function SetConsideredByFlowsToMe(_arg1:Tile){
var _local2:int;
_arg1.HaveIBeenConsidered = true;
trace(((("ftmconsider: " + _arg1.TilePosX) + ", ") + _arg1.TilePosY));
this.mm.sky.graphics.beginFill(16777011);
this.mm.sky.graphics.drawCircle(((_arg1.TilePosX * 10) + 5), ((_arg1.TilePosY * 10) + 5), 3);
if ((((_arg1.TilePosX < 40)) && ((_arg1.TilePosY < 40)))){
_local2 = 0;
while (_local2 < _arg1.FlowsToMe.length) {
if (_arg1.FlowsToMe[_local2] != null){
if ((((_arg1.FlowsToMe[_local2].isTraversable() == true)) && ((_arg1.FlowsToMe[_local2].HaveIBeenConsidered == false)))){
SetConsideredByFlowsToMe(_arg1.FlowsToMe[_local2]);
};
};
_local2++;
};
};
}
function SetUnconsideredAllTiles(){
var _local1:int;
var _local2:int;
_local1 = 0;
while (_local1 < 41) {
_local2 = 0;
while (_local2 < 41) {
if (allTiles[_local1][_local2].IFlowTo != null){
if (allTiles[_local1][_local2].IFlowTo.HasKeep == false){
if ((((allTiles[_local1][_local2].HaveIBeenConsidered == true)) && ((allTiles[_local1][_local2].DoNotConsiderMe == false)))){
if (allTiles[_local1][_local2].isTraversable() == true){
U.push(allTiles[_local1][_local2]);
};
allTiles[_local1][_local2].HaveIBeenConsidered = false;
};
};
};
_local2++;
};
_local1++;
};
}
function DrawMap(){
var _local1:Number;
this.graphics.beginFill(0xEEEEEE);
this.graphics.drawRoundRect(0, 0, 400, 400, 30, 30);
_local1 = 0;
while (_local1 < (gridNumberOfSquaresPerSide + 1)) {
this.graphics.lineStyle(1, gridLineColor);
this.graphics.moveTo(0, (_local1 * gridPixelsBetween));
this.graphics.lineTo((gridNumberOfSquaresPerSide * gridPixelsBetween), (_local1 * 10));
this.graphics.moveTo((_local1 * gridPixelsBetween), 0);
this.graphics.lineStyle(1, gridLineColor);
this.graphics.lineTo((_local1 * gridPixelsBetween), (gridNumberOfSquaresPerSide * gridPixelsBetween));
_local1++;
};
this.graphics.moveTo(200, 180);
this.graphics.lineTo(200.01, 180);
}
function CommitChanges(){
var _local1:int;
var _local2:int;
_local1 = 0;
while (_local1 < 41) {
_local2 = 0;
while (_local2 < 41) {
if (allTiles[_local1][_local2].possibleIFlowTo != allTiles[_local1][_local2].IFlowTo){
allTiles[_local1][_local2].IFlowTo = allTiles[_local1][_local2].possibleIFlowTo;
};
if (allTiles[_local1][_local2].possibleHasWall == true){
allTiles[_local1][_local2].possibleHasWall = false;
};
_local2++;
};
_local1++;
};
}
function fTimer(_arg1:TimerEvent):void{
if (this.mm.gm.pem.KeepHasBeenPlaced == true){
FlowConsiderOneLayer();
};
}
function BeginPropagation(_arg1:Array):Boolean{
OpenAllTiles();
PCurrentLayer = 0;
PHowManyInCurrentLayer = 0;
SetPossible(_arg1);
TellNextLayerToCalculatePropagation();
trace(CheckForBadPlacement());
if (CheckForBadPlacement() == true){
CommitChanges();
AllEnemiesSetEnd();
return (true);
};
UndoChanges();
return (false);
}
function SetDoNotConsiderMeByIFlowTo(_arg1:Tile){
_arg1.DoNotConsiderMe = true;
if (_arg1.IFlowTo != null){
if ((((_arg1.IFlowTo.HasKeep == false)) && ((_arg1.IFlowTo.isTraversable() == true)))){
SetDoNotConsiderMeByIFlowTo(_arg1.IFlowTo);
};
};
}
function DoTiles(){
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
allTiles = new Array();
_local1 = 0;
while (_local1 < 41) {
allTiles[_local1] = new Array();
_local3 = 0;
while (_local3 < 41) {
allTiles[_local1][_local3] = new Tile(this, _local1, _local3);
_local3++;
};
_local1++;
};
_local2 = 0;
while (_local2 < 41) {
_local4 = 0;
while (_local4 < 41) {
if (_local4 > 0){
allTiles[_local2][_local4].NearbyTiles[0] = allTiles[_local2][(_local4 - 1)];
};
if (_local4 < 40){
allTiles[_local2][_local4].NearbyTiles[4] = allTiles[_local2][(_local4 + 1)];
};
if (_local2 < 40){
allTiles[_local2][_local4].NearbyTiles[2] = allTiles[(_local2 + 1)][_local4];
};
if (_local2 > 0){
allTiles[_local2][_local4].NearbyTiles[6] = allTiles[(_local2 - 1)][_local4];
};
if ((((_local4 > 0)) && ((_local2 < 40)))){
allTiles[_local2][_local4].NearbyTiles[1] = allTiles[(_local2 + 1)][(_local4 - 1)];
};
if ((((_local4 < 40)) && ((_local2 < 40)))){
allTiles[_local2][_local4].NearbyTiles[3] = allTiles[(_local2 + 1)][(_local4 + 1)];
};
if ((((_local4 < 40)) && ((_local2 > 0)))){
allTiles[_local2][_local4].NearbyTiles[5] = allTiles[(_local2 - 1)][(_local4 + 1)];
};
if ((((_local4 > 0)) && ((_local2 > 0)))){
allTiles[_local2][_local4].NearbyTiles[7] = allTiles[(_local2 - 1)][(_local4 - 1)];
};
if (_local4 > 0){
allTiles[_local2][_local4].nTile = allTiles[_local2][(_local4 - 1)];
};
if (_local4 < 40){
allTiles[_local2][_local4].sTile = allTiles[_local2][(_local4 + 1)];
};
if (_local2 < 40){
allTiles[_local2][_local4].eTile = allTiles[(_local2 + 1)][_local4];
};
if (_local2 > 0){
allTiles[_local2][_local4].wTile = allTiles[(_local2 - 1)][_local4];
};
if ((((_local4 > 0)) && ((_local2 < 40)))){
allTiles[_local2][_local4].neTile = allTiles[(_local2 + 1)][(_local4 - 1)];
};
if ((((_local4 < 40)) && ((_local2 < 40)))){
allTiles[_local2][_local4].seTile = allTiles[(_local2 + 1)][(_local4 + 1)];
};
if ((((_local4 < 40)) && ((_local2 > 0)))){
allTiles[_local2][_local4].swTile = allTiles[(_local2 - 1)][(_local4 + 1)];
};
if ((((_local4 > 0)) && ((_local2 > 0)))){
allTiles[_local2][_local4].nwTile = allTiles[(_local2 - 1)][(_local4 - 1)];
};
_local4++;
};
_local2++;
};
}
function SetToUnconsideredByFlowsToMe(_arg1:Tile, _arg2:int){
var _local3:int;
var _local4:Tile;
_arg1.HaveIBeenConsidered = false;
_local3 = (_arg2 + 1);
for each (_local4 in _arg1.FlowsToMe) {
if (((((((((!((_local4 == null))) && ((_local4.HaveIBeenConsidered == true)))) && ((_local4.isTraversable() == true)))) && ((_local4.TilePosX < 41)))) && ((_local4.TilePosY < 41)))){
SetToUnconsideredByFlowsToMe(_local4, _local3);
};
};
}
function FlowSetHowFarAmI(){
var _local1:int;
var _local2:int;
_local1 = 0;
while (_local1 < 41) {
_local2 = 0;
while (_local2 < 41) {
allTiles[_local1][_local2].HowFarAmI = Math.sqrt((Math.pow(Math.abs((((allTiles[_local1][_local2].TilePosX * 10) + 5) - (this.mm.gm.pem.theKeep.x + 20))), 2) + Math.pow(Math.abs((((allTiles[_local1][_local2].TilePosY * 10) + 5) - (this.mm.gm.pem.theKeep.y + 20))), 2)));
_local2++;
};
_local1++;
};
}
function CheckForBadPlacement():Boolean{
var _local1:Enemy;
if (allTiles[1][1].Layer == 0){
return (false);
};
for each (_local1 in this.mm.gm.npem.allEnemies) {
if (_local1 != null){
if (_local1.WhichTileAmIOn().Layer == 0){
return (false);
};
};
};
return (true);
}
function FillDoNextFromU(_arg1:Array):Array{
var _local2:Array;
var _local3:int;
var _local4:Boolean;
var _local5:*;
_local2 = new Array();
_local3 = 0;
while (_local3 < _arg1.length) {
if ((((_arg1[_local3].HaveIBeenConsidered == false)) && ((_arg1[_local3].isTraversable() == true)))){
_local4 = false;
_local5 = 0;
while (_local5 <= 6) {
if (_arg1[_local3].NearbyTiles[_local5] != null){
if ((((((_arg1[_local3].NearbyTiles[_local5].isTraversable() == true)) && ((_arg1[_local3].NearbyTiles[_local5].HaveIBeenConsidered == true)))) && ((_local4 == false)))){
_local4 = true;
_local2.push(_arg1[_local3]);
this.mm.sky.graphics.beginFill(16724991);
this.mm.sky.graphics.drawCircle(((_arg1[_local3].TilePosX * 10) + 5), ((_arg1[_local3].TilePosY * 10) + 5), 4);
};
};
_local5 = (_local5 + 2);
};
};
_local3++;
};
return (_local2);
}
function SetPossible(_arg1:Array){
var _local2:Tile;
for each (_local2 in _arg1) {
_local2.possibleHasWall = true;
};
}
function DrawGhost(_arg1:MovieClip){
var _local2:int;
var _local3:int;
_local2 = SnapTo((this.mm.gm.ktk.stage.mouseX - 10));
_local3 = SnapTo((this.mm.gm.ktk.stage.mouseY - 10));
_arg1.x = _local2;
_arg1.y = _local3;
this.mm.sky.addChild(_arg1);
}
function Pause(){
this.Paused = true;
}
function FlowConsiderOneLayer(){
var _local1:int;
var _local2:int;
var _local3:Tile;
var _local4:Enemy;
var _local5:Tile;
var _local6:Number;
var _local7:Tile;
var _local8:Boolean;
var _local9:int;
var _local10:MovieClip;
var _local11:Tower;
var _local12:Tile;
if (ShouldIDisplayFlow == true){
DisplayFlow();
};
if (U.length > 0){
_local1 = U.length;
U.sortOn("HowFarAmI", Array.NUMERIC);
_local2 = 0;
while (_local2 < U.length) {
_local5 = U[_local2];
if (_local5.HaveIBeenConsidered == false){
if (ShouldIDisplayFlow == true){
this.mm.sky.graphics.lineStyle(1, 0x888888);
this.mm.sky.graphics.drawCircle(((_local5.TilePosX * 10) + 5), ((_local5.TilePosY * 10) + 5), 5);
};
_local6 = 10000;
_local8 = false;
_local9 = 0;
while (_local9 <= 6) {
if (_local5.NearbyTiles[_local9] != null){
if ((((_local5.NearbyTiles[_local9].HaveIBeenConsidered == true)) && ((_local5.NearbyTiles[_local9].isTraversable() == true)))){
if (_local5.NearbyTiles[_local9].HowFarAmI < _local6){
_local6 = _local5.NearbyTiles[_local9].HowFarAmI;
_local7 = _local5.NearbyTiles[_local9];
_local8 = true;
};
};
};
_local9 = (_local9 + 2);
};
if (_local8 == true){
_local5.HaveIBeenConsidered = true;
_local5.IFlowTo = _local7;
_local7.FlowsToMe.push(_local5);
};
};
_local2++;
};
for each (_local3 in U) {
if (_local3.HaveIBeenConsidered == true){
U.splice(U.indexOf(_local3), 1);
};
};
if (_local1 == U.length){
trace("OOPS - this placement has blocked off a section of tiles");
if (this.mm.gm.pem.ElementsPlacedInOrder[(this.mm.gm.pem.ElementsPlacedInOrder.length - 1)] != null){
_local10 = this.mm.gm.pem.ElementsPlacedInOrder[(this.mm.gm.pem.ElementsPlacedInOrder.length - 1)];
_local10.KillMe(true);
if ((_local10 is Tower)){
for each (_local12 in _local10.t) {
if (_local12.IFlowTo.HasKeep == false){
U.push(_local12);
_local12.HaveIBeenConsidered = false;
_local12.DoNotConsiderMe = false;
};
};
};
if ((_local10 is Wall)){
if (_local10.t.IFlowTo.HasKeep == false){
_local10.t.HaveIBeenConsidered = false;
_local10.t.DoNotConsiderMe = false;
U.push(_local10.t);
};
};
this.mm.gm.pem.ElementsPlacedInOrder.pop();
SetUnconsideredAllTiles();
trace("//have all towers redraw themselves");
for each (_local11 in this.mm.gm.pem.allTowers) {
if (_local11 != null){
_local11.RedrawMyself();
};
};
this.mm.PutSkyOnTop();
};
};
for each (_local4 in this.mm.gm.npem.allEnemies) {
if (_local4 != null){
_local4.SetEnd();
};
};
};
}
function Unpause(){
this.Paused = false;
}
function AllEnemiesSetEnd(){
var _local1:Enemy;
for each (_local1 in this.mm.gm.npem.allEnemies) {
if (_local1 != null){
_local1.SetEnd();
};
};
}
function mouseDown(_arg1:MouseEvent):void{
var _local2:Boolean;
var _local3:int;
var _local4:int;
var _local5:Boolean;
var _local6:Array;
var _local7:Enemy;
var _local8:int;
var _local9:int;
var _local10:Enemy;
var _local11:int;
var _local12:int;
var _local13:int;
var _local14:int;
var _local15:int;
var _local16:int;
var _local17:int;
var _local18:Enemy;
if (this.Paused == false){
if (this.mm.gm.pem.PlacingElement){
_local2 = false;
_local3 = (SnapTo(this.mm.gm.ktk.stage.mouseX) / 10);
_local4 = (SnapTo(this.mm.gm.ktk.stage.mouseY) / 10);
if (this.mm.gm.pem.WhichElement == 1){
_local5 = false;
if ((((((((_local3 > 39)) || ((_local4 > 39)))) || ((_local3 < 2)))) || ((_local4 < 2)))){
_local2 = true;
};
if (this.mm.gm.Gold < this.mm.gm.Settings.wallSettings.Cost){
_local2 = true;
};
if (this.allTiles[_local3] != null){
if (this.allTiles[_local3][_local4] != null){
if (IsSomethingNextToThisTile(this.allTiles[_local3][_local4]) == true){
_local5 = true;
};
if ((((((this.allTiles[_local3][_local4].HasTower == true)) || ((this.allTiles[_local3][_local4].HasKeep == true)))) || ((this.allTiles[_local3][_local4].HasWall == true)))){
_local2 = true;
};
for each (_local7 in this.mm.gm.npem.allEnemies) {
if (_local7 != null){
if (this.allTiles[_local3][_local4] == _local7.WhichTileAmIOn()){
_local2 = true;
};
};
};
} else {
_local2 = true;
};
} else {
_local2 = true;
};
if (this.mm.gm.Settings.StartingSettings.ContiguousElements == "Yes"){
if (_local5 == false){
_local2 = true;
};
};
_local6 = new Array();
trace("//why is this causing an error?");
trace((_local3 + " TilePosX exists"));
_local6.push(allTiles[_local3][_local4]);
if (BeginPropagation(_local6) == false){
_local2 = true;
};
while (_local6.length > 0) {
_local6.pop();
};
if (_local2 == false){
this.mm.gm.pem.createNewWall(SnapTo(this.mm.gm.ktk.stage.mouseX), SnapTo(this.mm.gm.ktk.stage.mouseY), this.mm.gm.WallHP);
this.mm.gm.Gold = (this.mm.gm.Gold - this.mm.gm.WallCost);
if ((((this.mm.gm.uim.AndSoOn == true)) && ((this.mm.gm.uim.AndSoOnOff == false)))){
this.mm.gm.uim.ExplainOff();
this.mm.gm.uim.AndSoOnOff = true;
};
if ((((this.mm.gm.uim.AndSoOn == false)) && ((this.mm.gm.uim.AndSoOnOff == false)))){
this.mm.gm.uim.Explain("And so on.", 4, 50, 50, 40);
this.mm.gm.uim.AndSoOn = true;
};
if (this.mm.gm.pem.KeepHasBeenPlaced == true){
};
};
};
if (this.mm.gm.pem.WhichElement == 0){
if ((((((((_local3 > 36)) || ((_local4 > 36)))) || ((_local3 < 2)))) || ((_local4 < 2)))){
_local2 = true;
};
_local8 = 0;
while (_local8 < 4) {
_local9 = 0;
while (_local9 < 4) {
if (this.allTiles[(_local3 + _local8)] != null){
if (this.allTiles[(_local3 + _local8)][(_local4 + _local9)] != null){
if ((((((this.allTiles[(_local3 + _local8)][(_local4 + _local9)].HasTower == true)) || ((this.allTiles[(_local3 + _local8)][(_local4 + _local9)].HasKeep == true)))) || ((this.allTiles[(_local3 + _local8)][(_local4 + _local9)].HasWall == true)))){
_local2 = true;
};
for each (_local10 in this.mm.gm.npem.allEnemies) {
if (_local10 != null){
if (this.allTiles[(_local3 + _local8)][(_local4 + _local9)] == _local10.WhichTileAmIOn()){
_local2 = true;
};
};
};
} else {
_local2 = true;
};
} else {
_local2 = true;
};
_local9++;
};
_local8++;
};
if (_local2 == false){
this.mm.gm.pem.PlaceKeep(SnapTo(this.mm.gm.ktk.stage.mouseX), SnapTo(this.mm.gm.ktk.stage.mouseY), this.mm.gm.KeepHP);
this.mm.gm.pem.PlacingElement = false;
if ((((this.mm.gm.uim.AndSoOn == true)) && ((this.mm.gm.uim.AndSoOnOff == false)))){
this.mm.gm.uim.ExplainOff();
this.mm.gm.uim.AndSoOnOff = true;
};
this.mm.gm.uim.Explain("Now select a tower or wall ----->", 5, 120, 120, 20);
trace("AddWBTB happens");
this.mm.me.AddWBTB();
this.mm.me.RemoveKB();
this.mm.gm.GhostImage.parent.removeChild(this.mm.gm.GhostImage);
this.mm.gm.uim.InfoArea.text = "";
FlowSetHowFarAmI();
BeginPropagation(new Array());
};
};
if (this.mm.gm.pem.WhichElement == 3){
_local11 = this.mm.gm.Settings.towerSettings.type[1].upgrade[0].Cost;
if (this.mm.gm.Gold < _local11){
_local2 = true;
};
if (this.allTiles[_local3][_local4] != null){
if ((((((this.allTiles[_local3][_local4].HasWall == false)) || ((this.allTiles[_local3][_local4].HasTower == true)))) || ((this.allTiles[_local3][_local4].HasKeep == true)))){
_local2 = true;
};
};
if (_local2 == false){
this.mm.gm.pem.createNewTower((SnapTo(this.mm.gm.ktk.stage.mouseX) + 5), (SnapTo(this.mm.gm.ktk.stage.mouseY) + 5), this.mm.gm.TowerHP, 1);
this.mm.gm.Gold = (this.mm.gm.Gold - _local11);
this.mm.gm.ktk.JustPlacedTower = true;
if ((((this.mm.gm.uim.AndSoOn == true)) && ((this.mm.gm.uim.AndSoOnOff == false)))){
this.mm.gm.uim.ExplainOff();
this.mm.gm.uim.AndSoOnOff = true;
};
if ((((this.mm.gm.uim.AndSoOn == false)) && ((this.mm.gm.uim.AndSoOnOff == false)))){
this.mm.gm.uim.Explain("And so on.", 4, 50, 120, 20);
this.mm.gm.uim.AndSoOn = true;
};
};
};
if (this.mm.gm.pem.WhichElement == 2){
if ((((((((_local3 > 38)) || ((_local4 > 38)))) || ((_local3 < 2)))) || ((_local4 < 2)))){
_local2 = true;
};
_local12 = 0;
_local13 = this.mm.gm.Settings.wallSettings.Cost;
if (this.allTiles[_local3][_local4].HasWall == false){
_local12 = (_local12 + _local13);
};
if (this.allTiles[_local3][(_local4 + 1)].HasWall == false){
_local12 = (_local12 + _local13);
};
if (this.allTiles[(_local3 + 1)][_local4].HasWall == false){
_local12 = (_local12 + _local13);
};
if (this.allTiles[(_local3 + 1)][(_local4 + 1)].HasWall == false){
_local12 = (_local12 + _local13);
};
_local14 = this.mm.gm.Settings.towerSettings.type[0].upgrade[0].Cost;
_local15 = (_local14 + _local12);
trace(_local15);
if (this.mm.gm.Gold < _local15){
_local2 = true;
};
_local5 = false;
_local6 = new Array();
_local16 = 0;
while (_local16 < 2) {
_local17 = 0;
while (_local17 < 2) {
if (this.allTiles[(_local3 + _local16)] != null){
if (this.allTiles[(_local3 + _local16)][(_local4 + _local17)] != null){
if (IsSomethingNextToThisTile(this.allTiles[(_local3 + _local16)][(_local4 + _local17)]) == true){
_local5 = true;
};
if (this.allTiles[(_local3 + _local16)][(_local4 + _local17)].HasWall == false){
_local6.push(this.allTiles[(_local3 + _local16)][(_local4 + _local17)]);
};
if ((((this.allTiles[(_local3 + _local16)][(_local4 + _local17)].HasTower == true)) || ((this.allTiles[(_local3 + _local16)][(_local4 + _local17)].HasKeep == true)))){
_local2 = true;
};
for each (_local18 in this.mm.gm.npem.allEnemies) {
if (_local18 != null){
if (this.allTiles[(_local3 + _local16)][(_local4 + _local17)] == _local18.WhichTileAmIOn()){
_local2 = true;
};
};
};
} else {
_local2 = true;
};
} else {
_local2 = true;
};
_local17++;
};
_local16++;
};
if ((((_local5 == false)) && ((this.mm.gm.Settings.StartingSettings.ContiguousElements == "Yes")))){
_local2 = true;
};
if (BeginPropagation(_local6) == false){
_local2 = true;
};
while (_local6.length > 0) {
_local6.pop();
};
if (_local2 == false){
if (this.allTiles[_local3][_local4].HasWall == false){
this.mm.gm.pem.createNewWall(SnapTo(this.mm.gm.ktk.stage.mouseX), SnapTo(this.mm.gm.ktk.stage.mouseY), this.mm.gm.WallHP);
};
if (this.allTiles[_local3][(_local4 + 1)].HasWall == false){
this.mm.gm.pem.createNewWall(SnapTo(this.mm.gm.ktk.stage.mouseX), SnapTo((this.mm.gm.ktk.stage.mouseY + 10)), this.mm.gm.WallHP);
};
if (this.allTiles[(_local3 + 1)][_local4].HasWall == false){
this.mm.gm.pem.createNewWall(SnapTo((this.mm.gm.ktk.stage.mouseX + 10)), SnapTo(this.mm.gm.ktk.stage.mouseY), this.mm.gm.WallHP);
};
if (this.allTiles[(_local3 + 1)][(_local4 + 1)].HasWall == false){
this.mm.gm.pem.createNewWall(SnapTo((this.mm.gm.ktk.stage.mouseX + 10)), SnapTo((this.mm.gm.ktk.stage.mouseY + 10)), this.mm.gm.WallHP);
};
this.mm.gm.pem.createNewTower(SnapTo(this.mm.gm.ktk.stage.mouseX), SnapTo(this.mm.gm.ktk.stage.mouseY), this.mm.gm.TowerHP, 0);
this.mm.gm.Gold = ((this.mm.gm.Gold - this.mm.gm.Settings.towerSettings.type[0].upgrade[0].Cost) - _local12);
this.mm.gm.ktk.JustPlacedTower = true;
if ((((this.mm.gm.uim.AndSoOn == true)) && ((this.mm.gm.uim.AndSoOnOff == false)))){
this.mm.gm.uim.ExplainOff();
this.mm.gm.uim.AndSoOnOff = true;
};
if ((((this.mm.gm.uim.AndSoOn == false)) && ((this.mm.gm.uim.AndSoOnOff == false)))){
this.mm.gm.uim.Explain("And so on.", 4, 50, 120, 20);
this.mm.gm.uim.AndSoOn = true;
};
if (this.mm.gm.pem.KeepHasBeenPlaced == true){
};
};
};
};
};
}
function DisplayFlow(){
var _local1:int;
var _local2:int;
this.mm.sky.graphics.clear();
_local1 = 0;
while (_local1 < 41) {
_local2 = 0;
while (_local2 < 41) {
this.mm.sky.graphics.beginFill(0x222222);
this.mm.sky.graphics.drawCircle(((allTiles[_local1][_local2].TilePosX * 10) + 5), ((allTiles[_local1][_local2].TilePosY * 10) + 5), 1);
if (allTiles[_local1][_local2].IFlowTo != null){
this.mm.sky.graphics.beginFill(0xFF);
this.mm.sky.graphics.drawCircle((((allTiles[_local1][_local2].TilePosX * 10) + 5) + (0.25 * (((allTiles[_local1][_local2].IFlowTo.TilePosX * 10) + 5) - ((allTiles[_local1][_local2].TilePosX * 10) + 5)))), (((allTiles[_local1][_local2].TilePosY * 10) + 5) + (0.25 * (((allTiles[_local1][_local2].IFlowTo.TilePosY * 10) + 5) - ((allTiles[_local1][_local2].TilePosY * 10) + 5)))), 1);
};
_local2++;
};
_local1++;
};
}
function SetFlowsToMe(){
var _local1:int;
var _local2:int;
_local1 = 0;
while (_local1 < 41) {
_local2 = 0;
while (_local2 < 41) {
if (allTiles[_local1][_local2].isTraversable() == true){
allTiles[_local1][_local2].IFlowTo.FlowsToMe.push(allTiles[_local1][_local2]);
};
_local2++;
};
_local1++;
};
}
}
}//package
Section 45
//MapEdit (MapEdit)
package {
class MapEdit {
var mm:MapManager;
var wwb:WallWalkerButton;
var wb:WallButton;
var tb:TowerButton;
var kb:KeepButton;
function MapEdit(_arg1:MapManager){
this.mm = _arg1;
kb = new KeepButton(this);
this.mm.gm.ktk.addChild(kb);
MakeWBTB();
}
function AddWBTB(){
trace("wwb created");
wwb = new WallWalkerButton(this);
this.mm.gm.ktk.addChild(wb);
this.mm.gm.ktk.addChild(tb);
this.mm.gm.ktk.addChild(wwb);
DoButtonPrices();
this.wwb.TowerColor = this.mm.gm.Settings.towerSettings.type[1].upgrade[0].Color;
}
function DoButtonPrices(){
wb.DoPrice();
wwb.DoPrice();
tb.DoPrice();
}
function RemoveKB(){
this.mm.gm.ktk.removeChild(kb);
}
function MakeWBTB(){
wb = new WallButton(this);
tb = new TowerButton(this);
}
}
}//package
Section 46
//MapManager (MapManager)
package {
import flash.display.*;
class MapManager {
var gm:GameManager;
var sky:MovieClip;
var theMap:Map;
var allBullets:Array;
var me:MapEdit;
private static var UNIT_WALL:int = 0;
private static var UNIT_TOWER:int = 1;
function MapManager(_arg1:GameManager){
this.gm = _arg1;
PlaceMap();
me = new MapEdit(this);
MakeSky();
allBullets = new Array();
}
function PutSkyOnTop(){
var _local1:int;
_local1 = 0;
while (_local1 < this.gm.ktk.numChildren) {
if (this.gm.ktk.getChildIndex(sky) < this.gm.ktk.getChildIndex(this.gm.ktk.getChildAt(_local1))){
this.gm.ktk.swapChildren(sky, this.gm.ktk.getChildAt(_local1));
};
_local1++;
};
}
function MakeSky(){
sky = new MovieClip();
this.gm.ktk.addChild(sky);
PutSkyOnTop();
}
function PlaceMap(){
theMap = new Map(this);
this.gm.ktk.addChild(theMap);
}
function MakeBullet(_arg1:MapManager, _arg2:MovieClip, _arg3:Number, _arg4:Number, _arg5:int, _arg6:int, _arg7:MovieClip, _arg8:int, _arg9:int, _arg10:int, _arg11:uint){
var _local12:Boolean;
var _local13:int;
var _local14:int;
var _local15:int;
_local12 = false;
_local15 = (allBullets.length - 1);
while (_local15 >= 0) {
if (allBullets[_local15] == null){
_local12 = true;
_local13 = _local15;
};
_local15--;
};
if (_local12 == true){
allBullets[_local13] = new Bullet(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11);
_local14 = _local13;
} else {
allBullets.push(new Bullet(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11));
_local14 = (allBullets.length - 1);
};
}
}
}//package
Section 47
//MediumButton (MediumButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
class MediumButton extends SimpleButton {
var buttonDown:MovieClip;
var buttonOver:MovieClip;
var buttonHitTest:Shape;
var ss:SplashScreen;
var buttonUp:MovieClip;
function MediumButton(_arg1){
var _local2:TextFormat;
var _local3:TextField;
super();
this.ss = _arg1;
this.x = 427;
this.y = 195;
_local2 = new TextFormat();
_local2.bold = false;
_local2.size = 35;
_local2.font = "Tahoma";
_local3 = new TextField();
_local3.x = 2;
_local3.y = 1;
_local3.textColor = 0xFFFFFF;
_local3.text = "Medium";
_local3.width = 126;
_local3.height = 48;
buttonOver = new MovieClip();
buttonOver.graphics.beginFill(13260);
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.drawRect(0, 0, 130, 50);
buttonOver.addChild(_local3);
buttonHitTest = new Shape();
buttonHitTest.graphics.beginFill(0x999999);
buttonHitTest.graphics.drawRect(0, 0, 130, 50);
this.upState = buttonOver;
this.downState = buttonOver;
this.overState = buttonOver;
this.hitTestState = buttonHitTest;
_local3.setTextFormat(_local2);
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
this.ss.gm.DifficultyMode = 1;
this.ss.gm.DoAfterSettingsLoaded();
this.ss.gm.RemoveSplashScreen();
this.ss.gm.uim.Explain("Click here to select the keep ----->", 5, 90, 120, 20);
}
}
}//package
Section 48
//MuteButton (MuteButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
class MuteButton extends SimpleButton {
var buttonDown:MovieClip;
var buttonOver:MovieClip;
var buttonHitTest:Shape;
var debugcounter:int;
var uim:UserInterfaceManager;
var buttonUp:MovieClip;
var IHaveAppeared:Boolean;
var t:TextField;
function MuteButton(_arg1){
var _local2:TextFormat;
super();
this.uim = _arg1;
this.x = 468.5;
this.y = 195;
IHaveAppeared = false;
_local2 = new TextFormat();
_local2.bold = false;
_local2.size = 11;
_local2.font = "Tahoma";
t = new TextField();
t.x = 2;
t.y = 1;
t.textColor = 0xFFFFFF;
t.text = "Mute";
t.width = 33;
t.height = 19;
buttonOver = new MovieClip();
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.beginFill(13260);
buttonOver.graphics.drawRect(0, 0, 35, 20);
buttonOver.addChild(t);
buttonHitTest = new Shape();
buttonHitTest.graphics.beginFill(0x999999);
buttonHitTest.graphics.drawRect(0, 0, 35, 20);
this.upState = buttonOver;
this.downState = buttonOver;
this.overState = buttonOver;
this.hitTestState = buttonHitTest;
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
t.setTextFormat(_local2);
debugcounter = 0;
}
function Disappear(){
if (this.parent == this.uim.gm.ktk){
this.uim.gm.ktk.removeChild(this);
IHaveAppeared = false;
};
}
function Appear(){
if (IHaveAppeared == false){
this.uim.gm.ktk.addChild(this);
this.uim.gm.mm.PutSkyOnTop();
IHaveAppeared = true;
};
}
function mouseDown(_arg1:MouseEvent):void{
if (debugcounter > 2){
debugcounter = 0;
this.uim.gm.mm.theMap.DisplayFlow();
};
if (this.uim.pb.Paused == true){
debugcounter++;
};
if (this.uim.gm.sounds.Mute == true){
this.uim.gm.sounds.Mute = false;
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.beginFill(13260);
buttonOver.graphics.drawRect(0, 0, 35, 20);
return;
};
if (this.uim.gm.sounds.Mute == false){
this.uim.gm.sounds.Mute = true;
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.beginFill(4522);
buttonOver.graphics.drawRect(0, 0, 35, 20);
return;
};
}
}
}//package
Section 49
//NewGameButton (NewGameButton)
package {
import flash.display.*;
public dynamic class NewGameButton extends MovieClip {
}
}//package
Section 50
//NEWWall (NEWWall)
package {
import flash.display.*;
public dynamic class NEWWall extends MovieClip {
}
}//package
Section 51
//NextButtonImage (NextButtonImage)
package {
import flash.display.*;
public dynamic class NextButtonImage extends MovieClip {
}
}//package
Section 52
//NonPlayerElementManager (NonPlayerElementManager)
package {
class NonPlayerElementManager {
var allEnemies:Array;
var gm:GameManager;
var shootingTimerInterval:int;
var allEnemiesAreSlotsOpen:Boolean;
var allEnemiesFirstOpenSlot:int;
var movingTimerInterval:int;
function NonPlayerElementManager(_arg1:GameManager){
allEnemies = new Array();
super();
this.gm = _arg1;
allEnemiesAreSlotsOpen = false;
movingTimerInterval = 80;
shootingTimerInterval = 1000;
}
function createNewEnemy(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:Number, _arg6:uint, _arg7:int, _arg8:int){
allEnemies.push(new Enemy(this, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8));
this.gm.ktk.addChild(allEnemies[(allEnemies.length - 1)]);
this.gm.mm.PutSkyOnTop();
}
}
}//package
Section 53
//NSEWWall (NSEWWall)
package {
import flash.display.*;
public dynamic class NSEWWall extends MovieClip {
}
}//package
Section 54
//NWWall (NWWall)
package {
import flash.display.*;
public dynamic class NWWall extends MovieClip {
}
}//package
Section 55
//PauseButton (PauseButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
class PauseButton extends SimpleButton {
var buttonDown:MovieClip;
var buttonOver:MovieClip;
var buttonHitTest:Shape;
var Paused:Boolean;// = false
var uim:UserInterfaceManager;
var buttonUp:MovieClip;
var IHaveAppeared:Boolean;
function PauseButton(_arg1){
var _local2:TextFormat;
var _local3:TextField;
Paused = false;
super();
this.uim = _arg1;
this.x = 427;
this.y = 195;
IHaveAppeared = false;
_local2 = new TextFormat();
_local2.bold = false;
_local2.size = 11;
_local2.font = "Tahoma";
_local3 = new TextField();
_local3.x = 2;
_local3.y = 1;
_local3.textColor = 0xFFFFFF;
_local3.text = "Pause";
_local3.width = 33;
_local3.height = 19;
buttonOver = new MovieClip();
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.beginFill(13260);
buttonOver.graphics.drawRect(0, 0, 35, 20);
buttonOver.addChild(_local3);
buttonHitTest = new Shape();
buttonHitTest.graphics.beginFill(0x999999);
buttonHitTest.graphics.drawRect(0, 0, 35, 20);
this.upState = buttonOver;
this.downState = buttonOver;
this.overState = buttonOver;
this.hitTestState = buttonHitTest;
_local3.setTextFormat(_local2);
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function PauseEverything(){
var _local1:Enemy;
var _local2:Tower;
this.uim.gm.Pause();
this.uim.gm.ktk.Pause();
this.uim.gm.mm.theMap.Pause();
if (this.uim.gm.mm.me.wb != null){
this.uim.gm.mm.me.wb.Pause();
};
if (this.uim.gm.mm.me.tb != null){
this.uim.gm.mm.me.tb.Pause();
};
if (this.uim.gm.mm.me.kb != null){
this.uim.gm.mm.me.kb.Pause();
};
this.uim.ub.Pause();
this.uim.sb.Pause();
for each (_local1 in this.uim.gm.npem.allEnemies) {
if (_local1 != null){
_local1.Pause();
};
};
for each (_local2 in this.uim.gm.pem.allTowers) {
if (_local2 != null){
_local2.Pause();
};
};
}
function UnpauseEverything(){
var _local1:Enemy;
var _local2:Tower;
this.uim.gm.Unpause();
this.uim.gm.ktk.Unpause();
this.uim.gm.mm.theMap.Unpause();
if (this.uim.gm.mm.me.wb != null){
this.uim.gm.mm.me.wb.Unpause();
};
if (this.uim.gm.mm.me.tb != null){
this.uim.gm.mm.me.tb.Unpause();
};
if (this.uim.gm.mm.me.kb != null){
this.uim.gm.mm.me.kb.Unpause();
};
this.uim.ub.Unpause();
this.uim.sb.Unpause();
for each (_local1 in this.uim.gm.npem.allEnemies) {
if (_local1 != null){
_local1.Unpause();
};
};
for each (_local2 in this.uim.gm.pem.allTowers) {
if (_local2 != null){
_local2.Unpause();
};
};
}
function Disappear(){
if (this.parent == this.uim.gm.ktk){
this.uim.gm.ktk.removeChild(this);
IHaveAppeared = false;
};
}
function Appear(){
if (IHaveAppeared == false){
this.uim.gm.ktk.addChild(this);
this.uim.gm.mm.PutSkyOnTop();
IHaveAppeared = true;
};
}
function mouseDown(_arg1:MouseEvent):void{
trace("Clicked on PauseButton");
if (Paused == false){
PauseEverything();
Paused = true;
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.beginFill(4522);
buttonOver.graphics.drawRect(0, 0, 35, 20);
return;
};
if (Paused == true){
UnpauseEverything();
Paused = false;
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.beginFill(13260);
buttonOver.graphics.drawRect(0, 0, 35, 20);
return;
};
}
}
}//package
Section 56
//PlayAgainButton (PlayAgainButton)
package {
import flash.display.*;
import flash.events.*;
class PlayAgainButton extends SimpleButton {
var HasBeenClicked:Boolean;
var ss:SplashScreen;
function PlayAgainButton(_arg1:SplashScreen){
this.ss = _arg1;
HasBeenClicked = false;
this.upState = new PlayAgainButtonImage();
this.downState = new PlayAgainButtonImage();
this.overState = new PlayAgainButtonImage();
this.hitTestState = new PlayAgainButtonImage();
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
var event = _arg1;
try {
this.ss.gm.SendScoreToServer();
} catch(e:Error) {
trace("Error here");
};
}
}
}//package
Section 57
//PlayAgainButtonImage (PlayAgainButtonImage)
package {
import flash.display.*;
public dynamic class PlayAgainButtonImage extends MovieClip {
}
}//package
Section 58
//PlayButton (PlayButton)
package {
import flash.display.*;
import flash.events.*;
class PlayButton extends SimpleButton {
var HasBeenClicked:Boolean;
var ss:SplashScreen;
function PlayButton(_arg1:SplashScreen){
this.ss = _arg1;
HasBeenClicked = false;
this.upState = new PlayButtonImage();
this.downState = new PlayButtonImage();
this.overState = new PlayButtonImage();
this.hitTestState = new PlayButtonImage();
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
this.ss.gm.RemoveSplashScreen();
this.ss.gm.uim.Explain("Click here to select the keep ----->", 5, 90, 120, 20);
}
}
}//package
Section 59
//PlayButtonImage (PlayButtonImage)
package {
import flash.display.*;
public dynamic class PlayButtonImage extends MovieClip {
}
}//package
Section 60
//PlayerElementManager (PlayerElementManager)
package {
class PlayerElementManager {
var allWalls:Array;
var allTowers:Array;
var ElementsPlacedInOrder:Array;
var HowOftenDoIShootMultiplier:Number;
var theKeep:Keep;
var KeepHasBeenPlaced:Boolean;
var gm:GameManager;
var PlacingElement:Boolean;
var WhichElement:int;
static var WALL_COST:int = 3;
private static var KEEP_ELEMENT:int = 0;
static var TOWER_COST:int = 50;
private static var TOWER_ELEMENT:int = 2;
private static var WALL_ELEMENT:int = 1;
function PlayerElementManager(_arg1:GameManager){
allWalls = new Array();
allTowers = new Array();
super();
this.gm = _arg1;
this.KeepHasBeenPlaced = false;
this.PlacingElement = false;
ElementsPlacedInOrder = new Array();
this.HowOftenDoIShootMultiplier = 1;
}
function SetWallImages(_arg1:Wall){
var _local2:Tile;
_arg1.WhatWallAmI();
for each (_local2 in _arg1.t.NearbyTiles) {
if (_local2.HasWall == true){
_local2.w.WhatWallAmI();
};
};
}
function PlaceKeep(_arg1:int, _arg2:int, _arg3:int){
this.gm.sounds.PlaySound(3);
theKeep = new Keep(this, _arg1, _arg2, _arg3);
this.gm.ktk.addChild(theKeep);
this.KeepHasBeenPlaced = true;
ElementsPlacedInOrder.push(theKeep);
this.gm.mm.PutSkyOnTop();
}
function createNewTower(_arg1:int, _arg2:int, _arg3:int, _arg4:int){
this.gm.sounds.PlaySound(3);
allTowers.push(new Tower(this, _arg1, _arg2, _arg3, _arg4));
this.gm.ktk.addChild(allTowers[(allTowers.length - 1)]);
allTowers[(allTowers.length - 1)].HaveNearbyKeepRedrawItself();
ElementsPlacedInOrder.push(allTowers[(allTowers.length - 1)]);
allTowers[(allTowers.length - 1)].MyPlaceInTheArray = (allTowers.length - 1);
this.gm.mm.PutSkyOnTop();
}
function createNewWall(_arg1:int, _arg2:int, _arg3:int){
this.gm.sounds.PlaySound(3);
allWalls.push(new Wall(this, _arg1, _arg2, _arg3));
this.gm.ktk.addChild(allWalls[(allWalls.length - 1)]);
ElementsPlacedInOrder.push(allWalls[(allWalls.length - 1)]);
allWalls[(allWalls.length - 1)].MyPlaceInTheArray = (allWalls.length - 1);
this.SetWallImages(allWalls[(allWalls.length - 1)]);
this.gm.mm.PutSkyOnTop();
}
}
}//package
Section 61
//ResetButton (ResetButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.net.*;
class ResetButton extends SimpleButton {
var buttonDown:MovieClip;
var buttonOver:MovieClip;
var buttonHitTest:Shape;
var uim:UserInterfaceManager;
var buttonUp:MovieClip;
var IHaveAppeared:Boolean;
function ResetButton(_arg1){
var _local2:TextFormat;
var _local3:TextField;
super();
this.uim = _arg1;
this.x = 510;
this.y = 195;
IHaveAppeared = false;
_local2 = new TextFormat();
_local2.bold = false;
_local2.size = 11;
_local2.font = "Tahoma";
_local3 = new TextField();
_local3.x = 2;
_local3.y = 1;
_local3.textColor = 0xFFFFFF;
_local3.text = "Reset";
_local3.width = 33;
_local3.height = 19;
buttonOver = new MovieClip();
buttonOver.graphics.beginFill(13260);
buttonOver.graphics.lineStyle(1, 0);
buttonOver.graphics.drawRect(0, 0, 35, 20);
buttonOver.addChild(_local3);
buttonHitTest = new Shape();
buttonHitTest.graphics.beginFill(0x999999);
buttonHitTest.graphics.drawRect(0, 0, 35, 20);
this.upState = buttonOver;
this.downState = buttonOver;
this.overState = buttonOver;
this.hitTestState = buttonHitTest;
_local3.setTextFormat(_local2);
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Disappear(){
if (this.parent == this.uim.gm.ktk){
this.uim.gm.ktk.removeChild(this);
IHaveAppeared = false;
};
}
function Appear(){
if (IHaveAppeared == false){
this.uim.gm.ktk.addChild(this);
this.uim.gm.mm.PutSkyOnTop();
IHaveAppeared = true;
};
}
function mouseDown(_arg1:MouseEvent):void{
trace("Clicked on ResetButton");
navigateToURL(new URLRequest("http://vectorflash.com/keepthekeep"), "_self");
}
}
}//package
Section 62
//Sounds (Sounds)
package {
import flash.media.*;
import flash.net.*;
class Sounds {
var TowerShootSound:Sound;
var EnemyDeathSound:Sound;
var AnythingSoundChannel:SoundChannel;
var EnemyShootSoundReq:URLRequest;
var AnythingSoundExists:Boolean;
var AnythingSoundReq:URLRequest;
var EnemyDeathSoundReq:URLRequest;
var AnythingSound:Sound;
var BuildSoundExists:Boolean;
var BuildSound:Sound;
var TowerShootSoundReq:URLRequest;
var gm:GameManager;
var BulletHitsSoundExists:Boolean;
var BulletHitsSound:Sound;
var BulletHitsSoundReq:URLRequest;
var EnemyShootSoundExists:Boolean;
var TowerShootSoundExists:Boolean;
var EnemyShootSound:Sound;
var Mute:Boolean;// = false
var BuildSoundReq:URLRequest;
var EnemyDeathSoundExists:Boolean;
function Sounds(_arg1:GameManager){
Mute = false;
super();
this.gm = _arg1;
if (this.gm.Settings.StartingSettings.EnemyDeathSound != "none"){
EnemyDeathSoundReq = new URLRequest(this.gm.Settings.StartingSettings.EnemyDeathSound);
EnemyDeathSound = new Sound(EnemyDeathSoundReq);
EnemyDeathSoundExists = true;
} else {
EnemyDeathSoundExists = false;
};
if (this.gm.Settings.StartingSettings.BulletHitsSound != "none"){
BulletHitsSoundReq = new URLRequest(this.gm.Settings.StartingSettings.BulletHitsSound);
BulletHitsSound = new Sound(BulletHitsSoundReq);
BulletHitsSoundExists = true;
} else {
BulletHitsSoundExists = false;
};
if (this.gm.Settings.StartingSettings.BuildSound != "none"){
BuildSoundReq = new URLRequest(this.gm.Settings.StartingSettings.BuildSound);
BuildSound = new Sound(BuildSoundReq);
BuildSoundExists = true;
} else {
BuildSoundExists = false;
};
if (this.gm.Settings.StartingSettings.EnemyShootSound != "none"){
EnemyShootSoundReq = new URLRequest(this.gm.Settings.StartingSettings.EnemyShootSound);
EnemyShootSound = new Sound(EnemyShootSoundReq);
EnemyShootSoundExists = true;
} else {
EnemyShootSoundExists = false;
};
if (this.gm.Settings.StartingSettings.TowerShootSound != "none"){
TowerShootSoundReq = new URLRequest(this.gm.Settings.StartingSettings.TowerShootSound);
TowerShootSound = new Sound(TowerShootSoundReq);
TowerShootSoundExists = true;
} else {
TowerShootSoundExists = false;
};
}
function PlaySound(_arg1:int){
if (Mute == false){
if (TowerShootSoundExists == true){
if (_arg1 == 0){
TowerShootSound.play();
};
};
if (EnemyDeathSoundExists == true){
if (_arg1 == 1){
EnemyDeathSound.play();
};
};
if (EnemyShootSoundExists == true){
if (_arg1 == 2){
EnemyShootSound.play();
};
};
if (BuildSoundExists == true){
if (_arg1 == 3){
BuildSound.play();
};
};
if (BulletHitsSoundExists == true){
if (_arg1 == 4){
BulletHitsSound.play();
};
};
};
}
function PlayAnything(_arg1:String){
if (Mute == false){
if (_arg1 == ""){
} else {
StopAnything();
AnythingSoundReq = new URLRequest(_arg1);
AnythingSound = new Sound(AnythingSoundReq);
AnythingSoundChannel = AnythingSound.play();
};
};
}
function StopAnything(){
if (Mute == false){
if (AnythingSound != null){
AnythingSoundChannel.stop();
};
};
}
}
}//package
Section 63
//SplashScreen (SplashScreen)
package {
import flash.display.*;
import flash.text.*;
public class SplashScreen extends MovieClip {
var hb:HardButton;
var SplashTextField:TextField;
var tf:TextFormat;
var pab:PlayAgainButton;
var mb:MediumButton;
var eb:EasyButton;
var ngb:NewGameButton;
var gm:GameManager;
var pb:PlayButton;
public function SplashScreen(_arg1:GameManager){
this.gm = _arg1;
BeforeGame();
}
function YouWin(){
if (eb.parent == this){
this.removeChild(eb);
};
if (mb.parent == this){
this.removeChild(mb);
};
if (hb.parent == this){
this.removeChild(hb);
};
this.x = 420;
this.y = 120;
this.graphics.clear();
this.graphics.beginFill(0xFFFFFF);
this.graphics.drawRect(0, 0, 130, 250);
this.graphics.beginFill(0xDD00);
this.graphics.drawRect(2, 2, 126, 246);
this.graphics.beginFill(0xFFFFFF);
this.graphics.drawRect(5, 5, 120, 240);
SplashTextField.x = 5;
SplashTextField.y = 5;
SplashTextField.width = 120;
SplashTextField.height = 270;
pab = new PlayAgainButton(this);
pab.x = 0;
pab.y = 250;
this.addChild(pab);
SplashTextField.text = (((((((("Congratulations!\rYou have kept the keep." + "\r\rYour score was: ") + this.gm.Score) + "\rYou had ") + this.gm.Gold) + " gold left over, and") + "\ryou won after wave ") + this.gm.wavesNumber) + ".");
SplashTextField.setTextFormat(tf);
}
function BeforeGame(){
this.gm = gm;
this.graphics.beginFill(0xFFFFFF);
this.graphics.drawRect(0, 0, 570, 420);
this.graphics.beginFill(0xDD00);
this.graphics.drawRect(2, 2, 566, 416);
this.graphics.beginFill(0xFFFFFF);
this.graphics.drawRect(5, 5, 560, 410);
tf = new TextFormat();
tf.font = "Tahoma";
tf.align = "center";
tf.size = 14;
tf.bold = true;
SplashTextField = new TextField();
SplashTextField.border = false;
SplashTextField.x = 20;
SplashTextField.y = 20;
SplashTextField.height = 380;
SplashTextField.width = 530;
SplashTextField.wordWrap = true;
SplashTextField.text = "Keep the Keep\r\rDefend your keep from the enemy hordes by building walls and defenses.\r\rYou must leave a path to the keep for the enemies.\r\rCatapults and Wall-walkers must be built on top of walls. The catapult can be placed on the map without walls, but it will cost 3 gold per open tile over the price quoted.\r\rAll walls must be connected to the keep.";
SplashTextField.setTextFormat(tf);
this.addChild(SplashTextField);
eb = new EasyButton(this);
mb = new MediumButton(this);
hb = new HardButton(this);
eb.x = 70;
eb.y = 295;
this.addChild(eb);
mb.x = 220;
mb.y = 295;
this.addChild(mb);
hb.x = 370;
hb.y = 295;
this.addChild(hb);
}
function AfterGame(){
this.x = 420;
this.y = 120;
this.graphics.clear();
this.graphics.beginFill(0xFFFFFF);
this.graphics.drawRect(0, 0, 130, 250);
this.graphics.beginFill(0xDD00);
this.graphics.drawRect(2, 2, 126, 246);
this.graphics.beginFill(0xFFFFFF);
this.graphics.drawRect(5, 5, 120, 240);
SplashTextField.x = 10;
SplashTextField.y = 10;
SplashTextField.width = 110;
SplashTextField.height = 260;
this.gm.mm.PutSkyOnTop();
if (((!((this.gm.pem.theKeep == null))) && (!((this.gm.pem.theKeep.parent == null))))){
this.gm.pem.theKeep.parent.removeChild(this.gm.pem.theKeep);
};
if (eb.parent == this){
this.removeChild(eb);
};
if (mb.parent == this){
this.removeChild(mb);
};
if (hb.parent == this){
this.removeChild(hb);
};
pab = new PlayAgainButton(this);
pab.x = 0;
pab.y = 250;
this.addChild(pab);
SplashTextField.text = (((((((("The hordes have prevailed!" + "\r\rYour score was: ") + this.gm.Score) + "\rYou had ") + this.gm.Gold) + " gold left over, and") + "\ryou died during wave ") + this.gm.wavesNumber) + ".");
SplashTextField.setTextFormat(tf);
}
}
}//package
Section 64
//StartButton (StartButton)
package {
import flash.display.*;
import flash.events.*;
class StartButton extends SimpleButton {
var uim:UserInterfaceManager;
var HasBeenClicked:Boolean;
function StartButton(_arg1:UserInterfaceManager){
this.uim = _arg1;
this.x = 420;
this.y = 370;
HasBeenClicked = false;
this.upState = new StartButtonImage();
this.downState = new StartButtonImage();
this.overState = new StartButtonImage();
this.hitTestState = new StartButtonImage();
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Pause(){
this.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Unpause(){
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
if (this.uim.gm.TheGameIsOver == false){
if (this.uim.gm.pem.KeepHasBeenPlaced == true){
trace("Start button clicked");
if (HasBeenClicked == false){
this.uim.gm.FirstWave();
this.upState = new NextButtonImage();
this.downState = new NextButtonImage();
this.overState = new NextButtonImage();
this.hitTestState = new NextButtonImage();
HasBeenClicked = true;
} else {
this.uim.gm.SendNextWave();
};
};
};
}
}
}//package
Section 65
//StartButtonImage (StartButtonImage)
package {
import flash.display.*;
public dynamic class StartButtonImage extends MovieClip {
}
}//package
Section 66
//TextInput_disabledSkin (TextInput_disabledSkin)
package {
import flash.display.*;
public dynamic class TextInput_disabledSkin extends MovieClip {
}
}//package
Section 67
//TextInput_upSkin (TextInput_upSkin)
package {
import flash.display.*;
public dynamic class TextInput_upSkin extends MovieClip {
}
}//package
Section 68
//Tile (Tile)
package {
import flash.utils.*;
class Tile {
var HaveIBeenConsidered:Boolean;
var tower:Tower;
var TilePosY:int;
var neTile:Tile;
var nwTile:Tile;
var HasKeep:Boolean;
var seTile:Tile;
var NearbyTiles:Array;
var TilePosX:int;
var HasTower:Boolean;
var WaitTimer:Timer;
var Layer:int;
var swTile:Tile;
var eTile:Tile;
var nTile:Tile;
var sTile:Tile;
var wTile:Tile;
var possibleHasWall:Boolean;
public var HowFarAmI:Number;
var possibleIFlowTo:Tile;
var IFlowTo:Tile;
var HasWall:Boolean;
var m:Map;
var w:Wall;
var DoNotConsiderMe:Boolean;
var k:Keep;
var FlowsToMe:Array;
function Tile(_arg1:Map, _arg2:int, _arg3:int){
NearbyTiles = new Array();
this.m = _arg1;
this.HasWall = false;
this.HasKeep = false;
this.HasTower = false;
this.TilePosX = _arg2;
this.TilePosY = _arg3;
FlowsToMe = new Array();
DoNotConsiderMe = false;
this.Layer = 0;
this.possibleHasWall = false;
}
function getNeighbors():Array{
return (NearbyTiles);
}
function isTraversable():Boolean{
if ((((((this.HasWall == false)) && ((this.HasTower == false)))) && ((this.HasKeep == false)))){
return (true);
};
return (false);
}
function SeeIfImOkay(){
if (this.IFlowTo.HasKeep == false){
if ((((this.IFlowTo.isTraversable() == false)) || ((this.IFlowTo.IFlowTo == this)))){
IAmFlowingBadly();
};
};
}
function CalculatePropagation(){
var _local1:int;
if ((((((((this.Layer == 0)) && ((this.HasWall == false)))) && ((this.possibleHasWall == false)))) && ((this.HasKeep == false)))){
_local1 = 0;
while (_local1 <= 6) {
if (this.NearbyTiles[_local1] != null){
if (this.NearbyTiles[_local1].HasKeep == true){
this.Layer = 1;
this.possibleIFlowTo = this.NearbyTiles[_local1];
this.m.TilePropagationReport();
return;
};
};
_local1 = (_local1 + 2);
};
};
if (this.Layer > 0){
_local1 = 0;
while (_local1 <= 6) {
if (this.NearbyTiles[_local1] != null){
if ((((((((this.NearbyTiles[_local1].HasWall == false)) && ((this.NearbyTiles[_local1].possibleHasWall == false)))) && ((this.NearbyTiles[_local1].HasKeep == false)))) && ((this.NearbyTiles[_local1].Layer == 0)))){
this.NearbyTiles[_local1].possibleIFlowTo = this;
this.NearbyTiles[_local1].Layer = (this.Layer + 1);
};
};
_local1 = (_local1 + 2);
};
};
this.m.TilePropagationReport();
}
function TryChangingMyFlow(){
var _local1:Tile;
for each (_local1 in CardinalNearbyTiles()) {
if (((!((_local1.IFlowTo == this))) && ((_local1.isTraversable() == true)))){
this.IFlowTo = _local1;
return;
};
};
}
function IAmFlowingBadly(){
var _local1:int;
var _local2:int;
this.INeedHelp();
_local1 = 0;
while (_local1 < 7) {
NearbyTiles[_local1].INeedHelp();
_local2 = 0;
while (_local2 < 7) {
NearbyTiles[_local1].NearbyTiles[_local2].INeedHelp();
_local2++;
};
_local1++;
};
}
function INeedHelp(){
DoNotConsiderMe = false;
HaveIBeenConsidered = false;
}
function CardinalNearbyTiles():Array{
var _local1:Array;
_local1 = new Array();
_local1[0] = this.NearbyTiles[0];
_local1[1] = this.NearbyTiles[2];
_local1[2] = this.NearbyTiles[4];
_local1[3] = this.NearbyTiles[6];
return (_local1);
}
}
}//package
Section 69
//Tower (Tower)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
class Tower extends MovieClip {
var TowerColor:uint;
var hp:int;
var Upgrade:int;
var i4:MovieClip;
var MyHeight:int;
var pem:PlayerElementManager;
var DamageIWillDo:int;
var HowOftenDoIShoot:int;
var Type:int;
var t:Array;
var MyWidth:int;
var HowOftenDoIShootMultiplier:Number;
var IJustUpgradedAllTheWay:Boolean;
var HowFarDoIShoot:int;
var TotalGoldICost:int;
var MyPlaceInTheArray:int;
var shootingTimer:Timer;
var ji:MovieClip;
var SplashDamage:int;
var i2:MovieClip;
var i1:MovieClip;
var i3:MovieClip;
function Tower(_arg1:PlayerElementManager, _arg2:int, _arg3:int, _arg4:int, _arg5:int){
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:TowerImage;
var _local11:Number;
super();
this.pem = _arg1;
this.t = new Array();
this.x = _arg2;
this.y = _arg3;
this.hp = _arg4;
this.Upgrade = 0;
this.Type = _arg5;
if (this.Type == 0){
this.MyWidth = 2;
this.MyHeight = 2;
};
if (this.Type == 1){
this.MyWidth = 1;
this.MyHeight = 1;
};
ji = new MovieClip();
this.TotalGoldICost = this.pem.gm.Settings.towerSettings.type[_arg5].upgrade[Upgrade].Cost;
this.HowFarDoIShoot = this.pem.gm.Settings.towerSettings.type[_arg5].upgrade[Upgrade].Range;
this.HowOftenDoIShoot = this.pem.gm.Settings.towerSettings.type[_arg5].upgrade[Upgrade].Frequency;
this.DamageIWillDo = this.pem.gm.Settings.towerSettings.type[_arg5].upgrade[Upgrade].Damage;
this.hp = this.pem.gm.Settings.towerSettings.type[_arg5].upgrade[Upgrade].HP;
this.SplashDamage = this.pem.gm.Settings.towerSettings.type[_arg5].upgrade[Upgrade].SplashDamage;
this.TowerColor = this.pem.gm.Settings.towerSettings.type[_arg5].upgrade[Upgrade].Color;
_local6 = (this.x / 10);
_local7 = (this.y / 10);
_local8 = 0;
while (_local8 < this.MyWidth) {
_local9 = 0;
while (_local9 < this.MyHeight) {
this.pem.gm.mm.theMap.allTiles[(_local6 + _local8)][(_local7 + _local9)].tower = this;
this.pem.gm.mm.theMap.allTiles[(_local6 + _local8)][(_local7 + _local9)].HasTower = true;
this.t.push(this.pem.gm.mm.theMap.allTiles[(_local6 + _local8)][(_local7 + _local9)]);
_local9++;
};
_local8++;
};
if (this.Type == 0){
_local10 = new TowerImage();
this.addChild(_local10);
};
if (this.Type == 1){
_local11 = 0.75;
ji.graphics.beginFill(this.TowerColor);
ji.graphics.lineStyle(1, 0);
ji.graphics.drawCircle(0, 0, (4.5 * _local11));
ji.graphics.beginFill(this.TowerColor);
ji.graphics.lineStyle(1, 0);
ji.graphics.drawCircle((5 * _local11), (-1.5 * _local11), (2.5 * _local11));
ji.graphics.beginFill(0, 0);
ji.graphics.lineStyle(1, 0);
ji.graphics.moveTo((5 * _local11), (-10 * _local11));
ji.graphics.lineTo((5 * _local11), (10 * _local11));
ji.graphics.moveTo((5 * _local11), (10 * _local11));
ji.graphics.lineTo((6 * _local11), (8 * _local11));
ji.graphics.moveTo((5 * _local11), (10 * _local11));
ji.graphics.lineTo((4 * _local11), (8 * _local11));
this.addChild(ji);
this.rotation = (Math.random() * 360);
};
HowOftenDoIShootMultiplier = this.pem.HowOftenDoIShootMultiplier;
shootingTimer = new Timer(Math.round((HowOftenDoIShoot * HowOftenDoIShootMultiplier)), 0);
shootingTimer.addEventListener("timer", sTimer);
shootingTimer.start();
IJustUpgradedAllTheWay = false;
}
function TakeDamage(_arg1:int){
this.hp = (this.hp - _arg1);
if (this.hp < 1){
this.KillMe(false);
};
}
function Shoot(_arg1:Enemy){
var _local2:uint;
var _local3:int;
var _local4:int;
this.pem.gm.sounds.PlaySound(0);
_local2 = 0;
_local3 = 1;
_local4 = 0;
if (this.Type == 0){
_local4 = 10;
};
if (this.Type == 1){
_local4 = 0;
_local3 = 3;
};
this.pem.gm.mm.MakeBullet(this.pem.gm.mm, this, (this.x + _local4), (this.y + _local4), 0, 0, _arg1, DamageIWillDo, this.SplashDamage, _local3, _local2);
if (this.Type == 1){
this.rotation = (((Math.atan2((_arg1.y - this.y), (_arg1.x - this.x)) * 180) / Math.PI) - 90);
};
}
function RedrawMyself(){
if (((!((this == null))) && (!((this.parent == null))))){
this.pem.gm.ktk.removeChild(this);
};
this.pem.gm.ktk.addChild(this);
if (i1 != null){
this.pem.gm.mm.sky.addChild(i1);
};
if (i2 != null){
this.pem.gm.mm.sky.addChild(i2);
};
if (i3 != null){
this.pem.gm.mm.sky.addChild(i3);
};
if (i4 != null){
this.pem.gm.mm.sky.addChild(i4);
};
HaveNearbyKeepRedrawItself();
}
function Unpause(){
if (shootingTimer != null){
shootingTimer.start();
};
}
function ShowInfo(){
var _local1:String;
var _local2:String;
var _local3:String;
var _local4:String;
var _local5:String;
var _local6:int;
trace(("ShowInfo, upgrade button disappears upgrade: " + this.Upgrade));
this.pem.gm.uim.ub.Disappear();
_local1 = "";
_local2 = "";
_local3 = "";
_local4 = "";
_local5 = "";
if (this.pem.gm.Settings.towerSettings.type[this.Type].upgrade[(this.Upgrade + 1)] != null){
_local6 = (this.Upgrade + 1);
_local1 = (" --> " + _local6);
_local2 = (" --> " + this.pem.gm.Settings.towerSettings.type[this.Type].upgrade[(this.Upgrade + 1)].Range);
_local3 = (" --> " + (this.pem.gm.Settings.towerSettings.type[this.Type].upgrade[(this.Upgrade + 1)].Frequency / 1000));
_local4 = (" --> " + this.pem.gm.Settings.towerSettings.type[this.Type].upgrade[(this.Upgrade + 1)].Damage);
_local5 = ("\rUpgrade Cost: " + this.pem.gm.Settings.towerSettings.type[this.Type].upgrade[(this.Upgrade + 1)].Cost);
trace("Upgrade button appears");
this.pem.gm.uim.ub.Appear();
} else {
if (IJustUpgradedAllTheWay == false){
this.pem.gm.ktk.TowerJustUpgradedAllTheWay = true;
IJustUpgradedAllTheWay = true;
};
};
this.pem.gm.uim.InfoArea.text = (((((((((((((("Tower Type " + this.Type) + "\rUpgrade: ") + this.Upgrade) + _local1) + "\rRange: ") + this.HowFarDoIShoot) + _local2) + "\rFrequency: ") + (this.HowOftenDoIShoot / 1000)) + _local3) + "\rPower: ") + this.DamageIWillDo) + _local4) + _local5);
this.pem.gm.ktk.Cursor.graphics.clear();
if (this.Type == 0){
this.pem.gm.ktk.Cursor.graphics.lineStyle(2, 0xFF0000);
this.pem.gm.ktk.Cursor.graphics.moveTo(0, 0);
this.pem.gm.ktk.Cursor.graphics.lineTo(0, 5);
this.pem.gm.ktk.Cursor.graphics.moveTo(0, 0);
this.pem.gm.ktk.Cursor.graphics.lineTo(5, 0);
this.pem.gm.ktk.Cursor.graphics.moveTo(0, 20);
this.pem.gm.ktk.Cursor.graphics.lineTo(0, 15);
this.pem.gm.ktk.Cursor.graphics.moveTo(0, 20);
this.pem.gm.ktk.Cursor.graphics.lineTo(5, 20);
this.pem.gm.ktk.Cursor.graphics.moveTo(20, 0);
this.pem.gm.ktk.Cursor.graphics.lineTo(15, 0);
this.pem.gm.ktk.Cursor.graphics.moveTo(20, 0);
this.pem.gm.ktk.Cursor.graphics.lineTo(20, 5);
this.pem.gm.ktk.Cursor.graphics.moveTo(20, 20);
this.pem.gm.ktk.Cursor.graphics.lineTo(15, 20);
this.pem.gm.ktk.Cursor.graphics.moveTo(20, 20);
this.pem.gm.ktk.Cursor.graphics.lineTo(20, 15);
this.pem.gm.ktk.Cursor.graphics.lineStyle(2, 0, 0.25);
this.pem.gm.ktk.Cursor.graphics.drawCircle(10, 10, this.HowFarDoIShoot);
};
if (this.Type == 1){
this.pem.gm.ktk.Cursor.graphics.lineStyle(2, 0xFF0000);
this.pem.gm.ktk.Cursor.graphics.drawCircle(0, 0, 7);
this.pem.gm.ktk.Cursor.graphics.lineStyle(2, 0, 0.25);
this.pem.gm.ktk.Cursor.graphics.drawCircle(0, 0, this.HowFarDoIShoot);
};
}
function DecideWhetherToShoot(){
var _local1:Array;
var _local2:*;
var _local3:Number;
var _local4:Enemy;
_local1 = new Array();
for each (_local2 in this.pem.gm.npem.allEnemies) {
if (_local2 != null){
if (Math.sqrt((Math.pow(Math.abs((this.x - _local2.x)), 2) + Math.pow(Math.abs((this.y - _local2.y)), 2))) < this.HowFarDoIShoot){
_local1.push(_local2);
};
};
};
_local3 = 10000;
if (_local1[(_local1.length - 1)] != null){
for each (_local2 in _local1) {
if (_local2.HowManyTilesLeft() < _local3){
_local3 = _local2.HowManyTilesLeft();
if (WouldAnotherBulletBeWasted(_local2) == false){
_local4 = _local2;
};
};
};
if (_local4 != null){
Shoot(_local4);
};
};
}
function HaveNearbyKeepRedrawItself(){
var _local1:Tile;
var _local2:Tile;
for each (_local1 in this.t) {
for each (_local2 in _local1.NearbyTiles) {
if (_local2.HasKeep == true){
_local2.k.RedrawMyself();
};
};
};
}
function sTimer(_arg1:TimerEvent):void{
DecideWhetherToShoot();
}
function ChangeTimerIntervals(_arg1:Number){
shootingTimer.stop();
shootingTimer.removeEventListener("timer", sTimer);
HowOftenDoIShootMultiplier = _arg1;
shootingTimer = new Timer(Math.round((HowOftenDoIShoot * HowOftenDoIShootMultiplier)), 0);
shootingTimer.addEventListener("timer", sTimer);
shootingTimer.start();
}
function KillMe(_arg1:Boolean){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:int;
trace("I am a tower! I am getting killed!");
if (_arg1 == true){
_local5 = this.TotalGoldICost;
this.pem.gm.Gold = (this.pem.gm.Gold + _local5);
};
if (this.pem.gm.ktk.Selected == this){
this.pem.gm.ktk.CursorDisappear();
};
this.Upgrade = 0;
if (i1 != null){
this.pem.gm.mm.sky.removeChild(i1);
};
if (i2 != null){
this.pem.gm.mm.sky.removeChild(i2);
};
if (i3 != null){
this.pem.gm.mm.sky.removeChild(i3);
};
if (i4 != null){
this.pem.gm.mm.sky.removeChild(i4);
};
for each (_local2 in t) {
_local2.HasTower = false;
_local2.tower = null;
};
shootingTimer.removeEventListener("timer", sTimer);
if (((!((this == null))) && (!((this.parent == null))))){
this.pem.gm.ktk.removeChild(this);
};
for each (_local3 in this.t) {
_local3.HasTower = false;
_local3.tower = null;
};
this.pem.allTowers[MyPlaceInTheArray] = null;
for each (_local4 in this) {
_local4 = null;
};
}
function towerUpgrade(){
var _local1:int;
var _local2:Number;
if (this.pem.gm.Gold >= this.pem.gm.Settings.towerSettings.type[Type].upgrade[(Upgrade + 1)].Cost){
if (this.pem.gm.Settings.towerSettings.type[Type].upgrade[(Upgrade + 1)] != null){
Upgrade = (Upgrade + 1);
_local1 = this.pem.gm.Settings.towerSettings.type[Type].upgrade[Upgrade].Cost;
this.TotalGoldICost = (this.TotalGoldICost + _local1);
this.HowFarDoIShoot = this.pem.gm.Settings.towerSettings.type[Type].upgrade[Upgrade].Range;
this.HowOftenDoIShoot = this.pem.gm.Settings.towerSettings.type[Type].upgrade[Upgrade].Frequency;
this.DamageIWillDo = this.pem.gm.Settings.towerSettings.type[Type].upgrade[Upgrade].Damage;
this.hp = this.pem.gm.Settings.towerSettings.type[Type].upgrade[Upgrade].HP;
this.SplashDamage = this.pem.gm.Settings.towerSettings.type[Type].upgrade[Upgrade].SplashDamage;
this.TowerColor = this.pem.gm.Settings.towerSettings.type[Type].upgrade[Upgrade].Color;
this.pem.gm.Gold = (this.pem.gm.Gold - this.pem.gm.Settings.towerSettings.type[Type].upgrade[Upgrade].Cost);
shootingTimer.stop();
shootingTimer.removeEventListener("timer", sTimer);
shootingTimer = new Timer(Math.round((HowOftenDoIShoot * HowOftenDoIShootMultiplier)), 0);
shootingTimer.addEventListener("timer", sTimer);
shootingTimer.start();
if (this.Type == 0){
if (this.Upgrade == 1){
i1 = new MovieClip();
i1.graphics.beginFill(0);
i1.graphics.drawCircle(0, 0, 2);
i1.x = (this.x + 10);
i1.y = (this.y + 6);
this.pem.gm.mm.sky.addChild(i1);
};
if (this.Upgrade == 2){
i2 = new MovieClip();
i2.graphics.beginFill(0);
i2.graphics.drawCircle(0, 0, 2);
i2.x = (this.x + 6);
i2.y = (this.y + 10);
this.pem.gm.mm.sky.addChild(i2);
};
if (this.Upgrade == 3){
i3 = new MovieClip();
i3.graphics.beginFill(0);
i3.graphics.drawCircle(0, 0, 2);
i3.x = (this.x + 10);
i3.y = (this.y + 14);
this.pem.gm.mm.sky.addChild(i3);
};
if (this.Upgrade == 4){
i4 = new MovieClip();
i4.graphics.beginFill(0);
i4.graphics.drawCircle(0, 0, 2);
i4.x = (this.x + 14);
i4.y = (this.y + 10);
this.pem.gm.mm.sky.addChild(i4);
};
};
if (this.Type == 1){
ji.graphics.clear();
_local2 = 0.75;
ji.graphics.beginFill(this.TowerColor);
ji.graphics.lineStyle(1, 0);
ji.graphics.drawCircle(0, 0, (4.5 * _local2));
ji.graphics.beginFill(this.TowerColor);
ji.graphics.lineStyle(1, 0);
ji.graphics.drawCircle((5 * _local2), (-1.5 * _local2), (2.5 * _local2));
ji.graphics.beginFill(0, 0);
ji.graphics.lineStyle(1, 0);
ji.graphics.moveTo((5 * _local2), (-10 * _local2));
ji.graphics.lineTo((5 * _local2), (10 * _local2));
ji.graphics.moveTo((5 * _local2), (10 * _local2));
ji.graphics.lineTo((6 * _local2), (8 * _local2));
ji.graphics.moveTo((5 * _local2), (10 * _local2));
ji.graphics.lineTo((4 * _local2), (8 * _local2));
};
};
};
ShowInfo();
}
function Pause(){
if (shootingTimer != null){
shootingTimer.stop();
};
}
function WouldAnotherBulletBeWasted(_arg1:Enemy):Boolean{
var _local2:int;
var _local3:Bullet;
_local2 = 0;
for each (_local3 in this.pem.gm.mm.allBullets) {
if (_local3 != null){
if (_local3.WhatIWillHit == _arg1){
_local2 = (_local2 + _local3.DamageIWillDo);
};
};
};
if (_local2 < _arg1.hp){
return (false);
};
return (true);
}
}
}//package
Section 70
//TowerButton (TowerButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
class TowerButton extends SimpleButton {
var buttonDown:Shape;
var buttonOver:Shape;
var Price:TextField;
var buttonHitTest:Shape;
var buttonUp:Shape;
var me:MapEdit;
function TowerButton(_arg1){
this.me = _arg1;
this.x = 490;
this.y = 130;
buttonUp = new Shape();
buttonUp.graphics.beginFill(0xFF00FF);
buttonUp.graphics.drawRect(0, 0, 50, 25);
buttonDown = new Shape();
buttonDown.graphics.beginFill(16733695);
buttonDown.graphics.drawRect(0, 0, 50, 25);
buttonOver = new Shape();
buttonOver.graphics.beginFill(16755455);
buttonOver.graphics.drawRect(0, 0, 50, 25);
buttonHitTest = new Shape();
buttonHitTest.graphics.beginFill(0x999999);
buttonHitTest.graphics.drawRect(0, 0, 50, 25);
this.upState = new TowerImage();
this.downState = new TowerImage();
this.overState = new TowerImage();
this.hitTestState = new TowerImage();
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function DoPrice(){
Price = new TextField();
Price.text = this.me.mm.gm.Settings.towerSettings.type[0].upgrade[0].Cost;
Price.height = 20;
Price.x = (this.x + 3);
Price.y = (this.y + 23);
this.me.mm.gm.ktk.addChild(Price);
}
function Pause(){
this.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Unpause(){
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
var _local2:TowerImage;
this.me.mm.gm.uim.MessageBoard.text = " Tower Clicked!";
this.me.mm.gm.pem.PlacingElement = true;
this.me.mm.gm.pem.WhichElement = 2;
if (this.me.mm.gm.uim.ExplainedTowerOrWallOnce == false){
this.me.mm.gm.uim.Explain("Place this next to the keep.", 10, 50, 120, 20);
this.me.mm.gm.uim.ExplainedTowerOrWallOnce = true;
};
if (this.me.mm.gm.GhostImage != null){
this.me.mm.gm.GhostImage.graphics.clear();
while (this.me.mm.gm.GhostImage.numChildren > 0) {
this.me.mm.gm.GhostImage.removeChildAt((this.me.mm.gm.GhostImage.numChildren - 1));
};
_local2 = new TowerImage();
_local2.x = 10;
_local2.y = 10;
this.me.mm.gm.GhostImage.addChild(_local2);
};
this.me.mm.gm.GhostImage.graphics.beginFill(11184895);
this.me.mm.gm.GhostImage.graphics.lineStyle(2, 0);
this.me.mm.gm.GhostImage.graphics.drawCircle(20, 20, this.me.mm.gm.Settings.towerSettings.type[0].upgrade[0].Range);
this.me.mm.gm.uim.InfoArea.text = (((((((("Tower\r\rShoots at enemies.\r" + "\rCost: ") + this.me.mm.gm.Settings.towerSettings.type[0].upgrade[0].Cost) + "\rRange: ") + this.me.mm.gm.Settings.towerSettings.type[0].upgrade[0].Range) + "\rFrequency: ") + (this.me.mm.gm.Settings.towerSettings.type[0].upgrade[0].Frequency / 1000)) + "\rPower: ") + this.me.mm.gm.Settings.towerSettings.type[0].upgrade[0].Damage);
}
}
}//package
Section 71
//TowerImage (TowerImage)
package {
import flash.display.*;
public dynamic class TowerImage extends MovieClip {
}
}//package
Section 72
//UpgradeButton (UpgradeButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
class UpgradeButton extends SimpleButton {
var buttonDown:MovieClip;
var buttonOver:MovieClip;
var buttonHitTest:Shape;
var uim:UserInterfaceManager;
var buttonUp:MovieClip;
var IHaveAppeared:Boolean;
function UpgradeButton(_arg1){
var _local2:TextFormat;
var _local3:TextField;
super();
this.uim = _arg1;
this.x = 450;
this.y = 330;
IHaveAppeared = false;
_local2 = new TextFormat();
_local2.bold = false;
_local2.size = 11;
_local2.font = "Tahoma";
_local3 = new TextField();
_local3.x = 12;
_local3.y = 3;
_local3.textColor = 0xFFFFFF;
_local3.text = "Upgrade";
buttonUp = new MovieClip();
buttonUp.graphics.beginFill(13260);
buttonUp.graphics.lineStyle(1, 0);
buttonUp.graphics.drawRect(0, 0, 70, 25);
buttonUp.addChild(_local3);
buttonDown = new MovieClip();
buttonDown.graphics.beginFill(13260);
buttonDown.graphics.drawRect(0, 0, 70, 25);
buttonDown.addChild(_local3);
buttonOver = new MovieClip();
buttonOver.graphics.beginFill(13260);
buttonOver.graphics.drawRect(0, 0, 70, 25);
buttonOver.addChild(_local3);
buttonHitTest = new Shape();
buttonHitTest.graphics.beginFill(0x999999);
buttonHitTest.graphics.drawRect(0, 0, 70, 25);
this.upState = buttonOver;
this.downState = buttonOver;
this.overState = buttonOver;
this.hitTestState = buttonHitTest;
_local3.setTextFormat(_local2);
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Disappear(){
if (this.parent == this.uim.gm.ktk){
this.uim.gm.ktk.removeChild(this);
IHaveAppeared = false;
};
}
function Appear(){
if (IHaveAppeared == false){
this.uim.gm.ktk.addChild(this);
this.uim.gm.mm.PutSkyOnTop();
IHaveAppeared = true;
};
}
function Pause(){
this.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Unpause(){
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
this.uim.gm.ktk.Selected.towerUpgrade();
}
}
}//package
Section 73
//UserInterfaceManager (UserInterfaceManager)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
class UserInterfaceManager {
var MessageIsOff:Boolean;
var ExplainedTowerOrWallOnce:Boolean;// = false
var tf:TextFormat;
var ub:UpgradeButton;
var mb:MuteButton;
var sb:StartButton;
var AndSoOnOff:Boolean;// = false
var TheText:TextField;
var gm:GameManager;
var ExplanatoryMessage:MovieClip;
var ghostlybubble:GhostlyBubble;
var messageTimer:Timer;
var rb:ResetButton;
var pb:PauseButton;
var AndSoOn:Boolean;// = false
var InfoArea:TextField;
var MessageBoard:TextField;
function UserInterfaceManager(_arg1:GameManager){
ExplainedTowerOrWallOnce = false;
AndSoOn = false;
AndSoOnOff = false;
super();
this.gm = _arg1;
TheText = new TextField();
ExplanatoryMessage = new MovieClip();
MessageBoard = new TextField();
MessageIsOff = true;
tf = new TextFormat();
tf.bold = false;
tf.size = 10;
tf.font = "Tahoma";
MessageBoard.x = 422;
MessageBoard.y = 20;
MessageBoard.width = 130;
MessageBoard.height = 90;
MessageBoard.text = "";
MessageBoard.setTextFormat(tf);
this.gm.ktk.addChild(MessageBoard);
InfoArea = new TextField();
InfoArea.y = 230;
InfoArea.x = 422;
InfoArea.width = 130;
InfoArea.height = 130;
InfoArea.text = "";
InfoArea.setTextFormat(tf);
this.gm.ktk.addChild(InfoArea);
sb = new StartButton(this);
this.gm.ktk.addChild(sb);
ub = new UpgradeButton(this);
pb = new PauseButton(this);
pb.Appear();
mb = new MuteButton(this);
mb.Appear();
rb = new ResetButton(this);
rb.Appear();
this.gm.mm.PutSkyOnTop();
}
function Explain(_arg1:String, _arg2:int, _arg3:int, _arg4:int, _arg5:int){
messageTimer = new Timer((_arg2 * 1000), 1);
messageTimer.addEventListener("timer", mTimer);
tf.bold = true;
tf.size = 22;
tf.font = "Tahoma";
tf.leftMargin = 5;
TheText.wordWrap = true;
TheText.multiline = true;
TheText.text = _arg1;
TheText.alpha = 0.25;
TheText.x = 240;
TheText.y = 110;
TheText.width = 150;
TheText.height = 90;
TheText.setTextFormat(tf);
ExplanatoryMessage.alpha = 0.25;
this.ExplanatoryMessage.addChild(TheText);
this.gm.mm.theMap.addChild(ExplanatoryMessage);
MessageIsOff = false;
}
function mTimer(_arg1:TimerEvent):void{
if (MessageIsOff == false){
this.gm.mm.theMap.removeChild(ExplanatoryMessage);
messageTimer.stop();
messageTimer.removeEventListener("timer", mTimer);
MessageIsOff = true;
};
}
function ExplainOff(){
if (MessageIsOff == false){
this.gm.mm.theMap.removeChild(ExplanatoryMessage);
messageTimer.removeEventListener("timer", mTimer);
MessageIsOff = true;
};
}
function SetTFForMessages(){
tf.bold = false;
tf.size = 11;
tf.font = "Tahoma";
MessageBoard.setTextFormat(tf);
InfoArea.setTextFormat(tf);
}
}
}//package
Section 74
//Wall (Wall)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
class Wall extends MovieClip {
var hp:int;
var pem:PlayerElementManager;
var t:Tile;
public var posX:int;
public var posY:int;
var MyPlaceInTheArray:int;
function Wall(_arg1:PlayerElementManager, _arg2:int, _arg3:int, _arg4:int){
this.pem = _arg1;
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
this.x = _arg2;
this.y = _arg3;
this.posX = this.x;
this.posY = this.y;
this.hp = _arg4;
this.pem.gm.mm.theMap.allTiles[(this.x / 10)][(this.y / 10)].w = this;
this.t = this.pem.gm.mm.theMap.allTiles[(this.x / 10)][(this.y / 10)];
this.t.HasWall = true;
}
function HaveNearbyTowersRedrawThemselves(){
var _local1:Tile;
for each (_local1 in this.t.NearbyTiles) {
if (_local1.HasTower == true){
_local1.tower.RedrawMyself();
};
};
}
function HaveNearbyKeepRedrawItself(){
var _local1:Tile;
for each (_local1 in this.t.NearbyTiles) {
if (_local1.HasKeep == true){
_local1.k.RedrawMyself();
};
};
}
function KillMe(_arg1:Boolean){
var _local2:*;
var _local3:int;
if (_arg1 == true){
_local3 = this.pem.gm.Settings.wallSettings.Cost;
this.pem.gm.Gold = (this.pem.gm.Gold + _local3);
};
if (((!((this == null))) && (!((this.parent == null))))){
this.pem.gm.ktk.removeChild(this);
};
this.t.HasWall = false;
this.t.w = null;
this.pem.allWalls[MyPlaceInTheArray] = null;
this.pem.SetWallImages(this);
for each (_local2 in this) {
_local2 = null;
};
}
function RemoveChildren(){
while (this.numChildren > 0) {
this.removeChildAt((this.numChildren - 1));
};
}
function Update(){
}
function mouseDown(_arg1:MouseEvent):void{
var _local2:Array;
var _local3:Object;
var _local4:Boolean;
var _local5:Object;
var _local6:MouseEvent;
_local2 = this.pem.gm.ktk.getObjectsUnderPoint(new Point(_arg1.stageX, _arg1.stageY));
for each (_local3 in _local2) {
if (((!((_local3 == this))) && ((_local3.hitTestPoint(_arg1.stageX, _arg1.stageY, true) == true)))){
_local4 = false;
for each (_local5 in _local2) {
if (_local5.parent == _local3){
_local4 = true;
};
};
if (_local4 == false){
_local6 = new MouseEvent(MouseEvent.MOUSE_DOWN);
_local3.dispatchEvent(_local6);
};
};
};
}
function WhatWallAmI(){
var _local1:MovieClip;
var _local2:MovieClip;
var _local3:Shape;
var _local4:Boolean;
var _local5:Boolean;
var _local6:Boolean;
var _local7:Boolean;
var _local8:Boolean;
var _local9:Boolean;
var _local10:Boolean;
var _local11:Boolean;
while (this.numChildren > 0) {
this.removeChildAt((this.numChildren - 1));
};
_local4 = false;
_local5 = false;
_local6 = false;
_local7 = false;
_local8 = false;
_local9 = false;
_local10 = false;
_local11 = false;
if (this.t.nTile != null){
if (this.t.nTile.HasWall == true){
_local5 = true;
};
};
if (this.t.sTile != null){
if (this.t.sTile.HasWall == true){
_local6 = true;
};
};
if (this.t.eTile != null){
if (this.t.eTile.HasWall == true){
_local7 = true;
};
};
if (this.t.wTile != null){
if (this.t.wTile.HasWall == true){
_local4 = true;
};
};
if (this.t.swTile != null){
if (this.t.swTile.HasWall == true){
_local8 = true;
};
};
if (this.t.seTile != null){
if (this.t.seTile.HasWall == true){
_local9 = true;
};
};
if (this.t.nwTile != null){
if (this.t.nwTile.HasWall == true){
_local10 = true;
};
};
if (this.t.neTile != null){
if (this.t.neTile.HasWall == true){
_local11 = true;
};
};
if (((((((_local5) && (_local6))) && (_local7))) && (_local4))){
_local3 = new Shape();
_local3.graphics.beginFill(0xFFFFFF);
_local3.graphics.drawRect(0, 0, 10, 10);
this.addChildAt(_local3, 0);
};
if (((((((_local5) && (_local6))) && (_local7))) && (!(_local4)))){
_local1 = new WWall();
this.addChildAt(_local1, 0);
};
if (((((((_local5) && (_local6))) && (!(_local7)))) && (_local4))){
_local1 = new WWall();
_local1.rotation = 180;
_local1.x = (_local1.x + 10);
_local1.y = (_local1.y + 10);
this.addChildAt(_local1, 0);
};
if (((((((_local5) && (!(_local6)))) && (_local7))) && (_local4))){
_local1 = new WWall();
_local1.rotation = -90;
_local1.y = (_local1.y + 10);
this.addChildAt(_local1, 0);
};
if (((((((!(_local5)) && (_local6))) && (_local7))) && (_local4))){
_local1 = new WWall();
_local1.rotation = 90;
_local1.x = (_local1.x + 10);
this.addChildAt(_local1, 0);
};
if (((((((!(_local5)) && (!(_local6)))) && (_local7))) && (_local4))){
_local1 = new EWWall();
_local1.rotation = -90;
_local1.y = (_local1.y + 10);
this.addChild(_local1);
};
if (((((((!(_local5)) && (_local6))) && (!(_local7)))) && (_local4))){
_local1 = new NWWall();
_local1.rotation = 90;
_local1.x = (_local1.x + 10);
this.addChildAt(_local1, 0);
};
if (((((((!(_local5)) && (_local6))) && (_local7))) && (!(_local4)))){
_local1 = new NWWall();
this.addChildAt(_local1, 0);
};
if (((((((_local5) && (!(_local6)))) && (!(_local7)))) && (_local4))){
_local1 = new NWWall();
_local1.rotation = 180;
_local1.x = (_local1.x + 10);
_local1.y = (_local1.y + 10);
this.addChildAt(_local1, 0);
};
if (((((((_local5) && (!(_local6)))) && (_local7))) && (!(_local4)))){
_local1 = new NWWall();
_local1.rotation = -90;
_local1.y = (_local1.y + 10);
this.addChildAt(_local1, 0);
};
if (((((((_local5) && (_local6))) && (!(_local7)))) && (!(_local4)))){
_local1 = new EWWall();
this.addChildAt(_local1, 0);
};
if (((((((!(_local5)) && (!(_local6)))) && (!(_local7)))) && (_local4))){
_local1 = new NEWWall();
_local1.rotation = 90;
_local1.x = (_local1.x + 10);
this.addChildAt(_local1, 0);
};
if (((((((!(_local5)) && (!(_local6)))) && (_local7))) && (!(_local4)))){
_local1 = new NEWWall();
_local1.rotation = -90;
_local1.y = (_local1.y + 10);
this.addChildAt(_local1, 0);
};
if (((((((!(_local5)) && (_local6))) && (!(_local7)))) && (!(_local4)))){
_local1 = new NEWWall();
this.addChildAt(_local1, 0);
};
if (((((((_local5) && (!(_local6)))) && (!(_local7)))) && (!(_local4)))){
_local1 = new NEWWall();
_local1.rotation = 180;
_local1.x = (_local1.x + 10);
_local1.y = (_local1.y + 10);
this.addChildAt(_local1, 0);
};
if (((((((!(_local5)) && (!(_local6)))) && (!(_local7)))) && (!(_local4)))){
_local1 = new NSEWWall();
this.addChildAt(_local1, 0);
};
if (((((!(_local6)) && (!(_local7)))) && (_local9))){
_local2 = new CrossWall();
_local2.x = (_local2.x + 10);
_local2.y = (_local2.y + 10);
this.addChild(_local2);
};
if (((((!(_local6)) && (!(_local4)))) && (_local8))){
_local2 = new CrossWall();
_local2.y = (_local2.y + 10);
this.addChild(_local2);
};
if (((((!(_local5)) && (!(_local4)))) && (_local10))){
_local2 = new CrossWall();
this.addChild(_local2);
};
if (((((!(_local5)) && (!(_local7)))) && (_local11))){
_local2 = new CrossWall();
_local2.x = (_local2.x + 10);
this.addChild(_local2);
};
if (((((!(_local6)) && (_local9))) && (_local7))){
_local2 = new LWall();
_local2.y = (_local2.y + 10);
_local2.x = (_local2.x + 10);
_local2.rotation = 90;
this.addChild(_local2);
};
if (((((_local6) && (_local9))) && (!(_local7)))){
_local2 = new LWall();
_local2.y = (_local2.y + 10);
_local2.x = (_local2.x + 10);
_local2.rotation = -90;
this.addChild(_local2);
};
if (((((!(_local6)) && (_local8))) && (_local4))){
_local2 = new LWall();
_local2.y = (_local2.y + 10);
this.addChild(_local2);
};
if (((((_local6) && (_local8))) && (!(_local4)))){
_local2 = new LWall();
_local2.y = (_local2.y + 10);
_local2.rotation = 180;
this.addChild(_local2);
};
if (((((_local6) && (_local7))) && (!(_local9)))){
_local2 = new LWall();
_local2.y = (_local2.y + 10);
_local2.x = (_local2.x + 10);
this.addChild(_local2);
};
if (((((_local6) && (_local4))) && (!(_local8)))){
_local2 = new LWall();
_local2.y = (_local2.y + 10);
_local2.rotation = 90;
this.addChild(_local2);
};
if (((((_local5) && (_local4))) && (!(_local10)))){
_local2 = new LWall();
_local2.rotation = 180;
this.addChild(_local2);
};
if (((((_local5) && (_local7))) && (!(_local11)))){
_local2 = new LWall();
_local2.rotation = -90;
_local2.x = (_local2.x + 10);
this.addChild(_local2);
};
HaveNearbyTowersRedrawThemselves();
HaveNearbyKeepRedrawItself();
}
function TakeDamage(_arg1:int){
this.hp = (this.hp - _arg1);
if (this.hp < 1){
this.KillMe(false);
};
}
}
}//package
Section 75
//WallButton (WallButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
class WallButton extends SimpleButton {
var Price:TextField;
var me:MapEdit;
function WallButton(_arg1){
this.me = _arg1;
this.x = 530;
this.y = 130;
this.upState = new NSEWWall();
this.downState = new NSEWWall();
this.overState = new NSEWWall();
this.hitTestState = new NSEWWall();
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function DoPrice(){
Price = new TextField();
Price.text = this.me.mm.gm.Settings.wallSettings.Cost;
Price.height = 20;
Price.x = this.x;
Price.y = (this.y + 13);
this.me.mm.gm.ktk.addChild(Price);
}
function Pause(){
this.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Unpause(){
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
var _local2:NSEWWall;
this.me.mm.gm.pem.PlacingElement = true;
this.me.mm.gm.pem.WhichElement = 1;
if (this.me.mm.gm.uim.ExplainedTowerOrWallOnce == false){
this.me.mm.gm.uim.Explain("Place this next to the keep.", 10, 50, 120, 20);
this.me.mm.gm.uim.ExplainedTowerOrWallOnce = true;
};
if (this.me.mm.gm.GhostImage != null){
this.me.mm.gm.GhostImage.graphics.clear();
};
while (this.me.mm.gm.GhostImage.numChildren > 0) {
this.me.mm.gm.GhostImage.removeChildAt((this.me.mm.gm.GhostImage.numChildren - 1));
};
_local2 = new NSEWWall();
_local2.x = 10;
_local2.y = 10;
this.me.mm.gm.GhostImage.addChild(_local2);
this.me.mm.gm.uim.InfoArea.text = ("Wall\r\rPlace these to block\renemies' progress.\r\rCost: " + this.me.mm.gm.Settings.wallSettings.Cost);
}
}
}//package
Section 76
//WallWalkerButton (WallWalkerButton)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
class WallWalkerButton extends SimpleButton {
var Price:TextField;
var me:MapEdit;
var WhatILookLike:MovieClip;
var TowerColor:uint;
function WallWalkerButton(_arg1){
var _local2:Number;
super();
this.me = _arg1;
this.x = 465;
this.y = 140;
WhatILookLike = new MovieClip();
_local2 = 0.75;
WhatILookLike.graphics.beginFill(this.me.mm.gm.Settings.towerSettings.type[1].upgrade[0].Color);
WhatILookLike.graphics.lineStyle(1, 0);
WhatILookLike.graphics.drawCircle(0, 0, (4.5 * _local2));
WhatILookLike.graphics.beginFill(this.me.mm.gm.Settings.towerSettings.type[1].upgrade[0].Color);
WhatILookLike.graphics.lineStyle(1, 0);
WhatILookLike.graphics.drawCircle((5 * _local2), (-1.5 * _local2), (2.5 * _local2));
WhatILookLike.graphics.beginFill(0, 0);
WhatILookLike.graphics.lineStyle(1, 0);
WhatILookLike.graphics.moveTo((5 * _local2), (-10 * _local2));
WhatILookLike.graphics.lineTo((5 * _local2), (10 * _local2));
WhatILookLike.graphics.moveTo((5 * _local2), (10 * _local2));
WhatILookLike.graphics.lineTo((6 * _local2), (8 * _local2));
WhatILookLike.graphics.moveTo((5 * _local2), (10 * _local2));
WhatILookLike.graphics.lineTo((4 * _local2), (8 * _local2));
this.upState = WhatILookLike;
this.downState = WhatILookLike;
this.overState = WhatILookLike;
this.hitTestState = WhatILookLike;
Price = new TextField();
Price.height = 20;
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function DoPrice(){
Price = new TextField();
Price.text = this.me.mm.gm.Settings.towerSettings.type[1].upgrade[0].Cost;
Price.height = 20;
Price.x = (this.x - 7);
Price.y = (this.y + 13);
this.me.mm.gm.ktk.addChild(Price);
}
function Pause(){
this.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function Unpause(){
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
function mouseDown(_arg1:MouseEvent):void{
var _local2:MovieClip;
var _local3:Number;
trace("Wall Walker Button Clicked!");
this.me.mm.gm.pem.PlacingElement = true;
this.me.mm.gm.pem.WhichElement = 3;
if (this.me.mm.gm.uim.ExplainedTowerOrWallOnce == false){
this.me.mm.gm.uim.Explain("Place this next to the keep.", 10, 50, 120, 20);
this.me.mm.gm.uim.ExplainedTowerOrWallOnce = true;
};
if (this.me.mm.gm.GhostImage != null){
this.me.mm.gm.GhostImage.graphics.clear();
while (this.me.mm.gm.GhostImage.numChildren > 0) {
this.me.mm.gm.GhostImage.removeChildAt((this.me.mm.gm.GhostImage.numChildren - 1));
};
_local2 = new MovieClip();
_local3 = 0.75;
_local2.graphics.beginFill(this.TowerColor);
_local2.graphics.lineStyle(1, 0);
_local2.graphics.drawCircle(0, 0, (4.5 * _local3));
_local2.graphics.beginFill(this.TowerColor);
_local2.graphics.lineStyle(1, 0);
_local2.graphics.drawCircle((5 * _local3), (-1.5 * _local3), (2.5 * _local3));
_local2.graphics.beginFill(0, 0);
_local2.graphics.lineStyle(1, 0);
_local2.graphics.moveTo((5 * _local3), (-10 * _local3));
_local2.graphics.lineTo((5 * _local3), (10 * _local3));
_local2.graphics.moveTo((5 * _local3), (10 * _local3));
_local2.graphics.lineTo((6 * _local3), (8 * _local3));
_local2.graphics.moveTo((5 * _local3), (10 * _local3));
_local2.graphics.lineTo((4 * _local3), (8 * _local3));
_local2.x = 15;
_local2.y = 15;
this.me.mm.gm.GhostImage.addChild(_local2);
};
this.me.mm.gm.GhostImage.graphics.beginFill(11184895);
this.me.mm.gm.GhostImage.graphics.lineStyle(2, 0);
this.me.mm.gm.GhostImage.graphics.drawCircle(15, 15, this.me.mm.gm.Settings.towerSettings.type[1].upgrade[0].Range);
this.me.mm.gm.uim.InfoArea.text = (((((((("Wall Walker\r\rStands on the walls and\rshoots at enemies.\r" + "\rCost: ") + this.me.mm.gm.Settings.towerSettings.type[1].upgrade[0].Cost) + "\rRange: ") + this.me.mm.gm.Settings.towerSettings.type[1].upgrade[0].Range) + "\rFrequency: ") + (this.me.mm.gm.Settings.towerSettings.type[1].upgrade[0].Frequency / 1000)) + "\rPower: ") + this.me.mm.gm.Settings.towerSettings.type[1].upgrade[0].Damage);
}
}
}//package
Section 77
//WhiteSquare (WhiteSquare)
package {
import flash.display.*;
public dynamic class WhiteSquare extends MovieClip {
}
}//package
Section 78
//WWall (WWall)
package {
import flash.display.*;
public dynamic class WWall extends MovieClip {
}
}//package