Section 1
//maskBtn_mc_16 (circle_Effect_fla.maskBtn_mc_16)
package circle_Effect_fla {
import flash.display.*;
public dynamic class maskBtn_mc_16 extends MovieClip {
public function maskBtn_mc_16(){
super();
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package circle_Effect_fla
Section 2
//BitString (com.adobe.images.BitString)
package com.adobe.images {
public class BitString {
public var val:int;// = 0
public var len:int;// = 0
public function BitString(){
super();
}
}
}//package com.adobe.images
Section 3
//JPGEncoder (com.adobe.images.JPGEncoder)
package com.adobe.images {
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
public class JPGEncoder {
var std_dc_luminance_nrcodes:Array;
var bitcode:Array;
var VDU:Array;
var std_ac_luminance_nrcodes:Array;
var std_dc_luminance_values:Array;
var bytepos:int;// = 7
var UVDC_HT:Array;
var YTable:Array;
var UVAC_HT:Array;
var byteout:ByteArray;
var category:Array;
var UDU:Array;
var YDU:Array;
var UVTable:Array;
var std_dc_chrominance_nrcodes:Array;
var std_ac_luminance_values:Array;
var DU:Array;
var std_ac_chrominance_nrcodes:Array;
var fdtbl_Y:Array;
var bytenew:int;// = 0
var YAC_HT:Array;
var YDC_HT:Array;
var ZigZag:Array;
var std_dc_chrominance_values:Array;
var std_ac_chrominance_values:Array;
var fdtbl_UV:Array;
public function JPGEncoder(arg1:Number=50){
this.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];
this.YTable = new Array(64);
this.UVTable = new Array(64);
this.fdtbl_Y = new Array(64);
this.fdtbl_UV = new Array(64);
this.std_dc_luminance_nrcodes = [0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0];
this.std_dc_luminance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
this.std_ac_luminance_nrcodes = [0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125];
this.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];
this.std_dc_chrominance_nrcodes = [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0];
this.std_dc_chrominance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
this.std_ac_chrominance_nrcodes = [0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119];
this.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];
this.bitcode = new Array(0xFFFF);
this.category = new Array(0xFFFF);
this.DU = new Array(64);
this.YDU = new Array(64);
this.UDU = new Array(64);
this.VDU = new Array(64);
super();
if (arg1 <= 0){
arg1 = 1;
};
if (arg1 > 100){
arg1 = 100;
};
var loc1:* = 0;
if (arg1 < 50){
loc1 = int((5000 / arg1));
} else {
loc1 = int((200 - (arg1 * 2)));
};
this.initHuffmanTbl();
this.initCategoryNumber();
this.initQuantTables(loc1);
}
function processDU(arg1:Array, arg2:Array, arg3:Number, arg4:Array, arg5:Array):Number{
var loc3:* = 0;
var loc7:* = 0;
var loc8:* = 0;
var loc9:* = 0;
var loc1:* = arg5[0];
var loc2:* = arg5[240];
var loc4:* = this.fDCTQuant(arg1, arg2);
loc3 = 0;
while (loc3 < 64) {
this.DU[this.ZigZag[loc3]] = loc4[loc3];
loc3++;
};
var loc5:* = (this.DU[0] - arg3);
arg3 = this.DU[0];
if (loc5 != 0){
this.writeBits(arg4[this.category[(32767 + loc5)]]);
this.writeBits(this.bitcode[(32767 + loc5)]);
} else {
this.writeBits(arg4[0]);
};
var loc6:* = 63;
while ((((loc6 > 0)) && ((this.DU[loc6] == 0)))) {
loc6--;
};
if (loc6 == 0){
this.writeBits(loc1);
return (arg3);
};
loc3 = 1;
while (loc3 <= loc6) {
loc7 = loc3;
while ((((this.DU[loc3] == 0)) && ((loc3 <= loc6)))) {
loc3++;
};
loc8 = (loc3 - loc7);
if (loc8 >= 16){
loc9 = 1;
while (loc9 <= (loc8 / 16)) {
this.writeBits(loc2);
loc9++;
};
loc8 = int((loc8 & 15));
};
this.writeBits(arg5[((loc8 * 16) + this.category[(32767 + this.DU[loc3])])]);
this.writeBits(this.bitcode[(32767 + this.DU[loc3])]);
loc3++;
};
if (loc6 != 63){
this.writeBits(loc1);
};
return (arg3);
}
function writeSOS():void{
this.writeWord(65498);
this.writeWord(12);
this.writeByte(3);
this.writeByte(1);
this.writeByte(0);
this.writeByte(2);
this.writeByte(17);
this.writeByte(3);
this.writeByte(17);
this.writeByte(0);
this.writeByte(63);
this.writeByte(0);
}
function writeAPP0():void{
this.writeWord(65504);
this.writeWord(16);
this.writeByte(74);
this.writeByte(70);
this.writeByte(73);
this.writeByte(70);
this.writeByte(0);
this.writeByte(1);
this.writeByte(1);
this.writeByte(0);
this.writeWord(1);
this.writeWord(1);
this.writeByte(0);
this.writeByte(0);
}
function initQuantTables(arg1:int):void{
var loc1:* = 0;
var loc2:* = NaN;
var loc7:* = 0;
var loc3:* = [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];
loc1 = 0;
while (loc1 < 64) {
loc2 = Math.floor((((loc3[loc1] * arg1) + 50) / 100));
if (loc2 < 1){
loc2 = 1;
} else {
if (loc2 > 0xFF){
loc2 = 0xFF;
};
};
this.YTable[this.ZigZag[loc1]] = loc2;
loc1++;
};
var loc4:* = [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];
loc1 = 0;
while (loc1 < 64) {
loc2 = Math.floor((((loc4[loc1] * arg1) + 50) / 100));
if (loc2 < 1){
loc2 = 1;
} else {
if (loc2 > 0xFF){
loc2 = 0xFF;
};
};
this.UVTable[this.ZigZag[loc1]] = loc2;
loc1++;
};
var loc5:* = [1, 1.387039845, 1.306562965, 1.175875602, 1, 0.785694958, 0.5411961, 0.275899379];
loc1 = 0;
var loc6:* = 0;
while (loc6 < 8) {
loc7 = 0;
while (loc7 < 8) {
this.fdtbl_Y[loc1] = (1 / (((this.YTable[this.ZigZag[loc1]] * loc5[loc6]) * loc5[loc7]) * 8));
this.fdtbl_UV[loc1] = (1 / (((this.UVTable[this.ZigZag[loc1]] * loc5[loc6]) * loc5[loc7]) * 8));
loc1++;
loc7++;
};
loc6++;
};
}
function writeSOF0(arg1:int, arg2:int):void{
this.writeWord(65472);
this.writeWord(17);
this.writeByte(8);
this.writeWord(arg2);
this.writeWord(arg1);
this.writeByte(3);
this.writeByte(1);
this.writeByte(17);
this.writeByte(0);
this.writeByte(2);
this.writeByte(17);
this.writeByte(1);
this.writeByte(3);
this.writeByte(17);
this.writeByte(1);
}
function writeDQT():void{
var loc1:* = 0;
this.writeWord(65499);
this.writeWord(132);
this.writeByte(0);
loc1 = 0;
while (loc1 < 64) {
this.writeByte(this.YTable[loc1]);
loc1++;
};
this.writeByte(1);
loc1 = 0;
while (loc1 < 64) {
this.writeByte(this.UVTable[loc1]);
loc1++;
};
}
function initCategoryNumber():void{
var loc3:* = 0;
var loc1:* = 1;
var loc2:* = 2;
var loc4:* = 1;
while (loc4 <= 15) {
loc3 = loc1;
while (loc3 < loc2) {
this.category[(32767 + loc3)] = loc4;
this.bitcode[(32767 + loc3)] = new BitString();
this.bitcode[(32767 + loc3)].len = loc4;
this.bitcode[(32767 + loc3)].val = loc3;
loc3++;
};
loc3 = -((loc2 - 1));
while (loc3 <= -(loc1)) {
this.category[(32767 + loc3)] = loc4;
this.bitcode[(32767 + loc3)] = new BitString();
this.bitcode[(32767 + loc3)].len = loc4;
this.bitcode[(32767 + loc3)].val = ((loc2 - 1) + loc3);
loc3++;
};
loc1 = (loc1 << 1);
loc2 = (loc2 << 1);
loc4++;
};
}
public function encode(arg1:BitmapData):ByteArray{
var loc5:* = 0;
var loc6:* = null;
this.byteout = new ByteArray();
this.bytenew = 0;
this.bytepos = 7;
this.writeWord(65496);
this.writeAPP0();
this.writeDQT();
this.writeSOF0(arg1.width, arg1.height);
this.writeDHT();
this.writeSOS();
var loc1:* = 0;
var loc2:* = 0;
var loc3:* = 0;
this.bytenew = 0;
this.bytepos = 7;
var loc4:* = 0;
while (loc4 < arg1.height) {
loc5 = 0;
while (loc5 < arg1.width) {
this.RGB2YUV(arg1, loc5, loc4);
loc1 = this.processDU(this.YDU, this.fdtbl_Y, loc1, this.YDC_HT, this.YAC_HT);
loc2 = this.processDU(this.UDU, this.fdtbl_UV, loc2, this.UVDC_HT, this.UVAC_HT);
loc3 = this.processDU(this.VDU, this.fdtbl_UV, loc3, this.UVDC_HT, this.UVAC_HT);
loc5 = (loc5 + 8);
};
loc4 = (loc4 + 8);
};
if (this.bytepos >= 0){
loc6 = new BitString();
loc6.len = (this.bytepos + 1);
loc6.val = (1 << ((this.bytepos + 1) - 1));
this.writeBits(loc6);
};
this.writeWord(65497);
return (this.byteout);
}
function computeHuffmanTbl(arg1:Array, arg2:Array):Array{
var loc5:* = 0;
var loc1:* = 0;
var loc2:* = 0;
var loc3:* = new Array();
var loc4:* = 1;
while (loc4 <= 16) {
loc5 = 1;
while (loc5 <= arg1[loc4]) {
loc3[arg2[loc2]] = new BitString();
loc3[arg2[loc2]].val = loc1;
loc3[arg2[loc2]].len = loc4;
loc2++;
loc1++;
loc5++;
};
loc1 = (loc1 * 2);
loc4++;
};
return (loc3);
}
function writeDHT():void{
var loc1:* = 0;
this.writeWord(65476);
this.writeWord(418);
this.writeByte(0);
loc1 = 0;
while (loc1 < 16) {
this.writeByte(this.std_dc_luminance_nrcodes[(loc1 + 1)]);
loc1++;
};
loc1 = 0;
while (loc1 <= 11) {
this.writeByte(this.std_dc_luminance_values[loc1]);
loc1++;
};
this.writeByte(16);
loc1 = 0;
while (loc1 < 16) {
this.writeByte(this.std_ac_luminance_nrcodes[(loc1 + 1)]);
loc1++;
};
loc1 = 0;
while (loc1 <= 161) {
this.writeByte(this.std_ac_luminance_values[loc1]);
loc1++;
};
this.writeByte(1);
loc1 = 0;
while (loc1 < 16) {
this.writeByte(this.std_dc_chrominance_nrcodes[(loc1 + 1)]);
loc1++;
};
loc1 = 0;
while (loc1 <= 11) {
this.writeByte(this.std_dc_chrominance_values[loc1]);
loc1++;
};
this.writeByte(17);
loc1 = 0;
while (loc1 < 16) {
this.writeByte(this.std_ac_chrominance_nrcodes[(loc1 + 1)]);
loc1++;
};
loc1 = 0;
while (loc1 <= 161) {
this.writeByte(this.std_ac_chrominance_values[loc1]);
loc1++;
};
}
function initHuffmanTbl():void{
this.YDC_HT = this.computeHuffmanTbl(this.std_dc_luminance_nrcodes, this.std_dc_luminance_values);
this.UVDC_HT = this.computeHuffmanTbl(this.std_dc_chrominance_nrcodes, this.std_dc_chrominance_values);
this.YAC_HT = this.computeHuffmanTbl(this.std_ac_luminance_nrcodes, this.std_ac_luminance_values);
this.UVAC_HT = this.computeHuffmanTbl(this.std_ac_chrominance_nrcodes, this.std_ac_chrominance_values);
}
function fDCTQuant(arg1:Array, arg2:Array):Array{
var loc1:* = NaN;
var loc2:* = NaN;
var loc3:* = NaN;
var loc4:* = NaN;
var loc5:* = NaN;
var loc6:* = NaN;
var loc7:* = NaN;
var loc8:* = NaN;
var loc9:* = NaN;
var loc10:* = NaN;
var loc11:* = NaN;
var loc12:* = NaN;
var loc13:* = NaN;
var loc14:* = NaN;
var loc15:* = NaN;
var loc16:* = NaN;
var loc17:* = NaN;
var loc18:* = NaN;
var loc19:* = NaN;
var loc20:* = 0;
var loc21:* = 0;
loc20 = 0;
while (loc20 < 8) {
loc1 = (arg1[(loc21 + 0)] + arg1[(loc21 + 7)]);
loc8 = (arg1[(loc21 + 0)] - arg1[(loc21 + 7)]);
loc2 = (arg1[(loc21 + 1)] + arg1[(loc21 + 6)]);
loc7 = (arg1[(loc21 + 1)] - arg1[(loc21 + 6)]);
loc3 = (arg1[(loc21 + 2)] + arg1[(loc21 + 5)]);
loc6 = (arg1[(loc21 + 2)] - arg1[(loc21 + 5)]);
loc4 = (arg1[(loc21 + 3)] + arg1[(loc21 + 4)]);
loc5 = (arg1[(loc21 + 3)] - arg1[(loc21 + 4)]);
loc9 = (loc1 + loc4);
loc12 = (loc1 - loc4);
loc10 = (loc2 + loc3);
loc11 = (loc2 - loc3);
arg1[(loc21 + 0)] = (loc9 + loc10);
arg1[(loc21 + 4)] = (loc9 - loc10);
loc13 = ((loc11 + loc12) * 0.707106781);
arg1[(loc21 + 2)] = (loc12 + loc13);
arg1[(loc21 + 6)] = (loc12 - loc13);
loc9 = (loc5 + loc6);
loc10 = (loc6 + loc7);
loc11 = (loc7 + loc8);
loc17 = ((loc9 - loc11) * 0.382683433);
loc14 = ((0.5411961 * loc9) + loc17);
loc16 = ((1.306562965 * loc11) + loc17);
loc15 = (loc10 * 0.707106781);
loc18 = (loc8 + loc15);
loc19 = (loc8 - loc15);
arg1[(loc21 + 5)] = (loc19 + loc14);
arg1[(loc21 + 3)] = (loc19 - loc14);
arg1[(loc21 + 1)] = (loc18 + loc16);
arg1[(loc21 + 7)] = (loc18 - loc16);
loc21 = (loc21 + 8);
loc20++;
};
loc21 = 0;
loc20 = 0;
while (loc20 < 8) {
loc1 = (arg1[(loc21 + 0)] + arg1[(loc21 + 56)]);
loc8 = (arg1[(loc21 + 0)] - arg1[(loc21 + 56)]);
loc2 = (arg1[(loc21 + 8)] + arg1[(loc21 + 48)]);
loc7 = (arg1[(loc21 + 8)] - arg1[(loc21 + 48)]);
loc3 = (arg1[(loc21 + 16)] + arg1[(loc21 + 40)]);
loc6 = (arg1[(loc21 + 16)] - arg1[(loc21 + 40)]);
loc4 = (arg1[(loc21 + 24)] + arg1[(loc21 + 32)]);
loc5 = (arg1[(loc21 + 24)] - arg1[(loc21 + 32)]);
loc9 = (loc1 + loc4);
loc12 = (loc1 - loc4);
loc10 = (loc2 + loc3);
loc11 = (loc2 - loc3);
arg1[(loc21 + 0)] = (loc9 + loc10);
arg1[(loc21 + 32)] = (loc9 - loc10);
loc13 = ((loc11 + loc12) * 0.707106781);
arg1[(loc21 + 16)] = (loc12 + loc13);
arg1[(loc21 + 48)] = (loc12 - loc13);
loc9 = (loc5 + loc6);
loc10 = (loc6 + loc7);
loc11 = (loc7 + loc8);
loc17 = ((loc9 - loc11) * 0.382683433);
loc14 = ((0.5411961 * loc9) + loc17);
loc16 = ((1.306562965 * loc11) + loc17);
loc15 = (loc10 * 0.707106781);
loc18 = (loc8 + loc15);
loc19 = (loc8 - loc15);
arg1[(loc21 + 40)] = (loc19 + loc14);
arg1[(loc21 + 24)] = (loc19 - loc14);
arg1[(loc21 + 8)] = (loc18 + loc16);
arg1[(loc21 + 56)] = (loc18 - loc16);
loc21++;
loc20++;
};
loc20 = 0;
while (loc20 < 64) {
arg1[loc20] = Math.round((arg1[loc20] * arg2[loc20]));
loc20++;
};
return (arg1);
}
function RGB2YUV(arg1:BitmapData, arg2:int, arg3:int):void{
var loc3:* = 0;
var loc4:* = 0;
var loc5:* = NaN;
var loc6:* = NaN;
var loc7:* = NaN;
var loc1:* = 0;
var loc2:* = 0;
while (loc2 < 8) {
loc3 = 0;
while (loc3 < 8) {
loc4 = arg1.getPixel32((arg2 + loc3), (arg3 + loc2));
loc5 = Number(((loc4 >> 16) & 0xFF));
loc6 = Number(((loc4 >> 8) & 0xFF));
loc7 = Number((loc4 & 0xFF));
this.YDU[loc1] = ((((0.299 * loc5) + (0.587 * loc6)) + (0.114 * loc7)) - 128);
this.UDU[loc1] = (((-0.16874 * loc5) + (-0.33126 * loc6)) + (0.5 * loc7));
this.VDU[loc1] = (((0.5 * loc5) + (-0.41869 * loc6)) + (-0.08131 * loc7));
loc1++;
loc3++;
};
loc2++;
};
}
function writeBits(arg1:BitString):void{
var loc3:*;
var loc4:*;
var loc1:* = arg1.val;
var loc2:* = (arg1.len - 1);
while (loc2 >= 0) {
if ((loc1 & uint((1 << loc2)))){
this.bytenew = (this.bytenew | uint((1 << this.bytepos)));
};
loc2--;
loc3 = this;
loc4 = (loc3.bytepos - 1);
loc3.bytepos = loc4;
if (!(this.bytepos < 0)){
} else {
if (this.bytenew != 0xFF){
this.writeByte(this.bytenew);
} else {
this.writeByte(0xFF);
this.writeByte(0);
};
this.bytepos = 7;
this.bytenew = 0;
};
};
}
function writeWord(arg1:int):void{
this.writeByte(((arg1 >> 8) & 0xFF));
this.writeByte((arg1 & 0xFF));
}
function writeByte(arg1:int):void{
this.byteout.writeByte(arg1);
}
}
}//package com.adobe.images
Section 4
//URLNavigator (com.zorked.URLNavigator)
package com.zorked {
import flash.net.*;
import flash.external.*;
public class URLNavigator {
public function URLNavigator(){
super();
}
public static function ChangePage(arg1, arg2:String="_self"):void{
var loc2:* = null;
var loc1:* = ((arg1 is String)) ? new URLRequest(arg1) : arg1;
if (ExternalInterface.available){
loc2 = String(ExternalInterface.call("function() {return navigator.userAgent;}")).toLowerCase();
if (((!((loc2.indexOf("firefox") == -1))) || (((!((loc2.indexOf("msie") == -1))) && ((uint(loc2.substr((loc2.indexOf("msie") + 5), 3)) >= 7)))))){
ExternalInterface.call("window.open", loc1.url, arg2);
} else {
navigateToURL(loc1, arg2);
};
} else {
navigateToURL(loc1, arg2);
};
}
}
}//package com.zorked
Section 5
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.utils.*;
import flash.events.*;
import fl.events.*;
public class BaseButton extends UIComponent {
protected var background:DisplayObject;
protected var mouseState:String;
protected var _selected:Boolean;// = false
protected var _autoRepeat:Boolean;// = false
protected var pressTimer:Timer;
private var _mouseStateLocked:Boolean;// = false
private var unlockedMouseState:String;
private static var defaultStyles:Object = {upSkin:"Button_upSkin", downSkin:"Button_downSkin", overSkin:"Button_overSkin", disabledSkin:"Button_disabledSkin", selectedDisabledSkin:"Button_selectedDisabledSkin", selectedUpSkin:"Button_selectedUpSkin", selectedDownSkin:"Button_selectedDownSkin", selectedOverSkin:"Button_selectedOverSkin", focusRectSkin:null, focusRectPadding:null, repeatDelay:500, repeatInterval:35};
public function BaseButton(){
super();
buttonMode = true;
mouseChildren = false;
useHandCursor = false;
setupMouseEvents();
setMouseState("up");
pressTimer = new Timer(1, 0);
pressTimer.addEventListener(TimerEvent.TIMER, buttonDown, false, 0, true);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override public function set enabled(value:Boolean):void{
super.enabled = value;
mouseEnabled = value;
}
public function get selected():Boolean{
return (_selected);
}
public function set selected(value:Boolean):void{
if (_selected == value){
return;
};
_selected = value;
invalidate(InvalidationType.STATE);
}
public function get autoRepeat():Boolean{
return (_autoRepeat);
}
public function set autoRepeat(value:Boolean):void{
_autoRepeat = value;
}
public function set mouseStateLocked(value:Boolean):void{
_mouseStateLocked = value;
if (value == false){
setMouseState(unlockedMouseState);
} else {
unlockedMouseState = mouseState;
};
}
public function setMouseState(state:String):void{
if (_mouseStateLocked){
unlockedMouseState = state;
return;
};
if (mouseState == state){
return;
};
mouseState = state;
invalidate(InvalidationType.STATE);
}
protected function setupMouseEvents():void{
addEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false, 0, true);
}
protected function mouseEventHandler(event:MouseEvent):void{
if (event.type == MouseEvent.MOUSE_DOWN){
setMouseState("down");
startPress();
} else {
if ((((event.type == MouseEvent.ROLL_OVER)) || ((event.type == MouseEvent.MOUSE_UP)))){
setMouseState("over");
endPress();
} else {
if (event.type == MouseEvent.ROLL_OUT){
setMouseState("up");
endPress();
};
};
};
}
protected function startPress():void{
if (_autoRepeat){
pressTimer.delay = Number(getStyleValue("repeatDelay"));
pressTimer.start();
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
protected function buttonDown(event:TimerEvent):void{
if (!_autoRepeat){
endPress();
return;
};
if (pressTimer.currentCount == 1){
pressTimer.delay = Number(getStyleValue("repeatInterval"));
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
protected function endPress():void{
pressTimer.reset();
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function drawBackground():void{
var styleName:String = (enabled) ? mouseState : "disabled";
if (selected){
styleName = (("selected" + styleName.substr(0, 1).toUpperCase()) + styleName.substr(1));
};
styleName = (styleName + "Skin");
var bg:DisplayObject = background;
background = getDisplayObjectInstance(getStyleValue(styleName));
addChildAt(background, 0);
if (((!((bg == null))) && (!((bg == background))))){
removeChild(bg);
};
}
protected function drawLayout():void{
background.width = width;
background.height = height;
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 6
//Button (fl.controls.Button)
package fl.controls {
import flash.display.*;
import fl.core.*;
import fl.managers.*;
public class Button extends LabelButton implements IFocusManagerComponent {
protected var _emphasized:Boolean;// = false
protected var emphasizedBorder:DisplayObject;
private static var defaultStyles:Object = {emphasizedSkin:"Button_emphasizedSkin", emphasizedPadding:2};
public static var createAccessibilityImplementation:Function;
public function Button(){
super();
}
public function get emphasized():Boolean{
return (_emphasized);
}
public function set emphasized(value:Boolean):void{
_emphasized = value;
invalidate(InvalidationType.STYLES);
}
override protected function draw():void{
if (((isInvalid(InvalidationType.STYLES)) || (isInvalid(InvalidationType.SIZE)))){
drawEmphasized();
};
super.draw();
if (emphasizedBorder != null){
setChildIndex(emphasizedBorder, (numChildren - 1));
};
}
protected function drawEmphasized():void{
var padding:Number;
if (emphasizedBorder != null){
removeChild(emphasizedBorder);
};
emphasizedBorder = null;
if (!_emphasized){
return;
};
var emphasizedStyle:Object = getStyleValue("emphasizedSkin");
if (emphasizedStyle != null){
emphasizedBorder = getDisplayObjectInstance(emphasizedStyle);
};
if (emphasizedBorder != null){
addChildAt(emphasizedBorder, 0);
padding = Number(getStyleValue("emphasizedPadding"));
emphasizedBorder.x = (emphasizedBorder.y = -(padding));
emphasizedBorder.width = (width + (padding * 2));
emphasizedBorder.height = (height + (padding * 2));
};
}
override public function drawFocus(focused:Boolean):void{
var emphasizedPadding:Number;
var focusPadding:*;
super.drawFocus(focused);
if (focused){
emphasizedPadding = Number(getStyleValue("emphasizedPadding"));
if ((((emphasizedPadding < 0)) || (!(_emphasized)))){
emphasizedPadding = 0;
};
focusPadding = getStyleValue("focusRectPadding");
focusPadding = ((focusPadding)==null) ? 2 : focusPadding;
focusPadding = (focusPadding + emphasizedPadding);
uiFocusRect.x = -(focusPadding);
uiFocusRect.y = -(focusPadding);
uiFocusRect.width = (width + (focusPadding * 2));
uiFocusRect.height = (height + (focusPadding * 2));
};
}
override protected function initializeAccessibility():void{
if (Button.createAccessibilityImplementation != null){
Button.createAccessibilityImplementation(this);
};
}
public static function getStyleDefinition():Object{
return (UIComponent.mergeStyles(LabelButton.getStyleDefinition(), defaultStyles));
}
}
}//package fl.controls
Section 7
//ButtonLabelPlacement (fl.controls.ButtonLabelPlacement)
package fl.controls {
public class ButtonLabelPlacement {
public static const BOTTOM:String = "bottom";
public static const TOP:String = "top";
public static const LEFT:String = "left";
public static const RIGHT:String = "right";
}
}//package fl.controls
Section 8
//ColorPicker (fl.controls.ColorPicker)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import fl.events.*;
import flash.geom.*;
import flash.text.*;
import flash.ui.*;
public class ColorPicker extends UIComponent implements IFocusManagerComponent {
public var textField:TextField;
protected var customColors:Array;
protected var colorHash:Object;
protected var paletteBG:DisplayObject;
protected var selectedSwatch:Sprite;
protected var _selectedColor:uint;
protected var rollOverColor:int;// = -1
protected var _editable:Boolean;// = true
protected var _showTextField:Boolean;// = true
protected var isOpen:Boolean;// = false
protected var doOpen:Boolean;// = false
protected var swatchButton:BaseButton;
protected var colorWell:DisplayObject;
protected var swatchSelectedSkin:DisplayObject;
protected var palette:Sprite;
protected var textFieldBG:DisplayObject;
protected var swatches:Sprite;
protected var swatchMap:Array;
protected var currRowIndex:int;
protected var currColIndex:int;
protected static const POPUP_BUTTON_STYLES:Object = {disabledSkin:"disabledSkin", downSkin:"downSkin", overSkin:"overSkin", upSkin:"upSkin"};
protected static const SWATCH_STYLES:Object = {disabledSkin:"swatchSkin", downSkin:"swatchSkin", overSkin:"swatchSkin", upSkin:"swatchSkin"};
public static var defaultColors:Array;
private static var defaultStyles:Object = {upSkin:"ColorPicker_upSkin", disabledSkin:"ColorPicker_disabledSkin", overSkin:"ColorPicker_overSkin", downSkin:"ColorPicker_downSkin", colorWell:"ColorPicker_colorWell", swatchSkin:"ColorPicker_swatchSkin", swatchSelectedSkin:"ColorPicker_swatchSelectedSkin", swatchWidth:10, swatchHeight:10, columnCount:18, swatchPadding:1, textFieldSkin:"ColorPicker_textFieldSkin", textFieldWidth:null, textFieldHeight:null, textPadding:3, background:"ColorPicker_backgroundSkin", backgroundPadding:5, textFormat:null, focusRectSkin:null, focusRectPadding:null, embedFonts:false};
public function ColorPicker(){
super();
}
public function get selectedColor():uint{
if (colorWell == null){
return (0);
};
return (colorWell.transform.colorTransform.color);
}
public function set selectedColor(value:uint):void{
if (!_enabled){
return;
};
_selectedColor = value;
rollOverColor = -1;
currColIndex = (currRowIndex = 0);
var ct:ColorTransform = new ColorTransform();
ct.color = value;
setColorWellColor(ct);
invalidate(InvalidationType.DATA);
}
public function get hexValue():String{
if (colorWell == null){
return (colorToString(0));
};
return (colorToString(colorWell.transform.colorTransform.color));
}
override public function get enabled():Boolean{
return (super.enabled);
}
override public function set enabled(value:Boolean):void{
super.enabled = value;
if (!value){
close();
};
swatchButton.enabled = value;
}
public function get editable():Boolean{
return (_editable);
}
public function set editable(value:Boolean):void{
_editable = value;
invalidate(InvalidationType.STATE);
}
public function get showTextField():Boolean{
return (_showTextField);
}
public function set showTextField(value:Boolean):void{
invalidate(InvalidationType.STYLES);
_showTextField = value;
}
public function get colors():Array{
return (((customColors)!=null) ? customColors : _slot1.defaultColors);
}
public function set colors(value:Array):void{
customColors = value;
invalidate(InvalidationType.DATA);
}
public function get imeMode():String{
return (_imeMode);
}
public function set imeMode(value:String):void{
_imeMode = value;
}
public function open():void{
if (!_enabled){
return;
};
doOpen = true;
var fm:IFocusManager = focusManager;
if (fm){
fm.defaultButtonEnabled = false;
};
invalidate(InvalidationType.STATE);
}
public function close():void{
if (isOpen){
stage.removeChild(palette);
isOpen = false;
dispatchEvent(new Event(Event.CLOSE));
};
var fm:IFocusManager = focusManager;
if (fm){
fm.defaultButtonEnabled = true;
};
removeStageListener();
cleanUpSelected();
}
private function addCloseListener(event:Event){
removeEventListener(Event.ENTER_FRAME, addCloseListener);
if (!isOpen){
return;
};
addStageListener();
}
protected function onStageClick(event:MouseEvent):void{
if (((!(contains((event.target as DisplayObject)))) && (!(palette.contains((event.target as DisplayObject)))))){
selectedColor = _selectedColor;
close();
};
}
protected function setStyles():void{
var bg:DisplayObject = colorWell;
var colorWellStyle:Object = getStyleValue("colorWell");
if (colorWellStyle != null){
colorWell = (getDisplayObjectInstance(colorWellStyle) as DisplayObject);
};
addChildAt(colorWell, getChildIndex(swatchButton));
copyStylesToChild(swatchButton, POPUP_BUTTON_STYLES);
swatchButton.drawNow();
if (((((!((bg == null))) && (contains(bg)))) && (!((bg == colorWell))))){
removeChild(bg);
};
}
protected function cleanUpSelected():void{
if (((swatchSelectedSkin) && (palette.contains(swatchSelectedSkin)))){
palette.removeChild(swatchSelectedSkin);
};
}
protected function onPopupButtonClick(event:MouseEvent):void{
if (isOpen){
close();
} else {
open();
};
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES, InvalidationType.DATA)){
setStyles();
drawPalette();
setEmbedFonts();
invalidate(InvalidationType.DATA, false);
invalidate(InvalidationType.STYLES, false);
};
if (isInvalid(InvalidationType.DATA)){
drawSwatchHighlight();
setColorDisplay();
};
if (isInvalid(InvalidationType.STATE)){
setTextEditable();
if (doOpen){
doOpen = false;
showPalette();
};
colorWell.visible = enabled;
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
swatchButton.setSize(width, height);
swatchButton.drawNow();
colorWell.width = width;
colorWell.height = height;
};
super.draw();
}
protected function showPalette():void{
if (isOpen){
positionPalette();
return;
};
addEventListener(Event.ENTER_FRAME, addCloseListener, false, 0, true);
stage.addChild(palette);
isOpen = true;
positionPalette();
dispatchEvent(new Event(Event.OPEN));
stage.focus = textField;
var swatch:Sprite = selectedSwatch;
if (swatch == null){
swatch = findSwatch(_selectedColor);
};
setSwatchHighlight(swatch);
}
protected function setEmbedFonts():void{
var embed:Object = getStyleValue("embedFonts");
if (embed != null){
textField.embedFonts = embed;
};
}
protected function drawSwatchHighlight():void{
cleanUpSelected();
var skin:Object = getStyleValue("swatchSelectedSkin");
var swatchPadding:Number = (getStyleValue("swatchPadding") as Number);
if (skin != null){
swatchSelectedSkin = getDisplayObjectInstance(skin);
swatchSelectedSkin.x = 0;
swatchSelectedSkin.y = 0;
swatchSelectedSkin.width = ((getStyleValue("swatchWidth") as Number) + 2);
swatchSelectedSkin.height = ((getStyleValue("swatchHeight") as Number) + 2);
};
}
protected function drawPalette():void{
if (isOpen){
stage.removeChild(palette);
};
palette = new Sprite();
drawTextField();
drawSwatches();
drawBG();
}
protected function drawTextField():void{
if (!showTextField){
return;
};
var padding:Number = (getStyleValue("backgroundPadding") as Number);
var textPadding:Number = (getStyleValue("textPadding") as Number);
textFieldBG = getDisplayObjectInstance(getStyleValue("textFieldSkin"));
if (textFieldBG != null){
palette.addChild(textFieldBG);
textFieldBG.x = (textFieldBG.y = padding);
};
var uiStyles:Object = UIComponent.getStyleDefinition();
var defaultTF:TextFormat = (enabled) ? (uiStyles.defaultTextFormat as TextFormat) : (uiStyles.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(defaultTF);
var tf:TextFormat = (getStyleValue("textFormat") as TextFormat);
if (tf != null){
textField.setTextFormat(tf);
} else {
tf = defaultTF;
};
textField.defaultTextFormat = tf;
setEmbedFonts();
textField.restrict = "A-Fa-f0-9#";
textField.maxChars = 6;
palette.addChild(textField);
textField.text = " #888888 ";
textField.height = (textField.textHeight + 3);
textField.width = (textField.textWidth + 3);
textField.text = "";
textField.x = (textField.y = (padding + textPadding));
textFieldBG.width = (textField.width + (textPadding * 2));
textFieldBG.height = (textField.height + (textPadding * 2));
setTextEditable();
}
protected function drawSwatches():void{
var s:Sprite;
var padding:Number = (getStyleValue("backgroundPadding") as Number);
var swatchY:Number = (showTextField) ? ((textFieldBG.y + textFieldBG.height) + padding) : padding;
swatches = new Sprite();
palette.addChild(swatches);
swatches.x = padding;
swatches.y = swatchY;
var cols:uint = (getStyleValue("columnCount") as uint);
var pad:uint = (getStyleValue("swatchPadding") as uint);
var w:Number = (getStyleValue("swatchWidth") as Number);
var h:Number = (getStyleValue("swatchHeight") as Number);
colorHash = {};
swatchMap = [];
var l:uint = Math.min(0x0400, colors.length);
var rc = -1;
var i:uint;
while (i < l) {
s = createSwatch(colors[i]);
s.x = ((w + pad) * (i % cols));
if (s.x == 0){
swatchMap.push([s]);
rc++;
} else {
swatchMap[rc].push(s);
};
colorHash[colors[i]] = {swatch:s, row:rc, col:(swatchMap[rc].length - 1)};
s.y = (Math.floor((i / cols)) * (h + pad));
swatches.addChild(s);
i++;
};
}
protected function drawBG():void{
var bg:Object = getStyleValue("background");
if (bg != null){
paletteBG = (getDisplayObjectInstance(bg) as Sprite);
};
if (paletteBG == null){
return;
};
var padding:Number = Number(getStyleValue("backgroundPadding"));
paletteBG.width = (Math.max((showTextField) ? textFieldBG.width : 0, swatches.width) + (padding * 2));
paletteBG.height = ((swatches.y + swatches.height) + padding);
palette.addChildAt(paletteBG, 0);
}
protected function positionPalette():void{
var p:Point = swatchButton.localToGlobal(new Point(0, 0));
var padding:Number = (getStyleValue("backgroundPadding") as Number);
if ((p.x + palette.width) > stage.stageWidth){
palette.x = ((p.x - palette.width) << 0);
} else {
palette.x = (((p.x + swatchButton.width) + padding) << 0);
};
palette.y = (Math.max(0, Math.min(p.y, (stage.stageHeight - palette.height))) << 0);
}
protected function setTextEditable():void{
if (!showTextField){
return;
};
textField.type = (editable) ? TextFieldType.INPUT : TextFieldType.DYNAMIC;
textField.selectable = editable;
}
override protected function keyUpHandler(event:KeyboardEvent):void{
var newColor:uint;
var color:String;
var swatch:Sprite;
if (!isOpen){
return;
};
var cTransform:ColorTransform = new ColorTransform();
if (((editable) && (showTextField))){
color = textField.text;
if (color.indexOf("#") > -1){
color = color.replace(/^\s+|\s+$/g, "");
color = color.replace(/#/g, "");
};
newColor = parseInt(color, 16);
swatch = findSwatch(newColor);
setSwatchHighlight(swatch);
cTransform.color = newColor;
setColorWellColor(cTransform);
} else {
newColor = rollOverColor;
cTransform.color = newColor;
};
if (event.keyCode != Keyboard.ENTER){
return;
};
dispatchEvent(new ColorPickerEvent(ColorPickerEvent.ENTER, newColor));
_selectedColor = rollOverColor;
setColorText(cTransform.color);
rollOverColor = cTransform.color;
dispatchEvent(new ColorPickerEvent(ColorPickerEvent.CHANGE, selectedColor));
close();
}
protected function positionTextField():void{
if (!showTextField){
return;
};
var padding:Number = (getStyleValue("backgroundPadding") as Number);
var textPadding:Number = (getStyleValue("textPadding") as Number);
textFieldBG.x = (paletteBG.x + padding);
textFieldBG.y = (paletteBG.y + padding);
textField.x = (textFieldBG.x + textPadding);
textField.y = (textFieldBG.y + textPadding);
}
protected function setColorDisplay():void{
if (!swatchMap.length){
return;
};
var ct:ColorTransform = new ColorTransform(0, 0, 0, 1, (_selectedColor >> 16), ((_selectedColor >> 8) & 0xFF), (_selectedColor & 0xFF), 0);
setColorWellColor(ct);
setColorText(_selectedColor);
var swatch:Sprite = findSwatch(_selectedColor);
setSwatchHighlight(swatch);
if (((swatchMap.length) && ((colorHash[_selectedColor] == undefined)))){
cleanUpSelected();
};
}
protected function setSwatchHighlight(swatch:Sprite):void{
if (swatch == null){
if (palette.contains(swatchSelectedSkin)){
palette.removeChild(swatchSelectedSkin);
};
return;
} else {
if (((!(palette.contains(swatchSelectedSkin))) && ((colors.length > 0)))){
palette.addChild(swatchSelectedSkin);
} else {
if (!colors.length){
return;
};
};
};
var swatchPadding:Number = (getStyleValue("swatchPadding") as Number);
palette.setChildIndex(swatchSelectedSkin, (palette.numChildren - 1));
swatchSelectedSkin.x = ((swatches.x + swatch.x) - 1);
swatchSelectedSkin.y = ((swatches.y + swatch.y) - 1);
var color:* = swatch.getChildByName("color").transform.colorTransform.color;
currColIndex = colorHash[color].col;
currRowIndex = colorHash[color].row;
}
protected function findSwatch(color:uint):Sprite{
if (!swatchMap.length){
return (null);
};
var so:Object = colorHash[color];
if (so != null){
return (so.swatch);
};
return (null);
}
protected function onSwatchClick(event:MouseEvent):void{
var cTransform:ColorTransform = event.target.getChildByName("color").transform.colorTransform;
_selectedColor = cTransform.color;
dispatchEvent(new ColorPickerEvent(ColorPickerEvent.CHANGE, selectedColor));
close();
}
protected function onSwatchOver(event:MouseEvent):void{
var color:BaseButton = (event.target.getChildByName("color") as BaseButton);
var cTransform:ColorTransform = color.transform.colorTransform;
setColorWellColor(cTransform);
setSwatchHighlight((event.target as Sprite));
setColorText(cTransform.color);
dispatchEvent(new ColorPickerEvent(ColorPickerEvent.ITEM_ROLL_OVER, cTransform.color));
}
protected function onSwatchOut(event:MouseEvent):void{
var cTransform:ColorTransform = event.target.transform.colorTransform;
dispatchEvent(new ColorPickerEvent(ColorPickerEvent.ITEM_ROLL_OUT, cTransform.color));
}
protected function setColorText(color:uint):void{
if (textField == null){
return;
};
textField.text = ("#" + colorToString(color));
}
protected function colorToString(color:uint):String{
var colorText:String = color.toString(16);
while (colorText.length < 6) {
colorText = ("0" + colorText);
};
return (colorText);
}
protected function setColorWellColor(colorTransform:ColorTransform):void{
if (!colorWell){
return;
};
colorWell.transform.colorTransform = colorTransform;
}
protected function createSwatch(color:uint):Sprite{
var swatch:Sprite = new Sprite();
var swatchSkin:BaseButton = new BaseButton();
swatchSkin.focusEnabled = false;
var w:Number = (getStyleValue("swatchWidth") as Number);
var h:Number = (getStyleValue("swatchHeight") as Number);
swatchSkin.setSize(w, h);
swatchSkin.transform.colorTransform = new ColorTransform(0, 0, 0, 1, (color >> 16), ((color >> 8) & 0xFF), (color & 0xFF), 0);
copyStylesToChild(swatchSkin, SWATCH_STYLES);
swatchSkin.mouseEnabled = false;
swatchSkin.drawNow();
swatchSkin.name = "color";
swatch.addChild(swatchSkin);
var padding:Number = (getStyleValue("swatchPadding") as Number);
var g:Graphics = swatch.graphics;
g.beginFill(0);
g.drawRect(-(padding), -(padding), (w + (padding * 2)), (h + (padding * 2)));
g.endFill();
swatch.addEventListener(MouseEvent.CLICK, onSwatchClick, false, 0, true);
swatch.addEventListener(MouseEvent.MOUSE_OVER, onSwatchOver, false, 0, true);
swatch.addEventListener(MouseEvent.MOUSE_OUT, onSwatchOut, false, 0, true);
return (swatch);
}
protected function addStageListener(event:Event=null):void{
stage.addEventListener(MouseEvent.MOUSE_DOWN, onStageClick, false, 0, true);
}
protected function removeStageListener(event:Event=null):void{
stage.removeEventListener(MouseEvent.MOUSE_DOWN, onStageClick, false);
}
override protected function focusInHandler(event:FocusEvent):void{
super.focusInHandler(event);
setIMEMode(true);
}
override protected function focusOutHandler(event:FocusEvent):void{
if (event.relatedObject == textField){
setFocus();
return;
};
if (isOpen){
close();
};
super.focusOutHandler(event);
setIMEMode(false);
}
override protected function isOurFocus(target:DisplayObject):Boolean{
return ((((target == textField)) || (super.isOurFocus(target))));
}
override protected function keyDownHandler(event:KeyboardEvent):void{
var _local3:Sprite;
switch (event.keyCode){
case Keyboard.SHIFT:
case Keyboard.CONTROL:
return;
};
if (event.ctrlKey){
switch (event.keyCode){
case Keyboard.DOWN:
open();
break;
case Keyboard.UP:
close();
break;
};
return;
};
if (!isOpen){
switch (event.keyCode){
case Keyboard.UP:
case Keyboard.DOWN:
case Keyboard.LEFT:
case Keyboard.RIGHT:
case Keyboard.SPACE:
open();
return;
};
};
textField.maxChars = ((((event.keyCode == "#".charCodeAt(0))) || ((textField.text.indexOf("#") > -1)))) ? 7 : 6;
switch (event.keyCode){
case Keyboard.TAB:
_local3 = findSwatch(_selectedColor);
setSwatchHighlight(_local3);
return;
case Keyboard.HOME:
currColIndex = (currRowIndex = 0);
break;
case Keyboard.END:
currColIndex = (swatchMap[(swatchMap.length - 1)].length - 1);
currRowIndex = (swatchMap.length - 1);
break;
case Keyboard.PAGE_DOWN:
currRowIndex = (swatchMap.length - 1);
break;
case Keyboard.PAGE_UP:
currRowIndex = 0;
break;
case Keyboard.ESCAPE:
if (isOpen){
selectedColor = _selectedColor;
};
close();
return;
case Keyboard.ENTER:
return;
case Keyboard.UP:
currRowIndex = Math.max(-1, (currRowIndex - 1));
if (currRowIndex == -1){
currRowIndex = (swatchMap.length - 1);
};
break;
case Keyboard.DOWN:
currRowIndex = Math.min(swatchMap.length, (currRowIndex + 1));
if (currRowIndex == swatchMap.length){
currRowIndex = 0;
};
break;
case Keyboard.RIGHT:
currColIndex = Math.min(swatchMap[currRowIndex].length, (currColIndex + 1));
if (currColIndex == swatchMap[currRowIndex].length){
currColIndex = 0;
currRowIndex = Math.min(swatchMap.length, (currRowIndex + 1));
if (currRowIndex == swatchMap.length){
currRowIndex = 0;
};
};
break;
case Keyboard.LEFT:
currColIndex = Math.max(-1, (currColIndex - 1));
if (currColIndex == -1){
currColIndex = (swatchMap[currRowIndex].length - 1);
currRowIndex = Math.max(-1, (currRowIndex - 1));
if (currRowIndex == -1){
currRowIndex = (swatchMap.length - 1);
};
};
break;
default:
return;
};
var cTransform:ColorTransform = swatchMap[currRowIndex][currColIndex].getChildByName("color").transform.colorTransform;
rollOverColor = cTransform.color;
setColorWellColor(cTransform);
setSwatchHighlight(swatchMap[currRowIndex][currColIndex]);
setColorText(cTransform.color);
}
override protected function configUI():void{
var i:uint;
super.configUI();
tabChildren = false;
if (_slot1.defaultColors == null){
_slot1.defaultColors = [];
i = 0;
while (i < 216) {
_slot1.defaultColors.push(((((((((i / 6) % 3) << 0) + (((i / 108) << 0) * 3)) * 51) << 16) | (((i % 6) * 51) << 8)) | ((((i / 18) << 0) % 6) * 51)));
i++;
};
};
colorHash = {};
swatchMap = [];
textField = new TextField();
textField.tabEnabled = false;
swatchButton = new BaseButton();
swatchButton.focusEnabled = false;
swatchButton.useHandCursor = false;
swatchButton.autoRepeat = false;
swatchButton.setSize(25, 25);
swatchButton.addEventListener(MouseEvent.CLICK, onPopupButtonClick, false, 0, true);
addChild(swatchButton);
palette = new Sprite();
palette.tabChildren = false;
palette.cacheAsBitmap = true;
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 9
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import fl.events.*;
import flash.text.*;
import flash.ui.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
public var textField:TextField;
protected var _labelPlacement:String;// = "right"
protected var _toggle:Boolean;// = false
protected var icon:DisplayObject;
protected var oldMouseState:String;
protected var _label:String;// = "Label"
protected var mode:String;// = "center"
private static var defaultStyles:Object = {icon:null, upIcon:null, downIcon:null, overIcon:null, disabledIcon:null, selectedDisabledIcon:null, selectedUpIcon:null, selectedDownIcon:null, selectedOverIcon:null, textFormat:null, disabledTextFormat:null, textPadding:5, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function LabelButton(){
super();
}
public function get label():String{
return (_label);
}
public function set label(value:String):void{
_label = value;
if (textField.text != _label){
textField.text = _label;
dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE));
};
invalidate(InvalidationType.SIZE);
invalidate(InvalidationType.STYLES);
}
public function get labelPlacement():String{
return (_labelPlacement);
}
public function set labelPlacement(value:String):void{
_labelPlacement = value;
invalidate(InvalidationType.SIZE);
}
public function get toggle():Boolean{
return (_toggle);
}
public function set toggle(value:Boolean):void{
if (((!(value)) && (super.selected))){
selected = false;
};
_toggle = value;
if (_toggle){
addEventListener(MouseEvent.CLICK, toggleSelected, false, 0, true);
} else {
removeEventListener(MouseEvent.CLICK, toggleSelected);
};
invalidate(InvalidationType.STATE);
}
protected function toggleSelected(event:MouseEvent):void{
selected = !(selected);
dispatchEvent(new Event(Event.CHANGE, true));
}
override public function get selected():Boolean{
return ((_toggle) ? _selected : false);
}
override public function set selected(value:Boolean):void{
_selected = value;
if (_toggle){
invalidate(InvalidationType.STATE);
};
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
addChild(textField);
}
override protected function draw():void{
if (textField.text != _label){
label = _label;
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
drawIcon();
drawTextFormat();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
protected function drawIcon():void{
var oldIcon:DisplayObject = icon;
var styleName:String = (enabled) ? mouseState : "disabled";
if (selected){
styleName = (("selected" + styleName.substr(0, 1).toUpperCase()) + styleName.substr(1));
};
styleName = (styleName + "Icon");
var iconStyle:Object = getStyleValue(styleName);
if (iconStyle == null){
iconStyle = getStyleValue("icon");
};
if (iconStyle != null){
icon = getDisplayObjectInstance(iconStyle);
};
if (icon != null){
addChildAt(icon, 1);
};
if (((!((oldIcon == null))) && (!((oldIcon == icon))))){
removeChild(oldIcon);
};
}
protected function drawTextFormat():void{
var uiStyles:Object = UIComponent.getStyleDefinition();
var defaultTF:TextFormat = (enabled) ? (uiStyles.defaultTextFormat as TextFormat) : (uiStyles.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(defaultTF);
var tf:TextFormat = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (tf != null){
textField.setTextFormat(tf);
} else {
tf = defaultTF;
};
textField.defaultTextFormat = tf;
setEmbedFont();
}
protected function setEmbedFont(){
var embed:Object = getStyleValue("embedFonts");
if (embed != null){
textField.embedFonts = embed;
};
}
override protected function drawLayout():void{
var tmpWidth:Number;
var tmpHeight:Number;
var txtPad:Number = Number(getStyleValue("textPadding"));
var placement:String = ((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement;
textField.height = (textField.textHeight + 4);
var txtW:Number = (textField.textWidth + 4);
var txtH:Number = (textField.textHeight + 4);
var paddedIconW:Number = ((icon)==null) ? 0 : (icon.width + txtPad);
var paddedIconH:Number = ((icon)==null) ? 0 : (icon.height + txtPad);
textField.visible = (label.length > 0);
if (icon != null){
icon.x = Math.round(((width - icon.width) / 2));
icon.y = Math.round(((height - icon.height) / 2));
};
if (textField.visible == false){
textField.width = 0;
textField.height = 0;
} else {
if ((((placement == ButtonLabelPlacement.BOTTOM)) || ((placement == ButtonLabelPlacement.TOP)))){
tmpWidth = Math.max(0, Math.min(txtW, (width - (2 * txtPad))));
if ((height - 2) > txtH){
tmpHeight = txtH;
} else {
tmpHeight = (height - 2);
};
txtW = tmpWidth;
textField.width = txtW;
txtH = tmpHeight;
textField.height = txtH;
textField.x = Math.round(((width - txtW) / 2));
textField.y = Math.round(((((height - textField.height) - paddedIconH) / 2) + ((placement)==ButtonLabelPlacement.BOTTOM) ? paddedIconH : 0));
if (icon != null){
icon.y = Math.round(((placement)==ButtonLabelPlacement.BOTTOM) ? (textField.y - paddedIconH) : ((textField.y + textField.height) + txtPad));
};
} else {
tmpWidth = Math.max(0, Math.min(txtW, ((width - paddedIconW) - (2 * txtPad))));
txtW = tmpWidth;
textField.width = txtW;
textField.x = Math.round(((((width - txtW) - paddedIconW) / 2) + ((placement)!=ButtonLabelPlacement.LEFT) ? paddedIconW : 0));
textField.y = Math.round(((height - textField.height) / 2));
if (icon != null){
icon.x = Math.round(((placement)!=ButtonLabelPlacement.LEFT) ? (textField.x - paddedIconW) : ((textField.x + txtW) + txtPad));
};
};
};
super.drawLayout();
}
override protected function keyDownHandler(event:KeyboardEvent):void{
if (!enabled){
return;
};
if (event.keyCode == Keyboard.SPACE){
if (oldMouseState == null){
oldMouseState = mouseState;
};
setMouseState("down");
startPress();
};
}
override protected function keyUpHandler(event:KeyboardEvent):void{
if (!enabled){
return;
};
if (event.keyCode == Keyboard.SPACE){
setMouseState(oldMouseState);
oldMouseState = null;
endPress();
dispatchEvent(new MouseEvent(MouseEvent.CLICK));
};
}
override protected function initializeAccessibility():void{
if (LabelButton.createAccessibilityImplementation != null){
LabelButton.createAccessibilityImplementation(this);
};
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
}
}
}//package fl.controls
Section 10
//ComponentShim (fl.core.ComponentShim)
package fl.core {
import flash.display.*;
public dynamic class ComponentShim extends MovieClip {
}
}//package fl.core
Section 11
//InvalidationType (fl.core.InvalidationType)
package fl.core {
public class InvalidationType {
public static const ALL:String = "all";
public static const SIZE:String = "size";
public static const STYLES:String = "styles";
public static const RENDERER_STYLES:String = "rendererStyles";
public static const STATE:String = "state";
public static const DATA:String = "data";
public static const SCROLL:String = "scroll";
public static const SELECTED:String = "selected";
}
}//package fl.core
Section 12
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.display.*;
import flash.utils.*;
import flash.events.*;
import fl.managers.*;
import fl.events.*;
import flash.text.*;
import flash.system.*;
public class UIComponent extends Sprite {
public const version:String = "3.0.2.3";
public var focusTarget:IFocusManagerComponent;
protected var isLivePreview:Boolean;// = false
private var tempText:TextField;
protected var instanceStyles:Object;
protected var sharedStyles:Object;
protected var callLaterMethods:Dictionary;
protected var invalidateFlag:Boolean;// = false
protected var _enabled:Boolean;// = true
protected var invalidHash:Object;
protected var uiFocusRect:DisplayObject;
protected var isFocused:Boolean;// = false
private var _focusEnabled:Boolean;// = true
private var _mouseFocusEnabled:Boolean;// = true
protected var _width:Number;
protected var _height:Number;
protected var _x:Number;
protected var _y:Number;
protected var startWidth:Number;
protected var startHeight:Number;
protected var _imeMode:String;// = null
protected var _oldIMEMode:String;// = null
protected var errorCaught:Boolean;// = false
protected var _inspector:Boolean;// = false
public static var inCallLaterPhase:Boolean = false;
private static var defaultStyles:Object = {focusRectSkin:"focusRectSkin", focusRectPadding:2, textFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), disabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultTextFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultDisabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0)};
private static var focusManagers:Dictionary = new Dictionary(true);
private static var focusManagerUsers:Dictionary = new Dictionary(true);
public static var createAccessibilityImplementation:Function;
public function UIComponent(){
super();
instanceStyles = {};
sharedStyles = {};
invalidHash = {};
callLaterMethods = new Dictionary();
StyleManager.registerInstance(this);
configUI();
invalidate(InvalidationType.ALL);
tabEnabled = (this is IFocusManagerComponent);
focusRect = false;
if (tabEnabled){
addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
};
initializeFocusManager();
addEventListener(Event.ENTER_FRAME, hookAccessibility, false, 0, true);
}
public function get componentInspectorSetting():Boolean{
return (_inspector);
}
public function set componentInspectorSetting(value:Boolean):void{
_inspector = value;
if (_inspector){
beforeComponentParameters();
} else {
afterComponentParameters();
};
}
protected function beforeComponentParameters():void{
}
protected function afterComponentParameters():void{
}
public function get enabled():Boolean{
return (_enabled);
}
public function set enabled(value:Boolean):void{
if (value == _enabled){
return;
};
_enabled = value;
invalidate(InvalidationType.STATE);
}
public function setSize(width:Number, height:Number):void{
_width = width;
_height = height;
invalidate(InvalidationType.SIZE);
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
}
override public function get width():Number{
return (_width);
}
override public function set width(value:Number):void{
if (_width == value){
return;
};
setSize(value, height);
}
override public function get height():Number{
return (_height);
}
override public function set height(value:Number):void{
if (_height == value){
return;
};
setSize(width, value);
}
public function setStyle(style:String, value:Object):void{
if ((((instanceStyles[style] === value)) && (!((value is TextFormat))))){
return;
};
instanceStyles[style] = value;
invalidate(InvalidationType.STYLES);
}
public function clearStyle(style:String):void{
setStyle(style, null);
}
public function getStyle(style:String):Object{
return (instanceStyles[style]);
}
public function move(x:Number, y:Number):void{
_x = x;
_y = y;
super.x = Math.round(x);
super.y = Math.round(y);
dispatchEvent(new ComponentEvent(ComponentEvent.MOVE));
}
override public function get x():Number{
return ((isNaN(_x)) ? super.x : _x);
}
override public function set x(value:Number):void{
move(value, _y);
}
override public function get y():Number{
return ((isNaN(_y)) ? super.y : _y);
}
override public function set y(value:Number):void{
move(_x, value);
}
override public function get scaleX():Number{
return ((width / startWidth));
}
override public function set scaleX(value:Number):void{
setSize((startWidth * value), height);
}
override public function get scaleY():Number{
return ((height / startHeight));
}
override public function set scaleY(value:Number):void{
setSize(width, (startHeight * value));
}
protected function getScaleY():Number{
return (super.scaleY);
}
protected function setScaleY(value:Number):void{
super.scaleY = value;
}
protected function getScaleX():Number{
return (super.scaleX);
}
protected function setScaleX(value:Number):void{
super.scaleX = value;
}
override public function get visible():Boolean{
return (super.visible);
}
override public function set visible(value:Boolean):void{
if (super.visible == value){
return;
};
super.visible = value;
var t:String = (value) ? ComponentEvent.SHOW : ComponentEvent.HIDE;
dispatchEvent(new ComponentEvent(t, true));
}
public function validateNow():void{
invalidate(InvalidationType.ALL, false);
draw();
}
public function invalidate(property:String="all", callLater:Boolean=true):void{
invalidHash[property] = true;
if (callLater){
this.callLater(draw);
};
}
public function setSharedStyle(name:String, style:Object):void{
if ((((sharedStyles[name] === style)) && (!((style is TextFormat))))){
return;
};
sharedStyles[name] = style;
if (instanceStyles[name] == null){
invalidate(InvalidationType.STYLES);
};
}
public function get focusEnabled():Boolean{
return (_focusEnabled);
}
public function set focusEnabled(b:Boolean):void{
_focusEnabled = b;
}
public function get mouseFocusEnabled():Boolean{
return (_mouseFocusEnabled);
}
public function set mouseFocusEnabled(b:Boolean):void{
_mouseFocusEnabled = b;
}
public function get focusManager():IFocusManager{
var o:DisplayObject = this;
while (o) {
if (UIComponent.focusManagers[o] != null){
return (IFocusManager(UIComponent.focusManagers[o]));
};
o = o.parent;
};
return (null);
}
public function set focusManager(f:IFocusManager):void{
UIComponent.focusManagers[this] = f;
}
public function drawFocus(focused:Boolean):void{
var focusPadding:Number;
isFocused = focused;
if (((!((uiFocusRect == null))) && (contains(uiFocusRect)))){
removeChild(uiFocusRect);
uiFocusRect = null;
};
if (focused){
uiFocusRect = (getDisplayObjectInstance(getStyleValue("focusRectSkin")) as Sprite);
if (uiFocusRect == null){
return;
};
focusPadding = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = -(focusPadding);
uiFocusRect.y = -(focusPadding);
uiFocusRect.width = (width + (focusPadding * 2));
uiFocusRect.height = (height + (focusPadding * 2));
addChildAt(uiFocusRect, 0);
};
}
public function setFocus():void{
if (stage){
stage.focus = this;
};
}
public function getFocus():InteractiveObject{
if (stage){
return (stage.focus);
};
return (null);
}
protected function setIMEMode(enabled:Boolean){
var enabled = enabled;
if (_imeMode != null){
if (enabled){
IME.enabled = true;
_oldIMEMode = IME.conversionMode;
if (((!(errorCaught)) && (!((IME.conversionMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _imeMode;
};
errorCaught = false;
//unresolved jump
var _slot1 = e;
errorCaught = true;
throw (new Error(("IME mode not supported: " + _imeMode)));
} else {
if (((!((IME.conversionMode == IMEConversionMode.UNKNOWN))) && (!((_oldIMEMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _oldIMEMode;
};
IME.enabled = false;
};
};
}
public function drawNow():void{
draw();
}
protected function configUI():void{
isLivePreview = checkLivePreview();
var r:Number = rotation;
rotation = 0;
var w:Number = super.width;
var h:Number = super.height;
var _local4 = 1;
super.scaleY = _local4;
super.scaleX = _local4;
setSize(w, h);
move(super.x, super.y);
rotation = r;
startWidth = w;
startHeight = h;
if (numChildren > 0){
removeChildAt(0);
};
}
protected function checkLivePreview():Boolean{
var className:String;
if (parent == null){
return (false);
};
className = getQualifiedClassName(parent);
//unresolved jump
var _slot1 = e;
return ((className == "fl.livepreview::LivePreviewParent"));
}
protected function isInvalid(property:String, ... _args):Boolean{
if (((invalidHash[property]) || (invalidHash[InvalidationType.ALL]))){
return (true);
};
while (_args.length > 0) {
if (invalidHash[_args.pop()]){
return (true);
};
};
return (false);
}
protected function validate():void{
invalidHash = {};
}
protected function draw():void{
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
protected function getDisplayObjectInstance(skin:Object):DisplayObject{
var skin = skin;
var classDef:Object;
if ((skin is Class)){
return ((new (skin) as DisplayObject));
};
if ((skin is DisplayObject)){
(skin as DisplayObject).x = 0;
(skin as DisplayObject).y = 0;
return ((skin as DisplayObject));
};
classDef = getDefinitionByName(skin.toString());
//unresolved jump
var _slot1 = e;
classDef = (loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object);
//unresolved jump
var _slot1 = e;
if (classDef == null){
return (null);
};
return ((new (classDef) as DisplayObject));
}
protected function getStyleValue(name:String):Object{
return (((instanceStyles[name])==null) ? sharedStyles[name] : instanceStyles[name]);
}
protected function copyStylesToChild(child:UIComponent, styleMap:Object):void{
var n:String;
for (n in styleMap) {
child.setStyle(n, getStyleValue(styleMap[n]));
};
}
protected function callLater(fn:Function):void{
if (inCallLaterPhase){
return;
};
callLaterMethods[fn] = true;
if (stage != null){
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
} else {
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
};
}
private function callLaterDispatcher(event:Event):void{
var method:Object;
if (event.type == Event.ADDED_TO_STAGE){
removeEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher);
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
return;
};
event.target.removeEventListener(Event.RENDER, callLaterDispatcher);
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
return;
};
inCallLaterPhase = true;
var methods:Dictionary = callLaterMethods;
for (method in methods) {
method();
delete methods[method];
};
inCallLaterPhase = false;
}
private function initializeFocusManager():void{
var fm:IFocusManager;
var fmUserDict:Dictionary;
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
} else {
createFocusManager();
fm = focusManager;
if (fm != null){
fmUserDict = focusManagerUsers[fm];
if (fmUserDict == null){
fmUserDict = new Dictionary(true);
focusManagerUsers[fm] = fmUserDict;
};
fmUserDict[this] = true;
};
};
addEventListener(Event.REMOVED_FROM_STAGE, removedHandler);
}
private function addedHandler(evt:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, addedHandler);
initializeFocusManager();
}
private function removedHandler(evt:Event):void{
var fmUserDict:Dictionary;
var dictEmpty:Boolean;
var key:*;
var key2:*;
var compFM:IFocusManager;
removeEventListener(Event.REMOVED_FROM_STAGE, removedHandler);
addEventListener(Event.ADDED_TO_STAGE, addedHandler);
var fm:IFocusManager = focusManager;
if (fm != null){
fmUserDict = focusManagerUsers[fm];
if (fmUserDict != null){
delete fmUserDict[this];
dictEmpty = true;
for (key in fmUserDict) {
dictEmpty = false;
break;
};
if (dictEmpty){
delete focusManagerUsers[fm];
fmUserDict = null;
};
};
if (fmUserDict == null){
fm.deactivate();
for (key2 in focusManagers) {
compFM = focusManagers[key2];
if (fm == compFM){
delete focusManagers[key2];
};
};
};
};
}
protected function createFocusManager():void{
if (focusManagers[stage] == null){
focusManagers[stage] = new FocusManager(stage);
};
}
protected function isOurFocus(target:DisplayObject):Boolean{
return ((target == this));
}
protected function focusInHandler(event:FocusEvent):void{
var fm:IFocusManager;
if (isOurFocus((event.target as DisplayObject))){
fm = focusManager;
if (((fm) && (fm.showFocusIndicator))){
drawFocus(true);
isFocused = true;
};
};
}
protected function focusOutHandler(event:FocusEvent):void{
if (isOurFocus((event.target as DisplayObject))){
drawFocus(false);
isFocused = false;
};
}
protected function keyDownHandler(event:KeyboardEvent):void{
}
protected function keyUpHandler(event:KeyboardEvent):void{
}
protected function hookAccessibility(event:Event):void{
removeEventListener(Event.ENTER_FRAME, hookAccessibility);
initializeAccessibility();
}
protected function initializeAccessibility():void{
if (UIComponent.createAccessibilityImplementation != null){
UIComponent.createAccessibilityImplementation(this);
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
public static function mergeStyles(... _args):Object{
var styleList:Object;
var n:String;
var styles:Object = {};
var l:uint = _args.length;
var i:uint;
while (i < l) {
styleList = _args[i];
for (n in styleList) {
if (styles[n] != null){
} else {
styles[n] = _args[i][n];
};
};
i++;
};
return (styles);
}
}
}//package fl.core
Section 13
//ColorPickerEvent (fl.events.ColorPickerEvent)
package fl.events {
import flash.events.*;
public class ColorPickerEvent extends Event {
protected var _color:uint;
public static const ITEM_ROLL_OUT:String = "itemRollOut";
public static const ITEM_ROLL_OVER:String = "itemRollOver";
public static const ENTER:String = "enter";
public static const CHANGE:String = "change";
public function ColorPickerEvent(type:String, color:uint){
super(type, true);
_color = color;
}
public function get color():uint{
return (_color);
}
override public function toString():String{
return (formatToString("ColorPickerEvent", "type", "bubbles", "cancelable", "color"));
}
override public function clone():Event{
return (new ColorPickerEvent(type, color));
}
}
}//package fl.events
Section 14
//ComponentEvent (fl.events.ComponentEvent)
package fl.events {
import flash.events.*;
public class ComponentEvent extends Event {
public static const BUTTON_DOWN:String = "buttonDown";
public static const LABEL_CHANGE:String = "labelChange";
public static const HIDE:String = "hide";
public static const SHOW:String = "show";
public static const RESIZE:String = "resize";
public static const MOVE:String = "move";
public static const ENTER:String = "enter";
public function ComponentEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
override public function toString():String{
return (formatToString("ComponentEvent", "type", "bubbles", "cancelable"));
}
override public function clone():Event{
return (new ComponentEvent(type, bubbles, cancelable));
}
}
}//package fl.events
Section 15
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
import fl.core.*;
import flash.utils.*;
import flash.events.*;
import flash.text.*;
import flash.ui.*;
public class FocusManager implements IFocusManager {
private var _form:DisplayObjectContainer;
private var focusableObjects:Dictionary;
private var focusableCandidates:Array;
private var activated:Boolean;// = false
private var calculateCandidates:Boolean;// = true
private var lastFocus:InteractiveObject;
private var _showFocusIndicator:Boolean;// = true
private var lastAction:String;
private var defButton:Button;
private var _defaultButton:Button;
private var _defaultButtonEnabled:Boolean;// = true
public function FocusManager(container:DisplayObjectContainer){
super();
focusableObjects = new Dictionary(true);
if (container != null){
_form = container;
activate();
};
}
private function addedHandler(event:Event):void{
var target:DisplayObject = DisplayObject(event.target);
if (target.stage){
addFocusables(DisplayObject(event.target));
};
}
private function removedHandler(event:Event):void{
var i:int;
var io:InteractiveObject;
var o:DisplayObject = DisplayObject(event.target);
if ((((o is IFocusManagerComponent)) && ((focusableObjects[o] == true)))){
if (o == lastFocus){
IFocusManagerComponent(lastFocus).drawFocus(false);
lastFocus = null;
};
o.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler, false);
delete focusableObjects[o];
calculateCandidates = true;
} else {
if ((((o is InteractiveObject)) && ((focusableObjects[o] == true)))){
io = (o as InteractiveObject);
if (io){
if (io == lastFocus){
lastFocus = null;
};
delete focusableObjects[io];
calculateCandidates = true;
};
o.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler, false, 0, true);
};
};
removeFocusables(o);
}
private function addFocusables(o:DisplayObject, skipTopLevel:Boolean=false):void{
var focusable:IFocusManagerComponent;
var io:InteractiveObject;
var doc:DisplayObjectContainer;
var i:int;
var child:DisplayObject;
var o = o;
var skipTopLevel = skipTopLevel;
if (!skipTopLevel){
if ((o is IFocusManagerComponent)){
focusable = IFocusManagerComponent(o);
if (focusable.focusEnabled){
if (((focusable.tabEnabled) && (isTabVisible(o)))){
focusableObjects[o] = true;
calculateCandidates = true;
};
o.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler, false, 0, true);
o.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler, false, 0, true);
};
} else {
if ((o is InteractiveObject)){
io = (o as InteractiveObject);
if (((((io) && (io.tabEnabled))) && ((findFocusManagerComponent(io) == io)))){
focusableObjects[io] = true;
calculateCandidates = true;
};
io.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler, false, 0, true);
io.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler, false, 0, true);
};
};
};
if ((o is DisplayObjectContainer)){
doc = DisplayObjectContainer(o);
o.addEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler, false, 0, true);
if ((((((doc is Stage)) || ((doc.parent is Stage)))) || (doc.tabChildren))){
i = 0;
for (;i < doc.numChildren;(i = (i + 1))) {
child = doc.getChildAt(i);
if (child != null){
addFocusables(doc.getChildAt(i));
};
continue;
var _slot1 = error;
};
};
};
}
private function removeFocusables(o:DisplayObject):void{
var p:Object;
var dob:DisplayObject;
if ((o is DisplayObjectContainer)){
o.removeEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler, false);
o.removeEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler, false);
for (p in focusableObjects) {
dob = DisplayObject(p);
if (DisplayObjectContainer(o).contains(dob)){
if (dob == lastFocus){
lastFocus = null;
};
dob.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler, false);
delete focusableObjects[p];
calculateCandidates = true;
};
};
};
}
private function isTabVisible(o:DisplayObject):Boolean{
var p:DisplayObjectContainer = o.parent;
while (((((p) && (!((p is Stage))))) && (!(((p.parent) && ((p.parent is Stage))))))) {
if (!p.tabChildren){
return (false);
};
p = p.parent;
};
return (true);
}
private function isValidFocusCandidate(o:DisplayObject, groupName:String):Boolean{
var tg:IFocusManagerGroup;
if (!isEnabledAndVisible(o)){
return (false);
};
if ((o is IFocusManagerGroup)){
tg = IFocusManagerGroup(o);
if (groupName == tg.groupName){
return (false);
};
};
return (true);
}
private function isEnabledAndVisible(o:DisplayObject):Boolean{
var tf:TextField;
var sb:SimpleButton;
var formParent:DisplayObjectContainer = DisplayObject(form).parent;
while (o != formParent) {
if ((o is UIComponent)){
if (!UIComponent(o).enabled){
return (false);
};
} else {
if ((o is TextField)){
tf = TextField(o);
if ((((tf.type == TextFieldType.DYNAMIC)) || (!(tf.selectable)))){
return (false);
};
} else {
if ((o is SimpleButton)){
sb = SimpleButton(o);
if (!sb.enabled){
return (false);
};
};
};
};
if (!o.visible){
return (false);
};
o = o.parent;
};
return (true);
}
private function tabEnabledChangeHandler(event:Event):void{
calculateCandidates = true;
var o:InteractiveObject = InteractiveObject(event.target);
var registeredFocusableObject = (focusableObjects[o] == true);
if (o.tabEnabled){
if (((!(registeredFocusableObject)) && (isTabVisible(o)))){
if (!(o is IFocusManagerComponent)){
o.focusRect = false;
};
focusableObjects[o] = true;
};
} else {
if (registeredFocusableObject){
delete focusableObjects[o];
};
};
}
private function tabIndexChangeHandler(event:Event):void{
calculateCandidates = true;
}
private function tabChildrenChangeHandler(event:Event):void{
if (event.target != event.currentTarget){
return;
};
calculateCandidates = true;
var o:DisplayObjectContainer = DisplayObjectContainer(event.target);
if (o.tabChildren){
addFocusables(o, true);
} else {
removeFocusables(o);
};
}
public function activate():void{
if (activated){
return;
};
addFocusables(form);
form.addEventListener(Event.ADDED, addedHandler, false, 0, true);
form.addEventListener(Event.REMOVED, removedHandler, false, 0, true);
form.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false, 0, true);
form.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false, 0, true);
form.addEventListener(FocusEvent.FOCUS_IN, focusInHandler, true, 0, true);
form.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true, 0, true);
form.stage.addEventListener(Event.ACTIVATE, activateHandler, false, 0, true);
form.stage.addEventListener(Event.DEACTIVATE, deactivateHandler, false, 0, true);
form.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false, 0, true);
form.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true, 0, true);
activated = true;
if (lastFocus){
setFocus(lastFocus);
};
}
public function deactivate():void{
if (!activated){
return;
};
focusableObjects = new Dictionary(true);
focusableCandidates = null;
lastFocus = null;
defButton = null;
form.removeEventListener(Event.ADDED, addedHandler, false);
form.removeEventListener(Event.REMOVED, removedHandler, false);
form.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false);
form.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false);
form.removeEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.removeEventListener(Event.ACTIVATE, activateHandler, false);
form.stage.removeEventListener(Event.DEACTIVATE, deactivateHandler, false);
form.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false);
form.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = false;
}
private function focusInHandler(event:FocusEvent):void{
var x:Button;
if (!activated){
return;
};
var target:InteractiveObject = InteractiveObject(event.target);
if (form.contains(target)){
lastFocus = findFocusManagerComponent(InteractiveObject(target));
if ((lastFocus is Button)){
x = Button(lastFocus);
if (defButton){
defButton.emphasized = false;
defButton = x;
x.emphasized = true;
};
} else {
if (((defButton) && (!((defButton == _defaultButton))))){
defButton.emphasized = false;
defButton = _defaultButton;
_defaultButton.emphasized = true;
};
};
};
}
private function focusOutHandler(event:FocusEvent):void{
if (!activated){
return;
};
var target:InteractiveObject = (event.target as InteractiveObject);
}
private function activateHandler(event:Event):void{
if (!activated){
return;
};
var target:InteractiveObject = InteractiveObject(event.target);
if (lastFocus){
if ((lastFocus is IFocusManagerComponent)){
IFocusManagerComponent(lastFocus).setFocus();
} else {
form.stage.focus = lastFocus;
};
};
lastAction = "ACTIVATE";
}
private function deactivateHandler(event:Event):void{
if (!activated){
return;
};
var target:InteractiveObject = InteractiveObject(event.target);
}
private function mouseFocusChangeHandler(event:FocusEvent):void{
if (!activated){
return;
};
if ((event.relatedObject is TextField)){
return;
};
event.preventDefault();
}
private function keyFocusChangeHandler(event:FocusEvent):void{
if (!activated){
return;
};
showFocusIndicator = true;
if ((((((event.keyCode == Keyboard.TAB)) || ((event.keyCode == 0)))) && (!(event.isDefaultPrevented())))){
setFocusToNextObject(event);
event.preventDefault();
};
}
private function keyDownHandler(event:KeyboardEvent):void{
if (!activated){
return;
};
if (event.keyCode == Keyboard.TAB){
lastAction = "KEY";
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
};
if (((((((defaultButtonEnabled) && ((event.keyCode == Keyboard.ENTER)))) && (defaultButton))) && (defButton.enabled))){
sendDefaultButtonEvent();
};
}
private function mouseDownHandler(event:MouseEvent):void{
if (!activated){
return;
};
if (event.isDefaultPrevented()){
return;
};
var o:InteractiveObject = getTopLevelFocusTarget(InteractiveObject(event.target));
if (!o){
return;
};
showFocusIndicator = false;
if (((((!((o == lastFocus))) || ((lastAction == "ACTIVATE")))) && (!((o is TextField))))){
setFocus(o);
};
lastAction = "MOUSEDOWN";
}
public function get defaultButton():Button{
return (_defaultButton);
}
public function set defaultButton(value:Button):void{
var button:Button = (value) ? Button(value) : null;
if (button != _defaultButton){
if (_defaultButton){
_defaultButton.emphasized = false;
};
if (defButton){
defButton.emphasized = false;
};
_defaultButton = button;
defButton = button;
if (button){
button.emphasized = true;
};
};
}
public function sendDefaultButtonEvent():void{
defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
private function setFocusToNextObject(event:FocusEvent):void{
if (!hasFocusableObjects()){
return;
};
var o:InteractiveObject = getNextFocusManagerComponent(event.shiftKey);
if (o){
setFocus(o);
};
}
private function hasFocusableObjects():Boolean{
var o:Object;
for (o in focusableObjects) {
return (true);
};
return (false);
}
public function getNextFocusManagerComponent(backward:Boolean=false):InteractiveObject{
var tg:IFocusManagerGroup;
if (!hasFocusableObjects()){
return (null);
};
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
var o:DisplayObject = form.stage.focus;
o = DisplayObject(findFocusManagerComponent(InteractiveObject(o)));
var g:String = "";
if ((o is IFocusManagerGroup)){
tg = IFocusManagerGroup(o);
g = tg.groupName;
};
var i:int = getIndexOfFocusedObject(o);
var bSearchAll:Boolean;
var start:int = i;
if (i == -1){
if (backward){
i = focusableCandidates.length;
};
bSearchAll = true;
};
var j:int = getIndexOfNextObject(i, backward, bSearchAll, g);
return (findFocusManagerComponent(focusableCandidates[j]));
}
private function getIndexOfFocusedObject(o:DisplayObject):int{
var n:int = focusableCandidates.length;
var i:int;
i = 0;
while (i < n) {
if (focusableCandidates[i] == o){
return (i);
};
i++;
};
return (-1);
}
private function getIndexOfNextObject(i:int, shiftKey:Boolean, bSearchAll:Boolean, groupName:String):int{
var o:DisplayObject;
var tg1:IFocusManagerGroup;
var j:int;
var obj:DisplayObject;
var tg2:IFocusManagerGroup;
var n:int = focusableCandidates.length;
var start:int = i;
while (true) {
if (shiftKey){
i--;
} else {
i++;
};
if (bSearchAll){
if (((shiftKey) && ((i < 0)))){
break;
};
if (((!(shiftKey)) && ((i == n)))){
break;
};
} else {
i = ((i + n) % n);
if (start == i){
break;
};
};
if (isValidFocusCandidate(focusableCandidates[i], groupName)){
o = DisplayObject(findFocusManagerComponent(focusableCandidates[i]));
if ((o is IFocusManagerGroup)){
tg1 = IFocusManagerGroup(o);
j = 0;
while (j < focusableCandidates.length) {
obj = focusableCandidates[j];
if ((obj is IFocusManagerGroup)){
tg2 = IFocusManagerGroup(obj);
if ((((tg2.groupName == tg1.groupName)) && (tg2.selected))){
i = j;
break;
};
};
j++;
};
};
return (i);
};
};
return (i);
}
private function sortFocusableObjects():void{
var o:Object;
var c:InteractiveObject;
focusableCandidates = [];
for (o in focusableObjects) {
c = InteractiveObject(o);
if (((((c.tabIndex) && (!(isNaN(Number(c.tabIndex)))))) && ((c.tabIndex > 0)))){
sortFocusableObjectsTabIndex();
return;
};
focusableCandidates.push(c);
};
focusableCandidates.sort(sortByDepth);
}
private function sortFocusableObjectsTabIndex():void{
var o:Object;
var c:InteractiveObject;
focusableCandidates = [];
for (o in focusableObjects) {
c = InteractiveObject(o);
if (((c.tabIndex) && (!(isNaN(Number(c.tabIndex)))))){
focusableCandidates.push(c);
};
};
focusableCandidates.sort(sortByTabIndex);
}
private function sortByDepth(aa:InteractiveObject, bb:InteractiveObject):Number{
var index:int;
var tmp:String;
var tmp2:String;
var val1:String = "";
var val2:String = "";
var zeros:String = "0000";
var a:DisplayObject = DisplayObject(aa);
var b:DisplayObject = DisplayObject(bb);
while (((!((a == DisplayObject(form)))) && (a.parent))) {
index = getChildIndex(a.parent, a);
tmp = index.toString(16);
if (tmp.length < 4){
tmp2 = (zeros.substring(0, (4 - tmp.length)) + tmp);
};
val1 = (tmp2 + val1);
a = a.parent;
};
while (((!((b == DisplayObject(form)))) && (b.parent))) {
index = getChildIndex(b.parent, b);
tmp = index.toString(16);
if (tmp.length < 4){
tmp2 = (zeros.substring(0, (4 - tmp.length)) + tmp);
};
val2 = (tmp2 + val2);
b = b.parent;
};
return (((val1 > val2)) ? 1 : ((val1 < val2)) ? -1 : 0);
}
private function getChildIndex(parent:DisplayObjectContainer, child:DisplayObject):int{
return (parent.getChildIndex(child));
}
private function sortByTabIndex(a:InteractiveObject, b:InteractiveObject):int{
return (((a.tabIndex > b.tabIndex)) ? 1 : ((a.tabIndex < b.tabIndex)) ? -1 : sortByDepth(a, b));
}
public function get defaultButtonEnabled():Boolean{
return (_defaultButtonEnabled);
}
public function set defaultButtonEnabled(value:Boolean):void{
_defaultButtonEnabled = value;
}
public function get nextTabIndex():int{
return (0);
}
public function get showFocusIndicator():Boolean{
return (_showFocusIndicator);
}
public function set showFocusIndicator(value:Boolean):void{
_showFocusIndicator = value;
}
public function get form():DisplayObjectContainer{
return (_form);
}
public function set form(value:DisplayObjectContainer):void{
_form = value;
}
public function getFocus():InteractiveObject{
var o:InteractiveObject = form.stage.focus;
return (findFocusManagerComponent(o));
}
public function setFocus(component:InteractiveObject):void{
if ((component is IFocusManagerComponent)){
IFocusManagerComponent(component).setFocus();
} else {
form.stage.focus = component;
};
}
public function showFocus():void{
}
public function hideFocus():void{
}
public function findFocusManagerComponent(component:InteractiveObject):InteractiveObject{
var p:InteractiveObject = component;
while (component) {
if ((((component is IFocusManagerComponent)) && (IFocusManagerComponent(component).focusEnabled))){
return (component);
};
component = component.parent;
};
return (p);
}
private function getTopLevelFocusTarget(o:InteractiveObject):InteractiveObject{
while (o != InteractiveObject(form)) {
if ((((((((o is IFocusManagerComponent)) && (IFocusManagerComponent(o).focusEnabled))) && (IFocusManagerComponent(o).mouseFocusEnabled))) && (UIComponent(o).enabled))){
return (o);
};
o = o.parent;
if (o == null){
break;
};
};
return (null);
}
}
}//package fl.managers
Section 16
//IFocusManager (fl.managers.IFocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
public interface IFocusManager {
function get defaultButton():Button;
function set defaultButton(/Applications/Adobe Flash CS5/Common/Configuration/Component Source/ActionScript 3.0/User Interface;fl/managers;IFocusManager.as:Button):void;
function get defaultButtonEnabled():Boolean;
function set defaultButtonEnabled(/Applications/Adobe Flash CS5/Common/Configuration/Component Source/ActionScript 3.0/User Interface;fl/managers;IFocusManager.as:Boolean):void;
function get nextTabIndex():int;
function get showFocusIndicator():Boolean;
function set showFocusIndicator(/Applications/Adobe Flash CS5/Common/Configuration/Component Source/ActionScript 3.0/User Interface;fl/managers;IFocusManager.as:Boolean):void;
function getFocus():InteractiveObject;
function setFocus(/Applications/Adobe Flash CS5/Common/Configuration/Component Source/ActionScript 3.0/User Interface;fl/managers;IFocusManager.as:InteractiveObject):void;
function showFocus():void;
function hideFocus():void;
function activate():void;
function deactivate():void;
function findFocusManagerComponent(Button:InteractiveObject):InteractiveObject;
function getNextFocusManagerComponent(Button:Boolean=false):InteractiveObject;
}
}//package fl.managers
Section 17
//IFocusManagerComponent (fl.managers.IFocusManagerComponent)
package fl.managers {
public interface IFocusManagerComponent {
function get focusEnabled():Boolean;
function set focusEnabled(/Applications/Adobe Flash CS5/Common/Configuration/Component Source/ActionScript 3.0/User Interface;fl/managers;IFocusManagerComponent.as:Boolean):void;
function get mouseFocusEnabled():Boolean;
function get tabEnabled():Boolean;
function get tabIndex():int;
function setFocus():void;
function drawFocus(/Applications/Adobe Flash CS5/Common/Configuration/Component Source/ActionScript 3.0/User Interface;fl/managers;IFocusManagerComponent.as:Boolean):void;
}
}//package fl.managers
Section 18
//IFocusManagerGroup (fl.managers.IFocusManagerGroup)
package fl.managers {
public interface IFocusManagerGroup {
function get groupName():String;
function set groupName(/Applications/Adobe Flash CS5/Common/Configuration/Component Source/ActionScript 3.0/User Interface;fl/managers;IFocusManagerGroup.as:String):void;
function get selected():Boolean;
function set selected(/Applications/Adobe Flash CS5/Common/Configuration/Component Source/ActionScript 3.0/User Interface;fl/managers;IFocusManagerGroup.as:Boolean):void;
}
}//package fl.managers
Section 19
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import fl.core.*;
import flash.utils.*;
import flash.text.*;
public class StyleManager {
private var styleToClassesHash:Object;
private var classToInstancesDict:Dictionary;
private var classToStylesDict:Dictionary;
private var classToDefaultStylesDict:Dictionary;
private var globalStyles:Object;
private static var _instance:StyleManager;
public function StyleManager(){
super();
styleToClassesHash = {};
classToInstancesDict = new Dictionary(true);
classToStylesDict = new Dictionary(true);
classToDefaultStylesDict = new Dictionary(true);
globalStyles = UIComponent.getStyleDefinition();
}
private static function getInstance(){
if (_instance == null){
_instance = new (StyleManager);
};
return (_instance);
}
public static function registerInstance(instance:UIComponent):void{
var target:Class;
var defaultStyles:Object;
var styleToClasses:Object;
var n:String;
var instance = instance;
var inst:StyleManager = getInstance();
var classDef:Class = getClassDef(instance);
if (classDef == null){
return;
};
if (inst.classToInstancesDict[classDef] == null){
inst.classToInstancesDict[classDef] = new Dictionary(true);
target = classDef;
while (defaultStyles == null) {
if (target["getStyleDefinition"] != null){
defaultStyles = target["getStyleDefinition"]();
break;
};
target = (instance.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(target)) as Class);
continue;
var _slot1 = err;
target = (getDefinitionByName(getQualifiedSuperclassName(target)) as Class);
//unresolved jump
var _slot1 = e;
defaultStyles = UIComponent.getStyleDefinition();
break;
};
styleToClasses = inst.styleToClassesHash;
for (n in defaultStyles) {
if (styleToClasses[n] == null){
styleToClasses[n] = new Dictionary(true);
};
styleToClasses[n][classDef] = true;
};
inst.classToDefaultStylesDict[classDef] = defaultStyles;
if (inst.classToStylesDict[classDef] == null){
inst.classToStylesDict[classDef] = {};
};
};
inst.classToInstancesDict[classDef][instance] = true;
setSharedStyles(instance);
}
private static function setSharedStyles(instance:UIComponent):void{
var n:String;
var inst:StyleManager = getInstance();
var classDef:Class = getClassDef(instance);
var styles:Object = inst.classToDefaultStylesDict[classDef];
for (n in styles) {
instance.setSharedStyle(n, getSharedStyle(instance, n));
};
}
private static function getSharedStyle(instance:UIComponent, name:String):Object{
var classDef:Class = getClassDef(instance);
var inst:StyleManager = getInstance();
var style:Object = inst.classToStylesDict[classDef][name];
if (style != null){
return (style);
};
style = inst.globalStyles[name];
if (style != null){
return (style);
};
return (inst.classToDefaultStylesDict[classDef][name]);
}
public static function getComponentStyle(component:Object, name:String):Object{
var classDef:Class = getClassDef(component);
var styleHash:Object = getInstance().classToStylesDict[classDef];
return (((styleHash)==null) ? null : styleHash[name]);
}
public static function clearComponentStyle(component:Object, name:String):void{
var classDef:Class = getClassDef(component);
var styleHash:Object = getInstance().classToStylesDict[classDef];
if (((!((styleHash == null))) && (!((styleHash[name] == null))))){
delete styleHash[name];
invalidateComponentStyle(classDef, name);
};
}
public static function setComponentStyle(component:Object, name:String, style:Object):void{
var classDef:Class = getClassDef(component);
var styleHash:Object = getInstance().classToStylesDict[classDef];
if (styleHash == null){
styleHash = (getInstance().classToStylesDict[classDef] = {});
};
if (styleHash == style){
return;
};
styleHash[name] = style;
invalidateComponentStyle(classDef, name);
}
private static function getClassDef(component:Object):Class{
var component = component;
if ((component is Class)){
return ((component as Class));
};
return ((getDefinitionByName(getQualifiedClassName(component)) as Class));
//unresolved jump
var _slot1 = e;
if ((component is UIComponent)){
return ((component.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(component)) as Class));
//unresolved jump
var _slot1 = e;
};
return (null);
}
private static function invalidateStyle(name:String):void{
var classRef:Object;
var classes:Dictionary = getInstance().styleToClassesHash[name];
if (classes == null){
return;
};
for (classRef in classes) {
invalidateComponentStyle(Class(classRef), name);
};
}
private static function invalidateComponentStyle(componentClass:Class, name:String):void{
var obj:Object;
var instance:UIComponent;
var instances:Dictionary = getInstance().classToInstancesDict[componentClass];
if (instances == null){
return;
};
for (obj in instances) {
instance = (obj as UIComponent);
if (instance == null){
} else {
instance.setSharedStyle(name, getSharedStyle(instance, name));
};
};
}
public static function setStyle(name:String, style:Object):void{
var styles:Object = getInstance().globalStyles;
if ((((styles[name] === style)) && (!((style is TextFormat))))){
return;
};
styles[name] = style;
invalidateStyle(name);
}
public static function clearStyle(name:String):void{
setStyle(name, null);
}
public static function getStyle(name:String):Object{
return (getInstance().globalStyles[name]);
}
}
}//package fl.managers
Section 20
//Circle (Circle)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.ui.*;
public class Circle extends MovieClip {
const DRAG_COLOR:int = 0xFFFF00;
const FRONT_COLOR:int = 0xFFFFFF;
const RESIZE_COLOR:int = 0xFFCC00;
const DEFAULT_COLOR:int = 0xFF0000;
var _PrevPoint:Point;
var _radius:Number;// = 50
var _draging:Boolean;// = false
public var _circleController:CircleController;
var _color:int;// = 0xFF0000
public var _container:Sprite;
var _alpha:Number;// = 0.2
var _resizing:Boolean;// = false
var _circleX:Number;// = 0
var _circleY:Number;// = 0
public function Circle(arg1:CircleController){
this._container = new Sprite();
super();
this._circleController = arg1;
this._container.buttonMode = true;
this._container.addEventListener(MouseEvent.MOUSE_DOWN, this.mMouseDown_handler);
var loc1:* = this._circleController._container.globalToLocal(new Point(mouseX, mouseY));
this.mDrawCircle(loc1.x, loc1.y, this._radius);
}
public function removeMe(){
var loc1:* = this._container;
this._container.parent.removeChild(loc1);
loc1 = null;
}
function setColor(arg1:int=0xFF0000):void{
this.mDrawCircle(this._circleX, this._circleY, this._radius, arg1);
}
function mStageMouseUp_handler(arg1:MouseEvent):void{
if (this._resizing){
this.mResizeMode(false);
};
if (this._draging){
this.mDragMode(false);
};
this._circleController.setFront(this);
}
function mDragMode(arg1:Boolean):void{
if (arg1){
this._draging = true;
this._container.addEventListener(Event.ENTER_FRAME, this.mDraging_handler);
this._container.stage.addEventListener(MouseEvent.MOUSE_UP, this.mStageMouseUp_handler);
} else {
if (!this._draging){
return;
};
this._draging = false;
this._container.removeEventListener(Event.ENTER_FRAME, this.mDraging_handler);
this._container.stage.removeEventListener(MouseEvent.MOUSE_UP, this.mStageMouseUp_handler);
};
}
function mResizing_handler(arg1:Event):void{
if (!this._resizing){
return;
};
var loc1:* = this._circleController._container.globalToLocal(new Point(mouseX, mouseY));
var loc2:* = Point.distance(loc1, this._PrevPoint);
var loc3:* = new Point(this._circleX, this._circleY);
if (Point.distance(loc3, this._PrevPoint) > Point.distance(loc3, loc1)){
loc2 = (loc2 * -1);
};
this._PrevPoint = loc1;
this._radius = (this._radius + loc2);
this.mDrawCircle(this._circleX, this._circleY, this._radius);
}
function mDraging_handler(arg1:Event):void{
if (!this._draging){
return;
};
var loc1:* = this._circleController._container.globalToLocal(new Point(mouseX, mouseY));
this._circleX = ((this._circleX + loc1.x) - this._PrevPoint.x);
this._circleY = ((this._circleY + loc1.y) - this._PrevPoint.y);
this.mDrawCircle(this._circleX, this._circleY, this._radius);
this._PrevPoint = loc1;
}
function mMouseDown_handler(arg1:MouseEvent):void{
if (arg1.shiftKey){
return;
};
this._PrevPoint = this._circleController._container.globalToLocal(new Point(mouseX, mouseY));
if (arg1.ctrlKey){
this.mResizeMode(true);
} else {
this.mDragMode(true);
};
}
function mResizeMode(arg1:Boolean):void{
if (arg1){
this._resizing = true;
this._container.addEventListener(Event.ENTER_FRAME, this.mResizing_handler);
this._container.stage.addEventListener(MouseEvent.MOUSE_UP, this.mStageMouseUp_handler);
} else {
this._resizing = false;
this._container.removeEventListener(Event.ENTER_FRAME, this.mResizing_handler);
this._container.stage.removeEventListener(MouseEvent.MOUSE_UP, this.mStageMouseUp_handler);
};
}
public function mKeyboadAction(arg1:KeyboardEvent):void{
var loc2:*;
var loc1:* = arg1.keyCode;
switch (loc1){
case Keyboard.UP:
if (arg1.shiftKey){
this._circleY = (this._circleY - 2);
} else {
loc1 = this;
loc2 = (loc1._circleY - 1);
loc1._circleY = loc2;
};
break;
case Keyboard.DOWN:
if (arg1.shiftKey){
this._circleY = (this._circleY + 2);
} else {
loc1 = this;
loc2 = (loc1._circleY + 1);
loc1._circleY = loc2;
};
break;
case Keyboard.LEFT:
if (arg1.shiftKey){
this._circleX = (this._circleX - 2);
} else {
loc1 = this;
loc2 = (loc1._circleX - 1);
loc1._circleX = loc2;
};
break;
case Keyboard.RIGHT:
if (arg1.ctrlKey){
this._circleX = (this._circleX + 2);
} else {
loc1 = this;
loc2 = (loc1._circleX + 1);
loc1._circleX = loc2;
};
break;
case Keyboard.NUMPAD_SUBTRACT:
if (arg1.shiftKey){
this._radius = (this._radius - 2);
} else {
loc1 = this;
loc2 = (loc1._radius - 1);
loc1._radius = loc2;
};
break;
case Keyboard.NUMPAD_ADD:
if (arg1.shiftKey){
this._radius = (this._radius + 2);
} else {
loc1 = this;
loc2 = (loc1._radius + 1);
loc1._radius = loc2;
};
break;
};
this.mDrawCircle(this._circleX, this._circleY, this._radius, this.FRONT_COLOR);
}
public function setDefaultColor():void{
this.setColor(this.DEFAULT_COLOR);
}
public function setFrontColor():void{
this.mDrawCircle(this._circleX, this._circleY, this._radius, this.FRONT_COLOR);
this.setColor(this.FRONT_COLOR);
}
function mDrawCircle(arg1:Number, arg2:Number, arg3:Number, arg4:int=0xFF0000):void{
if (this._draging){
arg4 = this.DRAG_COLOR;
} else {
if (this._resizing){
arg4 = this.RESIZE_COLOR;
};
};
this._container.graphics.clear();
this._container.graphics.lineStyle(0, arg4);
this._container.graphics.beginFill(arg4, this._alpha);
this._container.graphics.drawCircle(arg1, arg2, arg3);
this._container.graphics.endFill();
this._circleX = arg1;
this._circleY = arg2;
this._radius = arg3;
}
}
}//package
Section 21
//CircleController (CircleController)
package {
import flash.display.*;
import flash.events.*;
import flash.ui.*;
public class CircleController extends MovieClip {
public var _container:Sprite;
var _circles:Array;
var frontCircle:Circle;
public function CircleController(arg1:Sprite){
this._container = new Sprite();
this._circles = new Array();
super();
arg1.addChild(this._container);
this._container.stage.addEventListener(KeyboardEvent.KEY_UP, this.mKeyUp);
}
function setDefaultColor(){
var loc1:* = 0;
while (loc1 < this._circles.length) {
this._circles[loc1].setDefaultColor();
loc1++;
};
}
public function setFront(arg1:Circle){
this.setDefaultColor();
this._container.setChildIndex(arg1._container, (this._container.numChildren - 1));
arg1.setFrontColor();
this.frontCircle = arg1;
}
public function mAddCircle():void{
this.setDefaultColor();
var loc1:* = new Circle(this);
loc1.setFrontColor();
this._container.addChild(loc1._container);
this._circles.push(loc1);
this.frontCircle = loc1;
}
function mKeyUp(arg1:KeyboardEvent):void{
if (!this.frontCircle){
return;
};
var loc1:* = arg1.keyCode;
switch (loc1){
case Keyboard.DELETE:
this.deleteFrontCircle();
return;
};
this.frontCircle.mKeyboadAction(arg1);
}
public function deleteFrontCircle():void{
if (!this.frontCircle){
return;
};
this.frontCircle.removeMe();
this._circles.splice(this._circles.indexOf(this.frontCircle), 1);
this.frontCircle = null;
}
}
}//package
Section 22
//CircleEffect (CircleEffect)
package {
import flash.display.*;
import flash.utils.*;
import com.adobe.images.*;
import flash.events.*;
import fl.events.*;
import flash.geom.*;
import com.zorked.*;
import flash.net.*;
import flash.external.*;
public class CircleEffect extends MovieClip {
var resizing:Boolean;// = false
var fileRef:FileReference;
var testFname:String;
var frontCircle:Circle;
var canvas:Sprite;
var maskColor:int;// = 0
var uploadFileName:String;
var isPreview:Boolean;// = false
var SHIFT_pushed:Boolean;// = false
var centerPoint:Point;
var imgLoader:Loader;
var draging:Boolean;// = false
var prevRadius:Number;
var prevPoint:Point;
var loader:URLLoader;
var CTRL_pushed:Boolean;// = false
var circleController:CircleController;
public var panel:MovieClip;
var pic:Sprite;
public function CircleEffect(){
this.centerPoint = new Point(296, 296);
this.fileRef = new FileReference();
this.imgLoader = new Loader();
this.pic = new Sprite();
this.canvas = new Sprite();
this.loader = new URLLoader();
super();
addChild(this.canvas);
this.canvas.name = "canvas";
this.canvas.addChild(this.pic);
this.pic.name = "pic";
this.panel.maskBtn.addEventListener(MouseEvent.CLICK, this.mMaskBtnClick);
this.panel.delBtn.addEventListener(MouseEvent.CLICK, this.mdeleteBtnClick);
this.panel.uploadBtn.addEventListener(MouseEvent.CLICK, this.onUploadClick);
this.panel.colorPicker.addEventListener(ColorPickerEvent.CHANGE, this.changeHandler);
this.panel.creIMGBtn.addEventListener(MouseEvent.CLICK, this.onCreateIMG);
this.panel.creIMGBtn.visible = false;
this.canvas.addEventListener(MouseEvent.MOUSE_DOWN, this.mMouseDown);
this.pic.addEventListener(MouseEvent.MOUSE_DOWN, this.mAddCircleOnPic);
stage.addEventListener(MouseEvent.MOUSE_UP, this.mMouseUp);
this.fileRef.addEventListener(Event.SELECT, this.selectFile);
this.fileRef.addEventListener(Event.COMPLETE, this.uploadComplete);
this.imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.loaded);
this.circleController = new CircleController(this.canvas);
setChildIndex(this.panel, (numChildren - 1));
}
function maskDraw(){
this.canvas.graphics.clear();
this.canvas.graphics.lineStyle(0, this.maskColor);
this.canvas.graphics.beginFill(this.maskColor);
this.canvas.graphics.drawRect(0, 0, this.imgLoader.width, this.imgLoader.height);
this.canvas.graphics.endFill();
}
function mMaskBtnClick(arg1:MouseEvent):void{
if (this.isPreview){
this.pic.mask = null;
this.panel.maskBtn.gotoAndStop(1);
this.isPreview = false;
this.pic.addEventListener(MouseEvent.MOUSE_DOWN, this.mAddCircleOnPic);
this.canvas.removeEventListener(MouseEvent.MOUSE_DOWN, this.mAddCircleOnPic);
this.panel.creIMGBtn.visible = false;
} else {
this.pic.mask = this.circleController._container;
this.panel.maskBtn.gotoAndStop(2);
this.isPreview = true;
this.pic.removeEventListener(MouseEvent.MOUSE_DOWN, this.mAddCircleOnPic);
this.canvas.addEventListener(MouseEvent.MOUSE_DOWN, this.mAddCircleOnPic);
this.panel.creIMGBtn.visible = true;
};
}
function onUploadClick(arg1:MouseEvent):void{
this.fileRef.browse();
}
function mAddCircleOnPic(arg1:MouseEvent):void{
if (((this.isPreview) && (!((arg1.target.name == "canvas"))))){
return;
};
this.circleController.mAddCircle();
}
function uploadComplete(arg1:Event):void{
this.uploadFileName = ("./img/" + this.fileRef.name);
this.imgLoader.load(new URLRequest(this.uploadFileName));
}
function onIMGCOMPLETE(arg1:Event):void{
if (!ExternalInterface.available){
return;
};
URLNavigator.ChangePage(new URLRequest(("./img/" + this.loader.data)), "_blank");
}
function selectFile(arg1:Event):void{
var loc1:* = new URLRequest("upload.php");
this.fileRef.upload(loc1, "Filedata");
}
function mAddCircle(arg1:MouseEvent):void{
this.circleController.mAddCircle();
}
function onCreateIMG(arg1:MouseEvent):void{
var loc4:*;
var loc1:* = new BitmapData(this.pic.width, this.pic.height, false, this.maskColor);
loc1.draw(this.canvas);
var loc2:* = new JPGEncoder(80);
var loc3:* = loc2.encode(loc1);
loc4 = new URLRequest("tojpg.php");
loc4.contentType = "application/octet-stream";
loc4.method = URLRequestMethod.POST;
loc4.data = loc3;
this.loader.addEventListener(Event.COMPLETE, this.onIMGCOMPLETE);
this.loader.load(loc4);
}
function mMouseUp(arg1:MouseEvent):void{
this.canvas.stopDrag();
}
function changeHandler(arg1:ColorPickerEvent):void{
this.maskColor = arg1.target.selectedColor;
this.maskDraw();
}
function loaded(arg1:Event):void{
this.pic.addChild(this.imgLoader);
this.maskDraw();
this.canvas.x = ((-(this.pic.width) / 2) + this.centerPoint.x);
this.canvas.y = ((-(this.pic.height) / 2) + this.centerPoint.y);
}
function mdeleteBtnClick(arg1:MouseEvent):void{
this.circleController.deleteFrontCircle();
}
function mMouseDown(arg1:MouseEvent):void{
if (arg1.shiftKey){
this.canvas.startDrag();
};
}
}
}//package
Section 23
//ColorPicker_backgroundSkin (ColorPicker_backgroundSkin)
package {
import flash.display.*;
public dynamic class ColorPicker_backgroundSkin extends MovieClip {
public function ColorPicker_backgroundSkin(){
super();
}
}
}//package
Section 24
//ColorPicker_colorWell (ColorPicker_colorWell)
package {
import flash.display.*;
public dynamic class ColorPicker_colorWell extends MovieClip {
public function ColorPicker_colorWell(){
super();
}
}
}//package
Section 25
//ColorPicker_disabledSkin (ColorPicker_disabledSkin)
package {
import flash.display.*;
public dynamic class ColorPicker_disabledSkin extends MovieClip {
public function ColorPicker_disabledSkin(){
super();
}
}
}//package
Section 26
//ColorPicker_downSkin (ColorPicker_downSkin)
package {
import flash.display.*;
public dynamic class ColorPicker_downSkin extends MovieClip {
public function ColorPicker_downSkin(){
super();
}
}
}//package
Section 27
//ColorPicker_overSkin (ColorPicker_overSkin)
package {
import flash.display.*;
public dynamic class ColorPicker_overSkin extends MovieClip {
public function ColorPicker_overSkin(){
super();
}
}
}//package
Section 28
//ColorPicker_swatchSelectedSkin (ColorPicker_swatchSelectedSkin)
package {
import flash.display.*;
public dynamic class ColorPicker_swatchSelectedSkin extends MovieClip {
public function ColorPicker_swatchSelectedSkin(){
super();
}
}
}//package
Section 29
//ColorPicker_swatchSkin (ColorPicker_swatchSkin)
package {
import flash.display.*;
public dynamic class ColorPicker_swatchSkin extends Sprite {
public function ColorPicker_swatchSkin(){
super();
}
}
}//package
Section 30
//ColorPicker_textFieldSkin (ColorPicker_textFieldSkin)
package {
import flash.display.*;
public dynamic class ColorPicker_textFieldSkin extends MovieClip {
public function ColorPicker_textFieldSkin(){
super();
}
}
}//package
Section 31
//ColorPicker_upSkin (ColorPicker_upSkin)
package {
import flash.display.*;
public dynamic class ColorPicker_upSkin extends MovieClip {
public function ColorPicker_upSkin(){
super();
}
}
}//package