Section 1
//BitString (com.adobe.images.BitString)
package com.adobe.images {
public class BitString {
public var val:int;// = 0
public var len:int;// = 0
}
}//package com.adobe.images
Section 2
//JPGEncoder (com.adobe.images.JPGEncoder)
package com.adobe.images {
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
public class JPGEncoder {
private var fdtbl_UV:Array;
private var std_ac_chrominance_values:Array;
private var std_dc_chrominance_values:Array;
private var ZigZag:Array;
private var YDC_HT:Array;
private var YAC_HT:Array;
private var bytenew:int;// = 0
private var fdtbl_Y:Array;
private var std_ac_chrominance_nrcodes:Array;
private var DU:Array;
private var std_ac_luminance_values:Array;
private var std_dc_chrominance_nrcodes:Array;
private var UVTable:Array;
private var YDU:Array;
private var UDU:Array;
private var byteout:ByteArray;
private var UVAC_HT:Array;
private var UVDC_HT:Array;
private var bytepos:int;// = 7
private var VDU:Array;
private var std_ac_luminance_nrcodes:Array;
private var std_dc_luminance_values:Array;
private var YTable:Array;
private var std_dc_luminance_nrcodes:Array;
private var bitcode:Array;
private var category:Array;
public function JPGEncoder(_arg1:Number=50){
ZigZag = [0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63];
YTable = new Array(64);
UVTable = new Array(64);
fdtbl_Y = new Array(64);
fdtbl_UV = new Array(64);
std_dc_luminance_nrcodes = [0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0];
std_dc_luminance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
std_ac_luminance_nrcodes = [0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125];
std_ac_luminance_values = [1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145, 161, 8, 35, 66, 177, 193, 21, 82, 209, 240, 36, 51, 98, 114, 130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250];
std_dc_chrominance_nrcodes = [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0];
std_dc_chrominance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
std_ac_chrominance_nrcodes = [0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119];
std_ac_chrominance_values = [0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129, 8, 20, 66, 145, 161, 177, 193, 9, 35, 51, 82, 240, 21, 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 130, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242, 243, 244, 245, 246, 247, 248, 249, 250];
bitcode = new Array(0xFFFF);
category = new Array(0xFFFF);
DU = new Array(64);
YDU = new Array(64);
UDU = new Array(64);
VDU = new Array(64);
super();
if (_arg1 <= 0){
_arg1 = 1;
};
if (_arg1 > 100){
_arg1 = 100;
};
var _local2:int;
if (_arg1 < 50){
_local2 = int((5000 / _arg1));
} else {
_local2 = int((200 - (_arg1 * 2)));
};
initHuffmanTbl();
initCategoryNumber();
initQuantTables(_local2);
}
private function initHuffmanTbl():void{
YDC_HT = computeHuffmanTbl(std_dc_luminance_nrcodes, std_dc_luminance_values);
UVDC_HT = computeHuffmanTbl(std_dc_chrominance_nrcodes, std_dc_chrominance_values);
YAC_HT = computeHuffmanTbl(std_ac_luminance_nrcodes, std_ac_luminance_values);
UVAC_HT = computeHuffmanTbl(std_ac_chrominance_nrcodes, std_ac_chrominance_values);
}
private function RGB2YUV(_arg1:BitmapData, _arg2:int, _arg3:int):void{
var _local6:int;
var _local7:uint;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local4:int;
var _local5:int;
while (_local5 < 8) {
_local6 = 0;
while (_local6 < 8) {
_local7 = _arg1.getPixel32((_arg2 + _local6), (_arg3 + _local5));
_local8 = Number(((_local7 >> 16) & 0xFF));
_local9 = Number(((_local7 >> 8) & 0xFF));
_local10 = Number((_local7 & 0xFF));
YDU[_local4] = ((((0.299 * _local8) + (0.587 * _local9)) + (0.114 * _local10)) - 128);
UDU[_local4] = (((-0.16874 * _local8) + (-0.33126 * _local9)) + (0.5 * _local10));
VDU[_local4] = (((0.5 * _local8) + (-0.41869 * _local9)) + (-0.08131 * _local10));
_local4++;
_local6++;
};
_local5++;
};
}
private function writeBits(_arg1:BitString):void{
var _local2:int = _arg1.val;
var _local3:int = (_arg1.len - 1);
while (_local3 >= 0) {
if ((_local2 & uint((1 << _local3)))){
bytenew = (bytenew | uint((1 << bytepos)));
};
_local3--;
bytepos--;
if (bytepos < 0){
if (bytenew == 0xFF){
writeByte(0xFF);
writeByte(0);
} else {
writeByte(bytenew);
};
bytepos = 7;
bytenew = 0;
};
};
}
private function writeWord(_arg1:int):void{
writeByte(((_arg1 >> 8) & 0xFF));
writeByte((_arg1 & 0xFF));
}
private function writeByte(_arg1:int):void{
byteout.writeByte(_arg1);
}
private function writeDHT():void{
var _local1:int;
writeWord(65476);
writeWord(418);
writeByte(0);
_local1 = 0;
while (_local1 < 16) {
writeByte(std_dc_luminance_nrcodes[(_local1 + 1)]);
_local1++;
};
_local1 = 0;
while (_local1 <= 11) {
writeByte(std_dc_luminance_values[_local1]);
_local1++;
};
writeByte(16);
_local1 = 0;
while (_local1 < 16) {
writeByte(std_ac_luminance_nrcodes[(_local1 + 1)]);
_local1++;
};
_local1 = 0;
while (_local1 <= 161) {
writeByte(std_ac_luminance_values[_local1]);
_local1++;
};
writeByte(1);
_local1 = 0;
while (_local1 < 16) {
writeByte(std_dc_chrominance_nrcodes[(_local1 + 1)]);
_local1++;
};
_local1 = 0;
while (_local1 <= 11) {
writeByte(std_dc_chrominance_values[_local1]);
_local1++;
};
writeByte(17);
_local1 = 0;
while (_local1 < 16) {
writeByte(std_ac_chrominance_nrcodes[(_local1 + 1)]);
_local1++;
};
_local1 = 0;
while (_local1 <= 161) {
writeByte(std_ac_chrominance_values[_local1]);
_local1++;
};
}
public function encode(_arg1:BitmapData):ByteArray{
var _local6:int;
var _local7:BitString;
byteout = new ByteArray();
bytenew = 0;
bytepos = 7;
writeWord(65496);
writeAPP0();
writeDQT();
writeSOF0(_arg1.width, _arg1.height);
writeDHT();
writeSOS();
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 0;
bytenew = 0;
bytepos = 7;
var _local5:int;
while (_local5 < _arg1.height) {
_local6 = 0;
while (_local6 < _arg1.width) {
RGB2YUV(_arg1, _local6, _local5);
_local2 = processDU(YDU, fdtbl_Y, _local2, YDC_HT, YAC_HT);
_local3 = processDU(UDU, fdtbl_UV, _local3, UVDC_HT, UVAC_HT);
_local4 = processDU(VDU, fdtbl_UV, _local4, UVDC_HT, UVAC_HT);
_local6 = (_local6 + 8);
};
_local5 = (_local5 + 8);
};
if (bytepos >= 0){
_local7 = new BitString();
_local7.len = (bytepos + 1);
_local7.val = ((1 << (bytepos + 1)) - 1);
writeBits(_local7);
};
writeWord(65497);
return (byteout);
}
private function initCategoryNumber():void{
var _local3:int;
var _local1 = 1;
var _local2 = 2;
var _local4 = 1;
while (_local4 <= 15) {
_local3 = _local1;
while (_local3 < _local2) {
category[(32767 + _local3)] = _local4;
bitcode[(32767 + _local3)] = new BitString();
bitcode[(32767 + _local3)].len = _local4;
bitcode[(32767 + _local3)].val = _local3;
_local3++;
};
_local3 = -((_local2 - 1));
while (_local3 <= -(_local1)) {
category[(32767 + _local3)] = _local4;
bitcode[(32767 + _local3)] = new BitString();
bitcode[(32767 + _local3)].len = _local4;
bitcode[(32767 + _local3)].val = ((_local2 - 1) + _local3);
_local3++;
};
_local1 = (_local1 << 1);
_local2 = (_local2 << 1);
_local4++;
};
}
private function writeDQT():void{
var _local1:int;
writeWord(65499);
writeWord(132);
writeByte(0);
_local1 = 0;
while (_local1 < 64) {
writeByte(YTable[_local1]);
_local1++;
};
writeByte(1);
_local1 = 0;
while (_local1 < 64) {
writeByte(UVTable[_local1]);
_local1++;
};
}
private function writeAPP0():void{
writeWord(65504);
writeWord(16);
writeByte(74);
writeByte(70);
writeByte(73);
writeByte(70);
writeByte(0);
writeByte(1);
writeByte(1);
writeByte(0);
writeWord(1);
writeWord(1);
writeByte(0);
writeByte(0);
}
private function writeSOS():void{
writeWord(65498);
writeWord(12);
writeByte(3);
writeByte(1);
writeByte(0);
writeByte(2);
writeByte(17);
writeByte(3);
writeByte(17);
writeByte(0);
writeByte(63);
writeByte(0);
}
private function processDU(_arg1:Array, _arg2:Array, _arg3:Number, _arg4:Array, _arg5:Array):Number{
var _local8:int;
var _local12:int;
var _local13:int;
var _local14:int;
var _local6:BitString = _arg5[0];
var _local7:BitString = _arg5[240];
var _local9:Array = fDCTQuant(_arg1, _arg2);
_local8 = 0;
while (_local8 < 64) {
DU[ZigZag[_local8]] = _local9[_local8];
_local8++;
};
var _local10:int = (DU[0] - _arg3);
_arg3 = DU[0];
if (_local10 == 0){
writeBits(_arg4[0]);
} else {
writeBits(_arg4[category[(32767 + _local10)]]);
writeBits(bitcode[(32767 + _local10)]);
};
var _local11 = 63;
while ((((_local11 > 0)) && ((DU[_local11] == 0)))) {
_local11--;
};
if (_local11 == 0){
writeBits(_local6);
return (_arg3);
};
_local8 = 1;
while (_local8 <= _local11) {
_local12 = _local8;
while ((((DU[_local8] == 0)) && ((_local8 <= _local11)))) {
_local8++;
};
_local13 = (_local8 - _local12);
if (_local13 >= 16){
_local14 = 1;
while (_local14 <= (_local13 / 16)) {
writeBits(_local7);
_local14++;
};
_local13 = int((_local13 & 15));
};
writeBits(_arg5[((_local13 * 16) + category[(32767 + DU[_local8])])]);
writeBits(bitcode[(32767 + DU[_local8])]);
_local8++;
};
if (_local11 != 63){
writeBits(_local6);
};
return (_arg3);
}
private function initQuantTables(_arg1:int):void{
var _local2:int;
var _local3:Number;
var _local8:int;
var _local4:Array = [16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99];
_local2 = 0;
while (_local2 < 64) {
_local3 = Math.floor((((_local4[_local2] * _arg1) + 50) / 100));
if (_local3 < 1){
_local3 = 1;
} else {
if (_local3 > 0xFF){
_local3 = 0xFF;
};
};
YTable[ZigZag[_local2]] = _local3;
_local2++;
};
var _local5:Array = [17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99];
_local2 = 0;
while (_local2 < 64) {
_local3 = Math.floor((((_local5[_local2] * _arg1) + 50) / 100));
if (_local3 < 1){
_local3 = 1;
} else {
if (_local3 > 0xFF){
_local3 = 0xFF;
};
};
UVTable[ZigZag[_local2]] = _local3;
_local2++;
};
var _local6:Array = [1, 1.387039845, 1.306562965, 1.175875602, 1, 0.785694958, 0.5411961, 0.275899379];
_local2 = 0;
var _local7:int;
while (_local7 < 8) {
_local8 = 0;
while (_local8 < 8) {
fdtbl_Y[_local2] = (1 / (((YTable[ZigZag[_local2]] * _local6[_local7]) * _local6[_local8]) * 8));
fdtbl_UV[_local2] = (1 / (((UVTable[ZigZag[_local2]] * _local6[_local7]) * _local6[_local8]) * 8));
_local2++;
_local8++;
};
_local7++;
};
}
private function writeSOF0(_arg1:int, _arg2:int):void{
writeWord(65472);
writeWord(17);
writeByte(8);
writeWord(_arg2);
writeWord(_arg1);
writeByte(3);
writeByte(1);
writeByte(17);
writeByte(0);
writeByte(2);
writeByte(17);
writeByte(1);
writeByte(3);
writeByte(17);
writeByte(1);
}
private function computeHuffmanTbl(_arg1:Array, _arg2:Array):Array{
var _local7:int;
var _local3:int;
var _local4:int;
var _local5:Array = new Array();
var _local6 = 1;
while (_local6 <= 16) {
_local7 = 1;
while (_local7 <= _arg1[_local6]) {
_local5[_arg2[_local4]] = new BitString();
_local5[_arg2[_local4]].val = _local3;
_local5[_arg2[_local4]].len = _local6;
_local4++;
_local3++;
_local7++;
};
_local3 = (_local3 * 2);
_local6++;
};
return (_local5);
}
private function fDCTQuant(_arg1:Array, _arg2:Array):Array{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:int;
var _local23:int;
_local22 = 0;
while (_local22 < 8) {
_local3 = (_arg1[(_local23 + 0)] + _arg1[(_local23 + 7)]);
_local10 = (_arg1[(_local23 + 0)] - _arg1[(_local23 + 7)]);
_local4 = (_arg1[(_local23 + 1)] + _arg1[(_local23 + 6)]);
_local9 = (_arg1[(_local23 + 1)] - _arg1[(_local23 + 6)]);
_local5 = (_arg1[(_local23 + 2)] + _arg1[(_local23 + 5)]);
_local8 = (_arg1[(_local23 + 2)] - _arg1[(_local23 + 5)]);
_local6 = (_arg1[(_local23 + 3)] + _arg1[(_local23 + 4)]);
_local7 = (_arg1[(_local23 + 3)] - _arg1[(_local23 + 4)]);
_local11 = (_local3 + _local6);
_local14 = (_local3 - _local6);
_local12 = (_local4 + _local5);
_local13 = (_local4 - _local5);
_arg1[(_local23 + 0)] = (_local11 + _local12);
_arg1[(_local23 + 4)] = (_local11 - _local12);
_local15 = ((_local13 + _local14) * 0.707106781);
_arg1[(_local23 + 2)] = (_local14 + _local15);
_arg1[(_local23 + 6)] = (_local14 - _local15);
_local11 = (_local7 + _local8);
_local12 = (_local8 + _local9);
_local13 = (_local9 + _local10);
_local19 = ((_local11 - _local13) * 0.382683433);
_local16 = ((0.5411961 * _local11) + _local19);
_local18 = ((1.306562965 * _local13) + _local19);
_local17 = (_local12 * 0.707106781);
_local20 = (_local10 + _local17);
_local21 = (_local10 - _local17);
_arg1[(_local23 + 5)] = (_local21 + _local16);
_arg1[(_local23 + 3)] = (_local21 - _local16);
_arg1[(_local23 + 1)] = (_local20 + _local18);
_arg1[(_local23 + 7)] = (_local20 - _local18);
_local23 = (_local23 + 8);
_local22++;
};
_local23 = 0;
_local22 = 0;
while (_local22 < 8) {
_local3 = (_arg1[(_local23 + 0)] + _arg1[(_local23 + 56)]);
_local10 = (_arg1[(_local23 + 0)] - _arg1[(_local23 + 56)]);
_local4 = (_arg1[(_local23 + 8)] + _arg1[(_local23 + 48)]);
_local9 = (_arg1[(_local23 + 8)] - _arg1[(_local23 + 48)]);
_local5 = (_arg1[(_local23 + 16)] + _arg1[(_local23 + 40)]);
_local8 = (_arg1[(_local23 + 16)] - _arg1[(_local23 + 40)]);
_local6 = (_arg1[(_local23 + 24)] + _arg1[(_local23 + 32)]);
_local7 = (_arg1[(_local23 + 24)] - _arg1[(_local23 + 32)]);
_local11 = (_local3 + _local6);
_local14 = (_local3 - _local6);
_local12 = (_local4 + _local5);
_local13 = (_local4 - _local5);
_arg1[(_local23 + 0)] = (_local11 + _local12);
_arg1[(_local23 + 32)] = (_local11 - _local12);
_local15 = ((_local13 + _local14) * 0.707106781);
_arg1[(_local23 + 16)] = (_local14 + _local15);
_arg1[(_local23 + 48)] = (_local14 - _local15);
_local11 = (_local7 + _local8);
_local12 = (_local8 + _local9);
_local13 = (_local9 + _local10);
_local19 = ((_local11 - _local13) * 0.382683433);
_local16 = ((0.5411961 * _local11) + _local19);
_local18 = ((1.306562965 * _local13) + _local19);
_local17 = (_local12 * 0.707106781);
_local20 = (_local10 + _local17);
_local21 = (_local10 - _local17);
_arg1[(_local23 + 40)] = (_local21 + _local16);
_arg1[(_local23 + 24)] = (_local21 - _local16);
_arg1[(_local23 + 8)] = (_local20 + _local18);
_arg1[(_local23 + 56)] = (_local20 - _local18);
_local23++;
_local22++;
};
_local22 = 0;
while (_local22 < 64) {
_arg1[_local22] = Math.round((_arg1[_local22] * _arg2[_local22]));
_local22++;
};
return (_arg1);
}
}
}//package com.adobe.images
Section 3
//Arrangement (com.bobblebrook.garden.fx.Arrangement)
package com.bobblebrook.garden.fx {
import flash.utils.*;
import com.bobblebrook.lisa.math.*;
import com.bobblebrook.lisa.l3d.*;
public class Arrangement extends World3D {
protected var helixLength:Number;// = 1000
protected var helixParent:Node3D;
protected var particles:Array;
protected var state:int;// = 0
protected var numParts:Number;// = 30
public static const CIRCLE:int = 1;
public static const TORUS:int = 3;
public static const FALLING:int = 2;
public static const HELIX:int = 0;
public function Arrangement(){
var _local2:FlowerParticle;
super();
this.activeCamera = new Camera3D();
this.activeCamera.setPosition(new Vector3D(0, 0, -300, 1));
this.activeCamera.setScreen(550, 400);
helixParent = new Node3D();
this.addChildNode(helixParent);
this.activeCamera.nearClip = 100;
particles = [];
var _local1:int;
while (_local1 < numParts) {
_local2 = new FlowerParticle();
this.addChild(_local2);
helixParent.addChildNode(_local2);
particles.push(_local2);
_local2.setTexture(new getDefinitionByName(("flw" + ((_local1 % 20) + 1)))(126, 126));
_local2.setPos(new Vector3D(((Math.random() * 600) - 300), ((Math.random() * 600) - 300), 0, 1));
_local1++;
};
setState(FALLING);
this.process();
}
public function setState(_arg1:int):void{
var _local2:int;
var _local3:FlowerParticle;
var _local5:Vector3D;
state = _arg1;
var _local4:Matrix3D = helixParent.matrix;
_local2 = 0;
while (_local2 < particles.length) {
_local3 = particles[_local2];
_local3.setPos(_local4.postMultiplyVector(_local3.getPosition()));
_local3.counter = 0;
_local2++;
};
_local4.setToIdentity();
switch (state){
case TORUS:
_local2 = 0;
while (_local2 < particles.length) {
_local3 = particles[_local2];
_local5 = new Vector3D(300, 0, 0, 1);
Matrix3D.yRotationMatrix(((Number(_local2) * Constants.TWO_PI) / numParts)).postMultiplyVectorAndStoreIn(_local5, _local5);
_local3.setTargetPos(_local5);
_local2++;
};
break;
case HELIX:
_local2 = 0;
while (_local2 < particles.length) {
_local3 = particles[_local2];
_local5 = new Vector3D(0, 0, 0, 1);
_local5.y = ((-(Number(Math.floor((_local2 / 2)))) * (helixLength / (numParts / 2))) + (helixLength / 2));
_local5.x = (((_local2 % 2))==0) ? -100 : 100;
Matrix3D.yRotationMatrix(((Number(Math.floor((_local2 / 2))) * Constants.TWO_PI) / (numParts / 2))).postMultiplyVectorAndStoreIn(_local5, _local5);
_local3.setTargetPos(_local5);
_local2++;
};
break;
case CIRCLE:
_local2 = 0;
while (_local2 < particles.length) {
_local3 = particles[_local2];
_local5 = new Vector3D(((Math.sin((((5 * Constants.TWO_PI) * Number(_local2)) / numParts)) * 50) + 200), 0, 0, 1);
Matrix3D.zRotationMatrix(((Number(_local2) * Constants.TWO_PI) / numParts)).postMultiplyVectorAndStoreIn(_local5, _local5);
_local3.setTargetPos(_local5);
_local2++;
};
break;
case FALLING:
_local2 = 0;
while (_local2 < particles.length) {
_local3 = particles[_local2];
_local5 = new Vector3D(((Math.random() * 1000) - 500), ((Math.random() * -1000) - 500), ((Math.random() * 100) - 50), 1);
_local3.setTargetPos(_local5);
_local2++;
};
break;
};
}
override public function process():void{
var _local1:FlowerParticle;
var _local2:Vector3D;
var _local3:int;
var _local4:Matrix3D;
var _local5:Vector3D;
var _local6:Number;
var _local7:Number;
switch (state){
case HELIX:
helixParent.rotateY(0.05);
_local3 = 0;
while (_local3 < particles.length) {
_local1 = particles[_local3];
_local2 = _local1.targetPos;
_local2.y = (_local2.y + 5);
if (_local2.y > (helixLength / 2)){
_local2.y = (_local2.y - helixLength);
};
if (_local1.counter == 1){
_local1.setTargetPos(_local2);
};
_local3++;
};
break;
case CIRCLE:
helixParent.rotateZ(-0.03);
break;
case TORUS:
helixParent.rotateY(0.02);
_local4 = helixParent.matrix;
_local3 = 0;
while (_local3 < particles.length) {
_local1 = particles[_local3];
_local5 = _local4.postMultiplyVector(_local1.targetPos);
_local2 = _local1.targetPos;
_local6 = Math.abs((_local5.x / 350));
if (_local6 > 1){
_local6 = 1;
};
_local6 = (1 - _local6);
_local6 = Animation.sCurveCos(_local6);
if (_local1.counter == 1){
_local1.setTargetPos(_local2);
};
_local3++;
};
break;
case FALLING:
_local3 = 0;
while (_local3 < particles.length) {
_local1 = particles[_local3];
_local2 = _local1.targetPos;
_local2.y = (_local2.y + ((Math.random() * 2) + 4));
_local2.x = (_local2.x + Math.sin((_local2.y * 0.02)));
if (_local2.y > (helixLength / 2)){
_local2.y = (_local2.y - helixLength);
};
if (_local1.counter == 1){
_local1.setTargetPos(_local2);
};
_local3++;
};
break;
};
super.process();
while (_local3 < particles.length) {
_local1 = particles[_local3];
_local7 = (1 - ((_local1.z - 200) / 500));
if (_local7 < 0){
_local7 = 0;
};
if (_local7 > 1){
_local7 = 1;
};
_local1.alpha = _local7;
_local3++;
};
}
public function getState():int{
return (state);
}
}
}//package com.bobblebrook.garden.fx
Section 4
//FlowerParticle (com.bobblebrook.garden.fx.FlowerParticle)
package com.bobblebrook.garden.fx {
import flash.display.*;
import com.bobblebrook.lisa.math.*;
import com.bobblebrook.lisa.l3d.*;
import flash.geom.*;
public class FlowerParticle extends Billboard {
protected var container:MovieClip;
public var targetPos:Vector3D;
protected var tex:BitmapData;
public var counterSpeed:Number;// = 0.02
protected var oldPos:Vector3D;
public var counter:Number;
public function FlowerParticle(){
container = new MovieClip();
this.addChild(container);
this.size = 0.6;
targetPos = new Vector3D(0, 0, 0, 1);
oldPos = new Vector3D(0, 0, 0, 1);
counter = 1;
}
public function setTargetPos(_arg1:Vector3D):void{
oldPos = getPosition();
targetPos = _arg1;
}
override public function process():void{
container.rotation = (container.rotation + 2);
if (counter < 1){
counter = (counter + counterSpeed);
if (counter > 1){
counter = 1;
};
};
var _local1:Number = Animation.overshootAndReturn(counter, 3, 0.5);
var _local2:Vector3D = targetPos.copy().subtract(oldPos).multiply(_local1).add(oldPos);
this.setPosition(_local2);
super.process();
}
public function setPos(_arg1:Vector3D):void{
oldPos = _arg1;
targetPos = _arg1.copy();
setPosition(_arg1);
}
public function setTexture(_arg1:BitmapData):void{
this.tex = _arg1;
container.graphics.clear();
container.graphics.beginBitmapFill(tex, new Matrix(1, 0, 0, 1, (-(tex.width) / 2), (-(tex.height) / 2)), false, true);
container.graphics.drawRect((-(tex.width) / 2), (-(tex.height) / 2), tex.width, tex.height);
container.graphics.endFill();
}
}
}//package com.bobblebrook.garden.fx
Section 5
//FloatDictionary (com.bobblebrook.garden.genetics.FloatDictionary)
package com.bobblebrook.garden.genetics {
import com.bobblebrook.lisa.genetics.*;
public class FloatDictionary extends NucleotideDictionary {
override public function getRandomElement():Object{
return (Math.random());
}
override public function mutate(_arg1:Object):Object{
var _local4:Number;
var _local2:Number = (_arg1 as Number);
var _local3:Number = Math.pow(Math.random(), 15);
if (Math.random() < 0.5){
_local4 = -(_local2);
} else {
_local4 = (1 - _local2);
};
_local3 = (_local3 * _local4);
_local2 = (_local2 + _local3);
return (_local2);
}
}
}//package com.bobblebrook.garden.genetics
Section 6
//FuncDictionary (com.bobblebrook.garden.genetics.FuncDictionary)
package com.bobblebrook.garden.genetics {
import com.bobblebrook.lisa.genetics.*;
import com.bobblebrook.garden.operations.*;
public class FuncDictionary extends NucleotideDictionary {
override public function getRandomElement():Object{
var _local4:BaseFunc;
var _local1:Number = (Math.random() * probabilitySum);
var _local2:Number = 0;
var _local3:int;
while (_local3 < probabilities.length) {
_local2 = (_local2 + probabilities[_local3]);
if (_local1 <= _local2){
_local4 = (elements[_local3] as BaseFunc);
_local4 = _local4.copy();
_local4.randomizeOffset();
return (_local4);
};
_local3++;
};
return (null);
}
override public function mutate(_arg1:Object):Object{
var _local2:Object = _arg1;
if (Math.random() < 0){
(_local2 as BaseFunc).randomizeOffset();
} else {
while (_local2 == _arg1) {
_local2 = getRandomElement();
};
};
return (_local2);
}
}
}//package com.bobblebrook.garden.genetics
Section 7
//IO (com.bobblebrook.garden.genetics.IO)
package com.bobblebrook.garden.genetics {
import com.bobblebrook.garden.*;
import flash.utils.*;
import com.bobblebrook.lisa.genetics.*;
import com.bobblebrook.garden.operations.*;
public class IO {
protected static var colorDict:FuncDictionary;
protected static var translationDict:FuncDictionary;
protected static var aHex:Array = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
protected static var rotationDict:FuncDictionary;
protected static var _initialized:Boolean = false;
protected static var floatDict:FloatDictionary;
protected static function decode12BitInt(_arg1:int, _arg2:int, _arg3:int):int{
return ((((_arg1 << 8) | (_arg2 << 4)) | _arg3));
}
protected static function encodeFuncChromosome(_arg1:Chromosome, _arg2:FuncDictionary):String{
var func:BaseFunc;
var funcClass:Class;
var funcID:int;
var offsetEnc:Array;
var chrom = _arg1;
var dict = _arg2;
var initSeq:Array = chrom.getCompleteSequence();
var seq:Array = [];
var dic:Array = dict.getAllElements().map(function (_arg1:Object, _arg2:int, _arg3:Array){
return (Object(_arg1).constructor);
});
var i:int;
while (i < initSeq.length) {
func = initSeq[i];
funcClass = Object(func).constructor;
funcID = dic.indexOf(funcClass);
offsetEnc = encode12BitInt(func.offset);
seq.push(funcID);
seq = seq.concat(offsetEnc);
i = (i + 1);
};
seq = seq.map(intToHex);
return (seq.join(""));
}
protected static function encodeNumberChromosome(_arg1:Chromosome):String{
var _local5:Number;
var _local2:Array = _arg1.getCompleteSequence();
var _local3:Array = [];
var _local4:int;
while (_local4 < _local2.length) {
_local5 = _local2[_local4];
_local3 = _local3.concat(encodeNumber(_local5));
_local4++;
};
_local3 = _local3.map(intToHex);
return (_local3.join(""));
}
protected static function hexToInt(_arg1:String, _arg2:int=0, _arg3:Array=null):int{
return (aHex.indexOf(_arg1));
}
protected static function decodeNumber(_arg1:Array):Number{
var _local4:int;
var _local2:ByteArray = new ByteArray();
_arg1.endian = Endian.BIG_ENDIAN;
var _local3:int;
while (_local3 < (_arg1.length / 2)) {
_local4 = (((_arg1[(_local3 * 2)] as int) << 4) | (_arg1[((_local3 * 2) + 1)] as int));
_local2.writeByte(_local4);
_local3++;
};
_local2.position = 0;
return (_local2.readDouble());
}
public static function initDictionaries(_arg1:FuncDictionary, _arg2:FuncDictionary, _arg3:FuncDictionary, _arg4:FloatDictionary):void{
rotationDict = _arg1;
translationDict = _arg2;
colorDict = _arg3;
floatDict = _arg4;
_initialized = true;
}
public static function codeFromBlossom(_arg1:Blossom):String{
if (!_initialized){
trace("ERROR: IO CLASS NOT INITIALIZED!");
return (null);
};
var _local2 = (encodeFuncChromosome(_arg1.translationChromosome, translationDict) + "x");
_local2 = (_local2 + (encodeFuncChromosome(_arg1.rotationChromosome, rotationDict) + "x"));
_local2 = (_local2 + (encodeFuncChromosome(_arg1.colorChromosome, colorDict) + "x"));
_local2 = (_local2 + encodeNumberChromosome(_arg1.numericChromosome));
return (_local2);
}
protected static function decodeNumberChromosome(_arg1:Array):Chromosome{
var _local5:Array;
var _local6:int;
var _local7:int;
var _local8:Number;
var _local2:Array = [];
var _local3:int;
while (_local3 < (_arg1.length / 16)) {
_local5 = [];
_local6 = (_local3 * 16);
_local7 = 0;
while (_local7 < 16) {
_local5.push(_arg1[(_local6 + _local7)]);
_local7++;
};
_local8 = decodeNumber(_local5);
_local2.push(_local8);
_local3++;
};
var _local4:Chromosome = new Chromosome();
_local4.setSequence(_local2);
return (_local4);
}
protected static function decodeFuncChromosome(_arg1:Array, _arg2:FuncDictionary):Chromosome{
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:int;
var _local12:BaseFunc;
var _local3:Array = _arg2.getAllElements();
var _local4:Array = [];
var _local5:int;
while (_local5 < (_arg1.length / 4)) {
_local7 = _arg1[(_local5 * 4)];
if ((((_local7 < 0)) || ((_local7 >= _local3.length)))){
_local4.push(new BaseFunc());
} else {
_local8 = _arg1[((_local5 * 4) + 1)];
_local9 = _arg1[((_local5 * 4) + 2)];
_local10 = _arg1[((_local5 * 4) + 3)];
_local11 = decode12BitInt(_local8, _local9, _local10);
_local12 = (_local3[_local7] as BaseFunc).copy();
_local12.offset = _local11;
_local4.push(_local12);
};
_local5++;
};
var _local6:Chromosome = new Chromosome();
_local6.setSequence(_local4);
return (_local6);
}
protected static function intToHex(_arg1:int, _arg2:int=0, _arg3:Array=null):String{
if ((((_arg1 >= 0)) && ((_arg1 < aHex.length)))){
return (aHex[_arg1]);
};
return ("#");
}
protected static function encode12BitInt(_arg1:int):Array{
var _local2 = ((_arg1 & 0x0F00) >> 8);
var _local3 = ((_arg1 & 240) >> 4);
var _local4 = (_arg1 & 15);
return ([_local2, _local3, _local4]);
}
public static function blossomFromCode(_arg1:String):Blossom{
var i:int;
var cChar:String;
var ind:int;
var code = _arg1;
if (!_initialized){
trace("ERROR: IO CLASS NOT INITIALIZED!");
return (null);
};
code = code.toLowerCase();
var strippedCode = "";
i = 0;
while (i < (code.length - 1)) {
cChar = code.substr(i, 1);
if ((((cChar == "x")) || (!((aHex.indexOf(cChar) == -1))))){
strippedCode = (strippedCode + cChar);
};
i = (i + 1);
};
code = strippedCode;
var blossom:Blossom = new Blossom();
var chromosomes:Array = code.split("x");
while (chromosomes.length < 4) {
chromosomes.push("0");
};
i = 0;
while (i < 4) {
chromosomes[i] = (chromosomes[i] as String).split("");
chromosomes[i] = (chromosomes[i] as Array).map(function (_arg1:Object, _arg2:int, _arg3:Array){
return (hexToInt((_arg1 as String)));
});
while ((chromosomes[i] as Array).indexOf(-1) != -1) {
ind = (chromosomes[i] as Array).indexOf(-1);
(chromosomes[i] as Array)[ind] = 0;
};
i = (i + 1);
};
while ((chromosomes[0].length % 4) != 0) {
chromosomes[0].push(0);
};
while ((chromosomes[1].length % 4) != 0) {
chromosomes[1].push(0);
};
while ((chromosomes[2].length % 4) != 0) {
chromosomes[2].push(0);
};
while ((chromosomes[3].length % 16) != 0) {
chromosomes[3].push(0);
};
blossom.translationChromosome = decodeFuncChromosome(chromosomes[0], translationDict);
blossom.rotationChromosome = decodeFuncChromosome(chromosomes[1], rotationDict);
blossom.colorChromosome = decodeFuncChromosome(chromosomes[2], colorDict);
blossom.numericChromosome = decodeNumberChromosome(chromosomes[3]);
return (blossom);
}
protected static function encodeNumber(_arg1:Number):Array{
var _local6:int;
var _local7:int;
var _local8:int;
var _local2:ByteArray = new ByteArray();
_local2.endian = Endian.BIG_ENDIAN;
_local2.writeDouble(_arg1);
_local2.position = 0;
var _local3:Array = [];
while (_local2.bytesAvailable != 0) {
_local3.push(_local2.readByte());
};
var _local4:Array = [];
var _local5:int;
while (_local5 < _local3.length) {
_local6 = _local3[_local5];
_local7 = ((_local6 & 240) >> 4);
_local8 = (_local6 & 15);
_local4.push(_local7);
_local4.push(_local8);
_local5++;
};
return (_local4);
}
}
}//package com.bobblebrook.garden.genetics
Section 8
//VariableLengthLab (com.bobblebrook.garden.genetics.VariableLengthLab)
package com.bobblebrook.garden.genetics {
import com.bobblebrook.lisa.genetics.*;
import com.bobblebrook.garden.operations.*;
public class VariableLengthLab extends Lab {
public var addRate:Number;// = 0.001
public var removeRate:Number;// = 0.001
public var switchRate:Number;// = 0.0005
public var flipRate:Number;// = 0.001
public function VariableLengthLab(_arg1:NucleotideDictionary){
super(_arg1);
}
override public function buildRandomChromosome(_arg1:int):Chromosome{
var _local4:Object;
var _local2:Chromosome = new Chromosome();
var _local3:int;
while (_local3 < _arg1) {
_local4 = dict.getRandomElement();
if (!(_local4 is Number)){
_local4 = _local4.copy();
(_local4 as BaseFunc).randomizeOffset();
};
_local2.addElement(_local4);
_local3++;
};
return (_local2);
}
override public function crossOver(_arg1:Chromosome, _arg2:Chromosome, _arg3:Number, _arg4:Number):Chromosome{
var _local11:Object;
var _local12:Object;
var _local13:Object;
var _local14:Object;
var _local15:Object;
var _local5:Chromosome = new Chromosome();
_arg1.resetReadIndex();
_arg2.resetReadIndex();
var _local6:Chromosome = _arg1;
var _local7:Number = Math.random();
if (_local7 < 0.5){
_local6 = _arg2;
};
var _local8:Chromosome = _arg1;
if (_arg2.getLength() > _arg1.getLength()){
_local8 = _arg2;
};
while (_local8.hasNext()) {
_local11 = null;
_local12 = null;
if (_arg1.hasNext()){
_local11 = _arg1.readNext();
};
if (((!((_arg1 == _arg2))) && (_arg2.hasNext()))){
_local12 = _arg2.readNext();
} else {
_local12 = _local11;
};
if (_local11 == null){
_local11 = _local12;
};
if ((((_local11 == null)) || ((_local12 == null)))){
trace("------ LAB: both elements null");
};
if (_local6 == _arg1){
_local13 = _local11;
} else {
_local13 = _local12;
};
if (!(_local13 is Number)){
_local13 = _local13.copy();
};
if (Math.random() < flipRate){
_local13 = dict.mutate(_local13);
};
_local5.addElement(_local13);
if (Math.random() < _arg3){
if (_local6 == _arg1){
_local6 = _arg2;
} else {
_local6 = _arg1;
};
};
};
var _local9:Array = _local5.getCompleteSequence();
var _local10:int;
for (;_local10 < _local9.length;_local10++) {
if ((((Math.random() < removeRate)) && ((_local9.length > 1)))){
_local9.splice(_local10, 1);
_local10--;
} else {
if (Math.random() < addRate){
_local14 = dict.getRandomElement();
if (!(_local14 is Number)){
_local14 = _local14.copy();
(_local14 as BaseFunc).randomizeOffset();
};
_local9.splice(_local10, 0, _local14);
} else {
if ((((Math.random() < switchRate)) && ((_local10 < (_local9.length - 1))))){
_local15 = _local9[_local10];
_local9[_local10] = _local9[(_local10 + 1)];
_local9[(_local10 + 1)] = _local15;
continue;
};
};
};
};
_local5.setSequence(_local9);
return (_local5);
}
}
}//package com.bobblebrook.garden.genetics
Section 9
//Argument (com.bobblebrook.garden.operations.Argument)
package com.bobblebrook.garden.operations {
public class Argument {
public var min:Number;
public var max:Number;
public var skew:Number;// = 2
public var integer:Boolean;// = false
public var midPoint:Number;
public function Argument(){
min = 0.1;
max = 10;
midPoint = 2;
}
public function map(_arg1:Number):Number{
_arg1 = ((_arg1 * 2) - 1);
var _local2:Number = ((_arg1)<0) ? -1 : 1;
_arg1 = Math.pow(Math.abs(_arg1), skew);
if (_local2 == -1){
_arg1 = (((min - midPoint) * _arg1) + midPoint);
} else {
_arg1 = (((max - midPoint) * _arg1) + midPoint);
};
if (_arg1 < min){
_arg1 = min;
};
if (_arg1 > max){
_arg1 = max;
};
if (integer){
_arg1 = Math.round(_arg1);
};
return (_arg1);
}
}
}//package com.bobblebrook.garden.operations
Section 10
//BaseFunc (com.bobblebrook.garden.operations.BaseFunc)
package com.bobblebrook.garden.operations {
import com.bobblebrook.lisa.genetics.*;
public class BaseFunc {
public var offset:int;
protected var args:Array;
protected var cachedArgs:Array;
public function BaseFunc(){
cachedArgs = [];
super();
args = new Array();
randomizeOffset();
}
public function randomizeOffset():void{
offset = Math.floor((Math.random() * 4000));
}
protected function readNext(_arg1:Chromosome):Number{
if (!_arg1.hasNext()){
_arg1.resetReadIndex();
};
return (Number(_arg1.readNext()));
}
public function toString():String{
return (("baF" + offset));
}
public function apply(_arg1:Number):Number{
return (_arg1);
}
public function cacheArguments(_arg1:Chromosome):void{
cachedArgs = [];
setReadIndex(_arg1);
var _local2:int;
while (_local2 < args.length) {
cachedArgs.push(args[_local2].map(readNext(_arg1)));
_local2++;
};
}
public function copy():BaseFunc{
var _local1:BaseFunc = new BaseFunc();
_local1.offset = this.offset;
return (_local1);
}
protected function setReadIndex(_arg1:Chromosome):void{
_arg1.setReadIndex(offset);
}
public function addArgument(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean=false):void{
var _local6:Argument;
_local6 = new Argument();
_local6.min = _arg1;
_local6.max = _arg2;
_local6.midPoint = _arg3;
_local6.skew = _arg4;
_local6.integer = _arg5;
args.push(_local6);
}
}
}//package com.bobblebrook.garden.operations
Section 11
//Bell (com.bobblebrook.garden.operations.Bell)
package com.bobblebrook.garden.operations {
public class Bell extends BaseFunc {
public function Bell(){
this.addArgument(1, 10, 2, 2);
}
override public function toString():String{
return (("bel" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new Bell();
_local1.offset = this.offset;
return (_local1);
}
override public function apply(_arg1:Number):Number{
var _local2:Number = Math.abs(((_arg1 * 2) - 1));
var _local3:Number = cachedArgs[0];
if (_local2 > 1){
_local2 = 1;
};
if (_local2 < 0){
_local2 = 0;
};
return ((1 - ((((Math.pow((1 - Math.abs(((_local2 * 2) - 1))), _local3) - 1) * 0.5) * ((_local2)<0.5) ? 1 : -1) + 0.5)));
}
}
}//package com.bobblebrook.garden.operations
Section 12
//Cosine (com.bobblebrook.garden.operations.Cosine)
package com.bobblebrook.garden.operations {
import com.bobblebrook.lisa.math.*;
public class Cosine extends BaseFunc {
public function Cosine(){
this.addArgument(1, 5, 3, 6, true);
}
override public function toString():String{
return (("cos" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new Cosine();
_local1.offset = this.offset;
return (_local1);
}
override public function apply(_arg1:Number):Number{
var _local2:Number = _arg1;
var _local3:Number = cachedArgs[0];
if (_local2 > 1){
_local2 = 1;
};
if (_local2 < 0){
_local2 = 0;
};
return (-(((Math.cos(((_local2 * Constants.TWO_PI) * _local3)) * 0.5) - 0.5)));
}
}
}//package com.bobblebrook.garden.operations
Section 13
//EaseIn (com.bobblebrook.garden.operations.EaseIn)
package com.bobblebrook.garden.operations {
public class EaseIn extends BaseFunc {
public function EaseIn(){
this.addArgument(1, 10, 2, 8);
}
override public function toString():String{
return (("eIn" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new EaseIn();
_local1.offset = this.offset;
return (_local1);
}
override public function apply(_arg1:Number):Number{
var _local2:Number = _arg1;
var _local3:Number = cachedArgs[0];
if (_local2 > 1){
_local2 = 1;
};
if (_local2 < 0){
_local2 = 0;
};
return (Math.pow(_local2, _local3));
}
}
}//package com.bobblebrook.garden.operations
Section 14
//EaseInThenBounceBack (com.bobblebrook.garden.operations.EaseInThenBounceBack)
package com.bobblebrook.garden.operations {
public class EaseInThenBounceBack extends BaseFunc {
public function EaseInThenBounceBack(){
this.addArgument(1, 10, 2, 4, false);
this.addArgument(0, 1, 0.5, 4, false);
this.addArgument(1, 5, 2, 2, true);
this.addArgument(0, 1, 0.5, 3, false);
this.addArgument(0, 1, 0.9, 2, false);
}
override public function toString():String{
return (("eBB" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new EaseInThenBounceBack();
_local1.offset = this.offset;
return (_local1);
}
override public function apply(_arg1:Number):Number{
var _local8:Number;
var _local9:int;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local2:Number = _arg1;
var _local3:Number = cachedArgs[0];
var _local4:Number = cachedArgs[1];
var _local5:Number = cachedArgs[2];
var _local6:Number = cachedArgs[3];
var _local7:Number = cachedArgs[4];
if (_local2 > 1){
_local2 = 1;
};
if (_local2 < 0){
_local2 = 0;
};
if (_local2 > _local4){
_local8 = 0;
_local9 = 0;
while (_local9 < _local5) {
_local8 = (_local8 + Math.pow(_local7, _local9));
_local9++;
};
_local2 = (((_local2 - _local4) * _local8) / (1 - _local4));
_local10 = 0;
_local11 = 0;
_local9 = 0;
while (_local9 < _local5) {
_local12 = Math.pow(_local7, _local9);
_local11 = (_local11 + _local12);
if (_local2 <= _local11){
_local2 = ((_local2 - _local10) / (_local11 - _local10));
_local13 = _local2;
if (_local13 > 1){
_local13 = 1;
};
if (_local13 < 0){
_local13 = 0;
};
_local2 = (1 - ((Math.sin((_local13 * Math.PI)) * _local12) * _local6));
break;
};
_local10 = _local11;
_local9++;
};
} else {
_local14 = (_local2 / _local4);
if (_local14 > 1){
_local14 = 1;
};
if (_local14 < 0){
_local14 = 0;
};
return (Math.pow(_local14, _local3));
};
return (_local2);
}
}
}//package com.bobblebrook.garden.operations
Section 15
//EaseOut (com.bobblebrook.garden.operations.EaseOut)
package com.bobblebrook.garden.operations {
public class EaseOut extends BaseFunc {
public function EaseOut(){
this.addArgument(1, 10, 2, 8);
}
override public function toString():String{
return (("eOu" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new EaseOut();
_local1.offset = this.offset;
return (_local1);
}
override public function apply(_arg1:Number):Number{
var _local2:Number = _arg1;
var _local3:Number = cachedArgs[0];
if (_local2 > 1){
_local2 = 1;
};
if (_local2 < 0){
_local2 = 0;
};
return ((1 - Math.pow((1 - _local2), _local3)));
}
}
}//package com.bobblebrook.garden.operations
Section 16
//OvershootReturn (com.bobblebrook.garden.operations.OvershootReturn)
package com.bobblebrook.garden.operations {
public class OvershootReturn extends BaseFunc {
public function OvershootReturn(){
this.addArgument(0.01, 10, 1, 2);
this.addArgument(0, 1, 0.5, 2);
}
override public function toString():String{
return (("oRe" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new OvershootReturn();
_local1.offset = this.offset;
return (_local1);
}
override public function apply(_arg1:Number):Number{
var _local2:Number = _arg1;
var _local3:Number = cachedArgs[0];
var _local4:Number = cachedArgs[1];
if (_local2 >= 1){
return (1);
};
var _local5:Number = 1;
if (_local2 >= _local4){
_local5 = ((_local2 - _local4) / (1 - _local4));
_local5 = Math.pow((1 - _local5), _local3);
};
_local2 = Math.pow((_local2 / _local4), _local3);
_local2 = (1 + ((_local2 - 1) * _local5));
return (_local2);
}
}
}//package com.bobblebrook.garden.operations
Section 17
//SCurve (com.bobblebrook.garden.operations.SCurve)
package com.bobblebrook.garden.operations {
public class SCurve extends BaseFunc {
public function SCurve(){
this.addArgument(0.5, 30, 1, 8);
}
override public function toString():String{
return (("sCu" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new SCurve();
_local1.offset = this.offset;
return (_local1);
}
override public function apply(_arg1:Number):Number{
var _local2:Number = _arg1;
var _local3:Number = cachedArgs[0];
if (_local2 > 1){
_local2 = 1;
};
if (_local2 < 0){
_local2 = 0;
};
return (((((Math.pow((1 - Math.abs(((_local2 * 2) - 1))), _local3) - 1) * 0.5) * ((_local2)<0.5) ? 1 : -1) + 0.5));
}
}
}//package com.bobblebrook.garden.operations
Section 18
//SetColor (com.bobblebrook.garden.operations.SetColor)
package com.bobblebrook.garden.operations {
import com.bobblebrook.garden.*;
import flash.display.*;
import com.bobblebrook.lisa.genetics.*;
public class SetColor extends BaseFunc {
public function SetColor(){
this.addArgument(1, 4, 2.5, 1, true);
this.addArgument(0, 1, 0.5, 1, false);
this.addArgument(1, 3, 2, 3, true);
this.addArgument(0, 1, 0, 2, false);
this.addArgument(0, 1, 1, 2, false);
this.addArgument(0, 1, 0, 2, false);
this.addArgument(0, 1, 1, 2, false);
}
public function modifyColor(_arg1:int, _arg2:Chromosome, _arg3:Number, _arg4:Number):int{
var _local8:BitmapData;
var _local5:int = cachedArgs[0];
var _local6:Number = cachedArgs[1];
var _local7:int = cachedArgs[2];
var _local9:Number = cachedArgs[3];
var _local10:Number = cachedArgs[4];
var _local11:Number = cachedArgs[5];
var _local12:Number = cachedArgs[6];
switch (_local5){
case 1:
_local8 = Textures.baseTex;
break;
case 2:
_local8 = Textures.t1;
break;
case 3:
_local8 = Textures.t2;
break;
case 4:
_local8 = Textures.t3;
break;
};
_arg3 = ((_arg3 * (_local10 - _local9)) + _local9);
_arg4 = ((_arg4 * (_local12 - _local11)) + _local11);
var _local13:int = _arg1;
var _local14:int = Textures.getColor(_arg3, _arg4, _local8);
if (_local6 == 0){
return (_local13);
};
if (_local6 == 1){
return (_local14);
};
var _local15 = ((_local13 & 0xFF0000) >> 16);
var _local16 = ((_local14 & 0xFF0000) >> 16);
var _local17 = ((_local13 & 0xFF00) >> 8);
var _local18 = ((_local14 & 0xFF00) >> 8);
var _local19 = (_local13 & 0xFF);
var _local20 = (_local14 & 0xFF);
var _local21:Number = (1 - _local6);
_local15 = int(((_local15 * _local21) + (_local16 * _local6)));
_local17 = int(((_local17 * _local21) + (_local18 * _local6)));
_local19 = int(((_local19 * _local21) + (_local20 * _local6)));
return ((((_local15 << 16) | (_local17 << 8)) | _local19));
}
override public function toString():String{
return (("SCO" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new SetColor();
_local1.offset = this.offset;
return (_local1);
}
}
}//package com.bobblebrook.garden.operations
Section 19
//Spike (com.bobblebrook.garden.operations.Spike)
package com.bobblebrook.garden.operations {
public class Spike extends BaseFunc {
public function Spike(){
this.addArgument(1, 10, 2, 2);
}
override public function toString():String{
return (("spk" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new Spike();
_local1.offset = this.offset;
return (_local1);
}
override public function apply(_arg1:Number):Number{
var _local2:Number = _arg1;
var _local3:Number = cachedArgs[0];
if (_local2 > 1){
_local2 = 1;
};
if (_local2 < 0){
_local2 = 0;
};
return (Math.pow(((_local2 * (1 - _local2)) * 4), _local3));
}
}
}//package com.bobblebrook.garden.operations
Section 20
//TriangleSpike (com.bobblebrook.garden.operations.TriangleSpike)
package com.bobblebrook.garden.operations {
public class TriangleSpike extends BaseFunc {
public function TriangleSpike(){
this.addArgument(1, 10, 2, 2);
}
override public function toString():String{
return (("tSp" + offset));
}
override public function copy():BaseFunc{
var _local1:BaseFunc = new TriangleSpike();
_local1.offset = this.offset;
return (_local1);
}
override public function apply(_arg1:Number):Number{
var _local2:Number = _arg1;
var _local3:Number = cachedArgs[0];
if (_local2 > 1){
_local2 = 1;
};
if (_local2 < 0){
_local2 = 0;
};
return (Math.pow(Math.abs(((((_local2)>0.5) ? (_local2 - 0.5) : (_local2 + 0.5) * 2) - 1)), _local3));
}
}
}//package com.bobblebrook.garden.operations
Section 21
//Blossom (com.bobblebrook.garden.Blossom)
package com.bobblebrook.garden {
import flash.display.*;
import flash.utils.*;
import com.bobblebrook.lisa.genetics.*;
import flash.events.*;
import com.bobblebrook.lisa.math.*;
import com.bobblebrook.garden.operations.*;
import com.bobblebrook.lisa.utils.*;
import flash.geom.*;
public class Blossom extends MovieClip {
private const rotInc:Number = 0.02;
private const offsetInc:Number = 0.02;
public var translationChromosome:Chromosome;
private var profilerTimeForDrawing:Number;// = 0
private var dir:Vector2D;
public var rotationChromosome:Chromosome;
private var spAverageAngles:Number;// = 0
private var complete:Boolean;// = false
public var colorChromosome:Chromosome;
private var rotCounter:Number;
private var multiplier:Number;
private var spNumDirChanges:Number;// = 0
private var spAverageLightness:Number;
private var spAverageHue:Number;
public var numericChromosome:Chromosome;
private var offsetCounter:Number;
private var spAverageSaturation:Number;
private var spOriginalArea:Number;// = 0
public static const DRAWING_COMPLETE:String = "drawing complete";
public static const maxRadius:Number = 35;
public function Blossom(){
dir = new Vector2D(0, 0);
this.buttonMode = true;
}
public function isComplete():Boolean{
return (complete);
}
private function _cacheChrom(_arg1:Chromosome):void{
var _local2:Object;
_arg1.resetReadIndex();
while (_arg1.hasNext()) {
_local2 = _arg1.readNext();
(_local2 as BaseFunc).cacheArguments(numericChromosome);
};
}
public function spGetAverageAngle():Number{
return ((spAverageAngles * Constants.RAD2DEG));
}
private function cacheColors():void{
var _local1:BitmapData = new BitmapData(Blossom.maxRadius, Blossom.maxRadius, true, 0xFFFFFF);
_local1.draw(this, new Matrix(0.5, 0, 0, 0.5, (Blossom.maxRadius / 2), (Blossom.maxRadius / 2)));
var _local2:ByteArray = _local1.getPixels(new Rectangle(0, 0, Blossom.maxRadius, Blossom.maxRadius));
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
while (_local7 < _local2.length) {
if (_local2[_local7] == 0){
} else {
_local6++;
_local7++;
_local3 = (_local3 + _local2[_local7]);
_local7++;
_local4 = (_local4 + _local2[_local7]);
_local7++;
_local5 = (_local5 + _local2[_local7]);
_local7++;
};
_local7 = (_local7 + 4);
};
if (_local6 != 0){
_local3 = (_local3 / _local6);
_local4 = (_local4 / _local6);
_local5 = (_local5 / _local6);
} else {
_local5 = 0;
_local4 = _local5;
_local3 = _local4;
};
var _local8:int = Color.RGBtoHSL(Color.RGBfromChannels(_local3, _local4, _local5));
spAverageHue = Color.getChannel1f(_local8);
spAverageSaturation = Color.getChannel2f(_local8);
spAverageLightness = Color.getChannel3f(_local8);
}
public function spGetAverageLightness():Number{
return (spAverageLightness);
}
private function getColor(_arg1:Number, _arg2:Number, _arg3:Number):int{
var _local4:int = colorChromosomeOp(_arg1, _arg2, _arg3, colorChromosome);
return (_local4);
}
public function spGetAverageSaturation():Number{
return (spAverageSaturation);
}
public function spGetAverageHue():Number{
return (spAverageHue);
}
public function beginDrawing():void{
var _local1:Number;
var _local5:Vector2D;
var _local8:Number;
var _local9:*;
this.graphics.clear();
cacheAll();
multiplier = 0;
spOriginalArea = 0;
spNumDirChanges = 0;
spAverageAngles = 0;
profilerTimeForDrawing = 0;
var _local2:Number = getTimer();
var _local3:Vector2D = new Vector2D(0, 0);
var _local4:Vector2D = new Vector2D(0, 0);
_local5 = new Vector2D(0, 0);
var _local6:Vector2D = new Vector2D(0, 0);
var _local7:Boolean;
rotCounter = 0;
while (rotCounter <= 1) {
_local1 = (rotCounter % 1);
_local8 = chromosomeOp(_local1, translationChromosome);
spOriginalArea = (spOriginalArea + _local8);
if (_local8 > multiplier){
multiplier = _local8;
};
_local4.x = _local5.x;
_local4.y = _local5.y;
_local3.x = 0;
_local3.y = _local8;
_local3.rotate((rotCounter * Constants.TWO_PI));
if (rotCounter > 0){
if (rotCounter > rotInc){
_local6.x = _local5.x;
_local6.y = _local5.y;
};
_local3.subtractAndStoreIn(_local4, _local5);
if (rotCounter > rotInc){
if (_local7 != _local5.clockwise(_local6)){
spNumDirChanges++;
_local7 = !(_local7);
};
_local9 = _local6.angleTo(_local5);
if (!isNaN(_local9)){
spAverageAngles = (spAverageAngles + _local9);
};
};
};
rotCounter = (rotCounter + rotInc);
};
spAverageAngles = (spAverageAngles / (1 / rotInc));
if (multiplier != 0){
multiplier = (maxRadius / multiplier);
};
profilerTimeForDrawing = (profilerTimeForDrawing + (getTimer() - _local2));
rotCounter = 0;
offsetCounter = 0;
complete = false;
this.addEventListener(Event.ENTER_FRAME, draw);
}
private function cacheAll():void{
_cacheChrom(translationChromosome);
_cacheChrom(rotationChromosome);
_cacheChrom(colorChromosome);
}
private function draw(_arg1:Event=null):void{
var _local2:Number;
if (complete){
this.removeEventListener(Event.ENTER_FRAME, draw);
trace(("total ms for drawing: " + profilerTimeForDrawing));
return;
};
var _local3:Number = 300;
var _local4:Number = getTimer();
var _local5:int;
while (_local5 < _local3) {
dir.x = 0;
_local2 = (rotCounter % 1);
dir.y = chromosomeOp(_local2, translationChromosome);
graphics.lineStyle(2, getColor(_local2, dir.y, offsetCounter), 0.5);
dir.y = (dir.y * (multiplier * offsetCounter));
dir.rotate((chromosomeOp(_local2, rotationChromosome) * Constants.TWO_PI));
if (_local2 != 0){
graphics.lineTo(dir.x, dir.y);
} else {
graphics.moveTo(dir.x, dir.y);
};
rotCounter = (rotCounter + rotInc);
if (rotCounter > 1.1){
rotCounter = 0;
offsetCounter = (offsetCounter + offsetInc);
if (offsetCounter > 1.01){
this.dispatchEvent(new Event(DRAWING_COMPLETE));
complete = true;
cacheColors();
return;
};
};
_local5++;
};
profilerTimeForDrawing = (profilerTimeForDrawing + (getTimer() - _local4));
}
public function spGetOriginalArea():Number{
return (spOriginalArea);
}
public function spGetNumDirectionChanges():Number{
return (spNumDirChanges);
}
private function chromosomeOp(_arg1:Number, _arg2:Chromosome):Number{
_arg2.index = 0;
while (_arg2.index < _arg2.sequenceLength) {
_arg1 = BaseFunc(_arg2.readNext()).apply(_arg1);
};
return (_arg1);
}
public function destroy():void{
this.removeEventListener(Event.ENTER_FRAME, draw);
this.numericChromosome = null;
this.colorChromosome = null;
this.rotationChromosome = null;
this.translationChromosome = null;
this.dir = null;
}
private function colorChromosomeOp(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Chromosome):int{
var _local7:BaseFunc;
_arg4.index = 0;
_arg1 = (chromosomeOp(_arg1, translationChromosome) * chromosomeOp(Math.sqrt(_arg3), rotationChromosome));
_arg4.index = 0;
var _local5:Number = _arg1;
var _local6 = 0xFFFFFF;
while (_arg4.index < _arg4.sequenceLength) {
_local7 = BaseFunc(_arg4.readNext());
if ((_local7 is SetColor)){
_local6 = SetColor(_local7).modifyColor(_local6, numericChromosome, _local5, _arg2);
_local5 = _arg1;
} else {
_local5 = _local7.apply(_local5);
};
};
return (_local6);
}
}
}//package com.bobblebrook.garden
Section 22
//Game (com.bobblebrook.garden.Game)
package com.bobblebrook.garden {
import flash.display.*;
import com.bobblebrook.lisa.server.*;
import com.bobblebrook.garden.genetics.*;
import flash.events.*;
import com.bobblebrook.lisa.*;
import com.bobblebrook.lisa.math.*;
import flash.media.*;
import com.bobblebrook.gui.*;
public class Game extends Sprite {
protected const MUSIC_FADE_IN:int = 1;
protected const numPlantRows:Number = 3;
protected const numPlantCols:Number = 5;
protected const plantRowsWidth:Number = 400;
protected const plantColsHeight:Number = 140;
protected const plantRowsCenter:Number = 275;
protected const MUSIC_FADE_OUT:int = 2;
protected const plantColsCenter:Number = 260;
protected const MAX_VOLUME:Number = 0.2;
protected const MUSIC_FADE_IDLE:int = 0;
protected var scrollSpeed:Number;// = 0
protected var active:Boolean;
protected var lab:Laboratory;
protected var volume:Number;// = 0
protected var cA:Plant;// = null
protected var cB:Plant;// = null
protected var plantsComplete:Array;
protected var musicFade:int;// = 0
protected var iteration:int;
protected var plants:Array;
protected var scrollCounter:Number;// = 0
protected var draggedPlant:Plant;// = null
protected var prevPlants:Array;
protected var pleaseWait:MessageContainer;
public static const END_CROSSING:String = "end crossing";
public static const START_CROSSING:String = "start crossing";
public static var startCodes:Array = ["163a0709651f814281d307ad1c120ee81f4c3122x00210538075a05480b710d1a0b82x5bbf587e5a2519f710fe025b5d261df37b940a69582f025c37011ced6a375ef717f8a64952e57b3c47a65b571a631e334d4dx3fdddf66110000003fd0627c0952be1a3fec781498c772363fdb5a3268fffff53fbbd8eba60ba8e63fdb147057391d6c3fe6f6aba650e9733fd22760468000003fd2e70c8b8000003fd184d582dc99f83fdd94ee160000003fbdcc501c0000003fd32735ca8000003fe5fed9de264ba83fc8702f7549d6133fc59e3bd316e2f43fc82178a90000003fd56120d48000003fcdfc8cf803e3823fd11c62400000003fc8efcdea0000003fe61b3701c000003fb80877660000003fe50e62f04000003fc8141b08462a523fd5a629bdc6bf9b3fa29d807772ce8f3fe67703448000003fe639edaf5245963fcc9b1cbc000000", "5e322f13792416200e095ae9828822fa70ba3c75x0e7b0f9d0c9907460d4a06160cc7x10623db11389773e07ac1bf439ca288a1e864ed719a41c30069519f03d161ed559a493f5510459fd039a54dd5bf41532x3fb7b71ff00000003fef9cd20cc000003fd8a020270000003fd15ba6f90000003fe6c96410d882e83fd64957314239063fc2794fbd0000003fcc37f52b0000003fd93dad85ac31de3fb19062460000003fec9089f70000003fd3bab3faf86cc03fe4760e2823d1223fe023962604a75c3fd386ed4a9077ed3fb0d05dce83f2a63fe21a276c4d18df3fbc8902d60000003fdb076e65f0cf2f3fb4149cbc5ca4a13fe6c2b0d70000003fe7a45711c000003fd2dd45178269d53feb2eefde17dc2a3fd86d5ea37ff0ee3fedfeea61ba39983fec3c10964000003fcc75a83e0000003fd343c936182cc93fe41522f7000000", "93e820eb1f449324189d468f041b11a22c991b74x35b031e204a10c44029a1e8d02a4x50d3064b4a188b6e4e0a526f5c4e8b7970adaadf56111bb01ed6a9961b1c194861ea18eba5d458a320f315a9193c14fe5d8e7c5910c61caax3fdb7937000000003fb6cd295f0ca2d03fccc2873e60c3f43fc5170db433708d3fe1d37229657eca3fe6e2bed118d8cc3f8e4dd73fb9731f3f909af293f29ef13f879d621bf8faa13fd6c2451e6600e23fe2318e2e4000003fe8d5e9ffc041dc3fdaba551d0dc0233fd1d537be7fec953fc777657e2d86623fd28e8301392cec3fc018abf1e2993d3fd872c5ed845b773fe0b7ef55c000003fe4f7fac77095c43fc93ef4c9b019923fd5c24915b3447a3fa8337acaa5cbea3fe100aacab48af13fe4d93843791b523fea8952fc8000003fe3cef4958000003febd8348b70b82b3fa75af1b04a75203fc54c9e5049a983", "78a62e3a10a71f2529ad1ca6429838a714d923dbx09f602ab0ba30b7d0dd8055900adx1f9610e713fd6cb216f2143e58d552c32bfd1c865b1119600370179da16b57e08d7c7856018257e1946757c32bac51e6x3fdebe0154fc17d93fb21a53af8041063fb4e451ae32e5603fc4ece90e8897813f939cadef114fe43fea7c7c70ed58903fc11a685c167b443fb1e60e138888d83fba39cda859342f3fe79f41c71c347a3fe291dcadbfff133fda46c6907ffd513fd98255527fffd03fc5b18d130000003fcbf5f03cdd2e463fe4d6763b5387ff3fc496c1bd6c8ec23fe0d4923d5941963fe46b545edc66873fdab658ffb7f64a3fd13d9c4fcabbeb3fe8b94411c000003fe0e1f8e34000003fe7051d78bffffd3fce8ebd0afff78f3fed89f9d54000003fd8cd8ddf6c15093fdf8ef9c92458c23fdb5c43ea7d963b3fe03532acc00000", "865d2ae01117159b5c2827aa12340a5c02e434bcx0a4b016d00ab020706b504a30542x199aaa10409d56b79900116743fa498f0893685d149e13d20a29507213a80a751f844b6c12022c6218644ae81d74227e227ex3fc0451a7b0000003fb68a1d93b54bf83fd210f67e738d533fe5c83fa31026a83fed0a71c77100103fdffe8dfda13f9b3fd424061f440c563fc4ef8e673aec8a3fe05dfe79eb02db3fc37483d561f7873fdaa80172c2a7ed3feac80cac8018963fce0fced863ae1a3fedd9d4a8ccde373fc1f4943d0000003fe376ab4961e8273fe60579888000003fd0702cfe2e72283fef4052a4c199723fe459f5018000003fb5881f54a2a3263feec42b0595e5833fe1921bb86ec9a53fd207334b11a94e3fe5f4268806b5d23f7e683abddcdf823fe5de88ec1ffe923fb9b9930e188e983fe3ee21ea4000003fca7c92f6f3a8d1"];
public function Game(){
plants = [];
plantsComplete = [];
prevPlants = [];
super();
SoundMGR.instance.playMusic("backgroundSound", "bg");
SoundMGR.instance.playMusic("music", "music");
SoundMGR.instance.getChannel("music").soundTransform = new SoundTransform(0);
lab = new Laboratory();
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
this.addEventListener(Event.ENTER_FRAME, process);
process();
}
public function process(_arg1:Event=null):void{
var _local4:Number;
var _local2:SoundChannel = SoundMGR.instance.getChannel("music");
if (musicFade != MUSIC_FADE_IDLE){
_local4 = (0.01 * MAX_VOLUME);
if (musicFade == MUSIC_FADE_OUT){
_local4 = (_local4 * -1);
};
volume = (volume + _local4);
if (volume < 0){
volume = 0;
musicFade = MUSIC_FADE_IDLE;
};
if (volume > MAX_VOLUME){
volume = MAX_VOLUME;
musicFade = MUSIC_FADE_IDLE;
};
};
if (!SoundMGR.instance.musicMuted()){
_local2.soundTransform = new SoundTransform((Math.pow((volume / MAX_VOLUME), 2) * MAX_VOLUME));
};
if (this.pleaseWait != null){
Gauge(this.pleaseWait["gauge"]).setValue(getProgress());
};
scrollCounter = (scrollCounter + scrollSpeed);
if (scrollCounter < 0){
scrollCounter = 0;
};
if (scrollCounter > 1){
scrollCounter = 1;
};
var _local3:Number = Animation.sCurve(scrollCounter, 3);
this.y = ((1 - _local3) * 400);
}
public function gameInProgress():Boolean{
return ((plants.length > 10));
}
public function scrollDown():void{
scrollSpeed = 0.02;
musicFade = MUSIC_FADE_IN;
}
public function getDraggedPlant():Plant{
return (draggedPlant);
}
public function setCrossA(_arg1:Plant):void{
cA = _arg1;
crossIfPossible();
}
public function setCrossB(_arg1:Plant):void{
cB = _arg1;
crossIfPossible();
}
public function clearAll():void{
var _local1:int;
_local1 = 0;
while (_local1 < plants.length) {
Plant(plants[_local1]).remove();
_local1++;
};
plants = [];
_local1 = 0;
while (_local1 < prevPlants.length) {
Plant(prevPlants[_local1]).remove();
_local1++;
};
prevPlants = [];
}
protected function crossIfPossible():void{
var _local1:int;
var _local2:Plant;
if (((!((cA == null))) && (!((cB == null))))){
iteration++;
if ((iteration % 10) == 1){
Tracker.instance.send("iteration", [iteration], 2);
};
_local1 = 0;
while (_local1 < plants.length) {
_local2 = plants[_local1];
_local2.endDrag();
_local1++;
};
this.cross(cA, cB);
this.dispatchEvent(new Event(START_CROSSING));
addWaitMsg();
};
}
public function handleMOver(_arg1:MouseEvent):void{
var _local2:Plant;
if ((((_arg1.target is Sprite)) && ((Sprite(_arg1.target).parent is Plant)))){
_local2 = Plant(Sprite(_arg1.target).parent);
};
}
protected function onAllComplete():void{
var _local1:int;
if (this.pleaseWait != null){
this.removeChild(pleaseWait);
pleaseWait = null;
};
_local1 = 0;
while (_local1 < prevPlants.length) {
Plant(prevPlants[_local1]).remove();
_local1++;
};
prevPlants = [];
var _local2:Array = [];
_local1 = 0;
while (_local1 < plants.length) {
Plant(plants[_local1]).appear();
_local2.push(IO.codeFromBlossom(Plant(plants[_local1]).getBlossomData()));
_local1++;
};
if (plants.length > 10){
CookieMGR.instance.store("codes", _local2);
trace(("game saved. number of codes: " + _local2.length));
} else {
CookieMGR.instance.store("codes", null);
};
SoundMGR.instance.playSound("newFlowers");
active = true;
this.dispatchEvent(new Event(END_CROSSING));
}
public function handlePress(_arg1:MouseEvent):void{
var _local2:Plant;
if ((((_arg1.target is Sprite)) && ((Sprite(_arg1.target).parent is Plant)))){
_local2 = Plant(Sprite(_arg1.target).parent);
if (_local2.active){
_local2.beginDrag();
SoundMGR.instance.playSound("pickup");
draggedPlant = _local2;
};
};
}
protected function onAddedToStage(_arg1:Event):void{
this.stage.addEventListener(MouseEvent.MOUSE_UP, handleRelease);
}
public function getProgress():Number{
var _local1:Number = 0;
var _local2:int;
while (_local2 < plantsComplete.length) {
if (plantsComplete[_local2]){
_local1++;
};
_local2++;
};
return ((_local1 / plantsComplete.length));
}
protected function onPlantComplete(_arg1:Event):void{
var _local2:Plant = Plant(_arg1.target);
var _local3:int = plants.indexOf(_local2);
plantsComplete[_local3] = true;
trace(("complete: " + getProgress()));
if (_local3 == (plants.length - 1)){
onAllComplete();
} else {
_local3++;
Plant(plants[_local3]).beginDrawingBlossom();
};
}
public function newGame():void{
newGameFromArray();
iteration = 0;
}
public function newGameFromArray():void{
var _local4:Number;
var _local5:*;
var _local6:*;
var _local7:Blossom;
var _local8:Plant;
iteration = 0;
active = false;
prevPlants = plants;
var _local1:int;
while (_local1 < prevPlants.length) {
Plant(prevPlants[_local1]).active = false;
_local1++;
};
plants = [];
plantsComplete = [];
var _local2:int;
var _local3:Number = 0;
while (_local3 < 1) {
_local4 = 0;
while (_local4 < numPlantCols) {
_local5 = ((((_local4 / (numPlantCols - 1)) - 0.5) * plantRowsWidth) + plantRowsCenter);
_local6 = ((((_local3 / (numPlantRows - 1)) - 0.5) * plantColsHeight) + plantColsCenter);
_local7 = IO.blossomFromCode(startCodes[_local2]);
_local2++;
_local8 = new Plant();
this.addChild(_local8);
_local8.x = _local5;
_local8.y = _local6;
_local8.getBlossomSprite().addEventListener(MouseEvent.MOUSE_DOWN, handlePress);
_local8.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OVER, handleMOver);
_local8.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OUT, handleMOut);
_local8.setBlossomData(_local7);
_local8.addEventListener(Plant.PREPARATION_COMPLETE, onPlantComplete);
plants.push(_local8);
plantsComplete.push(false);
_local4++;
};
_local3++;
};
Plant(plants[0]).beginDrawingBlossom();
cA = null;
cB = null;
}
public function continueGame():void{
var _local6:Number;
var _local7:*;
var _local8:*;
var _local9:Blossom;
var _local10:Plant;
iteration = 0;
var _local1:Object = CookieMGR.instance.retrieve("codes");
if (_local1 == null){
trace("ERROR: could not continue!");
};
var _local2:Array = (_local1 as Array);
trace(("continuing. number of codes: " + _local2.length));
active = false;
prevPlants = plants;
var _local3:int;
while (_local3 < prevPlants.length) {
Plant(prevPlants[_local3]).active = false;
_local3++;
};
plants = [];
plantsComplete = [];
var _local4:int;
var _local5:Number = 0;
while (_local5 < numPlantRows) {
_local6 = 0;
while (_local6 < numPlantCols) {
_local7 = ((((_local6 / (numPlantCols - 1)) - 0.5) * plantRowsWidth) + plantRowsCenter);
_local8 = ((((_local5 / (numPlantRows - 1)) - 0.5) * plantColsHeight) + plantColsCenter);
_local9 = IO.blossomFromCode(_local2[_local4]);
_local4++;
_local10 = new Plant();
this.addChild(_local10);
_local10.x = _local7;
_local10.y = _local8;
_local10.getBlossomSprite().addEventListener(MouseEvent.MOUSE_DOWN, handlePress);
_local10.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OVER, handleMOver);
_local10.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OUT, handleMOut);
_local10.setBlossomData(_local9);
_local10.addEventListener(Plant.PREPARATION_COMPLETE, onPlantComplete);
plants.push(_local10);
plantsComplete.push(false);
_local6++;
};
_local5++;
};
Plant(plants[0]).beginDrawingBlossom();
cA = null;
cB = null;
}
public function handleRelease(_arg1:MouseEvent):void{
if ((_arg1.target is DropTarget)){
return;
};
var _local2:int;
while (_local2 < plants.length) {
plants[_local2].endDrag();
_local2++;
};
draggedPlant = null;
if ((((_arg1.target is Sprite)) && ((Sprite(_arg1.target).parent is Plant)))){
SoundMGR.instance.playSound("drop");
};
}
public function cross(_arg1:Plant, _arg2:Plant):void{
var _local5:Number;
var _local6:*;
var _local7:*;
var _local8:Blossom;
var _local9:Plant;
active = false;
prevPlants = plants;
plants = [];
plantsComplete = [];
var _local3:int;
while (_local3 < prevPlants.length) {
Plant(prevPlants[_local3]).active = false;
_local3++;
};
var _local4:Number = 0;
while (_local4 < numPlantRows) {
_local5 = 0;
while (_local5 < numPlantCols) {
_local6 = ((((_local5 / (numPlantCols - 1)) - 0.5) * plantRowsWidth) + plantRowsCenter);
_local7 = ((((_local4 / (numPlantRows - 1)) - 0.5) * plantColsHeight) + plantColsCenter);
_local8 = lab.crossFlowers(_arg1.getBlossomData(), _arg2.getBlossomData());
_local9 = new Plant();
this.addChild(_local9);
_local9.x = _local6;
_local9.y = _local7;
_local9.getBlossomSprite().addEventListener(MouseEvent.MOUSE_DOWN, handlePress);
_local9.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OVER, handleMOver);
_local9.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OUT, handleMOut);
_local9.setBlossomData(_local8);
_local9.addEventListener(Plant.PREPARATION_COMPLETE, onPlantComplete);
plants.push(_local9);
plantsComplete.push(false);
_local5++;
};
_local4++;
};
Plant(plants[0]).beginDrawingBlossom();
cA = null;
cB = null;
}
public function scrollUp():void{
musicFade = MUSIC_FADE_OUT;
scrollSpeed = -0.02;
}
public function crossAndReturnData(_arg1:Blossom, _arg2:Blossom):Blossom{
var _local3:Blossom = lab.crossFlowers(_arg1, _arg2);
return (_local3);
}
public function createRandom():void{
var _local3:Number;
var _local4:*;
var _local5:*;
var _local6:Blossom;
var _local7:Plant;
active = false;
prevPlants = plants;
plants = [];
plantsComplete = [];
var _local1:int;
while (_local1 < prevPlants.length) {
Plant(prevPlants[_local1]).active = false;
_local1++;
};
var _local2:Number = 0;
while (_local2 < numPlantRows) {
_local3 = 0;
while (_local3 < numPlantCols) {
_local4 = ((((_local3 / (numPlantCols - 1)) - 0.5) * plantRowsWidth) + plantRowsCenter);
_local5 = ((((_local2 / (numPlantRows - 1)) - 0.5) * plantColsHeight) + plantColsCenter);
_local6 = lab.createRandomFlower(30, 7, 10, 25);
_local7 = new Plant();
this.addChild(_local7);
_local7.x = _local4;
_local7.y = _local5;
_local7.getBlossomSprite().addEventListener(MouseEvent.MOUSE_DOWN, handlePress);
_local7.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OVER, handleMOver);
_local7.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OUT, handleMOut);
_local7.setBlossomData(_local6);
_local7.addEventListener(Plant.PREPARATION_COMPLETE, onPlantComplete);
plants.push(_local7);
plantsComplete.push(false);
_local3++;
};
_local2++;
};
Plant(plants[0]).beginDrawingBlossom();
cA = null;
cB = null;
}
public function handleMOut(_arg1:MouseEvent):void{
}
public function addWaitMsg():void{
SoundMGR.instance.playSound("growing");
pleaseWait = new PleaseWait();
pleaseWait.targetX = 275;
pleaseWait.targetY = 200;
this.addChild(pleaseWait);
}
public function newGameFromFlower(_arg1:Blossom):void{
var _local4:Number;
var _local5:*;
var _local6:*;
var _local7:Blossom;
var _local8:Plant;
iteration = 0;
active = false;
prevPlants = plants;
var _local2:int;
while (_local2 < prevPlants.length) {
Plant(prevPlants[_local2]).active = false;
_local2++;
};
plants = [];
plantsComplete = [];
var _local3:Number = 0;
while (_local3 < numPlantRows) {
_local4 = 0;
while (_local4 < numPlantCols) {
_local5 = ((((_local4 / (numPlantCols - 1)) - 0.5) * plantRowsWidth) + plantRowsCenter);
_local6 = ((((_local3 / (numPlantRows - 1)) - 0.5) * plantColsHeight) + plantColsCenter);
_local7 = lab.crossFlowers(_arg1, _arg1);
_local8 = new Plant();
this.addChild(_local8);
_local8.x = _local5;
_local8.y = _local6;
_local8.getBlossomSprite().addEventListener(MouseEvent.MOUSE_DOWN, handlePress);
_local8.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OVER, handleMOver);
_local8.getBlossomSprite().addEventListener(MouseEvent.MOUSE_OUT, handleMOut);
_local8.setBlossomData(_local7);
_local8.addEventListener(Plant.PREPARATION_COMPLETE, onPlantComplete);
plants.push(_local8);
plantsComplete.push(false);
_local4++;
};
_local3++;
};
Plant(plants[0]).beginDrawingBlossom();
cA = null;
cB = null;
}
}
}//package com.bobblebrook.garden
Section 23
//Laboratory (com.bobblebrook.garden.Laboratory)
package com.bobblebrook.garden {
import com.bobblebrook.garden.genetics.*;
import com.bobblebrook.garden.operations.*;
public class Laboratory {
var colorDict:FuncDictionary;
var translationDict:FuncDictionary;
var colorLab:VariableLengthLab;
var rotationLab:VariableLengthLab;
var floatLab:VariableLengthLab;
var floatDict:FloatDictionary;
var rotationDict:FuncDictionary;
var translationLab:VariableLengthLab;
public function Laboratory(){
rotationDict = new FuncDictionary();
translationDict = new FuncDictionary();
colorDict = new FuncDictionary();
floatDict = new FloatDictionary();
rotationLab = new VariableLengthLab(rotationDict);
translationLab = new VariableLengthLab(translationDict);
colorLab = new VariableLengthLab(colorDict);
floatLab = new VariableLengthLab(floatDict);
rotationLab.addRate = 0.002;
rotationLab.flipRate = 0.005;
rotationLab.removeRate = 0.002;
rotationLab.switchRate = 0.002;
translationLab.addRate = 0.002;
translationLab.flipRate = 0.005;
translationLab.removeRate = 0.002;
translationLab.switchRate = 0.002;
colorLab.addRate = 0.01;
colorLab.flipRate = 0.01;
colorLab.removeRate = 0.01;
colorLab.switchRate = 0.01;
floatLab.addRate = 0;
floatLab.flipRate = 0.5;
floatLab.removeRate = 0;
floatLab.switchRate = 0.005;
var _local1:BaseFunc = new BaseFunc();
var _local2:BaseFunc = new SCurve();
var _local3:EaseIn = new EaseIn();
var _local4:EaseOut = new EaseOut();
var _local5:Cosine = new Cosine();
var _local6:Spike = new Spike();
var _local7:TriangleSpike = new TriangleSpike();
var _local8:Bell = new Bell();
var _local9:EaseInThenBounceBack = new EaseInThenBounceBack();
var _local10:OvershootReturn = new OvershootReturn();
var _local11:SetColor = new SetColor();
rotationDict.addElement(_local1, 1);
rotationDict.addElement(_local2, 0.2);
rotationDict.addElement(_local3, 0.1);
rotationDict.addElement(_local4, 0.1);
translationDict.addElement(_local1, 0.3);
translationDict.addElement(_local2, 0.3);
translationDict.addElement(_local3, 0.3);
translationDict.addElement(_local4, 0.3);
translationDict.addElement(_local5, 0.1);
translationDict.addElement(_local6, 0.1);
translationDict.addElement(_local7, 0.1);
translationDict.addElement(_local8, 0.1);
translationDict.addElement(_local9, 0.18);
translationDict.addElement(_local10, 0.18);
colorDict.addElement(_local11, 0.4);
colorDict.addElement(_local2, 1.2);
colorDict.addElement(_local3, 0.2);
colorDict.addElement(_local4, 0.2);
colorDict.addElement(_local5, 0.3);
colorDict.addElement(_local1, 0.8);
colorDict.addElement(_local9, 0.2);
colorDict.addElement(_local10, 0.2);
colorDict.addElement(_local6, 0.1);
colorDict.addElement(_local7, 0.1);
colorDict.addElement(_local8, 0.1);
IO.initDictionaries(rotationDict, translationDict, colorDict, floatDict);
}
public function createRandomFlower(_arg1:int, _arg2:int, _arg3:int, _arg4:int):Blossom{
var _local5:Blossom = new Blossom();
_local5.numericChromosome = floatLab.buildRandomChromosome(_arg1);
_local5.rotationChromosome = rotationLab.buildRandomChromosome(_arg2);
_local5.translationChromosome = translationLab.buildRandomChromosome(_arg3);
_local5.colorChromosome = colorLab.buildRandomChromosome(_arg4);
return (_local5);
}
public function crossFlowers(_arg1:Blossom, _arg2:Blossom):Blossom{
var _local3:Blossom = new Blossom();
_local3.numericChromosome = floatLab.crossOver(_arg1.numericChromosome, _arg2.numericChromosome, 0, 0);
_local3.rotationChromosome = rotationLab.crossOver(_arg1.rotationChromosome, _arg2.rotationChromosome, 0, 0);
_local3.translationChromosome = translationLab.crossOver(_arg1.translationChromosome, _arg2.translationChromosome, 0, 0);
_local3.colorChromosome = colorLab.crossOver(_arg1.colorChromosome, _arg2.colorChromosome, 0, 0);
return (_local3);
}
}
}//package com.bobblebrook.garden
Section 24
//Plant (com.bobblebrook.garden.Plant)
package com.bobblebrook.garden {
import flash.display.*;
import flash.events.*;
import com.bobblebrook.lisa.*;
import com.bobblebrook.lisa.math.*;
import com.bobblebrook.gui.*;
import com.bobblebrook.*;
import flash.geom.*;
import flash.filters.*;
public class Plant extends MovieClip {
protected const removeLength:Number = 30;
protected const stemColorOuter:int = 8437808;
protected const stemColorInner:int = 12641133;
protected const mOverInc:Number = 0.125;
protected var removing:Boolean;// = false
protected var rotSpring:SimpleSpring;
protected var prepComplete:Boolean;// = false
protected var stem:Sprite;
protected var dragging:Boolean;// = false
protected var stemAnchors:Array;
protected var removeCounter:Number;// = 0
protected var mOverCounter:Number;// = 0
protected var mOver:Boolean;// = false
protected var blossom:Sprite;
public var active:Boolean;// = true
protected var blossomData:Blossom;
protected var currentTarget:DropTarget;// = null
protected var oldMouse:Vector2D;
public static const PREPARATION_COMPLETE:String = "prep complete";
public function Plant(){
var _local2:SimpleSpring;
super();
stem = new Sprite();
blossom = new Sprite();
var _local1:Number = 3;
stem.filters = [new GlowFilter(stemColorOuter, 1, _local1, _local1, 3, 1, true)];
this.addChild(stem);
this.addChild(blossom);
blossom.buttonMode = true;
stemAnchors = [];
_local2 = new SimpleSpring();
_local2.setInertia(0.8);
_local2.setStiffness(0.3);
_local2.setParticlePos(new Vector2D(0, 250));
_local2.setSpringPos(new Vector2D(0, 250));
stemAnchors.push(_local2);
_local2 = new SimpleSpring();
_local2.setInertia(0.75);
_local2.setStiffness(0.05);
_local2.setParticlePos(new Vector2D(0, 250));
_local2.setSpringPos(new Vector2D(((Math.random() * 60) - 30), -(((Math.random() * 10) + 10))));
_local2.getParticleDir().add(new Vector2D(((Math.random() * 100) - 50), ((Math.random() * 100) - 50)));
stemAnchors.push(_local2);
_local2 = new SimpleSpring();
_local2.setInertia(0.85);
_local2.setStiffness(0.05);
_local2.setParticlePos(new Vector2D(0, 250));
_local2.setSpringPos(new Vector2D(0, 0));
_local2.getParticleDir().add(new Vector2D(((Math.random() * 100) - 50), ((Math.random() * 100) - 50)));
stemAnchors.push(_local2);
rotSpring = new SimpleSpring();
rotSpring.setInertia(0.85);
rotSpring.setStiffness(0.4);
this.blossom.addEventListener(MouseEvent.MOUSE_OVER, handleMOver, false, 0, true);
this.blossom.addEventListener(MouseEvent.MOUSE_OUT, handleMOut, false, 0, true);
}
public function destroy():void{
this.removeEventListener(Event.ENTER_FRAME, process);
blossomData.removeEventListener(Blossom.DRAWING_COMPLETE, onDrawingComplete);
this.blossom.removeEventListener(MouseEvent.MOUSE_OVER, handleMOver);
this.blossom.removeEventListener(MouseEvent.MOUSE_OUT, handleMOut);
rotSpring = null;
oldMouse = null;
stemAnchors = null;
this.removeChild(blossom);
this.removeChild(stem);
blossomData.destroy();
blossomData = null;
blossom = null;
stem = null;
}
public function process(_arg1:Event=null):void{
var _local2:SimpleSpring;
var _local3:Vector2D;
var _local4:Number;
var _local5:Number;
var _local8:Point;
if (mOver){
mOverCounter = (mOverCounter + mOverInc);
if (mOverCounter > 1){
mOverCounter = 1;
};
} else {
mOverCounter = (mOverCounter - mOverInc);
if (mOverCounter < 0){
mOverCounter = 0;
};
};
if (dragging){
mOverCounter = 1;
};
if (!active){
mOverCounter = 0;
};
blossom.scaleX = (blossom.scaleY = ((Animation.overshootAndReturn(mOverCounter, 3, 0.5) * 0.5) + 1));
_local3 = new Vector2D(mouseX, mouseY);
_local3.subtract(stemAnchors[2].getSpringPos());
_local4 = _local3.length();
_local5 = (_local4 / 200);
if (_local5 > 1){
_local5 = 1;
};
_local5 = (1 - _local5);
_local5 = Math.pow(_local5, 1.5);
_local3.multiply((0.2 * _local5));
stemAnchors[2].getParticlePos().add(_local3);
var _local6:int;
while (_local6 < stemAnchors.length) {
if (active){
_local3 = new Vector2D(mouseX, mouseY);
if (_local3.x > ScreenMGR.screenWidth){
_local3.x = ScreenMGR.screenWidth;
};
if (_local3.x < -(ScreenMGR.screenWidth)){
_local3.x = -(ScreenMGR.screenWidth);
};
if (_local3.y > ScreenMGR.screenHeight){
_local3.y = ScreenMGR.screenHeight;
};
if (_local3.y < -(ScreenMGR.screenHeight)){
_local3.y = -(ScreenMGR.screenHeight);
};
if (oldMouse == null){
oldMouse = _local3.copy();
};
_local4 = _local3.length();
_local3.subtract(oldMouse);
_local5 = (_local4 / 200);
if (_local5 > 1){
_local5 = 1;
};
_local5 = (1 - _local5);
_local3.multiply((_local5 * 0.5));
if (_local6 != 0){
stemAnchors[_local6].getParticlePos().add(_local3);
};
};
stemAnchors[_local6].process();
_local6++;
};
_local3 = new Vector2D(mouseX, mouseY);
if (_local3.x > ScreenMGR.screenWidth){
_local3.x = ScreenMGR.screenWidth;
};
if (_local3.x < -(ScreenMGR.screenWidth)){
_local3.x = -(ScreenMGR.screenWidth);
};
if (_local3.y > ScreenMGR.screenHeight){
_local3.y = ScreenMGR.screenHeight;
};
if (_local3.y < -(ScreenMGR.screenHeight)){
_local3.y = -(ScreenMGR.screenHeight);
};
if (((dragging) && (active))){
_local2 = stemAnchors[2];
_local2.setParticlePosXY(_local3.x, _local3.y);
};
if (currentTarget != null){
_local2 = stemAnchors[2];
_local8 = new Point(currentTarget.x, currentTarget.y);
_local8 = this.globalToLocal(_local8);
_local2.setParticlePosXY(_local8.x, _local8.y);
};
oldMouse = _local3.copy();
stem.graphics.clear();
stem.graphics.lineStyle(3, stemColorInner);
stem.graphics.moveTo(stemAnchors[0].getParticlePos().x, stemAnchors[0].getParticlePos().y);
stem.graphics.curveTo(stemAnchors[1].getParticlePos().x, stemAnchors[1].getParticlePos().y, stemAnchors[2].getParticlePos().x, stemAnchors[2].getParticlePos().y);
blossom.x = stemAnchors[2].getParticlePos().x;
blossom.y = stemAnchors[2].getParticlePos().y;
rotSpring.setSpringPos(new Vector2D(0, stemAnchors[2].getParticleDir().x));
rotSpring.process();
var _local7:Number = rotSpring.getParticlePos().y;
blossom.rotation = _local7;
if (removing){
removeCounter++;
if (removeCounter == removeLength){
this.destroy();
};
};
}
public function remove():void{
var _local2:SimpleSpring;
var _local1:* = 1;
while (_local1 < stemAnchors.length) {
_local2 = stemAnchors[_local1];
_local2.setSpringPosXY(0, (_local1 * 400));
_local1++;
};
removing = true;
}
public function handleMOver(_arg1:MouseEvent):void{
mOver = true;
}
public function beginDrag():void{
dragging = true;
}
public function setDropTarget(_arg1:DropTarget):void{
currentTarget = _arg1;
if (currentTarget != null){
SoundMGR.instance.playSound("dropTarget");
this.blossom.visible = false;
} else {
this.blossom.visible = true;
};
}
public function onDrawingComplete(_arg1:Event=null):void{
prepComplete = true;
this.dispatchEvent(new Event(PREPARATION_COMPLETE));
}
public function handleMOut(_arg1:MouseEvent):void{
mOver = false;
}
public function setBlossomData(_arg1:Blossom):void{
blossomData = _arg1;
if (!blossomData.isComplete()){
blossomData.addEventListener(Blossom.DRAWING_COMPLETE, onDrawingComplete);
} else {
onDrawingComplete();
};
}
public function beginDrawingBlossom():void{
if (!blossomData.isComplete()){
blossomData.beginDrawing();
} else {
onDrawingComplete();
};
}
public function endDrag():void{
dragging = false;
}
public function getBlossomSprite():Sprite{
return (blossom);
}
public function appear():void{
var _local1:BitmapData = new BitmapData((Blossom.maxRadius * 2), (Blossom.maxRadius * 2), true, 0xFFFFFF);
_local1.draw(blossomData, new Matrix(1, 0, 0, 1, Blossom.maxRadius, Blossom.maxRadius));
blossom.graphics.beginBitmapFill(_local1, new Matrix(1, 0, 0, 1, -(Blossom.maxRadius), -(Blossom.maxRadius)), true, true);
blossom.graphics.drawRect(-(Blossom.maxRadius), -(Blossom.maxRadius), (Blossom.maxRadius * 2), (Blossom.maxRadius * 2));
this.addEventListener(Event.ENTER_FRAME, process, false, 0, true);
process();
}
public function getBlossomData():Blossom{
return (blossomData);
}
}
}//package com.bobblebrook.garden
Section 25
//Textures (com.bobblebrook.garden.Textures)
package com.bobblebrook.garden {
import flash.display.*;
public class Textures {
public static var baseTex:BitmapData = new BaseTex(200, 200);
public static var t1:BitmapData = new T1(200, 200);
public static var t2:BitmapData = new T2(200, 200);
public static var t3:BitmapData = new T3(200, 200);
public static function getColor(_arg1:Number, _arg2:Number, _arg3:BitmapData):int{
if (_arg1 < 0){
_arg1 = 0;
};
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg2 < 0){
_arg2 = 0;
};
if (_arg2 > 1){
_arg2 = 1;
};
_arg1 = Math.round((_arg1 * (_arg3.width - 1)));
_arg2 = Math.round((_arg2 * (_arg3.height - 1)));
return (_arg3.getPixel(_arg1, _arg2));
}
}
}//package com.bobblebrook.garden
Section 26
//ColorSelector (com.bobblebrook.gui.ColorSelector)
package com.bobblebrook.gui {
import flash.display.*;
import com.bobblebrook.lisa.utils.*;
import flash.geom.*;
public class ColorSelector extends MovieClip {
private var color:int;
public var swatch:MovieClip;
public function ColorSelector(){
this.mouseChildren = false;
}
public function setColor(_arg1:int):void{
swatch.transform.colorTransform = new ColorTransform(Color.getChannel1f(_arg1), Color.getChannel2f(_arg1), Color.getChannel3f(_arg1));
color = _arg1;
}
public function getColor():int{
return (color);
}
}
}//package com.bobblebrook.gui
Section 27
//DropTarget (com.bobblebrook.gui.DropTarget)
package com.bobblebrook.gui {
import com.bobblebrook.garden.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.geom.*;
public class DropTarget extends MovieClip {
public var toolTip:String;
protected var areaW:Number;// = 70
protected var plant:Plant;
public var tfTooltip:TextField;
protected var iconType:String;// = "none"
public var canvas:MovieClip;
public var icon:MovieClip;
protected var areaH:Number;// = 70
public static const ICON_FLOWER:String = "flower";
public static const TARGET_SET:String = "Target set";
public static const ICON_TOOLS:String = "tools";
public static const TARGET_RELEASED:String = "Target released";
public static const ICON_NONE:String = "none";
public function DropTarget(){
this.mouseChildren = false;
icon.gotoAndStop(ICON_NONE);
}
public function setIcon(_arg1:String):void{
iconType = _arg1;
icon.gotoAndStop(_arg1);
}
public function setPlant(_arg1:Plant):void{
var _local2:BitmapData;
if (plant != null){
plant.setDropTarget(null);
};
plant = _arg1;
if (plant != null){
_local2 = new BitmapData((Blossom.maxRadius * 2), (Blossom.maxRadius * 2), true, 0xFFFFFF);
_local2.draw(plant.getBlossomData(), new Matrix(0.9, 0, 0, 0.9, Blossom.maxRadius, Blossom.maxRadius));
canvas.graphics.clear();
canvas.graphics.beginBitmapFill(_local2, new Matrix(1, 0, 0, 1, -(Blossom.maxRadius), -(Blossom.maxRadius)), true, true);
canvas.graphics.drawRect(-(Blossom.maxRadius), -(Blossom.maxRadius), (Blossom.maxRadius * 2), (Blossom.maxRadius * 2));
icon.gotoAndStop(ICON_NONE);
} else {
icon.gotoAndStop(iconType);
canvas.graphics.clear();
this.dispatchEvent(new Event(TARGET_RELEASED));
};
}
public function getPlant():Plant{
return (plant);
}
}
}//package com.bobblebrook.gui
Section 28
//Gauge (com.bobblebrook.gui.Gauge)
package com.bobblebrook.gui {
import flash.display.*;
import com.bobblebrook.lisa.utils.*;
import flash.geom.*;
public class Gauge extends MovieClip {
public var leaf1:MovieClip;
public var leaf2:MovieClip;
public var leaf3:MovieClip;
public var leaf4:MovieClip;
public var leaf5:MovieClip;
public var leaf6:MovieClip;
public var leaf7:MovieClip;
public var leaf8:MovieClip;
public var leaves:Array;
public function Gauge(){
leaves = [leaf1, leaf2, leaf3, leaf4, leaf5, leaf6, leaf7, leaf8];
setValue(0);
}
public function setValue(_arg1:Number):void{
var _local5:MovieClip;
var _local2:int = Math.ceil((_arg1 * leaves.length));
var _local3:int = Color.HSLtoRGB(Color.HSLfromChannels(((_arg1 * 47) + 7), 0xFF, 160));
var _local4:int;
while (_local4 < leaves.length) {
_local5 = leaves[_local4];
if (_local4 < _local2){
_local5.transform.colorTransform = new ColorTransform(Color.getChannel1f(_local3), Color.getChannel2f(_local3), Color.getChannel3f(_local3));
} else {
_local3 = 6640250;
_local5.transform.colorTransform = new ColorTransform(0, 0, 0, 1, Color.getChannel1(_local3), Color.getChannel2(_local3), Color.getChannel3(_local3), 1);
};
_local4++;
};
}
}
}//package com.bobblebrook.gui
Section 29
//IntroText (com.bobblebrook.gui.IntroText)
package com.bobblebrook.gui {
import com.bobblebrook.*;
import flash.text.*;
public class IntroText extends MessageContainer {
public var btnNext:DefaultButton;
public var tfText:TextField;
public function IntroText(_arg1:Number=0, _arg2:Number=-50){
super(_arg1, _arg2);
}
}
}//package com.bobblebrook.gui
Section 30
//MessageBox (com.bobblebrook.gui.MessageBox)
package com.bobblebrook.gui {
import flash.display.*;
import flash.events.*;
import com.bobblebrook.*;
import flash.text.*;
public class MessageBox extends MovieClip {
public var boxContainer:MessageContainer;
public var background:MovieClip;
public function MessageBox(_arg1:String, _arg2:Array=null){
var _local3:TextField;
var _local13:String;
var _local14:Function;
var _local15:DefaultButton;
super();
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
boxContainer = new MessageBoxContainer();
boxContainer.targetY = 200;
boxContainer.targetX = 275;
this.addChild(boxContainer);
_local3 = TextField(boxContainer["tfText"]);
_local3.text = _arg1;
var _local4:Number = 20;
var _local5:Number = 20;
var _local6:Number = 50;
_local3.height = (_local3.textHeight + 10);
_local3.y = (-((_local3.height + _local6)) / 2);
var _local7:MovieClip = new MovieClip();
_local7.y = ((_local3.y + _local3.height) + _local4);
boxContainer.addChild(_local7);
_local7.x = 20;
if (_arg2 == null){
_arg2 = ["Okay", null];
};
var _local8:Array = [];
var _local9:Number = 0;
var _local10:int;
while (_local10 < _arg2.length) {
_local13 = _arg2[_local10];
_local14 = _arg2[(_local10 + 1)];
_local15 = new DefaultButton();
_local15.label = _local13;
if (_local14 != null){
_local15.addEventListener(DefaultButton.BUTTON_PRESSED, _local14, false, 0, true);
};
_local15.addEventListener(DefaultButton.BUTTON_PRESSED, remove, false, 0, true);
_local7.addChild(_local15);
_local8.push(_local15);
_local9 = (_local9 + (_local15.width + _local5));
_local10 = (_local10 + 2);
};
var _local11:Number = (-(_local9) / 2);
_local10 = 0;
while (_local10 < _local8.length) {
_local15 = _local8[_local10];
_local15.x = _local11;
_local11 = (_local11 + (_local15.width + _local5));
_local10++;
};
var _local12:MovieClip = boxContainer["msgGraphic"];
_local12.x = (_local3.x - 20);
_local12.width = (_local3.width + 40);
_local12.y = (_local3.y - 20);
_local12.height = ((_local3.height + _local6) + 40);
}
public function remove(_arg1:Event=null):void{
this.gotoAndPlay("fadeOut");
boxContainer.fadeOut();
}
protected function onEnterFrame(_arg1:Event):void{
var _local2:Array = this.currentLabels;
var _local3:FrameLabel;
var _local4:int;
while (_local4 < _local2.length) {
if (FrameLabel(_local2[_local4]).frame == currentFrame){
_local3 = _local2[_local4];
};
_local4++;
};
if (_local3 != null){
if (_local3.name == "complete"){
stop();
};
if (_local3.name == "destroy"){
destroy();
};
};
}
public function destroy():void{
this.stop();
if (this.parent != null){
this.parent.removeChild(this);
};
this.removeChild(background);
this.removeChild(boxContainer);
this.background = null;
this.boxContainer = null;
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}//package com.bobblebrook.gui
Section 31
//MessageContainer (com.bobblebrook.gui.MessageContainer)
package com.bobblebrook.gui {
import flash.display.*;
import flash.events.*;
import com.bobblebrook.lisa.math.*;
import flash.geom.*;
import flash.filters.*;
public class MessageContainer extends MovieClip {
protected var fadeInLength:Number;// = 20
protected var state:int;
protected var initialX:Number;
protected var initialY:Number;
protected var fadeCounter;// = 0
protected var fadeInOffsetX:Number;
protected var fadeInOffsetY:Number;
public var targetX:Number;// = 0
protected var fadeInMaxScale:Number;// = 1
public var targetY:Number;// = 0
protected var fadeInMaxBlur:Number;// = 10
public var blur:Boolean;// = true
protected var fadeOutLength:Number;// = 10
protected var fadeInMaxBright:Number;// = 1
public static const FADE_IN_COMPLETE:String = "fadein complete";
public static const FADE_IN:int = 0;
public static const FADE_OUT:int = 1;
public static const FADE_OUT_COMPLETE:String = "fadeout complete";
public function MessageContainer(_arg1:Number=0, _arg2:Number=-20){
fadeInOffsetX = _arg1;
fadeInOffsetY = _arg2;
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
this.addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
}
public function onRemovedFromStage(_arg1:Event=null):void{
this.removeEventListener(Event.ENTER_FRAME, process);
}
public function setState(_arg1:int):void{
state = _arg1;
fadeCounter = 0;
if (state == FADE_IN){
};
}
public function onAddedToStage(_arg1:Event=null):void{
initialX = (targetX + fadeInOffsetX);
initialY = (targetY + fadeInOffsetY);
fadeCounter = 0;
this.state = FADE_IN;
this.addEventListener(Event.ENTER_FRAME, process, false, 0, true);
process();
}
public function fadeOut():void{
setState(FADE_OUT);
}
public function process(_arg1:Event=null):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
if (fadeCounter < 1){
if (state == FADE_IN){
fadeCounter = (fadeCounter + (1 / fadeInLength));
if (fadeCounter >= 1){
this.dispatchEvent(new Event(FADE_IN_COMPLETE));
trace((this + ": FADE IN COMPLETE"));
fadeCounter = 1;
};
_local2 = (1 - Animation.sCurve(fadeCounter, 2));
this.alpha = Animation.easeOut(fadeCounter, 2);
} else {
fadeCounter = (fadeCounter + (1 / fadeOutLength));
if (fadeCounter >= 1){
this.dispatchEvent(new Event(FADE_OUT_COMPLETE));
trace((this + ": FADE OUT COMPLETE"));
fadeCounter = 1;
};
_local2 = Animation.sCurve(fadeCounter, 2);
this.alpha = (1 - Animation.easeIn(fadeCounter, 2));
};
_local3 = (1 + ((fadeInMaxScale - 1) * _local2));
_local4 = (fadeInMaxBlur * _local2);
_local5 = (fadeInMaxBright * _local2);
_local6 = (targetX + ((initialX - targetX) * _local2));
_local7 = (targetY + ((initialY - targetY) * _local2));
this.scaleX = (this.scaleY = _local3);
this.x = _local6;
this.y = _local7;
if (blur){
this.filters = [new BlurFilter(_local4, _local4)];
};
this.transform.colorTransform = new ColorTransform(1, 1, 1, this.alpha, _local5, _local5, _local5, 0);
};
}
}
}//package com.bobblebrook.gui
Section 32
//RadioButton (com.bobblebrook.gui.RadioButton)
package com.bobblebrook.gui {
import flash.display.*;
import com.bobblebrook.*;
public class RadioButton extends DefaultButton {
public var indicator:MovieClip;
public function RadioButton(){
addFrameScript(14, frame15, 29, frame30, 44, frame45, 59, frame60);
super();
indicator.gotoAndStop("off");
this.mouseChildren = false;
trace("RBN ");
}
function frame15(){
stop();
}
function frame45(){
stop();
}
function frame60(){
stop();
}
public function check():void{
indicator.gotoAndStop("on");
}
function frame30(){
stop();
}
public function uncheck():void{
indicator.gotoAndStop("off");
}
}
}//package com.bobblebrook.gui
Section 33
//Chromosome (com.bobblebrook.lisa.genetics.Chromosome)
package com.bobblebrook.lisa.genetics {
public class Chromosome {
private var sequence:Array;
public var sequenceLength:Number;// = 0
public var index:int;
public function Chromosome(){
sequence = [];
sequenceLength = 0;
index = 0;
}
public function setSequence(_arg1:Array):void{
sequence = _arg1.concat();
sequenceLength = sequence.length;
}
public function readNext():Object{
return (sequence[index++]);
}
public function toString():String{
return (sequence.join("-"));
}
public function resetReadIndex():void{
index = 0;
}
public function getCompleteSequence():Array{
return (sequence.concat());
}
public function hasNext():Boolean{
return ((index < sequenceLength));
}
public function setReadIndex(_arg1:int):Boolean{
var _local2:int = _arg1;
_arg1 = (_arg1 % sequenceLength);
if (_arg1 < 0){
_arg1 = (_arg1 + sequenceLength);
};
index = _arg1;
if (_arg1 != _local2){
return (true);
};
return (false);
}
public function addElement(_arg1:Object):void{
sequence.push(_arg1);
sequenceLength++;
}
public function getLength():Number{
return (sequenceLength);
}
public function overwriteNext(_arg1:Object):void{
if (hasNext()){
sequence[index] = _arg1;
index++;
};
}
public static function createFromArray(_arg1:Array):Chromosome{
var _local2:Chromosome = new (Chromosome);
_local2.sequence = _arg1.concat();
_local2.sequenceLength = _local2.sequence.length;
return (_local2);
}
}
}//package com.bobblebrook.lisa.genetics
Section 34
//Lab (com.bobblebrook.lisa.genetics.Lab)
package com.bobblebrook.lisa.genetics {
public class Lab {
protected var dict:NucleotideDictionary;
public function Lab(_arg1:NucleotideDictionary){
dict = _arg1;
}
public function buildRandomChromosome(_arg1:int):Chromosome{
var _local4:Object;
var _local2:Chromosome = new Chromosome();
var _local3:int;
while (_local3 < _arg1) {
_local4 = dict.getRandomElement();
_local2.addElement(_local4);
_local3++;
};
return (_local2);
}
public function crossOver(_arg1:Chromosome, _arg2:Chromosome, _arg3:Number, _arg4:Number):Chromosome{
var _local8:Object;
var _local9:Object;
var _local10:Object;
var _local5:Chromosome = new Chromosome();
_arg1.resetReadIndex();
_arg2.resetReadIndex();
var _local6:Chromosome = _arg1;
var _local7:Number = Math.random();
if (_local7 < 0.5){
_local6 = _arg2;
};
while (_local6.hasNext()) {
_local8 = _arg1.readNext();
if (_arg1 != _arg2){
_local10 = _arg2.readNext();
} else {
_local10 = _local8;
};
if (_local6 == _arg1){
_local9 = _local8;
} else {
_local9 = _local10;
};
if (Math.random() < _arg4){
_local9 = dict.mutate(_local9);
};
_local5.addElement(_local9);
if (Math.random() < _arg3){
if (_local6 == _arg1){
_local6 = _arg2;
} else {
_local6 = _arg1;
};
};
};
return (_local5);
}
}
}//package com.bobblebrook.lisa.genetics
Section 35
//NucleotideDictionary (com.bobblebrook.lisa.genetics.NucleotideDictionary)
package com.bobblebrook.lisa.genetics {
public class NucleotideDictionary {
protected var probabilities:Array;
protected var probabilitySum:Number;
protected var elements:Array;
public function NucleotideDictionary(){
elements = [];
probabilities = [];
probabilitySum = 0;
}
public function getRandomElement():Object{
var _local1:Number = (Math.random() * probabilitySum);
var _local2:Number = 0;
var _local3:int;
while (_local3 < probabilities.length) {
_local2 = (_local2 + probabilities[_local3]);
if (_local1 <= _local2){
return (elements[_local3]);
};
_local3++;
};
return (null);
}
public function getAllElements():Array{
return (elements.concat());
}
public function mutate(_arg1:Object):Object{
var _local2:Object = _arg1;
while (_local2 == _arg1) {
_local2 = getRandomElement();
};
return (_local2);
}
public function addElement(_arg1:Object, _arg2:Number=1):void{
elements.push(_arg1);
probabilities.push(_arg2);
probabilitySum = (probabilitySum + _arg2);
}
public function getProbability(_arg1:Object):Number{
var _local2:int;
while (_local2 < elements.length) {
if (elements[_local2] == _arg1){
return (probabilities[_local2]);
};
_local2++;
};
return (0);
}
}
}//package com.bobblebrook.lisa.genetics
Section 36
//Billboard (com.bobblebrook.lisa.l3d.Billboard)
package com.bobblebrook.lisa.l3d {
import com.bobblebrook.lisa.math.*;
public class Billboard extends Node3D {
public var flipX:Boolean;// = false
override public function get zSort():Boolean{
return (true);
}
override public function draw(_arg1:Matrix3D, _arg2:Camera3D):void{
var _local3:Vector3D = _arg1.v;
x = (_local3.x + (_arg2.screenWidth / 2));
y = (_local3.y + (_arg2.screenHeight / 2));
z = _local3.z;
if ((((((z > _arg2.nearClip)) && ((z < _arg2.farClip)))) && (this.getVisible()))){
scaleX = (scaleY = (((getScale() * size) * _arg2.distanceToScreen) / z));
if (flipX){
scaleX = -(scaleX);
};
visible = true;
} else {
visible = false;
};
}
}
}//package com.bobblebrook.lisa.l3d
Section 37
//Camera3D (com.bobblebrook.lisa.l3d.Camera3D)
package com.bobblebrook.lisa.l3d {
import com.bobblebrook.lisa.math.*;
public class Camera3D extends Node3D {
private var _farClip:Number;
public var distScr:Number;
public var scrH:Number;
public var scrW:Number;
private var _nearClip:Number;
public function Camera3D(){
distScr = 200;
scrW = 550;
scrH = 400;
_nearClip = 1;
_farClip = 10000;
}
public function get screenWidth():Number{
return (scrW);
}
public function setClipping(_arg1:Number, _arg2:Number):void{
_nearClip = _arg1;
_farClip = _arg2;
}
public function get farClip():Number{
return (_farClip);
}
public function set farClip(_arg1:Number):void{
_farClip = _arg1;
}
public function getLookAtYRotation(_arg1:Vector2D):Number{
_arg1 = _arg1.copy();
var _local2:Vector3D = matrix.r;
var _local3:Vector3D = matrix.v;
var _local4:Vector2D = new Vector2D(_local2.x, _local2.z);
_arg1.subtract(new Vector2D(_local3.x, _local3.z));
var _local5:Number = _local4.angleTo(_arg1);
if (!_local4.clockwise(_arg1)){
_local5 = -(_local5);
};
if (!isNaN(_local5)){
return (_local5);
};
return (0);
}
public function render(_arg1:World3D):void{
var _local8:int;
var _local11:Node3D;
var _local12:Matrix3D;
var _local2:Array = _arg1.getAllChildren();
var _local3:Matrix3D = this.toLocal();
var _local4:Vector3D = new Vector3D(0, 0, 0, 0);
var _local5:Vector3D = new Vector3D(0, 0, 0, 0);
var _local6:Vector3D = new Vector3D(0, 0, 0, 0);
var _local7:Vector3D = new Vector3D(0, 0, 0, 1);
var _local9:int = _local2.length;
_local8 = 0;
while (_local8 < _local9) {
_local11 = _local2[_local8];
if ((((_local11 == this)) || ((_local11 == _arg1)))){
} else {
_local12 = _local11.toGlobal().preMultiplyMatrix(_local3);
_local12.storePIn(_local4);
_local12.storeQIn(_local5);
_local12.storeRIn(_local6);
_local12.storeVIn(_local7);
projectPoint(_local7);
_local12.p = _local4;
_local12.q = _local5;
_local12.r = _local6;
_local12.v = _local7;
_local11.draw(_local12, this);
};
_local8++;
};
_local2.sort(compZ);
var _local10:int = (_arg1.numChildren - 1);
_local9 = _local2.length;
_local8 = 0;
while (_local8 < _local9) {
if (((_arg1.contains(_local2[_local8])) && (Node3D(_local2[_local8]).zSort))){
_arg1.swapChildren(_local2[_local8], _arg1.getChildAt(_local10));
_local10--;
};
_local8++;
};
}
public function getFOV():Number{
var _local1:Vector2D = new Vector2D((scrW / 2), distScr);
return ((_local1.angleTo(Vector2D.yAxis) * 2));
}
public function get nearClip():Number{
return (_nearClip);
}
public function get distanceToScreen():Number{
return (distScr);
}
public function getFOVY():Number{
var _local1:Vector2D = new Vector2D((scrH / 2), distScr);
return ((_local1.angleTo(Vector2D.yAxis) * 2));
}
private function compZ(_arg1:Node3D, _arg2:Node3D):Number{
if (_arg1.z < _arg2.z){
return (-1);
};
if (_arg1.z > _arg2.z){
return (1);
};
return (0);
}
public function setScreen(_arg1:Number, _arg2:Number):void{
scrW = _arg1;
scrH = _arg2;
}
public function set nearClip(_arg1:Number):void{
_nearClip = _arg1;
}
public function get screenHeight():Number{
return (scrH);
}
public function projectPoint(_arg1:Vector3D):Vector3D{
var _local2:Number;
if (_arg1.z != 0){
_local2 = (distScr / _arg1.z);
} else {
_local2 = 1E20;
};
_arg1.x = (_arg1.x * _local2);
_arg1.y = (_arg1.y * _local2);
return (_arg1);
}
public function set distanceToScreen(_arg1:Number):void{
distScr = _arg1;
}
public function reverseProjectPoint(_arg1:Number, _arg2:Number, _arg3:Number):Vector3D{
var _local4:Number = (distScr * _arg3);
var _local5:Number = (_local4 / distScr);
var _local6:Vector3D = new Vector3D((_arg1 * _local5), (_arg2 * _local5), _local4, 1);
this.localSpace.postMultiplyVectorAndStoreIn(_local6, _local6);
return (_local6);
}
}
}//package com.bobblebrook.lisa.l3d
Section 38
//Node3D (com.bobblebrook.lisa.l3d.Node3D)
package com.bobblebrook.lisa.l3d {
import flash.display.*;
import com.bobblebrook.lisa.math.*;
import com.bobblebrook.lisa.utils.*;
public class Node3D extends MovieClip {
public var z:Number;
protected var _scale:Number;
public var world:World3D;
protected var localSpace:Matrix3D;
protected var _parentNode:Node3D;
protected var _visible:Boolean;// = true
protected var aChildNodes:Array;
public function Node3D(){
localSpace = new Matrix3D();
_scale = 1;
z = 0;
aChildNodes = new Array();
_parentNode = undefined;
}
public function get size():Number{
return (_scale);
}
public function set size(_arg1:Number):void{
_scale = _arg1;
}
public function draw(_arg1:Matrix3D, _arg2:Camera3D):void{
}
public function localToLocal(_arg1:Node3D):Matrix3D{
var _local5:Matrix3D;
var _local2:Matrix3D = _arg1.toGlobal();
var _local3:Matrix3D = localSpace.inverseMatrix();
var _local4:Node3D = _parentNode;
while (((!((_local4 == null))) && (!((_local4 == this.world))))) {
_local5 = _local4.matrix.inverseMatrix();
_local3.postMultiplyMatrix(_local5);
_local4 = _local4._parentNode;
};
_local2.preMultiplyMatrix(_local3);
return (_local2);
}
public function axisAlign():void{
var _local1:Vector3D = localSpace.v;
localSpace.setToIdentity();
localSpace.v = _local1;
}
public function setScale(_arg1:Number):void{
var _local2:Vector3D = localSpace.p;
var _local3:Vector3D = localSpace.q;
var _local4:Vector3D = localSpace.r;
_local2.normalize();
_local3.normalize();
_local4.normalize();
_local2.multiply(_arg1);
_local3.multiply(_arg1);
_local4.multiply(_arg1);
localSpace.p = _local2;
localSpace.q = _local3;
localSpace.r = _local4;
}
public function scale(_arg1:Number):void{
var _local2:Vector3D = localSpace.p;
var _local3:Vector3D = localSpace.q;
var _local4:Vector3D = localSpace.r;
_local2.multiply(_arg1);
_local3.multiply(_arg1);
_local4.multiply(_arg1);
localSpace.p = _local2;
localSpace.q = _local3;
localSpace.r = _local4;
}
public function get parentNode():Node3D{
return (_parentNode);
}
public function translate(_arg1:Vector3D):void{
_arg1 = localSpace.postMultiplyVector(_arg1);
localSpace.v = localSpace.v.add(_arg1);
}
public function get matrix():Matrix3D{
return (localSpace);
}
public function set matrix(_arg1:Matrix3D):void{
localSpace = _arg1;
}
public function getScale():Number{
var _local1:Number = localSpace.p.length();
var _local2:Number = localSpace.q.length();
var _local3:Number = localSpace.r.length();
return ((((_local1 + _local2) + _local3) / 3));
}
public function removeAllChildNodes():void{
aChildNodes = new Array();
}
public function removeChildNode(_arg1:Node3D):void{
ArrayUtils.removeFromArray(_arg1, aChildNodes);
}
public function rotateYWS(_arg1:Number):void{
var _local2:Vector3D = localSpace.v;
var _local3:Matrix3D = Matrix3D.yRotationMatrix(_arg1);
localSpace.preMultiplyMatrix(_local3);
localSpace.v = _local2;
}
public function rotateY(_arg1:Number):void{
var _local2:Matrix3D = Matrix3D.yRotationMatrix(_arg1);
localSpace.postMultiplyMatrix(_local2);
}
public function getPosition():Vector3D{
return (localSpace.v);
}
public function getAllChildren():Array{
var _local4:Array;
var _local5:int;
var _local6:Number;
var _local1:Array = new Array();
var _local2:int = aChildNodes.length;
var _local3:Number = 0;
while (_local3 < _local2) {
_local4 = Node3D(aChildNodes[_local3]).getAllChildren();
_local5 = _local4.length;
_local6 = 0;
while (_local6 < _local5) {
_local1.push(_local4[_local6]);
_local6++;
};
_local3++;
};
_local1.push(this);
return (_local1);
}
public function destroy():void{
}
public function translateWS(_arg1:Vector3D):void{
localSpace.v = localSpace.v.add(_arg1);
}
public function rotateZ(_arg1:Number):void{
var _local2:Matrix3D = Matrix3D.zRotationMatrix(_arg1);
localSpace.postMultiplyMatrix(_local2);
}
public function process():void{
var _local1:int = aChildNodes.length;
var _local2:Array = aChildNodes.concat();
var _local3:Number = 0;
while (_local3 < _local1) {
Node3D(_local2[_local3]).process();
_local3++;
};
}
public function setVisible(_arg1:Boolean):void{
this._visible = _arg1;
}
public function setPosition(_arg1:Vector3D):void{
localSpace.v = _arg1;
}
public function rotateX(_arg1:Number):void{
var _local2:Matrix3D = Matrix3D.xRotationMatrix(_arg1);
localSpace.postMultiplyMatrix(_local2);
}
public function toLocal():Matrix3D{
var _local3:Matrix3D;
var _local1:Matrix3D = localSpace.inverseMatrix();
var _local2:Node3D = _parentNode;
while (((!((_local2 == null))) && (!((_local2 == this.world))))) {
_local3 = _local2.matrix.inverseMatrix();
_local1.postMultiplyMatrix(_local3);
_local2 = _local2._parentNode;
};
return (_local1);
}
public function get zSort():Boolean{
return (false);
}
public function rotateXWS(_arg1:Number):void{
var _local2:Vector3D = localSpace.v;
var _local3:Matrix3D = Matrix3D.xRotationMatrix(_arg1);
localSpace.preMultiplyMatrix(_local3);
localSpace.v = _local2;
}
public function rotateZWS(_arg1:Number):void{
var _local2:Vector3D = localSpace.v;
var _local3:Matrix3D = Matrix3D.zRotationMatrix(_arg1);
localSpace.preMultiplyMatrix(_local3);
localSpace.v = _local2;
}
public function getVisible():Boolean{
return (this._visible);
}
public function toGlobal():Matrix3D{
var _local3:Matrix3D;
var _local1:Matrix3D = localSpace.copy();
var _local2:Node3D = _parentNode;
while (((!((_local2 == null))) && (!((_local2 == this.world))))) {
_local3 = _local2.matrix;
_local1.preMultiplyMatrix(_local3);
_local2 = _local2._parentNode;
};
return (_local1);
}
public function addChildNode(_arg1:Node3D):void{
aChildNodes.push(_arg1);
_arg1._parentNode = this;
_arg1.world = this.world;
}
}
}//package com.bobblebrook.lisa.l3d
Section 39
//World3D (com.bobblebrook.lisa.l3d.World3D)
package com.bobblebrook.lisa.l3d {
public class World3D extends Node3D {
private var activeCam:Camera3D;
public function World3D(){
this.world = this;
}
public function get activeCamera():Camera3D{
return (activeCam);
}
public function set activeCamera(_arg1:Camera3D):void{
activeCam = _arg1;
}
override public function process():void{
super.process();
if (activeCam != null){
activeCam.render(this);
};
}
}
}//package com.bobblebrook.lisa.l3d
Section 40
//Animation (com.bobblebrook.lisa.math.Animation)
package com.bobblebrook.lisa.math {
public class Animation {
public static function easeOut(_arg1:Number, _arg2:Number=2):Number{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
return ((1 - Math.pow((1 - _arg1), _arg2)));
}
public static function bell(_arg1:Number, _arg2:Number=2):Number{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
return ((1 - sCurve(Math.abs(((_arg1 * 2) - 1)), _arg2)));
}
public static function spike(_arg1:Number, _arg2:Number=2):Number{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
return (Math.pow(((_arg1 * (1 - _arg1)) * 4), _arg2));
}
public static function sineSpike(_arg1:Number, _arg2:Number=2):Number{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
return (Math.pow(Math.sin((_arg1 * Math.PI)), _arg2));
}
public static function sCurveCos(_arg1:Number):Number{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
return (((Math.cos((_arg1 * Math.PI)) * -0.5) + 0.5));
}
public static function linearThenBounceBack(_arg1:Number, _arg2:Number=0.7, _arg3:Number=2, _arg4:Number=0.3, _arg5:Number=0.5):Number{
var _local6:Number;
var _local7:int;
var _local8:Number;
var _local9:Number;
var _local10:Number;
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
if (_arg1 > _arg2){
_local6 = 0;
_local7 = 0;
while (_local7 < _arg3) {
_local6 = (_local6 + Math.pow(_arg5, _local7));
_local7++;
};
_arg1 = (((_arg1 - _arg2) * _local6) / (1 - _arg2));
_local8 = 0;
_local9 = 0;
_local7 = 0;
while (_local7 < _arg3) {
_local10 = Math.pow(_arg5, _local7);
_local9 = (_local9 + _local10);
if (_arg1 <= _local9){
_arg1 = ((_arg1 - _local8) / (_local9 - _local8));
_arg1 = (1 - ((sineSpike(_arg1, 1) * _local10) * _arg4));
break;
};
_local8 = _local9;
_local7++;
};
} else {
_arg1 = (_arg1 / _arg2);
};
return (_arg1);
}
public static function easeIn(_arg1:Number, _arg2:Number=2):Number{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
return (Math.pow(_arg1, _arg2));
}
public static function overshootAndReturn(_arg1:Number, _arg2:Number=2, _arg3:Number=0.7):Number{
if (_arg1 >= 1){
return (1);
};
var _local4:Number = 1;
if (_arg1 >= _arg3){
_local4 = ((_arg1 - _arg3) / (1 - _arg3));
_local4 = Math.pow((1 - _local4), _arg2);
};
_arg1 = Math.pow((_arg1 / _arg3), _arg2);
_arg1 = (1 + ((_arg1 - 1) * _local4));
return (_arg1);
}
public static function decelerateThenAccelerate(_arg1:Number, _arg2:Number=2):Number{
if (_arg1 < 0.5){
return ((easeOut((_arg1 * 2), _arg2) * 0.5));
};
return (((easeIn(((_arg1 - 0.5) * 2)) * 0.5) + 0.5));
}
public static function cosine(_arg1:Number, _arg2:Number=1):Number{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
return (-(((Math.cos(((_arg1 * Constants.TWO_PI) * _arg2)) * 0.5) - 0.5)));
}
public static function sCurve(_arg1:Number, _arg2:Number=2):Number{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
return (((((Math.pow((1 - Math.abs(((_arg1 * 2) - 1))), _arg2) - 1) * 0.5) * ((_arg1)<0.5) ? 1 : -1) + 0.5));
}
public static function triangleSpike(_arg1:Number, _arg2:Number=2):Number{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
return (Math.pow(Math.abs(((((_arg1)>0.5) ? (_arg1 - 0.5) : (_arg1 + 0.5) * 2) - 1)), _arg2));
}
public static function easeInThenBounceBack(_arg1:Number, _arg2:Number=2, _arg3:Number=0.7, _arg4:Number=2, _arg5:Number=0.3, _arg6:Number=0.5):Number{
var _local7:Number;
var _local8:int;
var _local9:Number;
var _local10:Number;
var _local11:Number;
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
if (_arg1 > _arg3){
_local7 = 0;
_local8 = 0;
while (_local8 < _arg4) {
_local7 = (_local7 + Math.pow(_arg6, _local8));
_local8++;
};
_arg1 = (((_arg1 - _arg3) * _local7) / (1 - _arg3));
_local9 = 0;
_local10 = 0;
_local8 = 0;
while (_local8 < _arg4) {
_local11 = Math.pow(_arg6, _local8);
_local10 = (_local10 + _local11);
if (_arg1 <= _local10){
_arg1 = ((_arg1 - _local9) / (_local10 - _local9));
_arg1 = (1 - ((sineSpike(_arg1, 1) * _local11) * _arg5));
break;
};
_local9 = _local10;
_local8++;
};
} else {
_arg1 = easeIn((_arg1 / _arg3), _arg2);
};
return (_arg1);
}
}
}//package com.bobblebrook.lisa.math
Section 41
//Constants (com.bobblebrook.lisa.math.Constants)
package com.bobblebrook.lisa.math {
public class Constants {
public static const DEG2RAD:Number = 0.0174532925199433;
public static const INF:Number = 10000000000;
public static const TWO_PI:Number = 6.28318530717959;
public static const HALF_PI:Number = 1.5707963267949;
public static const RAD2DEG:Number = 57.2957795130823;
}
}//package com.bobblebrook.lisa.math
Section 42
//Matrix3D (com.bobblebrook.lisa.math.Matrix3D)
package com.bobblebrook.lisa.math {
public class Matrix3D {
protected var entries:Array;
public function Matrix3D(){
var _local3:Number;
super();
entries = new Array(16);
var _local1:Number = 0;
var _local2:Number = 0;
while (_local2 < 4) {
_local3 = 0;
while (_local3 < 4) {
if (_local3 == _local2){
entries[_local1] = 1;
} else {
entries[_local1] = 0;
};
_local1++;
_local3++;
};
_local2++;
};
}
public function addMatrix(_arg1:Matrix3D):Matrix3D{
var _local2:Number = 0;
while (_local2 < 16) {
entries[_local2] = (entries[_local2] + _arg1.entries[_local2]);
_local2++;
};
return (this);
}
public function setToZero():Matrix3D{
var _local1:Number = 0;
while (_local1 < 16) {
entries[_local1] = 0;
_local1++;
};
return (this);
}
public function postMultiplyVector(_arg1:Vector3D):Vector3D{
var _local2:Number = _arg1.x;
var _local3:Number = _arg1.y;
var _local4:Number = _arg1.z;
var _local5:Number = _arg1.w;
var _local6:Number = ((((entries[0] * _local2) + (entries[1] * _local3)) + (entries[2] * _local4)) + (entries[3] * _local5));
var _local7:Number = ((((entries[4] * _local2) + (entries[5] * _local3)) + (entries[6] * _local4)) + (entries[7] * _local5));
var _local8:Number = ((((entries[8] * _local2) + (entries[9] * _local3)) + (entries[10] * _local4)) + (entries[11] * _local5));
return (new Vector3D(_local6, _local7, _local8, _local5));
}
public function preMultiplyMatrix(_arg1:Matrix3D):Matrix3D{
var _local2:Array = new Array(16);
_local2[0] = (((_arg1.entries[0] * entries[0]) + (_arg1.entries[1] * entries[4])) + (_arg1.entries[2] * entries[8]));
_local2[1] = (((_arg1.entries[0] * entries[1]) + (_arg1.entries[1] * entries[5])) + (_arg1.entries[2] * entries[9]));
_local2[2] = (((_arg1.entries[0] * entries[2]) + (_arg1.entries[1] * entries[6])) + (_arg1.entries[2] * entries[10]));
_local2[3] = ((((_arg1.entries[0] * entries[3]) + (_arg1.entries[1] * entries[7])) + (_arg1.entries[2] * entries[11])) + (_arg1.entries[3] * entries[15]));
_local2[4] = (((_arg1.entries[4] * entries[0]) + (_arg1.entries[5] * entries[4])) + (_arg1.entries[6] * entries[8]));
_local2[5] = (((_arg1.entries[4] * entries[1]) + (_arg1.entries[5] * entries[5])) + (_arg1.entries[6] * entries[9]));
_local2[6] = (((_arg1.entries[4] * entries[2]) + (_arg1.entries[5] * entries[6])) + (_arg1.entries[6] * entries[10]));
_local2[7] = ((((_arg1.entries[4] * entries[3]) + (_arg1.entries[5] * entries[7])) + (_arg1.entries[6] * entries[11])) + (_arg1.entries[7] * entries[15]));
_local2[8] = (((_arg1.entries[8] * entries[0]) + (_arg1.entries[9] * entries[4])) + (_arg1.entries[10] * entries[8]));
_local2[9] = (((_arg1.entries[8] * entries[1]) + (_arg1.entries[9] * entries[5])) + (_arg1.entries[10] * entries[9]));
_local2[10] = (((_arg1.entries[8] * entries[2]) + (_arg1.entries[9] * entries[6])) + (_arg1.entries[10] * entries[10]));
_local2[11] = ((((_arg1.entries[8] * entries[3]) + (_arg1.entries[9] * entries[7])) + (_arg1.entries[10] * entries[11])) + (_arg1.entries[11] * entries[15]));
_local2[12] = 0;
_local2[13] = 0;
_local2[14] = 0;
_local2[15] = 1;
var _local3:Number = 0;
while (_local3 < 16) {
entries[_local3] = _local2[_local3];
_local3++;
};
return (this);
}
public function postMultiplyMatrix(_arg1:Matrix3D):Matrix3D{
var _local2:Array = new Array(16);
_local2[0] = (((entries[0] * _arg1.entries[0]) + (entries[1] * _arg1.entries[4])) + (entries[2] * _arg1.entries[8]));
_local2[1] = (((entries[0] * _arg1.entries[1]) + (entries[1] * _arg1.entries[5])) + (entries[2] * _arg1.entries[9]));
_local2[2] = (((entries[0] * _arg1.entries[2]) + (entries[1] * _arg1.entries[6])) + (entries[2] * _arg1.entries[10]));
_local2[3] = ((((entries[0] * _arg1.entries[3]) + (entries[1] * _arg1.entries[7])) + (entries[2] * _arg1.entries[11])) + (entries[3] * _arg1.entries[15]));
_local2[4] = (((entries[4] * _arg1.entries[0]) + (entries[5] * _arg1.entries[4])) + (entries[6] * _arg1.entries[8]));
_local2[5] = (((entries[4] * _arg1.entries[1]) + (entries[5] * _arg1.entries[5])) + (entries[6] * _arg1.entries[9]));
_local2[6] = (((entries[4] * _arg1.entries[2]) + (entries[5] * _arg1.entries[6])) + (entries[6] * _arg1.entries[10]));
_local2[7] = ((((entries[4] * _arg1.entries[3]) + (entries[5] * _arg1.entries[7])) + (entries[6] * _arg1.entries[11])) + (entries[7] * _arg1.entries[15]));
_local2[8] = (((entries[8] * _arg1.entries[0]) + (entries[9] * _arg1.entries[4])) + (entries[10] * _arg1.entries[8]));
_local2[9] = (((entries[8] * _arg1.entries[1]) + (entries[9] * _arg1.entries[5])) + (entries[10] * _arg1.entries[9]));
_local2[10] = (((entries[8] * _arg1.entries[2]) + (entries[9] * _arg1.entries[6])) + (entries[10] * _arg1.entries[10]));
_local2[11] = ((((entries[8] * _arg1.entries[3]) + (entries[9] * _arg1.entries[7])) + (entries[10] * _arg1.entries[11])) + (entries[11] * _arg1.entries[15]));
_local2[12] = (((entries[12] * _arg1.entries[0]) + (entries[13] * _arg1.entries[4])) + (entries[14] * _arg1.entries[8]));
_local2[13] = (((entries[12] * _arg1.entries[1]) + (entries[13] * _arg1.entries[5])) + (entries[14] * _arg1.entries[9]));
_local2[14] = (((entries[12] * _arg1.entries[2]) + (entries[13] * _arg1.entries[6])) + (entries[14] * _arg1.entries[10]));
_local2[15] = ((((entries[12] * _arg1.entries[3]) + (entries[13] * _arg1.entries[7])) + (entries[14] * _arg1.entries[11])) + (entries[15] * _arg1.entries[15]));
var _local3:Number = 0;
while (_local3 < 16) {
entries[_local3] = _local2[_local3];
_local3++;
};
return (this);
}
public function getValueAt(_arg1:Number, _arg2:Number):Number{
return (entries[((_arg1 * 4) + _arg2)]);
}
public function inverseMatrix():Matrix3D{
var _local1:Matrix3D = this.copy().transposeMatrix();
var _local2:Vector3D = v.flip();
_local1.postMultiplyVectorAndStoreIn(_local2, _local2);
_local1.entries[3] = _local2.x;
_local1.entries[7] = _local2.y;
_local1.entries[11] = _local2.z;
return (_local1);
}
public function storePIn(_arg1:Vector3D):void{
_arg1.x = entries[0];
_arg1.y = entries[4];
_arg1.z = entries[8];
_arg1.w = 0;
}
public function translate(_arg1:Vector3D):void{
entries[3] = (entries[3] + _arg1.x);
entries[7] = (entries[7] + _arg1.y);
entries[11] = (entries[11] + _arg1.z);
}
public function storeRIn(_arg1:Vector3D):void{
_arg1.x = entries[2];
_arg1.y = entries[6];
_arg1.z = entries[10];
_arg1.w = 0;
}
public function storeVIn(_arg1:Vector3D):void{
_arg1.x = entries[3];
_arg1.y = entries[7];
_arg1.z = entries[11];
_arg1.w = 0;
}
public function setToIdentity():Matrix3D{
var _local3:Number;
var _local1:Number = 0;
var _local2:Number = 0;
while (_local2 < 4) {
_local3 = 0;
while (_local3 < 4) {
if (_local3 == _local2){
entries[_local1] = 1;
} else {
entries[_local1] = 0;
};
_local1++;
_local3++;
};
_local2++;
};
return (this);
}
public function storeQIn(_arg1:Vector3D):void{
_arg1.x = entries[1];
_arg1.y = entries[5];
_arg1.z = entries[9];
_arg1.w = 0;
}
public function rotateX(_arg1:Number):Matrix3D{
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
var _local4:Array = new Array(16);
_local4[0] = entries[0];
_local4[1] = ((entries[1] * _local2) + (entries[2] * _local3));
_local4[2] = ((entries[2] * _local2) - (entries[1] * _local3));
_local4[3] = entries[3];
_local4[4] = entries[4];
_local4[5] = ((entries[5] * _local2) + (entries[6] * _local3));
_local4[6] = ((entries[6] * _local2) - (entries[5] * _local3));
_local4[7] = entries[7];
_local4[8] = entries[8];
_local4[9] = ((entries[9] * _local2) + (entries[10] * _local3));
_local4[10] = ((entries[10] * _local2) - (entries[9] * _local3));
_local4[11] = entries[11];
_local4[12] = 0;
_local4[13] = 0;
_local4[14] = 0;
_local4[15] = 1;
var _local5:Number = 0;
while (_local5 < 16) {
entries[_local5] = _local4[_local5];
_local5++;
};
return (this);
}
public function rotateY(_arg1:Number):Matrix3D{
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
var _local4:Array = new Array(16);
_local4[0] = ((entries[0] * _local2) + (entries[2] * _local3));
_local4[1] = entries[1];
_local4[2] = ((entries[2] * _local2) - (entries[0] * _local3));
_local4[3] = entries[3];
_local4[4] = ((entries[4] * _local2) + (entries[6] * _local3));
_local4[5] = entries[5];
_local4[6] = ((entries[6] * _local2) - (entries[4] * _local3));
_local4[7] = entries[7];
_local4[8] = ((entries[8] * _local2) + (entries[10] * _local3));
_local4[9] = entries[9];
_local4[10] = ((entries[10] * _local2) - (entries[8] * _local3));
_local4[11] = entries[11];
_local4[12] = 0;
_local4[13] = 0;
_local4[14] = 0;
_local4[15] = 1;
var _local5:Number = 0;
while (_local5 < 16) {
entries[_local5] = _local4[_local5];
_local5++;
};
return (this);
}
public function rotateZ(_arg1:Number):Matrix3D{
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
var _local4:Array = new Array(16);
_local4[0] = ((entries[0] * _local2) + (entries[1] * _local3));
_local4[1] = ((entries[1] * _local2) - (entries[0] * _local3));
_local4[2] = entries[2];
_local4[3] = entries[3];
_local4[4] = ((entries[4] * _local2) + (entries[5] * _local3));
_local4[5] = ((entries[5] * _local2) - (entries[4] * _local3));
_local4[6] = entries[6];
_local4[7] = entries[7];
_local4[8] = ((entries[8] * _local2) + (entries[9] * _local3));
_local4[9] = ((entries[9] * _local2) - (entries[8] * _local3));
_local4[10] = entries[10];
_local4[11] = entries[11];
_local4[12] = 0;
_local4[13] = 0;
_local4[14] = 0;
_local4[15] = 1;
var _local5:Number = 0;
while (_local5 < 16) {
entries[_local5] = _local4[_local5];
_local5++;
};
return (this);
}
public function transposeMatrix():Matrix3D{
var _local4:Number;
var _local1:Number = 0;
var _local2:Array = new Array(16);
var _local3:Number = 0;
while (_local3 < 4) {
_local4 = 0;
while (_local4 < 4) {
_local2[_local1] = entries[((_local4 * 4) + _local3)];
_local1++;
_local4++;
};
_local3++;
};
_local1 = 0;
while (_local1 < 16) {
entries[_local1] = _local2[_local1];
_local1++;
};
return (this);
}
public function set q(_arg1:Vector3D):void{
entries[1] = _arg1.x;
entries[5] = _arg1.y;
entries[9] = _arg1.z;
entries[13] = 0;
}
public function set r(_arg1:Vector3D):void{
entries[2] = _arg1.x;
entries[6] = _arg1.y;
entries[10] = _arg1.z;
entries[14] = 0;
}
public function set p(_arg1:Vector3D):void{
entries[0] = _arg1.x;
entries[4] = _arg1.y;
entries[8] = _arg1.z;
entries[12] = 0;
}
public function multiply(_arg1:Number):Matrix3D{
var _local2:Number = 0;
while (_local2 < 16) {
entries[_local2] = (entries[_local2] * _arg1);
_local2++;
};
return (this);
}
public function set v(_arg1:Vector3D):void{
entries[3] = _arg1.x;
entries[7] = _arg1.y;
entries[11] = _arg1.z;
entries[15] = 1;
}
public function orthonormalize():void{
var _local1:Vector3D = p;
var _local2:Vector3D = q;
var _local3:Vector3D = r;
_local2 = _local1.cross(_local3);
_local1 = _local3.cross(_local2);
_local1.normalize();
_local2.normalize();
_local3.normalize();
p = _local1;
q = _local2;
r = _local3;
}
public function get p():Vector3D{
return (new Vector3D(entries[0], entries[4], entries[8], 0));
}
public function get q():Vector3D{
return (new Vector3D(entries[1], entries[5], entries[9], 0));
}
public function get r():Vector3D{
return (new Vector3D(entries[2], entries[6], entries[10], 0));
}
public function copyAndStoreIn(_arg1:Matrix3D):void{
var _local2:Number = 0;
while (_local2 < 16) {
_arg1.entries[_local2] = entries[_local2];
_local2++;
};
}
public function copy():Matrix3D{
var _local1:Matrix3D = new Matrix3D();
copyAndStoreIn(_local1);
return (_local1);
}
public function get v():Vector3D{
return (new Vector3D(entries[3], entries[7], entries[11], 1));
}
public function toString():String{
var _local4:Number;
var _local1 = "";
var _local2:Number = 0;
var _local3:Number = 0;
while (_local3 < 4) {
_local4 = 0;
while (_local4 < 4) {
_local1 = (_local1 + (entries[_local2] + " "));
_local2++;
_local4++;
};
_local1 = (_local1 + "\n");
_local3++;
};
return (_local1);
}
public function postMultiplyVectorAndStoreIn(_arg1:Vector3D, _arg2:Vector3D):void{
var _local3:Number = _arg1.x;
var _local4:Number = _arg1.y;
var _local5:Number = _arg1.z;
var _local6:Number = _arg1.w;
var _local7:Number = ((((entries[0] * _local3) + (entries[1] * _local4)) + (entries[2] * _local5)) + (entries[3] * _local6));
var _local8:Number = ((((entries[4] * _local3) + (entries[5] * _local4)) + (entries[6] * _local5)) + (entries[7] * _local6));
var _local9:Number = ((((entries[8] * _local3) + (entries[9] * _local4)) + (entries[10] * _local5)) + (entries[11] * _local6));
_arg2.set(_local7, _local8, _local9, _local6);
}
public static function yRotationMatrix(_arg1:Number):Matrix3D{
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
var _local4:Matrix3D = new (Matrix3D);
_local4.entries[0] = _local2;
_local4.entries[2] = -(_local3);
_local4.entries[8] = _local3;
_local4.entries[10] = _local2;
return (_local4);
}
public static function zRotationMatrix(_arg1:Number):Matrix3D{
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
var _local4:Matrix3D = new (Matrix3D);
_local4.entries[0] = _local2;
_local4.entries[1] = -(_local3);
_local4.entries[4] = _local3;
_local4.entries[5] = _local2;
return (_local4);
}
public static function xRotationMatrix(_arg1:Number):Matrix3D{
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
var _local4:Matrix3D = new (Matrix3D);
_local4.entries[5] = _local2;
_local4.entries[6] = -(_local3);
_local4.entries[9] = _local3;
_local4.entries[10] = _local2;
return (_local4);
}
}
}//package com.bobblebrook.lisa.math
Section 43
//SimpleSpring (com.bobblebrook.lisa.math.SimpleSpring)
package com.bobblebrook.lisa.math {
public class SimpleSpring {
protected var springPos:Vector2D;
protected var dir:Vector2D;
protected var pos:Vector2D;
protected var stiffness:Number;// = 0.5
protected var inertia:Number;// = 0.9
public function SimpleSpring(){
dir = new Vector2D(0, 0);
pos = new Vector2D(0, 0);
springPos = new Vector2D(0, 0);
}
public function setSpringPos(_arg1:Vector2D):void{
springPos = _arg1;
}
public function setSpringPosXY(_arg1:Number, _arg2:Number):void{
springPos.x = _arg1;
springPos.y = _arg2;
}
public function getParticleDirY():Number{
return (dir.y);
}
public function getSpringPos():Vector2D{
return (springPos);
}
public function getParticleDirX():Number{
return (dir.x);
}
public function resetParticleDir():void{
dir.x = (dir.y = 0);
}
public function getParticlePosX():Number{
return (pos.x);
}
public function getParticlePosY():Number{
return (pos.y);
}
public function setParticleDir(_arg1:Vector2D):void{
dir = _arg1;
}
public function setParticleDirXY(_arg1:Number, _arg2:Number):void{
dir.x = _arg1;
dir.y = _arg2;
}
public function getSpringPosX():Number{
return (springPos.x);
}
public function setParticlePos(_arg1:Vector2D):void{
pos = _arg1;
}
public function setParticlePosXY(_arg1:Number, _arg2:Number):void{
pos.x = _arg1;
pos.y = _arg2;
}
public function process():void{
var _local1:Vector2D = springPos.copy().subtract(pos);
dir.multiply(inertia).add(_local1.multiply(stiffness));
pos.add(dir);
}
public function getParticleDir():Vector2D{
return (dir);
}
public function getSpringPosY():Number{
return (springPos.y);
}
public function getParticlePos():Vector2D{
return (pos);
}
public function setStiffness(_arg1:Number):void{
stiffness = _arg1;
}
public function setInertia(_arg1:Number):void{
inertia = _arg1;
}
}
}//package com.bobblebrook.lisa.math
Section 44
//Vector2D (com.bobblebrook.lisa.math.Vector2D)
package com.bobblebrook.lisa.math {
public class Vector2D {
public var y:Number;
public var x:Number;
public static var xAxis:Vector2D = new Vector2D(1, 0);
;
public static var yAxis:Vector2D = new Vector2D(0, 1);
;
public function Vector2D(_arg1:Number=0, _arg2:Number=0){
x = (y = 0);
x = _arg1;
y = _arg2;
}
public function degreesTo(_arg1:Vector2D):Number{
return ((angleTo(_arg1) * Constants.RAD2DEG));
}
public function subtractAndStoreIn(_arg1:Vector2D, _arg2:Vector2D):Vector2D{
_arg2.set((x - _arg1.x), (y - _arg1.y));
return (_arg2);
}
public function equalsApprox(_arg1:Vector2D, _arg2:Number=1E-7):Boolean{
if ((((Math.abs((_arg1.x - x)) <= _arg2)) && ((Math.abs((_arg1.y - y)) <= _arg2)))){
return (true);
};
return (false);
}
public function dot(_arg1:Vector2D):Number{
return (((x * _arg1.x) + (y * _arg1.y)));
}
public function normalizedDegreesTo(_arg1:Vector2D):Number{
return ((normalizedAngleTo(_arg1) * Constants.RAD2DEG));
}
public function rotateDegrees(_arg1:Number):Vector2D{
_arg1 = (_arg1 * Constants.DEG2RAD);
return (this.rotate(_arg1));
}
public function squareDistanceTo(_arg1:Vector2D):Number{
var _local2:Number = (x - _arg1.x);
var _local3:Number = (y - _arg1.y);
return (((_local2 * _local2) + (_local3 * _local3)));
}
public function addAndStoreIn(_arg1:Vector2D, _arg2:Vector2D):Vector2D{
_arg2.set((x + _arg1.x), (y + _arg1.y));
return (_arg2);
}
public function toNormal():Vector2D{
var _local1:Number = -(y);
y = x;
x = _local1;
return (this);
}
public function multiplyAndStoreIn(_arg1:Number, _arg2:Vector2D):Vector2D{
_arg2.set((x * _arg1), (y * _arg1));
return (_arg2);
}
public function normalize():Vector2D{
var _local1:Number = this.length();
if (_local1 == 0){
y = 1;
} else {
x = (x / _local1);
y = (y / _local1);
};
return (this);
}
public function distanceTo(_arg1:Vector2D):Number{
var _local2:Number = (x - _arg1.x);
var _local3:Number = (y - _arg1.y);
return (Math.sqrt(((_local2 * _local2) + (_local3 * _local3))));
}
public function rotate(_arg1:Number):Vector2D{
var _local2:Number = ((x * Math.cos(_arg1)) - (y * Math.sin(_arg1)));
var _local3:Number = ((x * Math.sin(_arg1)) + (y * Math.cos(_arg1)));
x = _local2;
y = _local3;
return (this);
}
public function add(_arg1:Vector2D):Vector2D{
x = (x + _arg1.x);
y = (y + _arg1.y);
return (this);
}
public function set(_arg1:Number, _arg2:Number):Vector2D{
x = _arg1;
y = _arg2;
return (this);
}
public function squareLength():Number{
return (((x * x) + (y * y)));
}
public function multiply(_arg1:Number):Vector2D{
x = (x * _arg1);
y = (y * _arg1);
return (this);
}
public function length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function normal():Vector2D{
return (new Vector2D(-(y), x));
}
public function copyAndStoreIn(_arg1:Vector2D):void{
_arg1.x = x;
_arg1.y = y;
}
public function subtract(_arg1:Vector2D):Vector2D{
x = (x - _arg1.x);
y = (y - _arg1.y);
return (this);
}
public function flip():Vector2D{
x = -(x);
y = -(y);
return (this);
}
public function angleTo(_arg1:Vector2D):Number{
return (Math.acos((this.dot(_arg1) / (this.length() * _arg1.length()))));
}
public function clockwise(_arg1:Vector2D):Boolean{
var _local2:Number = ((x * _arg1.y) - (_arg1.x * y));
return ((_local2 >= 0));
}
public function copy():Vector2D{
return (new Vector2D(x, y));
}
public function randomUnit():Vector2D{
x = (Math.random() - 0.5);
y = (Math.random() - 0.5);
normalize();
return (this);
}
public function normalizedAngleTo(_arg1:Vector2D):Number{
return (Math.acos(this.dot(_arg1)));
}
public function toString():String{
return (((("Vector: x:" + x) + ", y:") + y));
}
public function equals(_arg1:Vector2D):Boolean{
if ((((_arg1.x == x)) && ((_arg1.y == y)))){
return (true);
};
return (false);
}
}
}//package com.bobblebrook.lisa.math
Section 45
//Vector3D (com.bobblebrook.lisa.math.Vector3D)
package com.bobblebrook.lisa.math {
public class Vector3D {
public var w:Number;
public var x:Number;
public var y:Number;
public var z:Number;
public static var xAxis:Vector3D = new Vector3D(1, 0, 0, 0);
;
public static var yAxis:Vector3D = new Vector3D(0, 1, 0, 0);
;
public static var zAxis:Vector3D = new Vector3D(0, 0, 1, 0);
;
public function Vector3D(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){
x = _arg1;
y = _arg2;
z = _arg3;
w = _arg4;
}
public function cross(_arg1:Vector3D):Vector3D{
return (new Vector3D(((y * _arg1.z) - (z * _arg1.y)), ((z * _arg1.x) - (x * _arg1.z)), ((x * _arg1.y) - (y * _arg1.x)), 0));
}
public function degreesTo(_arg1:Vector3D):Number{
return ((angleTo(_arg1) * Constants.RAD2DEG));
}
public function subtractAndStoreIn(_arg1:Vector3D, _arg2:Vector3D):Vector3D{
_arg2.set((x - _arg1.x), (y - _arg1.y), (z - _arg1.z), (w - _arg1.w));
return (_arg2);
}
public function equalsApprox(_arg1:Vector3D, _arg2:Number=1E-7):Boolean{
if ((((((Math.abs((_arg1.x - x)) <= _arg2)) && ((Math.abs((_arg1.y - y)) <= _arg2)))) && ((Math.abs((_arg1.z - z)) <= _arg2)))){
return (true);
};
return (false);
}
public function dot(_arg1:Vector3D):Number{
return ((((x * _arg1.x) + (y * _arg1.y)) + (z * _arg1.z)));
}
public function normalizedDegreesTo(_arg1:Vector3D):Number{
return ((normalizedAngleTo(_arg1) * Constants.RAD2DEG));
}
public function normalize():Vector3D{
var _local1:Number = this.length();
if (_local1 == 0){
y = 1;
} else {
x = (x / _local1);
y = (y / _local1);
z = (z / _local1);
};
return (this);
}
public function addAndStoreIn(_arg1:Vector3D, _arg2:Vector3D):Vector3D{
_arg2.set((x + _arg1.x), (y + _arg1.y), (z + _arg1.z), (w + _arg1.w));
return (_arg2);
}
public function multiplyAndStoreIn(_arg1:Number, _arg2:Vector3D):Vector3D{
_arg2.set((x * _arg1), (y * _arg1), (z * _arg1), w);
return (_arg2);
}
public function squareDistanceTo(_arg1:Vector3D):Number{
return (((Math.pow((this.x - _arg1.x), 2) + Math.pow((this.y - _arg1.y), 2)) + Math.pow((this.z - _arg1.z), 2)));
}
public function flattenY():Vector2D{
return (new Vector2D(x, z));
}
public function flattenZ():Vector2D{
return (new Vector2D(x, y));
}
public function distanceTo(_arg1:Vector3D):Number{
return (Math.sqrt(((Math.pow((this.x - _arg1.x), 2) + Math.pow((this.y - _arg1.y), 2)) + Math.pow((this.z - _arg1.z), 2))));
}
public function subtract(_arg1:Vector3D):Vector3D{
x = (x - _arg1.x);
y = (y - _arg1.y);
z = (z - _arg1.z);
w = (w - _arg1.w);
return (this);
}
public function add(_arg1:Vector3D):Vector3D{
x = (x + _arg1.x);
y = (y + _arg1.y);
z = (z + _arg1.z);
w = (w + _arg1.w);
return (this);
}
public function set(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Vector3D{
x = _arg1;
y = _arg2;
z = _arg3;
w = _arg4;
return (this);
}
public function squareLength():Number{
return ((((x * x) + (y * y)) + (z * z)));
}
public function multiply(_arg1:Number):Vector3D{
x = (x * _arg1);
y = (y * _arg1);
z = (z * _arg1);
return (this);
}
public function length():Number{
return (Math.sqrt((((x * x) + (y * y)) + (z * z))));
}
public function randomUnit():Vector3D{
x = (Math.random() - 0.5);
y = (Math.random() - 0.5);
z = (Math.random() - 0.5);
normalize();
return (this);
}
public function copyAndStoreIn(_arg1:Vector3D):void{
_arg1.x = x;
_arg1.y = y;
_arg1.z = z;
_arg1.w = w;
}
public function toString():String{
return ((((((((("Vector: x:" + x) + ", y:") + y) + ", z:") + z) + "(, w:") + w) + ")"));
}
public function flip():Vector3D{
x = -(x);
y = -(y);
z = -(z);
return (this);
}
public function angleTo(_arg1:Vector3D):Number{
return (Math.acos((this.dot(_arg1) / (this.length() * _arg1.length()))));
}
public function copy():Vector3D{
return (new Vector3D(x, y, z, w));
}
public function normalizedAngleTo(_arg1:Vector3D):Number{
return (Math.acos(this.dot(_arg1)));
}
public function equals(_arg1:Vector3D):Boolean{
if ((((((_arg1.x == x)) && ((_arg1.y == y)))) && ((_arg1.z == z)))){
return (true);
};
return (false);
}
public static function get randomVector():Vector3D{
var _local1:Vector3D = new Vector3D((Math.random() - 0.5), (Math.random() - 0.5), (Math.random() - 0.5), 1);
_local1.normalize();
return (_local1);
}
}
}//package com.bobblebrook.lisa.math
Section 46
//AssetLoader (com.bobblebrook.lisa.server.AssetLoader)
package com.bobblebrook.lisa.server {
import flash.display.*;
import flash.events.*;
import com.bobblebrook.lisa.utils.*;
public class AssetLoader extends EventDispatcher {
public var debug:Boolean;// = false
protected static var criticalQueue:Array;
protected static var _instance:AssetLoader;
protected static var regularQueue:Array;
protected static var loadedAssets:Array;
public function AssetLoader(){
loadedAssets = new Array();
criticalQueue = new Array();
regularQueue = new Array();
}
public function getAsset(_arg1:String):Object{
var _local2:_Asset = getAssetObj(_arg1);
if ((((_local2 == null)) || (!(_local2.loaded)))){
return (null);
};
return (_local2.asset);
}
protected function getAssetObj(_arg1:String):_Asset{
var _local2:int;
var _local3:_Asset;
_local2 = 0;
while (_local2 < loadedAssets.length) {
_local3 = (loadedAssets[_local2] as _Asset);
if (_local3.id == _arg1){
return (_local3);
};
_local2++;
};
_local2 = 0;
while (_local2 < criticalQueue.length) {
_local3 = (criticalQueue[_local2] as _Asset);
if (_local3.id == _arg1){
return (_local3);
};
_local2++;
};
_local2 = 0;
while (_local2 < regularQueue.length) {
_local3 = (regularQueue[_local2] as _Asset);
if (_local3.id == _arg1){
return (_local3);
};
_local2++;
};
return (null);
}
protected function startLoadingAsset(_arg1:_Asset):void{
_arg1.startLoading();
_arg1.addEventListener(AssetLoaderEvent.ASSET_LOADED, onAssetLoaded);
_arg1.addEventListener(AssetLoaderEvent.ERROR, onError);
}
public function setPriority(_arg1:String, _arg2:Number):void{
var _local3:_Asset = getAssetObj(_arg1);
if (_local3 != null){
_local3.priority = _arg2;
};
}
public function setCritical(_arg1:String, _arg2:Boolean):void{
var _local3:_Asset = getAssetObj(_arg1);
if ((((_local3 == null)) || ((_local3.critical == _arg2)))){
return;
};
_local3.critical = _arg2;
if (_arg2){
if (!_local3.loaded){
ArrayUtils.removeFromArray(_local3, regularQueue);
} else {
ArrayUtils.removeFromArray(_local3, loadedAssets);
};
criticalQueue.push(_local3);
} else {
ArrayUtils.removeFromArray(_local3, criticalQueue);
if (!_local3.loaded){
regularQueue.push(_local3);
} else {
loadedAssets.push(_local3);
};
};
queueUpdated();
}
public function allAssetsLoaded():Boolean{
if (!allCriticalsLoaded()){
return (false);
};
if (regularQueue.length != 0){
return (false);
};
return (true);
}
protected function queueUpdated():void{
var _local1:int;
var _local2:_Asset;
if (!allCriticalsLoaded()){
cancelAllRegulars();
_local1 = 0;
while (_local1 < criticalQueue.length) {
_local2 = (criticalQueue[_local1] as _Asset);
if (_local2.isLoading()){
return;
};
_local1++;
};
criticalQueue.sortOn("priority", (Array.DESCENDING | Array.NUMERIC));
_local1 = 0;
while (_local1 < criticalQueue.length) {
_local2 = (criticalQueue[_local1] as _Asset);
if (!_local2.loaded){
startLoadingAsset(_local2);
return;
};
_local1++;
};
trace("-------- AssetLoader: ERROR: queueUpdated has not found any new criticals to load!");
} else {
_local1 = 0;
while (_local1 < regularQueue.length) {
_local2 = (regularQueue[_local1] as _Asset);
if (_local2.isLoading()){
return;
};
_local1++;
};
regularQueue.sortOn("priority", (Array.DESCENDING | Array.NUMERIC));
_local1 = 0;
while (_local1 < regularQueue.length) {
_local2 = (regularQueue[_local1] as _Asset);
if (!_local2.loaded){
startLoadingAsset(_local2);
return;
};
_local1++;
};
if (debug){
trace("DEBUG: AssetLoader: queueUpdated hasn't found any new regulars to load. Has the LOADING_COMPLETE event fired?");
};
};
}
protected function onError(_arg1:AssetLoaderEvent):void{
trace((("-------- AssetLoader: ERROR: asset " + _arg1.id) + " did not load!"));
cancelLoadingAsset(getAssetObj(_arg1.id));
this.dispatchEvent(new AssetLoaderEvent(AssetLoaderEvent.ERROR, _arg1.id));
}
protected function cancelLoadingAsset(_arg1:_Asset):void{
_arg1.cancelLoading();
_arg1.removeEventListener(AssetLoaderEvent.ASSET_LOADED, onAssetLoaded);
_arg1.removeEventListener(AssetLoaderEvent.ERROR, onError);
}
public function addAsset(_arg1:String, _arg2:String, _arg3:Number=0, _arg4:Boolean=false):void{
if (getAssetObj(_arg1) != null){
trace("AssetLoader: WARNING: id already in use - if you don't know what you're doing, this means things are about to go wonky!");
};
var _local5:_Asset = new _Asset(_arg1, _arg2, _arg3, _arg4);
_local5.addEventListener(AssetLoaderEvent.ASSET_LOADED, onAssetLoaded);
_local5.addEventListener(AssetLoaderEvent.ERROR, onError);
if (_arg4){
criticalQueue.push(_local5);
} else {
regularQueue.push(_local5);
};
queueUpdated();
}
public function isCritical(_arg1:String):Boolean{
var _local2:_Asset = getAssetObj(_arg1);
if (_local2 != null){
return (_local2.critical);
};
return (false);
}
public function getPriority(_arg1:String):Number{
var _local2:_Asset = getAssetObj(_arg1);
if (_local2 == null){
return (Number.NaN);
};
return (_local2.priority);
}
public function getProgressOfAsset(_arg1:String):Number{
var _local2:_Asset = this.getAssetObj(_arg1);
if (_local2 == null){
trace((("-------- AssetLoader: ERROR: asset " + _arg1) + " has not been added to AssetLoader!"));
return (0);
};
if (_local2.loader == null){
if (_local2.loaded){
return (1);
};
return (0);
};
var _local3:Number = _local2.loader.contentLoaderInfo.bytesTotal;
if (_local3 == 0){
return (0);
};
var _local4:Number = _local2.loader.contentLoaderInfo.bytesLoaded;
return ((_local4 / _local3));
}
public function removeAllCriticals():void{
var _local1:_Asset;
while (criticalQueue.length != 0) {
_local1 = (criticalQueue.shift() as _Asset);
_local1.critical = false;
if (_local1.loaded){
loadedAssets.push(_local1);
} else {
regularQueue.push(_local1);
};
};
queueUpdated();
}
public function allCriticalsLoaded():Boolean{
var _local2:_Asset;
var _local1:int;
while (_local1 < criticalQueue.length) {
_local2 = (criticalQueue[_local1] as _Asset);
if (!_local2.loaded){
return (false);
};
_local1++;
};
return (true);
}
public function getProgressOfCriticals():Number{
var _local4:_Asset;
var _local1:Number = 0;
var _local2:Number = (criticalQueue.length as Number);
if (_local2 == 0){
return (1);
};
var _local3:int;
while (_local3 < _local2) {
_local4 = (criticalQueue[_local3] as _Asset);
if (_local4.loaded){
_local1++;
};
_local3++;
};
return ((_local1 / _local2));
}
public function getClassInSwf(_arg1:String, _arg2:String):Class{
var _local3:DisplayObject = (getAsset(_arg1) as DisplayObject);
return ((_local3.loaderInfo.applicationDomain.getDefinition(_arg2) as Class));
}
protected function onAssetLoaded(_arg1:AssetLoaderEvent):void{
var _local2:_Asset = (_arg1.target as _Asset);
trace((("AssetLoader: asset " + _local2.id) + " loaded."));
this.dispatchEvent(new AssetLoaderEvent(AssetLoaderEvent.ASSET_LOADED, _local2.id));
if (!_local2.critical){
ArrayUtils.removeFromArray(_local2, regularQueue);
loadedAssets.push(_local2);
if ((((regularQueue.length == 0)) && (this.allCriticalsLoaded()))){
trace("AssetLoader: all assets loaded.");
this.dispatchEvent(new AssetLoaderEvent(AssetLoaderEvent.LOADING_COMPLETE));
};
} else {
if (this.allCriticalsLoaded()){
trace("AssetLoader: all critical assets loaded.");
this.dispatchEvent(new AssetLoaderEvent(AssetLoaderEvent.CRITICALS_COMPLETE));
};
};
queueUpdated();
}
protected function cancelAllRegulars():void{
var _local2:_Asset;
var _local1:int;
while (_local1 < regularQueue.length) {
_local2 = (regularQueue[_local1] as _Asset);
if (_local2.isLoading()){
cancelLoadingAsset(_local2);
};
_local1++;
};
}
public function hasLoaded(_arg1:String):Boolean{
var _local2:_Asset = getAssetObj(_arg1);
if (_local2 == null){
return (false);
};
return (_local2.loaded);
}
public static function get instance():AssetLoader{
if (_instance == null){
_instance = new (AssetLoader);
};
return (_instance);
}
}
}//package com.bobblebrook.lisa.server
import flash.display.*;
import flash.events.*;
import flash.net.*;
class _Asset extends EventDispatcher {
public var priority:Number;
public var loaded:Boolean;
public var filename:String;
public var asset:Object;
public var loader:Loader;
public var id:String;
protected var loading:Boolean;
public var critical:Boolean;
private function _Asset(_arg1:String, _arg2:String, _arg3:Number, _arg4:Boolean){
id = _arg1;
filename = _arg2;
priority = _arg3;
critical = _arg4;
asset = null;
loaded = false;
loader = null;
loading = false;
}
public function startLoading():void{
if (isLoading()){
return;
};
if (AssetLoader.instance.debug){
trace(("DEBUG: AssetLoader: begin loading " + this.id));
};
loading = true;
loader = new Loader();
var _local1:URLRequest = new URLRequest(filename);
loader.load(_local1);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
}
public function cancelLoading():void{
if (!isLoading()){
return;
};
if (AssetLoader.instance.debug){
trace(("DEBUG: AssetLoader: stop loading " + this.id));
};
loading = false;
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoaded);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onError);
loader.unload();
loader = null;
}
protected function onError(_arg1:Event):void{
if (AssetLoader.instance.debug){
trace(("DEBUG: AssetLoader: error " + this.id));
};
loading = false;
this.dispatchEvent(new AssetLoaderEvent(AssetLoaderEvent.ERROR, this.id));
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoaded);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onError);
loader = null;
}
protected function onLoaded(_arg1:Event):void{
if (AssetLoader.instance.debug){
trace(("DEBUG: AssetLoader: loaded " + this.id));
};
loading = false;
loaded = true;
this.asset = loader.contentLoaderInfo.content;
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoaded);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onError);
loader = null;
this.dispatchEvent(new AssetLoaderEvent(AssetLoaderEvent.ASSET_LOADED, this.id));
}
public function isLoading():Boolean{
return (loading);
}
}
Section 47
//AssetLoaderEvent (com.bobblebrook.lisa.server.AssetLoaderEvent)
package com.bobblebrook.lisa.server {
import flash.events.*;
public class AssetLoaderEvent extends Event {
public var id:String;
public static const ERROR:String = "AssetLoader: error loading asset";
public static const CRITICALS_COMPLETE:String = "AssetLoader: criticals complete";
public static const ASSET_LOADED:String = "AssetLoader: assets loaded";
public static const LOADING_COMPLETE:String = "AssetLoader: loading complete";
public function AssetLoaderEvent(_arg1:String, _arg2:String="", _arg3:Boolean=false, _arg4:Boolean=false){
super(_arg1, _arg3, _arg4);
this.id = _arg2;
}
}
}//package com.bobblebrook.lisa.server
Section 48
//CookieMGR (com.bobblebrook.lisa.server.CookieMGR)
package com.bobblebrook.lisa.server {
import flash.net.*;
public class CookieMGR {
protected var _so:SharedObject;
protected var _appName:String;
protected static var _instance:CookieMGR;
public function init(_arg1:String):void{
var $appName = _arg1;
this._appName = $appName;
try {
_so = SharedObject.getLocal($appName);
} catch(e:Error) {
};
}
public function store(_arg1:String, _arg2:Object):Boolean{
var id = _arg1;
var value = _arg2;
try {
this._so.data[id] = value;
this._so.flush();
return (true);
} catch(e:Error) {
trace(("Error storing cookie: " + e.message));
};
return (false);
}
public function retrieve(_arg1:String):Object{
var id = _arg1;
try {
return (this._so.data[id]);
} catch(e:Error) {
trace(("Error retrieving cookie: " + e.message));
};
return (null);
}
public function get appName():String{
return (this._appName);
}
public static function get instance():CookieMGR{
if (_instance == null){
_instance = new (CookieMGR);
};
return (_instance);
}
}
}//package com.bobblebrook.lisa.server
Section 49
//Tracker (com.bobblebrook.lisa.server.Tracker)
package com.bobblebrook.lisa.server {
import flash.utils.*;
import flash.events.*;
import flash.net.*;
public class Tracker {
private var level:int;
private var timer:Timer;
private var sID:String;
private var isActive:Boolean;
private var _status:Number;
private var _debug:Boolean;
private var aEvents:Array;
private var tURL:String;
private var urlLoader:URLLoader;
private var pingIntervalID:Number;
public static var CONNECTED:Number = 2;
private static var REQUEST_ID:Number = 2;
public static var ERROR:Number = 3;
private static var _instance:Tracker;
public static var UNCONNECTED:Number = 0;
public static var CONNECTING:Number = 1;
private static var PING:Number = 1;
private static var EVENT:Number = 0;
public function Tracker(){
sID = undefined;
tURL = undefined;
aEvents = new Array();
pingIntervalID = undefined;
_debug = false;
_status = UNCONNECTED;
isActive = true;
timer = null;
urlLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
}
public function get active():Boolean{
return (isActive);
}
public function set active(_arg1:Boolean):void{
isActive = _arg1;
}
public function send(_arg1:String, _arg2:Array=null, _arg3:int=3):void{
if (_arg3 > level){
return;
};
if (_arg2 == null){
_arg2 = new Array();
};
var _local4:Object = new Object();
_local4.event = _arg1;
_local4.args = _arg2;
var _local5:String = _dateString();
_local4.time = _local5;
aEvents.push(_local4);
_processEvents();
if (_debug){
trace(((((((_local5 + " | T R A C K I N G | lvl ") + _arg3) + " | ") + _arg1) + ", ") + _arg2.toString()));
};
}
public function get debug():Boolean{
return (_debug);
}
public function turnOnPing(_arg1:Number=30):void{
turnOffPing();
timer = new Timer((_arg1 * 1000), 0);
timer.addEventListener("timer", _pingServer);
timer.start();
}
public function init(_arg1:String, _arg2:String, _arg3:int=0):void{
level = (isNaN(_arg3)) ? 1 : _arg3;
if (_debug){
trace((((("Tracker initializing, game: " + _arg1) + " | Url: ") + _arg2) + " | "));
};
if (!active){
return;
};
tURL = _arg2;
_status = CONNECTING;
var _local4:URLRequest = new URLRequest(_arg2);
var _local5:URLVariables = new URLVariables();
_local5.msg = _arg1;
_local5.type = REQUEST_ID;
_local5.time = _dateString();
_local4.data = _local5;
_local4.method = URLRequestMethod.POST;
urlLoader.addEventListener(Event.COMPLETE, _connectSuccess);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, _connectError);
urlLoader.load(_local4);
}
protected function _connectSuccess(_arg1:Event):void{
if (_debug){
trace("tracker connected");
};
urlLoader.removeEventListener(Event.COMPLETE, _connectSuccess);
if (URLVariables(URLLoader(_arg1.target).data).sID){
Tracker.instance.sID = URLVariables(URLLoader(_arg1.target).data).sID;
};
Tracker.instance._status = CONNECTED;
Tracker.instance._processEvents();
}
protected function _connectError(_arg1:IOErrorEvent):void{
urlLoader.removeEventListener(IOErrorEvent.IO_ERROR, _connectError);
trace(("ERROR | " + _arg1.text));
Tracker.instance._status = ERROR;
}
public function set debug(_arg1:Boolean):void{
_debug = _arg1;
}
private function _processEvents():void{
var _local1:Object;
var _local2:String;
var _local3:Number;
var _local4:URLRequest;
var _local5:URLVariables;
if (!active){
return;
};
if (_status != CONNECTED){
return;
};
while (aEvents.length != 0) {
_local1 = aEvents.shift();
_local2 = ((((("" + sID) + ";") + _local1.time) + ";") + _local1.event);
_local3 = 0;
while (_local3 < _local1.args.length) {
_local2 = (_local2 + (";" + String(_local1.args[_local3])));
_local3++;
};
urlLoader = new URLLoader();
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, _connectError);
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
_local4 = new URLRequest(tURL);
_local5 = new URLVariables();
_local5.msg = _local2;
_local5.type = EVENT;
_local4.data = _local5;
_local4.method = URLRequestMethod.POST;
urlLoader.load(_local4);
};
}
public function turnOffPing():void{
if (timer != null){
timer.stop();
timer.removeEventListener("timer", _pingServer);
timer = null;
};
}
public function status():Number{
return (_status);
}
private function _pingServer(_arg1:TimerEvent):void{
var _local2:URLRequest;
var _local3:URLVariables;
if (!active){
return;
};
if (_status == CONNECTED){
if (level < 2){
return;
};
_local2 = new URLRequest(tURL);
_local3 = new URLVariables();
_local3.msg = this.sID;
_local3.type = PING;
_local3.time = _dateString();
_local2.data = _local3;
_local2.method = URLRequestMethod.POST;
urlLoader = new URLLoader();
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, _connectError);
urlLoader.load(_local2);
};
}
private function _dateString():String{
var _local1:Date = new Date();
return ((((((((((((("" + _local1.getFullYear()) + "-") + ((_local1.getMonth())<9) ? "0" : "") + (_local1.getMonth() + 1)) + "-") + _local1.getDate()) + " ") + _local1.getHours()) + ":") + _local1.getMinutes()) + ":") + _local1.getSeconds()));
}
public static function get instance():Tracker{
if (_instance == null){
_instance = new (Tracker);
};
return (_instance);
}
}
}//package com.bobblebrook.lisa.server
Section 50
//ArrayUtils (com.bobblebrook.lisa.utils.ArrayUtils)
package com.bobblebrook.lisa.utils {
public class ArrayUtils {
public static function randomizeArray(_arg1:Array):void{
var _local2:Array = _arg1;
_arg1 = _arg1.concat();
_local2.splice(0, _local2.length);
while (_arg1.length > 0) {
_local2.push(_arg1.splice(Math.floor((Math.random() * _arg1.length)), 1)[0]);
};
}
public static function removeFromArray(_arg1:Object, _arg2:Array):Number{
var _local3:Number = 0;
var _local4:int = _arg2.indexOf(_arg1);
while (_local4 != -1) {
_arg2.splice(_local4, 1);
_local3++;
_local4 = _arg2.indexOf(_arg1);
};
return (_local3);
}
public static function inArray(_arg1:Object, _arg2:Array):Boolean{
return (!((_arg2.indexOf(_arg1) == -1)));
}
public static function subtract(_arg1:Array, _arg2:Array):Array{
var _local5:Object;
var _local3:Array = new Array();
var _local4:int;
while (_local4 < _arg1.length) {
_local5 = _arg1[_local4];
if (_arg2.indexOf(_local5) == -1){
_local3.push(_local5);
};
_local4++;
};
return (_local3);
}
}
}//package com.bobblebrook.lisa.utils
Section 51
//Color (com.bobblebrook.lisa.utils.Color)
package com.bobblebrook.lisa.utils {
public class Color {
public static function getChannel3f(_arg1:int):Number{
return ((Number((_arg1 & 0xFF)) / 0xFF));
}
public static function getChannel2f(_arg1:int):Number{
return ((Number(((_arg1 & 0xFF00) >> 8)) / 0xFF));
}
public static function addColor(_arg1:int, _arg2:int, _arg3:Number=1):int{
var _local4:Number = getChannel1f(_arg1);
var _local5:Number = getChannel1f(_arg2);
var _local6:Number = getChannel2f(_arg1);
var _local7:Number = getChannel2f(_arg2);
var _local8:Number = getChannel3f(_arg1);
var _local9:Number = getChannel3f(_arg2);
if (_arg3 != 1){
_local5 = (_local5 * _arg3);
_local7 = (_local7 * _arg3);
_local9 = (_local9 * _arg3);
};
_local4 = (_local4 + _local5);
_local6 = (_local6 + _local7);
_local8 = (_local8 + _local9);
if (_local4 > 1){
_local4 = 1;
};
if (_local6 > 1){
_local6 = 1;
};
if (_local8 > 1){
_local8 = 1;
};
return (RGBfromChannelsf(_local4, _local6, _local8));
}
public static function getChannel1(_arg1:int):int{
return (((_arg1 & 0xFF0000) >> 16));
}
public static function getChannel2(_arg1:int):int{
return (((_arg1 & 0xFF00) >> 8));
}
public static function getChannel3(_arg1:int):int{
return ((_arg1 & 0xFF));
}
public static function RGBfromChannels(_arg1:int, _arg2:int, _arg3:int):int{
return ((((_arg1 << 16) | (_arg2 << 8)) | _arg3));
}
public static function interpolateColor(_arg1:int, _arg2:int, _arg3:Number=0.5):int{
if (_arg3 == 0){
return (_arg1);
};
if (_arg3 == 1){
return (_arg2);
};
var _local4:Number = getChannel1f(_arg1);
var _local5:Number = getChannel1f(_arg2);
var _local6:Number = getChannel2f(_arg1);
var _local7:Number = getChannel2f(_arg2);
var _local8:Number = getChannel3f(_arg1);
var _local9:Number = getChannel3f(_arg2);
var _local10:Number = (1 - _arg3);
_local4 = ((_local4 * _local10) + (_local5 * _arg3));
_local6 = ((_local6 * _local10) + (_local7 * _arg3));
_local8 = ((_local8 * _local10) + (_local9 * _arg3));
if (_local4 > 1){
_local4 = 1;
};
if (_local6 > 1){
_local6 = 1;
};
if (_local8 > 1){
_local8 = 1;
};
return (RGBfromChannelsf(_local4, _local6, _local8));
}
public static function HSLfromChannelsf(_arg1:Number, _arg2:Number, _arg3:Number):int{
return ((((int((_arg1 * 0xFF)) << 16) | (int((_arg2 * 0xFF)) << 8)) | int((_arg3 * 0xFF))));
}
public static function RGBfromChannelsf(_arg1:Number, _arg2:Number, _arg3:Number):int{
return ((((int((_arg1 * 0xFF)) << 16) | (int((_arg2 * 0xFF)) << 8)) | int((_arg3 * 0xFF))));
}
public static function HSLtoRGB(_arg1:int):int{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local2:Number = getChannel1f(_arg1);
var _local3:Number = getChannel2f(_arg1);
var _local4:Number = getChannel3f(_arg1);
if (_local3 == 0){
_local7 = _local4;
_local6 = _local7;
_local5 = _local6;
} else {
if (_local4 < 0.5){
_local9 = (_local4 * (1 + _local3));
} else {
_local9 = ((_local4 + _local3) - (_local4 * _local3));
};
_local8 = ((2 * _local4) - _local9);
_local10 = (_local2 + (1 / 3));
if (_local10 > 1){
_local10--;
};
_local11 = _local2;
_local12 = (_local2 - (1 / 3));
if (_local12 < 0){
_local12++;
};
if (_local10 < (1 / 6)){
_local5 = (_local8 + (((_local9 - _local8) * 6) * _local10));
} else {
if (_local10 < 0.5){
_local5 = _local9;
} else {
if (_local10 < (2 / 3)){
_local5 = (_local8 + (((_local9 - _local8) * ((2 / 3) - _local10)) * 6));
} else {
_local5 = _local8;
};
};
};
if (_local11 < (1 / 6)){
_local6 = (_local8 + (((_local9 - _local8) * 6) * _local11));
} else {
if (_local11 < 0.5){
_local6 = _local9;
} else {
if (_local11 < (2 / 3)){
_local6 = (_local8 + (((_local9 - _local8) * ((2 / 3) - _local11)) * 6));
} else {
_local6 = _local8;
};
};
};
if (_local12 < (1 / 6)){
_local7 = (_local8 + (((_local9 - _local8) * 6) * _local12));
} else {
if (_local12 < 0.5){
_local7 = _local9;
} else {
if (_local12 < (2 / 3)){
_local7 = (_local8 + (((_local9 - _local8) * ((2 / 3) - _local12)) * 6));
} else {
_local7 = _local8;
};
};
};
};
return (RGBfromChannelsf(_local5, _local6, _local7));
}
public static function RGBtoHSL(_arg1:int):int{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local2:Number = getChannel1f(_arg1);
var _local3:Number = getChannel2f(_arg1);
var _local4:Number = getChannel3f(_arg1);
var _local8:Number = Math.max(_local2, _local3, _local4);
var _local9:Number = Math.min(_local2, _local3, _local4);
if ((((_local2 == _local3)) && ((_local2 == _local4)))){
_local5 = 0;
_local6 = 0;
_local7 = _local2;
} else {
_local7 = ((_local9 + _local8) / 2);
if (_local7 < 0.5){
_local6 = ((_local8 - _local9) / (_local8 + _local9));
} else {
_local6 = ((_local8 - _local9) / ((2 - _local8) - _local9));
};
if (_local2 == _local8){
_local5 = ((_local3 - _local4) / (_local8 - _local9));
} else {
if (_local3 == _local8){
_local5 = (2 + ((_local4 - _local2) / (_local8 - _local9)));
} else {
_local5 = (4 + ((_local2 - _local3) / (_local8 - _local9)));
};
};
_local5 = (_local5 / 6);
if (_local5 < 0){
_local5++;
};
};
return (HSLfromChannelsf(_local5, _local6, _local7));
}
public static function getChannel1f(_arg1:int):Number{
return ((Number(((_arg1 & 0xFF0000) >> 16)) / 0xFF));
}
public static function HSLfromChannels(_arg1:int, _arg2:int, _arg3:int):int{
return ((((_arg1 << 16) | (_arg2 << 8)) | _arg3));
}
public static function multiplyColor(_arg1:int, _arg2:int, _arg3:Number=1):int{
var _local4:Number = getChannel1f(_arg1);
var _local5:Number = getChannel1f(_arg2);
var _local6:Number = getChannel2f(_arg1);
var _local7:Number = getChannel2f(_arg2);
var _local8:Number = getChannel3f(_arg1);
var _local9:Number = getChannel3f(_arg2);
if (_arg3 != 1){
_local5 = (1 - ((1 - _local5) * _arg3));
_local7 = (1 - ((1 - _local7) * _arg3));
_local9 = (1 - ((1 - _local9) * _arg3));
};
_local4 = (_local4 * _local5);
_local6 = (_local6 * _local7);
_local8 = (_local8 * _local9);
return (RGBfromChannelsf(_local4, _local6, _local8));
}
}
}//package com.bobblebrook.lisa.utils
Section 52
//StringUtils (com.bobblebrook.lisa.utils.StringUtils)
package com.bobblebrook.lisa.utils {
public class StringUtils {
private static var _numbers:Array = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
private static var _whitespace:Array = new Array(" ", "\n", "\r");
public static function removeWhitespace(_arg1:String):String{
while (ArrayUtils.inArray(_arg1.charAt(0), _whitespace)) {
_arg1 = _arg1.substring(1, _arg1.length);
};
while (ArrayUtils.inArray(_arg1.charAt((_arg1.length - 1)), _whitespace)) {
_arg1 = _arg1.substring(0, (_arg1.length - 1));
};
return (_arg1);
}
public static function isMail(_arg1:String):Boolean{
var _local2:Number = _arg1.indexOf("@");
if ((((_local2 < 1)) || (!((_arg1.indexOf("@", (_local2 + 1)) == -1))))){
return (false);
};
if (_arg1.indexOf(".", (_local2 + 2)) == -1){
return (false);
};
return (true);
}
public static function isNumeric(_arg1:String):Boolean{
return (!(isNaN(Number(_arg1))));
}
public static function intToBitString(_arg1:int, _arg2:int=32):String{
var _local5:int;
var _local3 = "";
var _local4:int;
while (_local4 < _arg2) {
_local5 = (1 << _local4);
if ((_arg1 & _local5) != 0){
_local3 = ("1" + _local3);
} else {
_local3 = ("0" + _local3);
};
_local4++;
};
return (_local3);
}
public static function convertFramesToMS(_arg1:Number):String{
_arg1 = (Math.ceil(((100 * _arg1) / 30)) / 100);
var _local2:Number = Math.floor((_arg1 / 60));
var _local3:Number = (_arg1 - (_local2 * 60));
_local3 = Math.floor(_local3);
return ((((_local2 + ":") + ((_local3)<10) ? "0" : "") + _local3));
}
public static function convertFramesToMSM(_arg1:Number):String{
_arg1 = (Math.ceil(((100 * _arg1) / 30)) / 100);
var _local2:Number = Math.floor((_arg1 / 60));
var _local3:Number = (_arg1 - (_local2 * 60));
var _local4:Number = Math.floor(((_local3 % 1) * 100));
_local3 = Math.floor(_local3);
return (((((((_local2 + ":") + ((_local3)<10) ? "0" : "") + _local3) + ":") + ((_local4)<10) ? "0" : "") + _local4));
}
public static function randomNumberString():String{
var _local1:String = ("" + (Math.floor((Math.random() * 90000)) + 9999));
return (_local1);
}
}
}//package com.bobblebrook.lisa.utils
Section 53
//ScoreMGR (com.bobblebrook.lisa.ScoreMGR)
package com.bobblebrook.lisa {
public class ScoreMGR {
private var currentScore:Number;
private var scriptURL:String;
private var appName:String;
private static var _instance:ScoreMGR;
public function ScoreMGR(){
currentScore = 0;
scriptURL = "";
}
public function resetScore():void{
currentScore = 0;
}
public function set score(_arg1:Number):void{
currentScore = _arg1;
}
public function get score():Number{
return (currentScore);
}
public function set gameName(_arg1:String):void{
appName = _arg1;
trace(("gameName: " + _arg1));
}
public function get gameName():String{
return (appName);
}
public function set highscoreURL(_arg1:String):void{
scriptURL = _arg1;
}
public function get highscoreURL():String{
return (scriptURL);
}
public static function get instance():ScoreMGR{
if (_instance == null){
_instance = new (ScoreMGR);
};
return (_instance);
}
}
}//package com.bobblebrook.lisa
Section 54
//SoundMGR (com.bobblebrook.lisa.SoundMGR)
package com.bobblebrook.lisa {
import flash.display.*;
import flash.utils.*;
import com.bobblebrook.lisa.server.*;
import flash.events.*;
import flash.media.*;
public class SoundMGR extends MovieClip {
protected var _soundsMuted:Boolean;
protected var soundChannels:Array;
protected var musicChannels:Array;
protected var _musicMuted:Boolean;
protected var externalSounds:Array;
protected static const INF:Number = 1000000000;
public static const NUM_MUSIC_CHANNELS:int = 4;
public static const SOUNDS_MUTED:String = "sounds muted";
public static const MUSIC_MUTED:String = "music muted";
public static const SOUNDS_UNMUTED:String = "sounds unmuted";
public static const MUSIC_UNMUTED:String = "music unmuted";
public static const NUM_SOUND_CHANNELS:int = 28;
protected static var _instance:SoundMGR;
public function SoundMGR(){
addFrameScript(0, frame1, 1, frame2, 2, frame3);
trace("SoundMGR: constructor");
soundChannels = new Array();
musicChannels = new Array();
externalSounds = new Array();
_instance = this;
_soundsMuted = (_musicMuted = false);
}
public function stopMusic():void{
var _local1:int;
while (_local1 < musicChannels.length) {
musicChannels[_local1].channel.stop();
_local1++;
};
musicChannels = new Array();
}
protected function createSoundObj(_arg1:Sound, _arg2:SoundChannel, _arg3:String="", _arg4:Function=null):Object{
var _local5:Object = new Object();
_local5.sound = _arg1;
_local5.prevPos = Number(0);
_local5.channelName = _arg3;
_local5.channel = _arg2;
_local5.callback = _arg4;
return (_local5);
}
public function getChannels(_arg1:Array):Array{
var _local4:SoundChannel;
var _local2:Array = new Array();
var _local3:int;
while (_local3 < _arg1.length) {
_local4 = getChannel(_arg1[_local3]);
if (_local4 != null){
_local2.push(_local4);
};
_local3++;
};
return (_local2);
}
public function soundsMuted():Boolean{
return (_soundsMuted);
}
public function muteMusic(_arg1:Boolean):void{
var _local3:SoundTransform;
if (_musicMuted != _arg1){
if (_arg1){
this.dispatchEvent(new Event(MUSIC_MUTED));
} else {
this.dispatchEvent(new Event(MUSIC_UNMUTED));
};
};
_musicMuted = _arg1;
var _local2:int;
while (_local2 < musicChannels.length) {
_local3 = musicChannels[_local2].channel.soundTransform;
if (_arg1){
_local3.volume = 0;
} else {
_local3.volume = 1;
};
musicChannels[_local2].channel.soundTransform = _local3;
_local2++;
};
}
public function getChannel(_arg1:String):SoundChannel{
var _local2:int;
if (_arg1 == ""){
return (null);
};
_local2 = 0;
while (_local2 < musicChannels.length) {
if (musicChannels[_local2].channelName == _arg1){
return (musicChannels[_local2].channel);
};
_local2++;
};
_local2 = 0;
while (_local2 < soundChannels.length) {
if (soundChannels[_local2].channelName == _arg1){
return (soundChannels[_local2].channel);
};
_local2++;
};
return (null);
}
public function playMusic(_arg1:String, _arg2:String="", _arg3:Function=null):SoundChannel{
var _local6:SoundTransform;
if (musicChannels.length == NUM_MUSIC_CHANNELS){
return (new SoundChannel());
};
var _local4:Sound = new (getDefinitionByName(_arg1));
var _local5:SoundChannel;
if (_arg3 != null){
_local5 = _local4.play();
} else {
_local5 = _local4.play(0, INF);
};
if (_musicMuted){
_local6 = _local5.soundTransform;
_local6.volume = 0;
_local5.soundTransform = _local6;
};
_local5.addEventListener(Event.SOUND_COMPLETE, _onSoundComplete);
musicChannels.push(createSoundObj(_local4, _local5, _arg2, _arg3));
return (_local5);
}
protected function _onSoundComplete(_arg1:Event):void{
var _local2:Object;
var _local3:int;
_local3 = 0;
while (_local3 < soundChannels.length) {
_local2 = soundChannels[_local3];
if (_local2.channel == _arg1.target){
soundChannels.splice(_local3, 1);
_local3--;
};
_local3++;
};
_local3 = 0;
while (_local3 < musicChannels.length) {
_local2 = musicChannels[_local3];
if (_local2.channel == _arg1.target){
if (_local2.callback != null){
_local2.callback(getQualifiedClassName(_local2.sound));
};
musicChannels.splice(_local3, 1);
_local3--;
};
_local3++;
};
}
public function musicMuted():Boolean{
return (_musicMuted);
}
public function mute(_arg1:Boolean):void{
muteMusic(_arg1);
muteSounds(_arg1);
}
public function registerSoundFromExternalSWF(_arg1:String, _arg2:String, _arg3:String):void{
var _local4:Object = new Object();
_local4.name = _arg1;
_local4.swfID = _arg2;
_local4.className = _arg3;
externalSounds[_arg1] = _local4;
}
function frame1(){
stop();
}
public function stopSounds():void{
var _local1:int;
while (_local1 < soundChannels.length) {
soundChannels[_local1].channel.stop();
_local1++;
};
soundChannels = new Array();
}
function frame2(){
gotoAndStop(1);
}
function frame3(){
trace("soundmgr: wrong frame reached");
}
public function process(_arg1:Event):void{
}
public function playSound(_arg1:String, _arg2:Boolean=false, _arg3:String=""):SoundChannel{
var _local4:Sound;
var _local6:Object;
var _local7:String;
var _local8:String;
var _local9:DisplayObject;
var _local10:Class;
var _local11:SoundTransform;
if (soundChannels.length == NUM_SOUND_CHANNELS){
return (new SoundChannel());
};
if (externalSounds.hasOwnProperty(_arg1)){
_local6 = externalSounds[_arg1];
_local7 = _local6.swfID;
_local8 = _local6.className;
if (!AssetLoader.instance.hasLoaded(_local7)){
trace("SoundMGR: attempt to play a sound from an external SWF that hasn't (fully) loaded!");
return (new SoundChannel());
};
_local9 = (AssetLoader.instance.getAsset(_local7) as DisplayObject);
_local10 = (_local9.loaderInfo.applicationDomain.getDefinition(_local8) as Class);
_local4 = (new (_local10) as Sound);
} else {
_local4 = new (getDefinitionByName(_arg1));
};
var _local5:SoundChannel;
if (!_arg2){
_local5 = _local4.play();
} else {
_local5 = _local4.play(0, INF);
};
if (_soundsMuted){
_local11 = _local5.soundTransform;
_local11.volume = 0;
_local5.soundTransform = _local11;
};
_local5.addEventListener(Event.SOUND_COMPLETE, _onSoundComplete);
soundChannels.push(createSoundObj(_local4, _local5, _arg3, null));
return (_local5);
}
public function muteSounds(_arg1:Boolean):void{
var _local3:SoundTransform;
if (_soundsMuted != _arg1){
if (_arg1){
this.dispatchEvent(new Event(SOUNDS_MUTED));
} else {
this.dispatchEvent(new Event(SOUNDS_UNMUTED));
};
};
_soundsMuted = _arg1;
var _local2:int;
while (_local2 < soundChannels.length) {
_local3 = soundChannels[_local2].channel.soundTransform;
if (_arg1){
_local3.volume = 0;
} else {
_local3.volume = 1;
};
soundChannels[_local2].channel.soundTransform = _local3;
_local2++;
};
}
public function stopAll():void{
stopMusic();
stopSounds();
}
public static function get instance():SoundMGR{
if (_instance == null){
_instance = new (SoundMGR);
};
return (_instance);
}
}
}//package com.bobblebrook.lisa
Section 55
//AboutScreen (com.bobblebrook.menu.AboutScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.display.*;
import flash.events.*;
import com.bobblebrook.garden.fx.*;
import flash.net.*;
import com.bobblebrook.*;
public class AboutScreen extends BaseScreen {
public var btnBack:DefaultButton;
public var btnBobblebrook:SimpleButton;
private var arrangement:Arrangement;
public function AboutScreen(_arg1:Game=null, _arg2:Arrangement=null){
super(_arg1);
arrangement = _arg2;
btnBack.label = "back to menu";
btnBack.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnBobblebrook.addEventListener(MouseEvent.CLICK, handleButton);
}
public function handleButton(_arg1:Event){
var _local2:URLRequest;
trace(("button event. target.name: " + _arg1.target.name));
switch (_arg1.target){
case btnBack:
arrangement.setState(Arrangement.TORUS);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "menu"));
break;
case btnBobblebrook:
_local2 = new URLRequest("http://www.bobblebrook.com");
navigateToURL(_local2, "_self");
break;
};
}
}
}//package com.bobblebrook.menu
Section 56
//BaseScreen (com.bobblebrook.menu.BaseScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.events.*;
import com.bobblebrook.gui.*;
public class BaseScreen extends MessageContainer {
protected var game:Game;
public function BaseScreen(_arg1:Game=null){
this.game = _arg1;
blur = false;
}
override public function onAddedToStage(_arg1:Event=null):void{
super.onAddedToStage(_arg1);
}
override public function process(_arg1:Event=null):void{
super.process(_arg1);
}
}
}//package com.bobblebrook.menu
Section 57
//ConfirmLoadScreen (com.bobblebrook.menu.ConfirmLoadScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.display.*;
import flash.events.*;
import com.bobblebrook.garden.fx.*;
import com.bobblebrook.*;
import flash.text.*;
public class ConfirmLoadScreen extends BaseScreen {
public var btnBack:DefaultButton;
public var btnConfirm:DefaultButton;
protected var gameScreen:GameScreen;
private var arrangement:Arrangement;
public var blossomData:Blossom;
public var blossomCanvas:MovieClip;
public var tfCode:TextField;
public function ConfirmLoadScreen(_arg1:Game=null, _arg2:Arrangement=null, _arg3:GameScreen=null){
super(_arg1);
gameScreen = _arg3;
arrangement = _arg2;
btnBack.label = "I'd like to use a different code.";
btnBack.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnConfirm.label = "Yes! Let's create my garden!";
btnConfirm.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
}
public function handleButton(_arg1:Event){
trace(("button event. target.name: " + _arg1.target.name));
switch (_arg1.target){
case btnBack:
arrangement.setState(Arrangement.HELIX);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "load"));
break;
case btnConfirm:
arrangement.setState(Arrangement.TORUS);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "game"));
gameScreen.newGameFromBlossom(blossomData);
break;
};
}
}
}//package com.bobblebrook.menu
Section 58
//GameScreen (com.bobblebrook.menu.GameScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.display.*;
import com.bobblebrook.lisa.server.*;
import com.bobblebrook.garden.genetics.*;
import flash.events.*;
import com.bobblebrook.lisa.*;
import com.bobblebrook.lisa.math.*;
import com.bobblebrook.gui.*;
import com.bobblebrook.garden.fx.*;
import com.bobblebrook.*;
import flash.text.*;
public class GameScreen extends BaseScreen {
public var tooltip:MovieClip;
protected var wallpaperScreen:WallpaperScreen;
public var btnSound:DefaultButton;
protected var sendScreen:SendScreen;
protected var initialBatch:Boolean;
public var btnExit:DefaultButton;
public var crossTarget1:DropTarget;
public var crossTarget2:DropTarget;
protected var guiFadeCounter:Number;
protected var inspectScreen:InspectScreen;
public var saveTarget:DropTarget;
protected var tfTooltip:TextField;
public var initialTarget:DropTarget;
protected var guiFadeOut:Boolean;
public var tfInstruction:TextField;
public function GameScreen(_arg1:Game=null, _arg2:Arrangement=null, _arg3:InspectScreen=null, _arg4:SendScreen=null, _arg5:WallpaperScreen=null){
super(_arg1);
inspectScreen = _arg3;
sendScreen = _arg4;
wallpaperScreen = _arg5;
btnExit.label = "back to menu";
btnSound.label = "sound on";
var _local6:Number = 1;
if (game != null){
game.addEventListener(Game.START_CROSSING, onStartCrossing);
};
if (game != null){
game.addEventListener(Game.END_CROSSING, fadeInGUI);
};
tfTooltip = tooltip.tfTooltip;
tooltip.visible = false;
btnExit.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnSound.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
initialTarget.addEventListener(MouseEvent.MOUSE_OVER, handleDropTargetMOver);
initialTarget.addEventListener(MouseEvent.MOUSE_OUT, handleDropTargetMOut);
initialTarget.addEventListener(MouseEvent.MOUSE_DOWN, handleDropTargetPress);
initialTarget.addEventListener(DropTarget.TARGET_SET, dropTargetSet);
initialTarget.addEventListener(DropTarget.TARGET_RELEASED, dropTargetReleased, false);
initialTarget.addEventListener(MouseEvent.MOUSE_UP, handleDropTargetRelease, false, _local6);
initialTarget.toolTip = "Drag a flower here to start your garden!";
initialTarget.setIcon(DropTarget.ICON_FLOWER);
crossTarget1.addEventListener(MouseEvent.MOUSE_OVER, handleDropTargetMOver);
crossTarget1.addEventListener(MouseEvent.MOUSE_OUT, handleDropTargetMOut);
crossTarget1.addEventListener(MouseEvent.MOUSE_DOWN, handleDropTargetPress);
crossTarget1.addEventListener(DropTarget.TARGET_SET, dropTargetSet);
crossTarget1.addEventListener(DropTarget.TARGET_RELEASED, dropTargetReleased, false);
crossTarget1.addEventListener(MouseEvent.MOUSE_UP, handleDropTargetRelease, false, _local6);
crossTarget1.toolTip = "Drag two flowers here to cross them!";
crossTarget1.setIcon(DropTarget.ICON_FLOWER);
crossTarget2.addEventListener(MouseEvent.MOUSE_OVER, handleDropTargetMOver);
crossTarget2.addEventListener(MouseEvent.MOUSE_OUT, handleDropTargetMOut);
crossTarget2.addEventListener(MouseEvent.MOUSE_DOWN, handleDropTargetPress);
crossTarget2.addEventListener(DropTarget.TARGET_SET, dropTargetSet);
crossTarget2.addEventListener(DropTarget.TARGET_RELEASED, dropTargetReleased, false);
crossTarget2.addEventListener(MouseEvent.MOUSE_UP, handleDropTargetRelease, false, _local6);
crossTarget2.toolTip = "Drag two flowers here to cross them!";
crossTarget2.setIcon(DropTarget.ICON_FLOWER);
saveTarget.addEventListener(MouseEvent.MOUSE_OVER, handleDropTargetMOver);
saveTarget.addEventListener(MouseEvent.MOUSE_OUT, handleDropTargetMOut);
saveTarget.addEventListener(MouseEvent.MOUSE_DOWN, handleDropTargetPress);
saveTarget.addEventListener(DropTarget.TARGET_SET, dropTargetSet);
saveTarget.addEventListener(DropTarget.TARGET_RELEASED, dropTargetReleased, false);
saveTarget.addEventListener(MouseEvent.MOUSE_UP, handleDropTargetRelease, false, _local6);
saveTarget.toolTip = "Drag a flower here to take it to the doctor.";
saveTarget.setIcon(DropTarget.ICON_TOOLS);
}
public function handleDropTargetMOut(_arg1:MouseEvent):void{
if (game.getDraggedPlant() != null){
DropTarget(_arg1.target).setPlant(null);
game.getDraggedPlant().setDropTarget(null);
};
tooltip.visible = false;
}
public function dropTargetSet(_arg1:Event):void{
var _local2:DropTarget;
var _local3:String;
var _local4:int;
_local2 = DropTarget(_arg1.target);
switch (_local2){
case crossTarget1:
game.setCrossA(_local2.getPlant());
if (_local2.getPlant() != null){
trace("-----------");
trace(("original area: " + _local2.getPlant().getBlossomData().spGetOriginalArea()));
trace(("numDirChanges: " + _local2.getPlant().getBlossomData().spGetNumDirectionChanges()));
trace(("averageAngles: " + _local2.getPlant().getBlossomData().spGetAverageAngle()));
trace(("averageHue : " + _local2.getPlant().getBlossomData().spGetAverageHue()));
trace(("averageSat : " + _local2.getPlant().getBlossomData().spGetAverageSaturation()));
trace(("averageLight : " + _local2.getPlant().getBlossomData().spGetAverageLightness()));
};
break;
case crossTarget2:
game.setCrossB(_local2.getPlant());
break;
case initialTarget:
_local3 = IO.codeFromBlossom(_local2.getPlant().getBlossomData());
_local4 = Game.startCodes.indexOf(_local3);
Tracker.instance.send("initialFlower", [_local4], 1);
game.setCrossA(_local2.getPlant());
game.setCrossB(_local2.getPlant());
initialBatch = false;
break;
case saveTarget:
inspectScreen.setBlossom(_local2.getPlant().getBlossomData());
wallpaperScreen.setBlossom(_local2.getPlant().getBlossomData());
sendScreen.setBlossom(_local2.getPlant().getBlossomData());
saveTarget.setPlant(null);
crossTarget1.setPlant(null);
crossTarget2.setPlant(null);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "inspect"));
break;
};
}
public function onStartCrossing(_arg1:Event):void{
swapGUIVisibility();
trace("start crossing");
crossTarget1.setPlant(null);
crossTarget2.setPlant(null);
initialTarget.setPlant(null);
saveTarget.setPlant(null);
initialBatch = false;
fadeOutGUI();
}
public function handleButton(_arg1:Event){
var _local2:MessageBox;
switch (_arg1.target){
case btnExit:
if (((game.gameInProgress()) && ((CookieMGR.instance.retrieve("codes") == null)))){
_local2 = new MessageBox("We can't save your garden because your Flash Player settings either don't allow us to store data on your computer, or the amount of data we can store isn't enough.\n\nYou can edit these settings by right clicking and choosing \"preferences\" from the context menu, but you might have to reload this page afterwards for your changes to take effect.\n\nTo save your flowers, you could use the toolbox to copy their genetic code.", ["Back to menu anyway!", overrideExit, "Cancel!", null]);
this.addChild(_local2);
} else {
overrideExit();
};
break;
case btnSound:
if (SoundMGR.instance.musicMuted()){
Tracker.instance.send("sound", ["on"], 2);
SoundMGR.instance.mute(false);
} else {
Tracker.instance.send("sound", ["off"], 2);
SoundMGR.instance.mute(true);
};
break;
};
}
public function dropTargetReleased(_arg1:Event):void{
var _local2:DropTarget = DropTarget(_arg1.target);
switch (_local2){
case crossTarget1:
game.setCrossA(null);
break;
case crossTarget2:
game.setCrossB(null);
break;
case saveTarget:
break;
};
}
override public function onAddedToStage(_arg1:Event=null):void{
super.onAddedToStage(_arg1);
}
private function overrideExit(_arg1:Event=null):void{
saveTarget.setPlant(null);
crossTarget1.setPlant(null);
crossTarget2.setPlant(null);
initialTarget.setPlant(null);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "menu"));
}
public function handleDropTargetMOver(_arg1:MouseEvent):void{
var _local2:DropTarget;
if (game.getDraggedPlant() != null){
DropTarget(_arg1.target).setPlant(game.getDraggedPlant());
game.getDraggedPlant().setDropTarget(DropTarget(_arg1.target));
} else {
_local2 = DropTarget(_arg1.target);
tfTooltip.text = _local2.toolTip;
tooltip.visible = true;
tooltip.y = (_local2.y + 40);
tooltip.x = _local2.x;
tfTooltip.width = (tfTooltip.textWidth + 20);
tfTooltip.x = (-(tfTooltip.width) / 2);
if ((tooltip.x + (tooltip.width / 2)) > (ScreenMGR.screenWidth - 20)){
tooltip.x = ((ScreenMGR.screenWidth - 20) - (tooltip.width / 2));
};
};
}
public function newGameFromBlossom(_arg1:Blossom):void{
game.clearAll();
initialBatch = false;
game.newGameFromFlower(_arg1);
fadeOutGUI();
guiFadeCounter = 0.9;
swapGUIVisibility();
game.addWaitMsg();
}
protected function swapGUIVisibility():void{
if (initialBatch){
crossTarget1.visible = false;
crossTarget2.visible = false;
saveTarget.visible = false;
initialTarget.visible = true;
tfInstruction.visible = true;
} else {
crossTarget1.visible = true;
crossTarget2.visible = true;
saveTarget.visible = true;
initialTarget.visible = false;
tfInstruction.visible = false;
};
}
override public function process(_arg1:Event=null):void{
var _local2:Number;
super.process(_arg1);
if (guiFadeCounter != 1){
guiFadeCounter = (guiFadeCounter + 0.07);
if (guiFadeCounter > 1){
guiFadeCounter = 1;
};
_local2 = guiFadeCounter;
if (guiFadeOut){
_local2 = (1 - _local2);
};
_local2 = Animation.easeIn(_local2);
initialTarget.alpha = _local2;
tfInstruction.alpha = _local2;
crossTarget1.alpha = _local2;
crossTarget2.alpha = _local2;
saveTarget.alpha = _local2;
btnExit.alpha = _local2;
btnSound.alpha = _local2;
};
}
protected function fadeOutGUI():void{
crossTarget1.mouseEnabled = false;
crossTarget1.mouseChildren = false;
crossTarget2.mouseEnabled = false;
crossTarget2.mouseChildren = false;
initialTarget.mouseEnabled = false;
initialTarget.mouseChildren = false;
saveTarget.mouseEnabled = false;
saveTarget.mouseChildren = false;
btnExit.mouseEnabled = false;
btnExit.mouseChildren = false;
btnSound.mouseEnabled = false;
btnSound.mouseChildren = false;
guiFadeOut = true;
guiFadeCounter = 0;
}
public function newGame():void{
game.clearAll();
initialBatch = true;
game.newGame();
fadeOutGUI();
guiFadeCounter = 0.9;
swapGUIVisibility();
game.addWaitMsg();
}
public function continueGame():void{
game.clearAll();
initialBatch = false;
game.continueGame();
fadeOutGUI();
guiFadeCounter = 0.9;
swapGUIVisibility();
game.addWaitMsg();
}
protected function fadeInGUI(_arg1:Event=null):void{
swapGUIVisibility();
initialTarget.mouseEnabled = true;
crossTarget1.mouseEnabled = true;
crossTarget2.mouseEnabled = true;
saveTarget.mouseEnabled = true;
btnExit.mouseEnabled = true;
btnSound.mouseEnabled = true;
guiFadeOut = false;
guiFadeCounter = 0;
}
protected function handleDropTargetPress(_arg1:MouseEvent):void{
var _local2:DropTarget = DropTarget(_arg1.target);
if (_local2.getPlant() != null){
_local2.getPlant().getBlossomSprite().dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN));
};
}
protected function handleDropTargetRelease(_arg1:MouseEvent):void{
var _local2:DropTarget = DropTarget(_arg1.target);
if (((!((_local2.getPlant() == null))) && (!((game.getDraggedPlant() == null))))){
_local2.dispatchEvent(new Event(DropTarget.TARGET_SET));
} else {
_local2.dispatchEvent(new Event(DropTarget.TARGET_RELEASED));
};
if (stage != null){
stage.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_UP));
};
}
}
}//package com.bobblebrook.menu
Section 59
//InspectScreen (com.bobblebrook.menu.InspectScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.display.*;
import com.bobblebrook.lisa.server.*;
import com.bobblebrook.garden.genetics.*;
import flash.events.*;
import com.bobblebrook.garden.fx.*;
import com.bobblebrook.*;
import flash.text.*;
import flash.geom.*;
import flash.system.*;
public class InspectScreen extends BaseScreen {
public var btnBack:DefaultButton;
public var btnSend:DefaultButton;
private var arrangement:Arrangement;
public var btnWallpaper:DefaultButton;
public var btnCopy:DefaultButton;
public var blossomCanvas:MovieClip;
public var tfCode:TextField;
public function InspectScreen(_arg1:Game=null, _arg2:Arrangement=null){
super(_arg1);
arrangement = _arg2;
btnBack.label = "back to your garden";
btnBack.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnSend.label = "share your flower with a friend";
btnSend.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnWallpaper.label = "create a desktop wallpaper";
btnWallpaper.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnCopy.label = "copy code to clipboard";
btnCopy.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
if (GameParams.PORTAL_VERSION){
btnSend.visible = false;
btnWallpaper.visible = false;
};
}
public function setBlossom(_arg1:Blossom):void{
var _local2:Blossom;
_local2 = _arg1;
var _local3:MovieClip = blossomCanvas;
var _local4:BitmapData = new BitmapData((Blossom.maxRadius * 2), (Blossom.maxRadius * 2), true, 0xFFFFFF);
_local4.draw(_local2, new Matrix(1, 0, 0, 1, Blossom.maxRadius, Blossom.maxRadius));
_local3.graphics.clear();
_local3.graphics.beginBitmapFill(_local4, new Matrix(1, 0, 0, 1, -(Blossom.maxRadius), -(Blossom.maxRadius)), true, true);
_local3.graphics.drawRect(-(Blossom.maxRadius), -(Blossom.maxRadius), (Blossom.maxRadius * 2), (Blossom.maxRadius * 2));
_local3.scaleX = 1;
_local3.scaleY = 1;
tfCode.text = IO.codeFromBlossom(_local2);
}
override public function onAddedToStage(_arg1:Event=null):void{
super.onAddedToStage(_arg1);
arrangement.setState(Arrangement.HELIX);
Tracker.instance.send("inspect screen", null, 2);
}
public function handleButton(_arg1:Event){
switch (_arg1.target){
case btnBack:
arrangement.setState(Arrangement.TORUS);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "game"));
break;
case btnCopy:
System.setClipboard(tfCode.text);
break;
case btnSend:
arrangement.setState(Arrangement.CIRCLE);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "sendFriend"));
break;
case btnWallpaper:
arrangement.setState(Arrangement.CIRCLE);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "wallpaper"));
break;
};
}
}
}//package com.bobblebrook.menu
Section 60
//IntroScreen (com.bobblebrook.menu.IntroScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import com.bobblebrook.lisa.server.*;
import flash.events.*;
import com.bobblebrook.gui.*;
import com.bobblebrook.garden.fx.*;
import com.bobblebrook.*;
public class IntroScreen extends BaseScreen {
protected var arrStates:Array;
protected var arrangement:Arrangement;
protected var texts:Array;
protected var cText:int;// = -1
public var btnSkip:DefaultButton;
public function IntroScreen(_arg1:Game=null, _arg2:Arrangement=null){
super(_arg1);
arrangement = _arg2;
texts = [];
arrStates = [];
this.addText("This is a game about breeding flowers.", Arrangement.CIRCLE);
this.addText("Each flower's traits are determined by its genes.", Arrangement.HELIX);
this.addText("Pick two flowers and their genes combine to create new variations.", Arrangement.HELIX);
this.addText("There is no aim in this game... Feel free to set yourself one.", Arrangement.FALLING);
btnSkip.label = "skip introduction";
btnSkip.addEventListener(DefaultButton.BUTTON_PRESSED, onSkip);
nextText();
}
protected function nextText(_arg1:Event=null):void{
if (cText >= 0){
IntroText(texts[cText]).setState(MessageContainer.FADE_OUT);
};
cText++;
if (cText >= texts.length){
arrangement.setState(Arrangement.TORUS);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "menu"));
return;
};
this.addChild(IntroText(texts[cText]));
IntroText(texts[cText]).setState(MessageContainer.FADE_IN);
var _local2:int = arrangement.getState();
if (_local2 != arrStates[cText]){
arrangement.setState(arrStates[cText]);
};
}
protected function addText(_arg1:String, _arg2:int):void{
var _local3:IntroText;
_local3 = new IntroText();
_local3.btnNext.addEventListener(DefaultButton.BUTTON_PRESSED, nextText);
_local3.btnNext.label = "continue";
_local3.tfText.text = _arg1;
_local3.btnNext.y = ((_local3.tfText.y + _local3.tfText.textHeight) + 20);
_local3.targetX = 275;
_local3.targetY = 200;
texts.push(_local3);
arrStates.push(_arg2);
}
protected function onSkip(_arg1:Event):void{
Tracker.instance.send("skipIntro", [(cText + 1)], 3);
arrangement.setState(Arrangement.TORUS);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "menu"));
}
}
}//package com.bobblebrook.menu
Section 61
//LoadScreen (com.bobblebrook.menu.LoadScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.events.*;
import com.bobblebrook.garden.fx.*;
import com.bobblebrook.*;
import flash.text.*;
public class LoadScreen extends BaseScreen {
public var btnBack:DefaultButton;
private var arrangement:Arrangement;
private var defaultText:String;// = "Paste your flower's genetic code into this text field!"
public var btnCreate:DefaultButton;
public var tfCode:TextField;
public function LoadScreen(_arg1:Game=null, _arg2:Arrangement=null){
super(_arg1);
arrangement = _arg2;
btnBack.label = "back to menu";
btnBack.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnCreate.label = "create flower";
btnCreate.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
tfCode.addEventListener(MouseEvent.CLICK, onTFFocus);
}
override public function onAddedToStage(_arg1:Event=null):void{
super.onAddedToStage(_arg1);
tfCode.text = defaultText;
}
protected function onTFFocus(_arg1:Event):void{
if (tfCode.text == defaultText){
tfCode.text = "";
};
}
public function handleButton(_arg1:Event){
trace(("button event. target.name: " + _arg1.target.name));
switch (_arg1.target){
case btnBack:
arrangement.setState(Arrangement.TORUS);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "menu"));
break;
case btnCreate:
arrangement.setState(Arrangement.CIRCLE);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "loadWait"));
break;
};
}
}
}//package com.bobblebrook.menu
Section 62
//LoadWaitScreen (com.bobblebrook.menu.LoadWaitScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.display.*;
import com.bobblebrook.garden.genetics.*;
import flash.events.*;
import com.bobblebrook.gui.*;
import com.bobblebrook.garden.fx.*;
import com.bobblebrook.lisa.utils.*;
import flash.geom.*;
public class LoadWaitScreen extends BaseScreen {
public var loadScreen:LoadScreen;
private var blossom:Blossom;
public var confirmLoadScreen:ConfirmLoadScreen;
private var arrangement:Arrangement;
public function LoadWaitScreen(_arg1:Game=null, _arg2:Arrangement=null){
super(_arg1);
arrangement = _arg2;
this.addEventListener(MessageContainer.FADE_IN_COMPLETE, onFadedIn);
}
override public function onAddedToStage(_arg1:Event=null):void{
super.onAddedToStage(_arg1);
}
private function onDrawingComplete(_arg1:Event):void{
var _local2:MovieClip = confirmLoadScreen.blossomCanvas;
var _local3:BitmapData = new BitmapData((Blossom.maxRadius * 2), (Blossom.maxRadius * 2), true, 0xFFFFFF);
_local3.draw(blossom, new Matrix(1, 0, 0, 1, Blossom.maxRadius, Blossom.maxRadius));
_local2.graphics.clear();
_local2.graphics.beginBitmapFill(_local3, new Matrix(1, 0, 0, 1, -(Blossom.maxRadius), -(Blossom.maxRadius)), true, true);
_local2.graphics.drawRect(-(Blossom.maxRadius), -(Blossom.maxRadius), (Blossom.maxRadius * 2), (Blossom.maxRadius * 2));
_local2.scaleX = 1.5;
_local2.scaleY = 1.5;
confirmLoadScreen.blossomData = blossom;
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "confirmLoad"));
}
private function onFadedIn(_arg1:Event):void{
blossom = IO.blossomFromCode(StringUtils.removeWhitespace(loadScreen.tfCode.text));
blossom.addEventListener(Blossom.DRAWING_COMPLETE, onDrawingComplete);
blossom.beginDrawing();
}
}
}//package com.bobblebrook.menu
Section 63
//MenuEvent (com.bobblebrook.menu.MenuEvent)
package com.bobblebrook.menu {
import flash.events.*;
public class MenuEvent extends Event {
public var param:String;
public static const REQUEST_SCREEN:String = "request screen";
public static const TRANSITION_FULL:String = "transition full";
public static const TRANSITION_DONE:String = "transition done";
public function MenuEvent(_arg1:String, _arg2:String="", _arg3:Boolean=false, _arg4:Boolean=false){
super(_arg1, _arg3, _arg4);
this.param = _arg2;
}
}
}//package com.bobblebrook.menu
Section 64
//MenuScreen (com.bobblebrook.menu.MenuScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.display.*;
import com.bobblebrook.lisa.server.*;
import flash.events.*;
import com.bobblebrook.lisa.*;
import com.bobblebrook.gui.*;
import com.bobblebrook.garden.fx.*;
import flash.net.*;
import com.bobblebrook.*;
import flash.text.*;
import flash.geom.*;
public class MenuScreen extends BaseScreen {
protected var btnSpacing:Number;// = -15
public var tfTip:TextField;
protected var arrangement:Arrangement;
public var btnAbout:DefaultButton;
public var btnSound:DefaultButton;
public var btnLoad:DefaultButton;
public var btnContinue:DefaultButton;
public var btnStart:DefaultButton;
public var buttonContainer:MovieClip;
public var btnBobblebrook:SimpleButton;
protected var gameScreen:GameScreen;
public function MenuScreen(_arg1:Game=null, _arg2:Arrangement=null, _arg3:GameScreen=null){
super(_arg1);
gameScreen = _arg3;
arrangement = _arg2;
btnContinue = buttonContainer.btnContinue;
btnStart = buttonContainer.btnStart;
btnLoad = buttonContainer.btnLoad;
btnAbout = buttonContainer.btnAbout;
btnSound.label = "sound on";
btnContinue.label = "continue";
btnStart.label = "start a new garden";
btnLoad.label = "load a flower";
btnAbout.label = "about this game";
layoutButtons();
centerButtons();
btnContinue.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnBobblebrook.addEventListener(MouseEvent.CLICK, handleButton);
btnStart.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnLoad.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnAbout.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnSound.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
}
protected function overrideStartNew(_arg1:Event=null):void{
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "game"));
Tracker.instance.send("new game", null, 1);
gameScreen.newGame();
}
protected function centerButtons():void{
var _local1:Rectangle = buttonContainer.getBounds(this);
var _local2:Number = (_local1.width / 2);
if (btnContinue.visible == false){
_local2 = (_local2 + ((btnContinue.width + btnSpacing) / 2));
};
buttonContainer.x = ((10 + (ScreenMGR.screenWidth / 2)) - _local2);
}
override public function onAddedToStage(_arg1:Event=null):void{
super.onAddedToStage(_arg1);
tfTip.text = ("Tip:\n" + Tip.getTip());
var _local2:Array = (CookieMGR.instance.retrieve("codes") as Array);
if (_local2 != null){
btnContinue.visible = true;
} else {
btnContinue.visible = false;
};
centerButtons();
}
protected function layoutButtons():void{
btnContinue.x = 0;
btnStart.x = ((btnContinue.x + btnContinue.width) + btnSpacing);
btnLoad.x = ((btnStart.x + btnStart.width) + btnSpacing);
btnAbout.x = ((btnLoad.x + btnLoad.width) + btnSpacing);
}
public function handleButton(_arg1:Event){
var _local2:Array;
var _local3:URLRequest;
var _local4:MessageBox;
trace(("button event. target.name: " + _arg1.target.name));
switch (_arg1.target){
case btnStart:
trace("start");
_local2 = (CookieMGR.instance.retrieve("codes") as Array);
if (_local2 != null){
_local4 = new MessageBox("You have already created a garden. You can start a new one, but you'll lose all your progress.", ["Start a new garden!", overrideStartNew, "I've changed my mind!", null]);
this.addChild(_local4);
} else {
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "game"));
Tracker.instance.send("new game", null, 1);
gameScreen.newGame();
};
break;
case btnContinue:
trace("cont");
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "game"));
Tracker.instance.send("continue game", null, 1);
gameScreen.continueGame();
break;
case btnLoad:
trace("load");
arrangement.setState(Arrangement.HELIX);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "load"));
Tracker.instance.send("load", null, 1);
break;
case btnAbout:
trace("about");
Tracker.instance.send("about", null, 2);
arrangement.setState(Arrangement.FALLING);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "about"));
break;
case btnSound:
if (SoundMGR.instance.musicMuted()){
Tracker.instance.send("sound", ["on"], 2);
SoundMGR.instance.mute(false);
} else {
Tracker.instance.send("sound", ["off"], 2);
SoundMGR.instance.mute(true);
};
break;
case btnBobblebrook:
_local3 = new URLRequest("http://www.bobblebrook.com");
navigateToURL(_local3, "_self");
break;
};
}
}
}//package com.bobblebrook.menu
Section 65
//SendScreen (com.bobblebrook.menu.SendScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import com.adobe.images.*;
import flash.display.*;
import flash.utils.*;
import com.bobblebrook.garden.genetics.*;
import flash.events.*;
import com.bobblebrook.gui.*;
import com.bobblebrook.garden.fx.*;
import flash.net.*;
import com.bobblebrook.*;
import com.bobblebrook.lisa.utils.*;
import flash.text.*;
import flash.geom.*;
public class SendScreen extends BaseScreen {
public var btnSubmit:DefaultButton;
public var tfMail:TextField;
private var arrangement:Arrangement;
public var tfMailRecipient:TextField;
public var blossomObj:Blossom;
public var blossomCanvas:MovieClip;
public var tfName:TextField;
public var btnBack:DefaultButton;
public var blossomCode:String;
public var tfMessage:TextField;
public var tfError:TextField;
public var tfNameRecipient:TextField;
public static const SUBMIT_SUCCEEDED:String = "submit succeeded";
public function SendScreen(_arg1:Game=null, _arg2:Arrangement=null){
super(_arg1);
arrangement = _arg2;
btnBack.label = "back to your garden";
btnBack.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnSubmit.label = "send your flower";
btnSubmit.addEventListener(MouseEvent.CLICK, handleSubmit, false, 0, true);
tfNameRecipient.tabIndex = 0;
tfMailRecipient.tabIndex = 1;
tfName.tabIndex = 2;
tfMail.tabIndex = 3;
}
public function handleSubmit(_arg1:Event):void{
var _local10:Object;
var _local11:ByteArray;
var _local12:URLRequest;
var _local13:URLLoader;
trace("submit!");
var _local2:String = StringUtils.removeWhitespace(tfNameRecipient.text);
var _local3:String = StringUtils.removeWhitespace(tfMailRecipient.text);
var _local4:String = StringUtils.removeWhitespace(tfName.text);
var _local5:String = StringUtils.removeWhitespace(tfMail.text);
var _local6:String = StringUtils.removeWhitespace(tfMessage.text);
var _local7:String = StringUtils.removeWhitespace(blossomCode);
var _local8:Boolean;
var _local9 = "";
if (!StringUtils.isMail(_local3)){
if (_local9 != ""){
_local9 = (_local9 + ",");
};
_local9 = (_local9 + " a valid e-mail address of your friend");
_local8 = true;
};
if (!StringUtils.isMail(_local5)){
if (_local9 != ""){
_local9 = (_local9 + ",");
};
_local9 = (_local9 + " a valid e-mail address for yourself");
_local8 = true;
};
if (_local2 == ""){
if (_local9 != ""){
_local9 = (_local9 + ",");
};
_local9 = (_local9 + " the name of your friend");
_local8 = true;
};
if (_local4 == ""){
if (_local9 != ""){
_local9 = (_local9 + ",");
};
_local9 = (_local9 + " your name");
_local8 = true;
};
if (_local8){
_local9 = (_local9 + ".");
if (_local9.lastIndexOf(",") != -1){
_local9 = ((_local9.substr(0, _local9.lastIndexOf(",")) + " and") + _local9.substr((_local9.lastIndexOf(",") + 1)));
};
showError(_local9);
} else {
_local10 = new Object();
_local10.fromName = _local4;
_local10.fromMail = _local5;
_local10.toName = _local2;
_local10.toMail = _local3;
_local10.msg = _local6;
_local10.code = blossomCode;
_local11 = createJPG();
_local12 = new URLRequest();
_local12.url = "http://www.bobblebrook.com/lisa/rarebreeds/send.php";
_local12.contentType = ("multipart/form-data; boundary=" + UploadPostHelper.getBoundary());
_local12.method = URLRequestMethod.POST;
_local12.data = UploadPostHelper.getPostData("flower.jpg", _local11, _local10);
_local12.requestHeaders.push(new URLRequestHeader("Cache-Control", "no-cache"));
_local13 = new URLLoader();
_local13.dataFormat = URLLoaderDataFormat.BINARY;
_local13.addEventListener(IOErrorEvent.IO_ERROR, onSubmitError, false, 0, true);
_local13.addEventListener(Event.COMPLETE, onLoadingComplete, false, 0, true);
_local13.load(_local12);
btnSubmit.visible = false;
tfError.text = "Your flower is being sent. Just a moment...";
};
}
protected function createJPG():ByteArray{
var _local1:int = 4278190080;
if (blossomObj.spGetAverageLightness() < 0.5){
_local1 = 4294967295;
};
var _local2:BitmapData = new BitmapData((Blossom.maxRadius * 4), (Blossom.maxRadius * 4), true, _local1);
_local2.draw(blossomObj, new Matrix(2, 0, 0, 2, (Blossom.maxRadius * 2), (Blossom.maxRadius * 2)), null, null, null, true);
var _local3:JPGEncoder = new JPGEncoder(90);
var _local4:ByteArray = _local3.encode(_local2);
return (_local4);
}
protected function showError(_arg1:String):void{
tfError.autoSize = TextFieldAutoSize.RIGHT;
tfError.text = ("Please enter" + _arg1);
}
protected function onLoadingComplete(_arg1:Event):void{
var _local2:MessageBox;
trace(("on loading complete: " + _arg1.target.data));
if (_arg1.target.data == "success"){
dispatchEvent(new Event(SUBMIT_SUCCEEDED));
tfError.text = "";
btnSubmit.visible = true;
_local2 = new MessageBox("Your flower has been sent!", ["back to your garden!", backToGarden, "send another e-mail!", null]);
this.addChild(_local2);
} else {
onSubmitError(_arg1);
};
}
protected function clearInputs(_arg1:Event=null):void{
tfNameRecipient.text = "";
tfName.text = "";
tfMailRecipient.text = "";
tfMail.text = "";
}
private function backToGarden(_arg1:Event=null):void{
arrangement.setState(Arrangement.TORUS);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "game"));
}
public function handleButton(_arg1:Event){
trace(("button event. target.name: " + _arg1.target.name));
switch (_arg1.target){
case btnBack:
arrangement.setState(Arrangement.TORUS);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "game"));
break;
};
}
public function setBlossom(_arg1:Blossom):void{
var _local2:Blossom = _arg1;
var _local3:MovieClip = blossomCanvas;
var _local4:BitmapData = new BitmapData((Blossom.maxRadius * 2), (Blossom.maxRadius * 2), true, 0xFFFFFF);
_local4.draw(_local2, new Matrix(1, 0, 0, 1, Blossom.maxRadius, Blossom.maxRadius));
_local3.graphics.clear();
_local3.graphics.beginBitmapFill(_local4, new Matrix(1, 0, 0, 1, -(Blossom.maxRadius), -(Blossom.maxRadius)), true, true);
_local3.graphics.drawRect(-(Blossom.maxRadius), -(Blossom.maxRadius), (Blossom.maxRadius * 2), (Blossom.maxRadius * 2));
_local3.scaleX = 1;
_local3.scaleY = 1;
blossomCode = IO.codeFromBlossom(_arg1);
blossomObj = _arg1;
}
override public function onAddedToStage(_arg1:Event=null):void{
super.onAddedToStage(_arg1);
tfError.text = "";
}
protected function onSubmitError(_arg1:Event):void{
btnSubmit.visible = true;
tfError.text = "It looks like we're having trouble sending your flower. Please try again later.";
}
}
}//package com.bobblebrook.menu
Section 66
//Tip (com.bobblebrook.menu.Tip)
package com.bobblebrook.menu {
import com.bobblebrook.lisa.server.*;
import com.bobblebrook.*;
public class Tip {
private static var tipIndex:int = -1;
private static var tips:Array = null;
private static function storeIndex():void{
CookieMGR.instance.store("TipIndex", tipIndex);
}
public static function getTip():String{
var _local1:Object;
if (tips == null){
if (!GameParams.PORTAL_VERSION){
tips = ["This game automatically saves your progress. You can come back and continue on the same computer at any time.", "If you like a flower you have created, you can save it for later or send it to a friend.", "You can pick a flower and create a wallpaper for your desktop.", "Flowers pass on their traits to their offspring. Crossbreed flowers that show traits that you like!", "Pick two similar flowers and their offspring will likely be similar as well. Pick two flowers that are very different from the rest of the batch and you might get lots of variations.", "Can you create clovers? How about tulips or petunia? Can you get from a white daisy to a yellow daffodil?", "Some flowers are more difficult to create than others. See if you can breed green flowers!", "Next time you see a flower shop, why not get some for a good friend? No need to wait for special occasions.", "It looks like we're out of tips. Maybe you've found some on your own? Tell us about them!"];
} else {
tips = ["This game automatically saves your progress. You can come back and continue on the same computer at any time.", "If you like a flower you have created, you can save its genetic code to load it again later.", "Flowers pass on their traits to their offspring. Crossbreed flowers that show traits that you like!", "Pick two similar flowers and their offspring will likely be similar as well. Pick two flowers that are very different from the rest of the batch and you might get lots of variations.", "Can you create clovers? How about tulips or petunia? Can you get from a white daisy to a yellow daffodil?", "Some flowers are more difficult to create than others. See if you can breed green flowers!", "Next time you see a flower shop, why not get some for a good friend? No need to wait for special occasions.", "It looks like we're out of tips. Maybe you've found some on your own? Tell us about them!"];
};
};
if (tipIndex == -1){
_local1 = CookieMGR.instance.retrieve("TipIndex");
if (_local1 != null){
tipIndex = int(_local1);
};
};
tipIndex++;
if (tipIndex >= tips.length){
tipIndex = 0;
};
storeIndex();
return (tips[tipIndex]);
}
}
}//package com.bobblebrook.menu
Section 67
//WallpaperDownloadScreen (com.bobblebrook.menu.WallpaperDownloadScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import com.adobe.images.*;
import flash.display.*;
import flash.utils.*;
import flash.events.*;
import com.bobblebrook.garden.fx.*;
import flash.net.*;
import com.bobblebrook.*;
public class WallpaperDownloadScreen extends BaseScreen {
public var btnGarden:DefaultButton;
public var wallpaper:BitmapData;
public var btnDownload:DefaultButton;
public var btnWallpaper:DefaultButton;
private var arrangement:Arrangement;
public function WallpaperDownloadScreen(_arg1:Game=null, _arg2:Arrangement=null){
super(_arg1);
arrangement = _arg2;
btnDownload.label = "download it now!";
btnDownload.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnWallpaper.label = "create another wallpaper";
btnWallpaper.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnGarden.label = "back to your garden";
btnGarden.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
}
public function handleButton(_arg1:Event){
var _local2:JPGEncoder;
var _local3:ByteArray;
var _local4:URLRequestHeader;
var _local5:URLRequest;
trace(("button event. target.name: " + _arg1.target.name));
switch (_arg1.target){
case btnDownload:
_local2 = new JPGEncoder(90);
_local3 = _local2.encode(wallpaper);
_local4 = new URLRequestHeader("Content-type", "application/octet-stream");
_local5 = new URLRequest("http://www.bobblebrook.com/lisa/rarebreeds/wallpaper.php");
_local5.requestHeaders.push(_local4);
_local5.method = URLRequestMethod.POST;
_local5.data = _local3;
navigateToURL(_local5, "_blank");
break;
case btnWallpaper:
arrangement.setState(Arrangement.TORUS);
wallpaper = null;
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "wallpaper"));
break;
case btnGarden:
arrangement.setState(Arrangement.TORUS);
wallpaper = null;
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "game"));
break;
};
}
}
}//package com.bobblebrook.menu
Section 68
//WallpaperScreen (com.bobblebrook.menu.WallpaperScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.display.*;
import flash.events.*;
import com.bobblebrook.gui.*;
import com.bobblebrook.garden.fx.*;
import com.bobblebrook.*;
import flash.geom.*;
public class WallpaperScreen extends BaseScreen {
public var resolution1:RadioButton;
public var resolution3:RadioButton;
private var selectedColor:int;
private var arrangement:Arrangement;
public var resolution2:RadioButton;
public var resolution4:RadioButton;
private var bitmapFill:BitmapData;
public var radioButtons:Array;
public var colorRadio1:ColorSelector;
public var colorRadio2:ColorSelector;
public var colorRadio3:ColorSelector;
public var colorRadio4:ColorSelector;
public var colorRadio5:ColorSelector;
public var colorRadio6:ColorSelector;
public var blossomCanvas:MovieClip;
public var btnBack:DefaultButton;
public var wallpaperPreview:MovieClip;
private var selectedRbn:int;// = 0
public var blossomData:Blossom;
public var btnCreate:DefaultButton;
static var resolutionsHeight:Array = [0x0300, 800, 0x0400, 900];
static var resolutionsWidth:Array = [0x0400, 0x0500, 0x0500, 1440];
public function WallpaperScreen(_arg1:Game=null, _arg2:Arrangement=null){
var _local3:int;
super(_arg1);
radioButtons = [resolution1, resolution2, resolution3, resolution4];
arrangement = _arg2;
btnBack.label = "back to your garden";
btnBack.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
btnCreate.label = "create your wallpaper";
btnCreate.addEventListener(DefaultButton.BUTTON_PRESSED, handleButton);
colorRadio1.setColor(0);
colorRadio2.setColor(0xFFFFFF);
colorRadio3.setColor(7740187);
colorRadio4.setColor(2960731);
colorRadio5.setColor(6243335);
colorRadio6.setColor(3629326);
selectedColor = colorRadio1.getColor();
colorRadio1.addEventListener(MouseEvent.CLICK, colorRadioHandler, false, 0, true);
colorRadio2.addEventListener(MouseEvent.CLICK, colorRadioHandler, false, 0, true);
colorRadio3.addEventListener(MouseEvent.CLICK, colorRadioHandler, false, 0, true);
colorRadio4.addEventListener(MouseEvent.CLICK, colorRadioHandler, false, 0, true);
colorRadio5.addEventListener(MouseEvent.CLICK, colorRadioHandler, false, 0, true);
colorRadio6.addEventListener(MouseEvent.CLICK, colorRadioHandler, false, 0, true);
_local3 = 0;
while (_local3 < radioButtons.length) {
RadioButton(radioButtons[_local3]).label = ((resolutionsWidth[_local3] + "x") + resolutionsHeight[_local3]);
RadioButton(radioButtons[_local3]).addEventListener(DefaultButton.BUTTON_PRESSED, rbnHandler, false, 0, true);
_local3++;
};
selectRbn(0);
}
public function getSelectedResolutionWidth():int{
return (resolutionsWidth[selectedRbn]);
}
public function handleButton(_arg1:Event){
trace(("button event. target.name: " + _arg1.target.name));
switch (_arg1.target){
case btnBack:
arrangement.setState(Arrangement.TORUS);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "game"));
break;
case btnCreate:
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "wallpaperWait"));
break;
};
}
public function getSelectedColor():int{
return (selectedColor);
}
public function colorRadioHandler(_arg1:MouseEvent):void{
var _local2:ColorSelector = ColorSelector(_arg1.target);
selectedColor = _local2.getColor();
createPreview();
}
private function selectRbn(_arg1:int):void{
selectedRbn = _arg1;
var _local2:int;
while (_local2 < radioButtons.length) {
RadioButton(radioButtons[_local2]).uncheck();
_local2++;
};
RadioButton(radioButtons[_arg1]).check();
}
public function getSelectedResolutionHeight():int{
return (resolutionsHeight[selectedRbn]);
}
private function rbnHandler(_arg1:Event):void{
var _local2:RadioButton = RadioButton(_arg1.target);
selectRbn(radioButtons.indexOf(_local2));
}
public function setBlossom(_arg1:Blossom):void{
var _local2:Blossom = _arg1;
var _local3:MovieClip = blossomCanvas;
var _local4:BitmapData = new BitmapData((Blossom.maxRadius * 2), (Blossom.maxRadius * 2), true, 0xFFFFFF);
_local4.draw(_local2, new Matrix(1, 0, 0, 1, Blossom.maxRadius, Blossom.maxRadius));
_local3.graphics.clear();
_local3.graphics.beginBitmapFill(_local4, new Matrix(1, 0, 0, 1, -(Blossom.maxRadius), -(Blossom.maxRadius)), true, true);
_local3.graphics.drawRect(-(Blossom.maxRadius), -(Blossom.maxRadius), (Blossom.maxRadius * 2), (Blossom.maxRadius * 2));
_local3.scaleX = 1;
_local3.scaleY = 1;
blossomData = _local2;
bitmapFill = _local4;
createPreview();
}
public function createPreview():void{
wallpaperPreview.graphics.clear();
wallpaperPreview.graphics.lineStyle();
wallpaperPreview.graphics.beginFill(selectedColor);
wallpaperPreview.graphics.drawRect(0, 0, 168, 117);
wallpaperPreview.graphics.endFill();
var _local1:Number = 0.3;
wallpaperPreview.graphics.beginBitmapFill(bitmapFill, new Matrix(_local1, 0, 0, _local1), true, true);
wallpaperPreview.graphics.drawRect(0, 0, 168, 117);
wallpaperPreview.graphics.endFill();
wallpaperPreview.graphics.lineStyle(2, 2833019);
wallpaperPreview.graphics.drawRect(0, 0, 168, 117);
}
}
}//package com.bobblebrook.menu
Section 69
//WallpaperWaitScreen (com.bobblebrook.menu.WallpaperWaitScreen)
package com.bobblebrook.menu {
import com.bobblebrook.garden.*;
import flash.display.*;
import com.bobblebrook.lisa.server.*;
import flash.events.*;
import com.bobblebrook.gui.*;
import com.bobblebrook.*;
import flash.text.*;
import flash.geom.*;
public class WallpaperWaitScreen extends BaseScreen {
public var gauge:Gauge;
public var wallpaperScreen:WallpaperScreen;
public var wallpaperDLScreen:WallpaperDownloadScreen;
protected var blossomCanvas:BitmapData;
protected var origBlossom:Blossom;
protected var h:Number;// = 0x0300
protected var blossoms:Array;
public var btnCancel:DefaultButton;
protected var w:Number;// = 0x0400
public var tfProgress:TextField;
public function WallpaperWaitScreen(_arg1:Game=null, _arg2:WallpaperScreen=null, _arg3:WallpaperDownloadScreen=null){
super(_arg1);
wallpaperScreen = _arg2;
wallpaperDLScreen = _arg3;
btnCancel.label = "cancel";
btnCancel.addEventListener(DefaultButton.BUTTON_PRESSED, onCancel);
btnCancel.x = ((550 - btnCancel.width) / 2);
blossoms = [];
}
public function beginWallpaper(_arg1:Blossom){
var _local7:Blossom;
blossoms = [];
w = wallpaperScreen.getSelectedResolutionWidth();
h = wallpaperScreen.getSelectedResolutionHeight();
var _local2:int = wallpaperScreen.getSelectedColor();
var _local3:Number = ((Blossom.maxRadius * 2) + 10);
var _local4:Number = ((Blossom.maxRadius * 2) + 10);
blossomCanvas = new BitmapData(w, h, false, _local2);
var _local5:int = (Math.floor((w / _local3)) * Math.floor((h / _local4)));
var _local6:int;
while (_local6 < _local5) {
_local7 = game.crossAndReturnData(origBlossom, origBlossom);
blossoms.push(_local7);
_local7.addEventListener(Blossom.DRAWING_COMPLETE, onComplete, false, 0, true);
_local6++;
};
Blossom(blossoms[0]).beginDrawing();
Tracker.instance.send("beginWallpaper", null, 2);
}
override public function onAddedToStage(_arg1:Event=null):void{
super.onAddedToStage(_arg1);
origBlossom = wallpaperScreen.blossomData;
beginWallpaper(origBlossom);
tfProgress.text = "please wait...";
gauge.setValue(0);
}
protected function onAllComplete(){
var _local2:Blossom;
wallpaperDLScreen.wallpaper = blossomCanvas;
blossomCanvas = null;
var _local1:int;
while (_local1 < blossoms.length) {
_local2 = blossoms[_local1];
_local2.destroy();
_local2.removeEventListener(Blossom.DRAWING_COMPLETE, onComplete);
_local1++;
};
blossoms = [];
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "wallpaperDownload"));
Tracker.instance.send("completeWallpaper", null, 2);
}
override public function process(_arg1:Event=null):void{
super.process(_arg1);
}
protected function onComplete(_arg1:Event){
var _local2:Blossom = Blossom(_arg1.target);
var _local3:int = blossoms.indexOf(_local2);
tfProgress.text = (((("drawing flower " + (_local3 + 1)) + " of ") + blossoms.length) + "...");
gauge.setValue((Number(_local3) / (blossoms.length - 1)));
var _local4:Number = ((Blossom.maxRadius * 2) + 10);
var _local5:Number = ((Blossom.maxRadius * 2) + 10);
var _local6:int = Math.floor((w / _local4));
var _local7:int = Math.floor((h / _local5));
var _local8:Number = (_local3 % _local6);
var _local9:Number = ((_local3 - _local8) / _local6);
var _local10:Number = (Blossom.maxRadius + ((w - (_local4 * _local6)) / 2));
var _local11:Number = (Blossom.maxRadius + ((h - (_local5 * _local7)) / 2));
var _local12:Matrix = new Matrix(1, 0, 0, 1, ((_local8 * _local4) + _local10), ((_local9 * _local5) + _local11));
blossomCanvas.draw(_local2, _local12, null, null, null, true);
if (_local3 == (blossoms.length - 1)){
onAllComplete();
} else {
_local3++;
Blossom(blossoms[_local3]).beginDrawing();
};
}
protected function onCancel(_arg1:Event):void{
var _local3:Blossom;
blossomCanvas = null;
var _local2:int;
while (_local2 < blossoms.length) {
_local3 = blossoms[_local2];
_local3.destroy();
_local3.removeEventListener(Blossom.DRAWING_COMPLETE, onComplete);
_local2++;
};
blossoms = [];
gauge.setValue(0);
this.dispatchEvent(new MenuEvent(MenuEvent.REQUEST_SCREEN, "wallpaper"));
Tracker.instance.send("cancelWallpaper", null, 2);
}
}
}//package com.bobblebrook.menu
Section 70
//BaseGame (com.bobblebrook.BaseGame)
package com.bobblebrook {
import flash.display.*;
import com.bobblebrook.lisa.server.*;
import flash.events.*;
import mochi.as3.*;
public dynamic class BaseGame extends MovieClip {
protected var showAds:Boolean;// = true
protected var intro:Intro;
protected var skipIntro:Boolean;// = false
protected var sitelock:Boolean;// = true
protected var preloader:Preloader;
public function BaseGame(){
var _local2:*;
addFrameScript(18, frame19, 30, frame31, 57, frame58, 77, frame78);
super();
var _local1:int = (root.loaderInfo.parameters.trackerlevel) ? int(root.loaderInfo.parameters.trackerlevel) : 2;
Tracker.instance.debug = !(GameParams.PORTAL_VERSION);
if (!GameParams.PORTAL_VERSION){
Tracker.instance.init("rbpetunia", "http://www.bobblebrook.com/lisa/tracker.php", _local1);
};
Tracker.instance.turnOnPing(60);
Tracker.instance.send("LdgStart", null, 1);
CookieMGR.instance.init("garden");
if (skipIntro){
showPreloader();
} else {
intro = new Intro();
intro.scaleX = (intro.scaleY = 0.86);
addChild(intro);
intro.addEventListener(Intro.INTRO_LOADED, onIntroLoaded, false, 0, true);
intro.addEventListener(Intro.INTRO_FINISHED, onIntroFinished, false, 0, true);
};
if (!GameParams.PORTAL_VERSION){
_local2 = new Frame();
_local2.x = -5.5;
_local2.y = -6.2;
stage.addChild(_local2);
};
}
protected function showPreloader():void{
var _local1:MovieClip;
if (preloader != null){
return;
};
preloader = new Preloader();
if (!showAds){
preloader.addEventListener(Preloader.LOADING_FINISHED, onLoadingFinished, false, 0, true);
};
gotoAndPlay("preloader");
addChild(preloader);
Tracker.instance.send("ScrStart", ["Preloader"], 2);
if (showAds){
_local1 = new MovieClip();
addChild(_local1);
MochiAd.showPreGameAd({id:"af1a14421d3b0d79", res:"550x400", clip:_local1, no_bg:false, fadeout_time:7000, ad_progress:adProgress, ad_finished:adFinished});
};
}
function frame31(){
stop();
}
function frame78(){
stop();
}
protected function onLoadingFinished(_arg1:Event):void{
if (preloader){
preloader.removeEventListener(Preloader.LOADING_FINISHED, onLoadingFinished);
preloader.destroy();
removeChild(preloader);
preloader = null;
};
trace(decodeURI(loaderInfo.url));
if ((((((((((((((((((((((((loaderInfo.url.indexOf("http://www.bobblebrook.com") == -1)) && ((loaderInfo.url.indexOf("http://jayisgames.com") == -1)))) && ((loaderInfo.url.indexOf("http://bobblebrook.com") == -1)))) && ((loaderInfo.url.indexOf("http://bobblebrook.net") == -1)))) && ((loaderInfo.url.indexOf("http://www.bobblebrook.net") == -1)))) && ((loaderInfo.url.indexOf("http://www.jayisgames.com") == -1)))) && ((loaderInfo.url.indexOf("http://casualgameplay.com") == -1)))) && ((loaderInfo.url.indexOf("http://www.casualgameplay.com") == -1)))) && ((loaderInfo.url.indexOf("http://cgdc8.fizzlebot.com") == -1)))) && ((loaderInfo.url.indexOf("http://72.47.235.141") == -1)))) && ((loaderInfo.url.indexOf("file:///") == -1)))) && (sitelock))){
Tracker.instance.send("ScrStart", ["sitelock"], 1);
gotoAndPlay("sitelock");
} else {
startGame();
};
}
private function adProgress(_arg1:Number):void{
}
protected function startGame():void{
gotoAndPlay("game");
}
private function adFinished():void{
if (!preloader){
return;
};
if (preloader.getPercent() == 100){
onLoadingFinished(null);
} else {
preloader.addEventListener(Preloader.LOADING_FINISHED, onLoadingFinished, false, 0, true);
};
}
function frame58(){
stop();
}
protected function onIntroLoaded(_arg1:Event):void{
intro.removeEventListener(Intro.INTRO_LOADED, onIntroLoaded);
intro.play();
Tracker.instance.send("ScrStart", ["Intro"], 2);
}
function frame19(){
stop();
}
protected function onIntroFinished(_arg1:Event):void{
intro.removeEventListener(Intro.INTRO_FINISHED, onIntroFinished);
intro.destroy();
removeChild(intro);
intro = null;
showPreloader();
}
}
}//package com.bobblebrook
Section 71
//DefaultButton (com.bobblebrook.DefaultButton)
package com.bobblebrook {
import flash.display.*;
import com.bobblebrook.lisa.server.*;
import flash.events.*;
import com.bobblebrook.lisa.*;
import flash.text.*;
public class DefaultButton extends MovieClip {
private var $label:String;
public var transpRect:MovieClip;
private var $active:Boolean;
private var $state:String;
public var mcLabel:MovieClip;
private static var DOWN:String = "down";
private static var INACTIVE:String = "inactive";
private static var OUT:String = "out";
private static var OVER:String = "over";
public static var BUTTON_PRESSED:String = "buttonPressed";
private static var UP:String = "up";
public function DefaultButton(){
addFrameScript(14, frame15, 29, frame30, 44, frame45, 59, frame60);
super();
state = OUT;
initListeners();
active = true;
label = "DefaultButton";
}
private function onMouseUp(_arg1:Event):void{
Tracker.instance.send("Btn", [name], 2);
dispatchEvent(new Event(BUTTON_PRESSED));
state = UP;
}
public function get active():Boolean{
return ($active);
}
private function onMouseDown(_arg1:Event):void{
SoundMGR.instance.playSound("btnPress");
state = DOWN;
}
function frame30(){
stop();
}
public function set active(_arg1:Boolean):void{
$active = _arg1;
if (!_arg1){
removeListeners();
state = INACTIVE;
} else {
initListeners();
state = OUT;
};
}
private function initListeners():void{
addEventListener(MouseEvent.MOUSE_UP, onMouseUp, false, 0, true);
addEventListener(MouseEvent.ROLL_OVER, onRollOver, false, 0, true);
addEventListener(MouseEvent.ROLL_OUT, onRollOut, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true);
}
function frame15(){
stop();
}
public function get state():String{
return ($state);
}
private function removeListeners():void{
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
}
public function set state(_arg1:String):void{
$state = _arg1;
gotoAndPlay(_arg1);
}
function frame60(){
stop();
}
public function set label(_arg1:String):void{
$label = _arg1;
mcLabel["tfLabel"].htmlText = _arg1;
TextField(mcLabel.tfLabel).width = (TextField(mcLabel.tfLabel).textWidth + 10);
transpRect.width = (TextField(mcLabel.tfLabel).textWidth + 10);
}
function frame45(){
stop();
}
private function onRollOver(_arg1:Event):void{
state = OVER;
SoundMGR.instance.playSound("btnOver");
}
private function onRollOut(_arg1:Event):void{
state = OUT;
}
public function get label():String{
return ($label);
}
}
}//package com.bobblebrook
Section 72
//GameParams (com.bobblebrook.GameParams)
package com.bobblebrook {
public class GameParams {
public static const PORTAL_VERSION:Boolean = false;
}
}//package com.bobblebrook
Section 73
//Intro (com.bobblebrook.Intro)
package com.bobblebrook {
import flash.display.*;
import flash.events.*;
public class Intro extends MovieClip {
public static var INTRO_LOADED:String = "IntroLoaded";
public static var INTRO_FINISHED:String = "IntroFinished";
public function Intro(){
addFrameScript(89, frame90);
super();
stop();
addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
}
public function destroy():void{
}
public function start():void{
gotoAndPlay(1);
}
public function onEnterFrame(_arg1:Event):void{
if (framesLoaded == totalFrames){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
dispatchEvent(new Event(INTRO_LOADED));
};
}
function frame90(){
onLastFrameReached();
}
public function onLastFrameReached():void{
stop();
dispatchEvent(new Event(INTRO_FINISHED));
}
}
}//package com.bobblebrook
Section 74
//Preloader (com.bobblebrook.Preloader)
package com.bobblebrook {
import flash.display.*;
import flash.events.*;
import com.bobblebrook.gui.*;
import flash.text.*;
public class Preloader extends MovieClip {
public var gauge:Gauge;
private var percentage:Number;
public var tfPercentage:TextField;
public static var LOADING_FINISHED:String = "loadingFinished";
public function Preloader(){
addFrameScript(0, frame1);
super();
addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
}
public function destroy():void{
}
public function onLoadingFinished(_arg1:Event):void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
dispatchEvent(new Event(LOADING_FINISHED));
}
public function onEnterFrame(_arg1:Event):void{
var _local2:int = percentage;
percentage = Math.round(((loaderInfo.bytesLoaded / loaderInfo.bytesTotal) * 100));
gauge.setValue((percentage / 100));
tfPercentage.text = (String(percentage) + "%");
if (loaderInfo.bytesLoaded == loaderInfo.bytesTotal){
onLoadingFinished(new Event(""));
};
}
function frame1(){
stop();
}
public function getPercent():Number{
return (percentage);
}
}
}//package com.bobblebrook
Section 75
//ScreenMGR (com.bobblebrook.ScreenMGR)
package com.bobblebrook {
import com.bobblebrook.garden.*;
import flash.display.*;
import com.bobblebrook.lisa.server.*;
import flash.events.*;
import com.bobblebrook.lisa.*;
import com.bobblebrook.menu.*;
import com.bobblebrook.gui.*;
import com.bobblebrook.garden.fx.*;
public class ScreenMGR extends MovieClip {
protected var _currentScreen:BaseScreen;
protected var screens:Array;
protected var arrangement:Arrangement;
public var transitionContainer:MovieClip;
public var gameContainer:MovieClip;
protected var game:Game;
public var screenContainer:MovieClip;
public var messageContainer:MovieClip;
protected var nextScreen:BaseScreen;// = null
public static const screenWidth:Number = 550;
public static const screenHeight:Number = 400;
public function ScreenMGR(){
ScoreMGR.instance.gameName = "rarebreedspetunia";
ScoreMGR.instance.highscoreURL = "http://www.bobblebrook.com/lisa/highscoresAS3.php";
game = new Game();
gameContainer.addChild(game);
arrangement = new Arrangement();
arrangement.mouseEnabled = false;
arrangement.mouseChildren = false;
gameContainer.addChild(arrangement);
screens = [];
createAllScreens();
SoundMGR.instance.addEventListener(SoundMGR.MUSIC_MUTED, onMute);
SoundMGR.instance.addEventListener(SoundMGR.MUSIC_UNMUTED, onUnmute);
this.addEventListener(Event.ENTER_FRAME, process);
}
public function createAllScreens():void{
var _local1:BaseScreen;
_local1 = new IntroScreen(game, arrangement);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
_local1.x = (_local1.y = 0);
screens["intro"] = _local1;
_local1 = new AboutScreen(game, arrangement);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
screens["about"] = _local1;
_local1 = new InspectScreen(game, arrangement);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
screens["inspect"] = _local1;
_local1 = new LoadScreen(game, arrangement);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
screens["load"] = _local1;
_local1 = new WallpaperScreen(game, arrangement);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
screens["wallpaper"] = _local1;
_local1 = new WallpaperDownloadScreen(game, arrangement);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
screens["wallpaperDownload"] = _local1;
_local1 = new WallpaperWaitScreen(game, screens["wallpaper"], screens["wallpaperDownload"]);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
screens["wallpaperWait"] = _local1;
_local1 = new SendScreen(game, arrangement);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
screens["sendFriend"] = _local1;
_local1 = new GameScreen(game, arrangement, screens["inspect"], screens["sendFriend"], screens["wallpaper"]);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
screens["game"] = _local1;
_local1 = new ConfirmLoadScreen(game, arrangement, screens["game"]);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
screens["confirmLoad"] = _local1;
_local1 = new LoadWaitScreen(game, arrangement);
_local1.x = (_local1.y = 0);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
LoadWaitScreen(_local1).confirmLoadScreen = screens["confirmLoad"];
LoadWaitScreen(_local1).loadScreen = screens["load"];
screens["loadWait"] = _local1;
_local1 = new MenuScreen(game, arrangement, screens["game"]);
_local1.addEventListener(MenuEvent.REQUEST_SCREEN, onRequestScreen);
_local1.addEventListener(MessageContainer.FADE_OUT_COMPLETE, onFadeOutComplete);
_local1.x = (_local1.y = 0);
screens["menu"] = _local1;
_currentScreen = screens["intro"];
this.screenContainer.addChild(_currentScreen);
}
public function getCurrentScreen():BaseScreen{
return (_currentScreen);
}
protected function onMute(_arg1:Event=null):void{
trace("on mute");
var _local2 = "sound off";
screens["menu"].btnSound.label = _local2;
screens["game"].btnSound.label = _local2;
}
protected function _clearScreen():void{
while (screenContainer.numChildren != 0) {
screenContainer.removeChildAt(0);
};
}
public function switchToScreen(_arg1:String):void{
_currentScreen.mouseChildren = false;
Tracker.instance.send("ScrStart", [_arg1], 3);
nextScreen = screens[_arg1];
_currentScreen.setState(MessageContainer.FADE_OUT);
screenContainer.addChild(nextScreen);
_currentScreen = nextScreen;
nextScreen = null;
_currentScreen.mouseChildren = true;
if ((_currentScreen is GameScreen)){
game.scrollDown();
arrangement.visible = false;
} else {
arrangement.visible = true;
game.scrollUp();
};
}
protected function onUnmute(_arg1:Event=null):void{
var _local2 = "sound on";
screens["menu"].btnSound.label = _local2;
screens["game"].btnSound.label = _local2;
}
public function process(_arg1:Event=null):void{
arrangement.process();
}
public function onFadeOutComplete(_arg1:Event):void{
if (this.screenContainer.contains(DisplayObject(_arg1.target))){
this.screenContainer.removeChild(DisplayObject(_arg1.target));
};
}
public function onRequestScreen(_arg1:MenuEvent):void{
switchToScreen(_arg1.param);
}
}
}//package com.bobblebrook
Section 76
//UploadPostHelper (com.bobblebrook.UploadPostHelper)
package com.bobblebrook {
import flash.utils.*;
import flash.events.*;
import flash.net.*;
public class UploadPostHelper {
private static var _boundary:String = "";
public static function getBoundary():String{
var _local1:int;
if (_boundary.length == 0){
_local1 = 0;
while (_local1 < 20) {
_boundary = (_boundary + String.fromCharCode(int((97 + (Math.random() * 25)))));
_local1++;
};
};
return (_boundary);
}
private static function DOUBLEDASH(_arg1:ByteArray):ByteArray{
_arg1.writeShort(0x2D2D);
return (_arg1);
}
public static function getPostData(_arg1:String, _arg2:ByteArray, _arg3:Object=null):ByteArray{
var _local4:int;
var _local5:String;
var _local7:String;
var _local6:ByteArray = new ByteArray();
_local6.endian = Endian.BIG_ENDIAN;
if (_arg3 == null){
_arg3 = new Object();
};
_arg3.Filename = _arg1;
for (_local7 in _arg3) {
_local6 = BOUNDARY(_local6);
_local6 = LINEBREAK(_local6);
_local5 = (("Content-Disposition: form-data; name=\"" + _local7) + "\"");
_local4 = 0;
while (_local4 < _local5.length) {
_local6.writeByte(_local5.charCodeAt(_local4));
_local4++;
};
_local6 = LINEBREAK(_local6);
_local6 = LINEBREAK(_local6);
_local6.writeUTFBytes(_arg3[_local7]);
_local6 = LINEBREAK(_local6);
};
_local6 = BOUNDARY(_local6);
_local6 = LINEBREAK(_local6);
_local5 = "Content-Disposition: form-data; name=\"Filedata\"; filename=\"";
_local4 = 0;
while (_local4 < _local5.length) {
_local6.writeByte(_local5.charCodeAt(_local4));
_local4++;
};
_local6.writeUTFBytes(_arg1);
_local6 = QUOTATIONMARK(_local6);
_local6 = LINEBREAK(_local6);
_local5 = "Content-Type: application/octet-stream";
_local4 = 0;
while (_local4 < _local5.length) {
_local6.writeByte(_local5.charCodeAt(_local4));
_local4++;
};
_local6 = LINEBREAK(_local6);
_local6 = LINEBREAK(_local6);
_local6.writeBytes(_arg2, 0, _arg2.length);
_local6 = LINEBREAK(_local6);
_local6 = LINEBREAK(_local6);
_local6 = BOUNDARY(_local6);
_local6 = LINEBREAK(_local6);
_local5 = "Content-Disposition: form-data; name=\"Upload\"";
_local4 = 0;
while (_local4 < _local5.length) {
_local6.writeByte(_local5.charCodeAt(_local4));
_local4++;
};
_local6 = LINEBREAK(_local6);
_local6 = LINEBREAK(_local6);
_local5 = "Submit Query";
_local4 = 0;
while (_local4 < _local5.length) {
_local6.writeByte(_local5.charCodeAt(_local4));
_local4++;
};
_local6 = LINEBREAK(_local6);
_local6 = BOUNDARY(_local6);
_local6 = DOUBLEDASH(_local6);
return (_local6);
}
private static function QUOTATIONMARK(_arg1:ByteArray):ByteArray{
_arg1.writeByte(34);
return (_arg1);
}
private static function BOUNDARY(_arg1:ByteArray):ByteArray{
var _local2:int = UploadPostHelper.getBoundary().length;
_arg1 = DOUBLEDASH(_arg1);
var _local3:int;
while (_local3 < _local2) {
_arg1.writeByte(_boundary.charCodeAt(_local3));
_local3++;
};
return (_arg1);
}
private static function LINEBREAK(_arg1:ByteArray):ByteArray{
_arg1.writeShort(3338);
return (_arg1);
}
}
}//package com.bobblebrook
Section 77
//MochiAd (mochi.as3.MochiAd)
package mochi.as3 {
import flash.display.*;
import flash.utils.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showClickAwayAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:5500, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
_local3 = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.root == null){
_local3 = true;
};
if (_local3){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(_arg1:String):String{
var _local2:String = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType == "application"){
return (_local2);
};
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (_arg1.origFrameRate != undefined){
_arg1.stage.frameRate = _arg1.origFrameRate;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad._containerLCName != undefined){
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "notify", {id:"unload"});
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:5500, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (_local2 > chk.ad_msec){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _cleanup(_arg1:Object):void{
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
var idx:Number = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(_arg1:Object):MovieClip{
var clip:Object;
var mc:MovieClip;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!(clip is DisplayObject)){
trace("Warning: Object passed as container clip not a descendant of the DisplayObject type");
return (null);
};
if (MovieClip(clip).stage == null){
trace("Warning: Container clip for ad is not attached to the stage");
return (null);
};
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
var depth:Number = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
var wh:Array = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
} else {
trace("[MochiAd] NOTE: Security Sandbox Violation errors below are normal");
};
var lv:URLVariables = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
loader = new Loader();
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest(((server + ".swf?cacheBust=") + new Date().getTime()));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (_arg1:IOErrorEvent):void{
trace("[MochiAds] Blocked URL");
});
if (!options.skip){
loader.load(req);
};
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(_arg1:Object, _arg2:String, _arg3:Array):Object{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
if (typeof(_arg1[_local4[_local5]]) == "function"){
return (_arg1[_local4[_local5]].apply(_arg1, _arg3));
};
return (undefined);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local6:Array;
var _local3:Object = _arg2.getBounds(_arg2.root);
var _local4:Number = 0;
var _local5:Number = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.right - _local3.left);
_local5 = (_local3.top - _local3.bottom);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function adShowing(_arg1:Object):void{
_arg1.origFrameRate = _arg1.stage.frameRate;
_arg1.stage.frameRate = 30;
}
public static function getValue(_arg1:Object, _arg2:String):Object{
var _local3:Array = _arg2.split(".");
var _local4:Number = 0;
while (_local4 < (_local3.length - 1)) {
if ((((_arg1[_local3[_local4]] == undefined)) || ((_arg1[_local3[_local4]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local3[_local4]];
_local4++;
};
return (_arg1[_local3[_local4]]);
}
public static function rpc(_arg1:Object, _arg2:Number, _arg3:Object):void{
var _local4:Object;
var _local5:Object;
switch (_arg3.id){
case "setValue":
MochiAd.setValue(_arg1, _arg3.objectName, _arg3.value);
break;
case "getValue":
_local4 = MochiAd.getValue(_arg1, _arg3.objectName);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(_arg1, _arg3.method, _arg3.args);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + _arg3.id));
};
}
public static function setValue(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return;
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
_arg1[_local4[_local5]] = _arg3;
}
public static function showPreGameAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var complete:Boolean;
var unloaded:Boolean;
var sendHostProgress:Boolean;
var fn:Function;
var r:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:5500, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (_arg1:Number):void{
}, progress_override:function (_arg1:Object):Number{
return (NaN);
}, bar_offset:0};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
return;
};
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
if (options.skip){
ad_timeout = 0;
};
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
var fn:Function = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = (10 + options.bar_offset);
bar.y = (h - 20);
};
var bar_w:Number = ((w - bar.x) - 10);
var bar_color:Number = options.color;
delete options.color;
var bar_background:Number = options.background;
delete options.background;
var bar_outline:Number = options.outline;
delete options.outline;
var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1);
var backing:Object = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo(bar_w, 0);
backing.lineTo(bar_w, 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2);
var inside:Object = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo(bar_w, 0);
inside.lineTo(bar_w, 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3);
var outline:Object = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo(bar_w, 0);
outline.lineTo(bar_w, 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
var progress:Number = Math.min(1, options.progress_override(clip));
var f:Function = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
if (!isNaN(progress)){
complete = (progress == 1);
} else {
if (clip.loaderInfo.bytesLoaded == clip.loaderInfo.bytesTotal){
complete = true;
} else {
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
mc.rpcTestFn = function (_arg1:String):Object{
trace(("[MOCHIAD rpcTestFn] " + _arg1));
return (_arg1);
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (_arg1:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var _local12:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
var _local1:Object = this.parent.parent.root;
var _local2:Object = this.parent._mochiad_ctr;
var _local3:Number = (getTimer() - this.started);
var _local4:Boolean;
var _local5:Number = _local1.loaderInfo.bytesTotal;
var _local6:Number = _local1.loaderInfo.bytesLoaded;
var _local7:Number = Math.min(1, options.progress_override(_local1));
if (_local7 == 1){
complete = true;
};
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
var _local8:Number = ((100 * _local6) / _local5);
if (!isNaN(_local7)){
_local8 = (100 * _local7);
};
var _local9:Number = ((100 * _local3) / chk.ad_msec);
var _local10:Object = this._mochiad_bar._inside;
var _local11:Number = Math.min(100, Math.min(((_local8) || (0)), _local9));
_local11 = Math.max(this.last_pcnt, _local11);
this.last_pcnt = _local11;
_local10.scaleX = (_local11 * 0.01);
options.ad_progress(_local11);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local8});
if (_local8 >= 100){
sendHostProgress = false;
};
};
if (!chk.showing){
_local12 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local12 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((_local3 > chk.ad_timeout)) && ((_local8 == 100)))){
options.ad_failed();
_local4 = true;
};
};
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (unloaded){
MochiAd.unload(_local1);
} else {
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(_arg1);
}
public static function showTimedAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(_arg1);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var mc = _arg1;
var f:Function = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package mochi.as3
Section 78
//MochiCoins (mochi.as3.MochiCoins)
package mochi.as3 {
public class MochiCoins {
public static const STORE_HIDE:String = "StoreHide";
public static const NO_USER:String = "NoUser";
public static const IO_ERROR:String = "IOError";
public static const ITEM_NEW:String = "ItemNew";
public static const ITEM_OWNED:String = "ItemOwned";
public static const STORE_ITEMS:String = "StoreItems";
public static const ERROR:String = "Error";
public static const STORE_SHOW:String = "StoreShow";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static var _inventory:MochiInventory;
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function getStoreItems():void{
MochiServices.send("coins_getStoreItems");
}
public static function get inventory():MochiInventory{
return (_inventory);
}
public static function showStore(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showStore", {options:_arg1}, null, null);
}
public static function requestFunding(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_requestFunding", _arg1);
}
public static function showItem(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showItem call must pass an Object with an item key");
return;
};
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showItem", {options:_arg1}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showVideo(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showVideo call must pass an Object with an item key");
return;
};
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showVideo", {options:_arg1}, null, null);
}
addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_inventory = new MochiInventory();
});
addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_inventory = null;
});
}
}//package mochi.as3
Section 79
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Sibling:MochiDigits;
private var Fragment:Number;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function reencode():void{
var _local1:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function toString():String{
var _local1:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String = _arg1.toString();
var _temp1 = _arg2;
_arg2 = (_arg2 + 1);
Fragment = (_local3.charCodeAt(_temp1) ^ Encoder);
if (_arg2 < _local3.length){
Sibling = new MochiDigits(_arg1, _arg2);
} else {
Sibling = null;
};
reencode();
}
public function get value():Number{
return (Number(this.toString()));
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
}
}//package mochi.as3
Section 80
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher)
package mochi.as3 {
public class MochiEventDispatcher {
private var eventTable:Object;
public function MochiEventDispatcher():void{
eventTable = {};
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
return;
};
for (_local3 in eventTable[_arg1]) {
var _local6 = eventTable[_arg1];
_local6[_local3](_arg2);
};
}
public function removeEventListener(_arg1:String, _arg2:Function):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
eventTable[_arg1] = [];
return;
};
for (_local3 in eventTable[_arg1]) {
if (eventTable[_arg1][_local3] != _arg2){
} else {
eventTable[_arg1].splice(Number(_local3), 1);
};
};
}
public function addEventListener(_arg1:String, _arg2:Function):void{
removeEventListener(_arg1, _arg2);
eventTable[_arg1].push(_arg2);
}
}
}//package mochi.as3
Section 81
//MochiEvents (mochi.as3.MochiEvents)
package mochi.as3 {
import flash.display.*;
public class MochiEvents {
public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL";
public static const FORMAT_LONG:String = "LongForm";
public static const ALIGN_BOTTOM:String = "ALIGN_B";
public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived";
public static const FORMAT_SHORT:String = "ShortForm";
public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR";
public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR";
public static const ALIGN_TOP:String = "ALIGN_T";
public static const ALIGN_LEFT:String = "ALIGN_L";
public static const ALIGN_RIGHT:String = "ALIGN_R";
public static const ALIGN_TOP_LEFT:String = "ALIGN_TL";
public static const ALIGN_CENTER:String = "ALIGN_C";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
private static var gameStart:Number;
private static var levelStart:Number;
public static function endPlay():void{
MochiServices.send("events_clearRoundID", null, null, null);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function trackEvent(_arg1:String, _arg2=null):void{
MochiServices.send("events_trackEvent", {tag:_arg1, value:_arg2}, null, null);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function startSession(_arg1:String):void{
MochiServices.send("events_beginSession", {achievementID:_arg1}, null, null);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function setNotifications(_arg1:MovieClip, _arg2:Object):void{
var _local4:Object;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
_local3.clip = _arg1;
MochiServices.send("events_setNotifications", _local3, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function startPlay(_arg1:String="gameplay"):void{
MochiServices.send("events_setRoundID", {tag:String(_arg1)}, null, null);
}
}
}//package mochi.as3
Section 82
//MochiInventory (mochi.as3.MochiInventory)
package mochi.as3 {
import flash.utils.*;
import flash.events.*;
public dynamic class MochiInventory extends Proxy {
private var _timer:Timer;
private var _names:Array;
private var _syncID:Number;
private var _consumableProperties:Object;
private var _storeSync:Object;
private var _outstandingID:Number;
private var _syncPending:Boolean;
public static const READY:String = "InvReady";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IoError";
private static const KEY_SALT:String = " syncMaint";
public static const WRITTEN:String = "InvWritten";
public static const NOT_READY:String = "InvNotReady";
public static const VALUE_ERROR:String = "InvValueError";
private static const CONSUMER_KEY:String = "MochiConsumables";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public function MochiInventory():void{
MochiCoins.addEventListener(MochiCoins.ITEM_OWNED, itemOwned);
MochiCoins.addEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, loggedOut);
_storeSync = new Object();
_syncPending = false;
_outstandingID = 0;
_syncID = 0;
_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, sync);
_timer.start();
if (MochiSocial.loggedIn){
loggedIn();
} else {
loggedOut();
};
}
private function newItems(_arg1:Object):void{
if (!this[(_arg1.id + KEY_SALT)]){
this[(_arg1.id + KEY_SALT)] = 0;
};
if (!this[_arg1.id]){
this[_arg1.id] = 0;
};
this[(_arg1.id + KEY_SALT)] = (this[(_arg1.id + KEY_SALT)] + _arg1.count);
this[_arg1.id] = (this[_arg1.id] + _arg1.count);
if (((_arg1.privateProperties) && (_arg1.privateProperties.consumable))){
if (!this[_arg1.privateProperties.tag]){
this[_arg1.privateProperties.tag] = 0;
};
this[_arg1.privateProperties.tag] = (this[_arg1.privateProperties.tag] + (_arg1.privateProperties.inc * _arg1.count));
};
}
public function release():void{
MochiCoins.removeEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.removeEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.removeEventListener(MochiSocial.LOGGED_OUT, loggedOut);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (-1);
};
if (_consumableProperties[_arg1]){
return (MochiDigits(_consumableProperties[_arg1]).value);
};
return (undefined);
}
private function loggedIn(_arg1:Object=null):void{
MochiUserData.get(CONSUMER_KEY, getConsumableBag);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(_arg1):Boolean{
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (false);
};
if (_consumableProperties[_arg1] == undefined){
return (false);
};
return (true);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(_arg1:int):int{
return (((_arg1)>=_names.length) ? 0 : (_arg1 + 1));
}
private function putConsumableBag(_arg1:MochiUserData):void{
_syncPending = false;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
_outstandingID = -1;
};
triggerEvent(WRITTEN, {});
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
var _local3:MochiDigits;
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return;
};
if (!(_arg2 is Number)){
triggerEvent(ERROR, {type:VALUE_ERROR, error:"Invalid type", arg:_arg2});
return;
};
if (_consumableProperties[_arg1]){
_local3 = MochiDigits(_consumableProperties[_arg1]);
if (_local3.value == _arg2){
return;
};
_local3.value = _arg2;
} else {
_names.push(_arg1);
_consumableProperties[_arg1] = new MochiDigits(_arg2);
};
_syncID++;
}
private function itemOwned(_arg1:Object):void{
_storeSync[_arg1.id] = {properties:_arg1.properties, count:_arg1.count};
}
private function sync(_arg1:Event=null):void{
var _local3:String;
if (((_syncPending) || ((_syncID == _outstandingID)))){
return;
};
_outstandingID = _syncID;
var _local2:Object = {};
for (_local3 in _consumableProperties) {
_local2[_local3] = MochiDigits(_consumableProperties[_local3]).value;
};
MochiUserData.put(CONSUMER_KEY, _local2, putConsumableBag);
_syncPending = true;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(_arg1:int):String{
return (_names[(_arg1 - 1)]);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(_arg1):Boolean{
if (!_consumableProperties[_arg1]){
return (false);
};
_names.splice(_names.indexOf(_arg1), 1);
delete _consumableProperties[_arg1];
return (true);
}
private function getConsumableBag(_arg1:MochiUserData):void{
var _local2:String;
var _local3:Number;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
return;
};
_consumableProperties = {};
_names = new Array();
if (_arg1.data){
for (_local2 in _arg1.data) {
_names.push(_local2);
_consumableProperties[_local2] = new MochiDigits(_arg1.data[_local2]);
};
};
for (_local2 in _storeSync) {
_local3 = _storeSync[_local2].count;
if (_consumableProperties[(_local2 + KEY_SALT)]){
_local3 = (_local3 - _consumableProperties[(_local2 + KEY_SALT)].value);
};
if (_local3 == 0){
} else {
newItems({id:_local2, count:_local3, properties:_storeSync[_local2].properties});
};
};
triggerEvent(READY, {});
}
private function loggedOut(_arg1:Object=null):void{
_consumableProperties = null;
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
}
}//package mochi.as3
Section 83
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.display.*;
import flash.utils.*;
import flash.events.*;
import flash.net.*;
import flash.geom.*;
import flash.system.*;
public class MochiServices {
public static const CONNECTED:String = "onConnected";
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _queue:Array;
private static var _swfVersion:String;
private static var _preserved:Object;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
private static var _nextCallbackID:Number;
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _services:String = "services.swf";
private static var _servURL:String = "http://www.mochiads.com/static/lib/services/";
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
private static var _callbacks:Object;
private static var _connecting:Boolean = false;
private static var _mochiLocalConnection:MovieClip;
private static var _listenChannelName:String = "__ms_";
public static var onError:Object;
public static var netup:Boolean = true;
private static var _mochiLC:String = "MochiLC.swf";
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function onReceive(_arg1:Object):void{
var methodName:String;
var pkg = _arg1;
var cb:String = pkg.callbackID;
var cblst:Object = _callbacks[cb];
if (!cblst){
return;
};
var method:* = cblst.callbackMethod;
methodName = "";
var obj:Object = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete _callbacks[cb];
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_nextCallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + _arg1));
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_queue.push({methodName:_arg1, args:_arg2, callbackID:_nextCallbackID});
};
if (_clip != null){
if (_callbacks != null){
_callbacks[_nextCallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_nextCallbackID++;
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local4:int;
var _local14:Loader;
var _local3:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
var _local5:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var _local6:Array = [0, 64, 0, 0, 0];
var _local7:MovieClip = new MovieClip();
var _local8:LocalConnection = new LocalConnection();
var _local9:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().time));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
var _local10:ByteArray = new ByteArray();
var _local11:ByteArray = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
var _local12:uint = ((_local3.length + _local11.length) + 4);
var _local13:uint = (_local12 + 35);
_local10.endian = Endian.LITTLE_ENDIAN;
_local10.writeUTFBytes("FWS");
_local10.writeByte(8);
_local10.writeUnsignedInt(_local13);
for each (_local4 in _local5) {
_local10.writeByte(_local4);
};
_local10.writeUnsignedInt(_local12);
_local10.writeByte(136);
_local10.writeShort(_local11.length);
_local10.writeBytes(_local11);
for each (_local4 in _local3) {
_local10.writeByte(_local4);
};
for each (_local4 in _local6) {
_local10.writeByte(_local4);
};
_local14 = new Loader();
_local14.loadBytes(_local10);
_local7.addChild(_local14);
return (_local7);
}
private static function detach(_arg1:Event):void{
var _local2:LoaderInfo = LoaderInfo(_arg1.target);
_local2.removeEventListener(Event.COMPLETE, detach);
_local2.removeEventListener(IOErrorEvent.IO_ERROR, detach);
_local2.removeEventListener(Event.COMPLETE, loadLCBridgeComplete);
_local2.removeEventListener(IOErrorEvent.IO_ERROR, loadError);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
private static function loadLCBridgeComplete(_arg1:Event):void{
var _local2:Loader = LoaderInfo(_arg1.target).loader;
_mochiLocalConnection = MovieClip(_local2.content);
listen();
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_mochiLocalConnection.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
_timer.removeEventListener(TimerEvent.TIMER, connectWait);
_timer = null;
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
};
return (_local2);
}
public static function getVersion():String{
return ("3.9.1 as3");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
}
public static function warnID(_arg1:String, _arg2:Boolean):void{
_arg1 = _arg1.toLowerCase();
if (_arg1.length != 16){
trace((("WARNING: " + (_arg2) ? "board" : "game") + " ID is not the appropriate length"));
return;
} else {
if (_arg1 == "1e113c7239048b3f"){
if (_arg2){
trace("WARNING: Using testing board ID");
} else {
trace("WARNING: Using testing board ID as game ID");
};
return;
} else {
if (_arg1 == "84993a1de4031cd8"){
if (_arg2){
trace("WARNING: Using testing game ID as board ID");
} else {
trace("WARNING: Using testing game ID");
};
return;
};
};
};
var _local3:Number = 0;
while (_local3 < _arg1.length) {
switch (_arg1.charAt(_local3)){
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
break;
default:
trace(("WARNING: Board ID contains illegal characters: " + _arg1));
return;
};
_local3++;
};
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (((_clip) && (_queue))){
while (_queue.length > 0) {
_local2 = _queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _callbacks[_local2.callbackID];
};
delete _callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
}
public static function get id():String{
return (_id);
}
private static function onEvent(_arg1:Object):void{
var _local2:String = _arg1.target;
var _local3:String = _arg1.event;
switch (_local2){
case "services":
MochiServices.triggerEvent(_arg1.event, _arg1.args);
break;
case "events":
MochiEvents.triggerEvent(_arg1.event, _arg1.args);
break;
case "coins":
MochiCoins.triggerEvent(_arg1.event, _arg1.args);
break;
case "social":
MochiSocial.triggerEvent(_arg1.event, _arg1.args);
break;
};
}
private static function urlOptions(_arg1:Object):Object{
var _local3:String;
var _local4:Array;
var _local5:Number;
var _local6:Array;
var _local2:Object = {};
if (_arg1.stage){
_local3 = _arg1.stage.loaderInfo.parameters.mochiad_options;
} else {
_local3 = _arg1.loaderInfo.parameters.mochiad_options;
};
if (_local3){
_local4 = _local3.split("&");
_local5 = 0;
while (_local5 < _local4.length) {
_local6 = _local4[_local5].split("=");
_local2[unescape(_local6[0])] = unescape(_local6[1]);
_local5++;
};
};
return (_local2);
}
public static function addLinkEvent(_arg1:String, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Function=null):void{
var avm1Click:DisplayObject;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = _arg1;
var burl = _arg2;
var btn = _arg3;
var onClick = _arg4;
var vars:Object = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
var s = "?";
var i:Number = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://link.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (_arg1:String):void{
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
var _local2:Rectangle = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = _local2.x;
avm1Click.y = _local2.y;
avm1Click.scaleX = (0.01 * _local2.width);
avm1Click.scaleY = (0.01 * _local2.height);
};
err = function (_arg1:Object):void{
netup = false;
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
setURL(burl);
};
complete = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_clip.parent){
_clip.parent.removeChild(_clip);
};
if (_arg1 != null){
if ((_arg1 is DisplayObjectContainer)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is DisplayObjectContainer)){
DisplayObjectContainer(_container).addChild(_clip);
};
};
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
private static function loadError(_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
}
public static function get childClip():Object{
return (_clip);
}
private static function initComChannels():void{
if (!_connected){
trace("[SERVICES_API] connected!");
_connecting = false;
_connected = true;
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"registerGame", preserved:_preserved, id:_id, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_clip.onReceive = onReceive;
_clip.onEvent = onEvent;
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
while (_queue.length > 0) {
_mochiLocalConnection.send(_sendChannelName, "onReceive", _queue.shift());
};
};
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
private static function listen():void{
_mochiLocalConnection.connect(_listenChannelName);
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
trace("Waiting for MochiAds services to connect...");
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
private static function loadLCBridge(_arg1:Object):void{
var _local2:Loader = new Loader();
var _local3:String = (_servURL + _mochiLC);
var _local4:URLRequest = new URLRequest(_local3);
_local2.contentLoaderInfo.addEventListener(Event.COMPLETE, detach);
_local2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, detach);
_local2.contentLoaderInfo.addEventListener(Event.COMPLETE, loadLCBridgeComplete);
_local2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
_local2.load(_local4);
_arg1.addChild(_local2);
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(_arg2).servURL){
_servURL = urlOptions(_arg2).servURL;
};
var _local3:String = (_servURL + _services);
if (urlOptions(_arg2).servicesURL){
_local3 = urlOptions(_arg2).servicesURL;
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999))));
MochiServices.allowDomains(_local3);
_clip = new MovieClip();
loadLCBridge(_clip);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, detach);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, detach);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
var _local4:URLRequest = new URLRequest(_local3);
var _local5:URLVariables = new URLVariables();
_local5.listenLC = _listenChannelName;
_local5.mochiad_options = _arg2.loaderInfo.parameters.mochiad_options;
_local5.api_version = getVersion();
if (widget){
_local5.widget = true;
};
_local4.data = _local5;
_loader.load(_local4);
_clip.addChild(_loader);
_sendChannel = new LocalConnection();
_queue = [];
_nextCallbackID = 0;
_callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
public static function get clip():Object{
return (_container);
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
warnID(id, false);
if ((clip is DisplayObject)){
if (clip.stage == null){
trace("MochiServices connect requires the containing clip be attached to the stage");
};
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function bringToTop(_arg1:Event=null):void{
var e = _arg1;
if (((!((MochiServices.clip == null))) && (!((MochiServices.childClip == null))))){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
}
public static function connectWait(_arg1:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
} else {
_timer.stop();
_timer.removeEventListener(TimerEvent.TIMER, connectWait);
_timer = null;
};
}
}
}//package mochi.as3
Section 84
//MochiSocial (mochi.as3.MochiSocial)
package mochi.as3 {
public class MochiSocial {
public static const LOGGED_IN:String = "LoggedIn";
public static const ACTION_CANCELED:String = "onCancel";
public static const PROPERTIES_SIZE:String = "PropertiesSize";
public static const IO_ERROR:String = "IOError";
public static const NO_USER:String = "NoUser";
public static const FRIEND_LIST:String = "FriendsList";
public static const PROFILE_DATA:String = "ProfileData";
public static const GAMEPLAY_DATA:String = "GameplayData";
public static const ACTION_COMPLETE:String = "onComplete";
public static const LOGIN_SHOW:String = "LoginShow";
public static const PROFILE_HIDE:String = "ProfileHide";
public static const USER_INFO:String = "UserInfo";
public static const PROPERTIES_SAVED:String = "PropertySaved";
public static const WIDGET_LOADED:String = "WidgetLoaded";
public static const ERROR:String = "Error";
public static const LOGGED_OUT:String = "LoggedOut";
public static const PROFILE_SHOW:String = "ProfileShow";
public static const LOGIN_HIDE:String = "LoginHide";
public static const LOGIN_SHOWN:String = "LoginShown";
public static var _user_info:Object = null;
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static function requestFan(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_requestFan", _arg1);
}
public static function postToStream(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_postToStream", _arg1);
}
public static function getFriendsList(_arg1:Object=null):void{
MochiServices.send("social_getFriendsList", _arg1);
}
public static function requestLogin(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_requestLogin", _arg1);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function saveUserProperties(_arg1:Object):void{
MochiServices.send("social_saveUserProperties", _arg1);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function inviteFriends(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_inviteFriends", _arg1);
}
public static function get loggedIn():Boolean{
return (!((_user_info == null)));
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function showLoginWidget(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_showLoginWidget", {options:_arg1});
}
public static function getAPIURL():String{
if (!_user_info){
return (null);
};
return (_user_info.api_url);
}
public static function hideLoginWidget():void{
MochiServices.send("social_hideLoginWidget");
}
public static function getAPIToken():String{
if (!_user_info){
return (null);
};
return (_user_info.api_token);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_user_info = _arg1;
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_user_info = null;
});
}
}//package mochi.as3
Section 85
//MochiUserData (mochi.as3.MochiUserData)
package mochi.as3 {
import flash.utils.*;
import flash.events.*;
import flash.net.*;
public class MochiUserData extends EventDispatcher {
public var callback:Function;// = null
public var operation:String;// = null
public var error:Event;// = null
public var data;// = null
public var _loader:URLLoader;
public var key:String;// = null
public function MochiUserData(_arg1:String="", _arg2:Function=null){
this.key = _arg1;
this.callback = _arg2;
}
public function serialize(_arg1):ByteArray{
var _local2:ByteArray = new ByteArray();
_local2.objectEncoding = ObjectEncoding.AMF3;
_local2.writeObject(_arg1);
_local2.compress();
return (_local2);
}
public function errorHandler(_arg1:IOErrorEvent):void{
data = null;
error = _arg1;
if (callback != null){
performCallback();
} else {
dispatchEvent(_arg1);
};
close();
}
public function putEvent(_arg1):void{
request("put", serialize(_arg1));
}
public function deserialize(_arg1:ByteArray){
_arg1.objectEncoding = ObjectEncoding.AMF3;
_arg1.uncompress();
return (_arg1.readObject());
}
public function securityErrorHandler(_arg1:SecurityErrorEvent):void{
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + _arg1.toString())));
}
public function getEvent():void{
request("get", serialize(null));
}
override public function toString():String{
return ((((((((("[MochiUserData operation=" + operation) + " key=\"") + key) + "\" data=") + data) + " error=\"") + error) + "\"]"));
}
public function performCallback():void{
try {
callback(this);
} catch(e:Error) {
trace(("[MochiUserData] exception during callback: " + e));
};
}
public function request(_arg1:String, _arg2:ByteArray):void{
var _operation = _arg1;
var _data = _arg2;
operation = _operation;
var api_url:String = MochiSocial.getAPIURL();
var api_token:String = MochiSocial.getAPIToken();
if ((((api_url == null)) || ((api_token == null)))){
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "not logged in"));
return;
};
_loader = new URLLoader();
var args:URLVariables = new URLVariables();
args.op = _operation;
args.key = key;
var req:URLRequest = new URLRequest((((MochiSocial.getAPIURL() + "/") + "MochiUserData?") + args.toString()));
req.method = URLRequestMethod.POST;
req.contentType = "application/x-mochi-userdata";
req.requestHeaders = [new URLRequestHeader("x-mochi-services-version", MochiServices.getVersion()), new URLRequestHeader("x-mochi-api-token", api_token)];
req.data = _data;
_loader.dataFormat = URLLoaderDataFormat.BINARY;
_loader.addEventListener(Event.COMPLETE, completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
try {
_loader.load(req);
} catch(e:SecurityError) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + e.toString())));
};
}
public function completeHandler(_arg1:Event):void{
var event = _arg1;
try {
if (_loader.data.length){
data = deserialize(_loader.data);
} else {
data = null;
};
} catch(e:Error) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("deserialize error: " + e.toString())));
return;
};
if (callback != null){
performCallback();
} else {
dispatchEvent(event);
};
close();
}
public function close():void{
if (_loader){
_loader.removeEventListener(Event.COMPLETE, completeHandler);
_loader.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_loader.close();
_loader = null;
};
error = null;
callback = null;
}
public static function get(_arg1:String, _arg2:Function):void{
var _local3:MochiUserData = new MochiUserData(_arg1, _arg2);
_local3.getEvent();
}
public static function put(_arg1:String, _arg2, _arg3:Function):void{
var _local4:MochiUserData = new MochiUserData(_arg1, _arg3);
_local4.putEvent(_arg2);
}
}
}//package mochi.as3
Section 86
//Assets_2 (rarebreeds_fla.Assets_2)
package rarebreeds_fla {
import flash.display.*;
public dynamic class Assets_2 extends MovieClip {
public function Assets_2(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package rarebreeds_fla
Section 87
//DropTargetIcons_12 (rarebreeds_fla.DropTargetIcons_12)
package rarebreeds_fla {
import flash.display.*;
public dynamic class DropTargetIcons_12 extends MovieClip {
public function DropTargetIcons_12(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
function frame4(){
stop();
}
}
}//package rarebreeds_fla
Section 88
//Logo_top_72 (rarebreeds_fla.Logo_top_72)
package rarebreeds_fla {
import flash.display.*;
public dynamic class Logo_top_72 extends MovieClip {
public function Logo_top_72(){
addFrameScript(50, frame51);
}
function frame51(){
stop();
}
}
}//package rarebreeds_fla
Section 89
//preloadBG_57 (rarebreeds_fla.preloadBG_57)
package rarebreeds_fla {
import flash.display.*;
public dynamic class preloadBG_57 extends MovieClip {
public function preloadBG_57(){
addFrameScript(30, frame31);
}
function frame31(){
stop();
}
}
}//package rarebreeds_fla
Section 90
//SwirlyBG_60 (rarebreeds_fla.SwirlyBG_60)
package rarebreeds_fla {
import flash.display.*;
public dynamic class SwirlyBG_60 extends MovieClip {
public function SwirlyBG_60(){
addFrameScript(51, frame52);
}
function frame52(){
stop();
}
}
}//package rarebreeds_fla
Section 91
//backgroundSound (backgroundSound)
package {
import flash.media.*;
public dynamic class backgroundSound extends Sound {
}
}//package
Section 92
//BaseTex (BaseTex)
package {
import flash.display.*;
public dynamic class BaseTex extends BitmapData {
public function BaseTex(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 93
//btnOver (btnOver)
package {
import flash.media.*;
public dynamic class btnOver extends Sound {
}
}//package
Section 94
//btnPress (btnPress)
package {
import flash.media.*;
public dynamic class btnPress extends Sound {
}
}//package
Section 95
//drop (drop)
package {
import flash.media.*;
public dynamic class drop extends Sound {
}
}//package
Section 96
//dropTarget (dropTarget)
package {
import flash.media.*;
public dynamic class dropTarget extends Sound {
}
}//package
Section 97
//flw1 (flw1)
package {
import flash.display.*;
public dynamic class flw1 extends BitmapData {
public function flw1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 98
//flw10 (flw10)
package {
import flash.display.*;
public dynamic class flw10 extends BitmapData {
public function flw10(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 99
//flw11 (flw11)
package {
import flash.display.*;
public dynamic class flw11 extends BitmapData {
public function flw11(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 100
//flw12 (flw12)
package {
import flash.display.*;
public dynamic class flw12 extends BitmapData {
public function flw12(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 101
//flw13 (flw13)
package {
import flash.display.*;
public dynamic class flw13 extends BitmapData {
public function flw13(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 102
//flw14 (flw14)
package {
import flash.display.*;
public dynamic class flw14 extends BitmapData {
public function flw14(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 103
//flw15 (flw15)
package {
import flash.display.*;
public dynamic class flw15 extends BitmapData {
public function flw15(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 104
//flw16 (flw16)
package {
import flash.display.*;
public dynamic class flw16 extends BitmapData {
public function flw16(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 105
//flw17 (flw17)
package {
import flash.display.*;
public dynamic class flw17 extends BitmapData {
public function flw17(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 106
//flw18 (flw18)
package {
import flash.display.*;
public dynamic class flw18 extends BitmapData {
public function flw18(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 107
//flw19 (flw19)
package {
import flash.display.*;
public dynamic class flw19 extends BitmapData {
public function flw19(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 108
//flw2 (flw2)
package {
import flash.display.*;
public dynamic class flw2 extends BitmapData {
public function flw2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 109
//flw20 (flw20)
package {
import flash.display.*;
public dynamic class flw20 extends BitmapData {
public function flw20(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 110
//flw3 (flw3)
package {
import flash.display.*;
public dynamic class flw3 extends BitmapData {
public function flw3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 111
//flw4 (flw4)
package {
import flash.display.*;
public dynamic class flw4 extends BitmapData {
public function flw4(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 112
//flw5 (flw5)
package {
import flash.display.*;
public dynamic class flw5 extends BitmapData {
public function flw5(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 113
//flw6 (flw6)
package {
import flash.display.*;
public dynamic class flw6 extends BitmapData {
public function flw6(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 114
//flw7 (flw7)
package {
import flash.display.*;
public dynamic class flw7 extends BitmapData {
public function flw7(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 115
//flw8 (flw8)
package {
import flash.display.*;
public dynamic class flw8 extends BitmapData {
public function flw8(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 116
//flw9 (flw9)
package {
import flash.display.*;
public dynamic class flw9 extends BitmapData {
public function flw9(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 117
//Frame (Frame)
package {
import flash.display.*;
public dynamic class Frame extends MovieClip {
}
}//package
Section 118
//growing (growing)
package {
import flash.media.*;
public dynamic class growing extends Sound {
}
}//package
Section 119
//MessageBoxContainer (MessageBoxContainer)
package {
import com.bobblebrook.gui.*;
public dynamic class MessageBoxContainer extends MessageContainer {
}
}//package
Section 120
//music (music)
package {
import flash.media.*;
public dynamic class music extends Sound {
}
}//package
Section 121
//newFlowers (newFlowers)
package {
import flash.media.*;
public dynamic class newFlowers extends Sound {
}
}//package
Section 122
//pickup (pickup)
package {
import flash.media.*;
public dynamic class pickup extends Sound {
}
}//package
Section 123
//PleaseWait (PleaseWait)
package {
import com.bobblebrook.gui.*;
public dynamic class PleaseWait extends MessageContainer {
}
}//package
Section 124
//T1 (T1)
package {
import flash.display.*;
public dynamic class T1 extends BitmapData {
public function T1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 125
//T2 (T2)
package {
import flash.display.*;
public dynamic class T2 extends BitmapData {
public function T2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 126
//T3 (T3)
package {
import flash.display.*;
public dynamic class T3 extends BitmapData {
public function T3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package