Brought up to date with the private repository (feea4c7)

This commit is contained in:
S committed 2026-10-14 20:57:33 +03:00
1 parent 1aa738d692
commit 1b1df1ae48
7925 files changed
+2617237 -20

No files matched your search

@@ -0,0 +1,466 @@
package com.sbi.graphics
{
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
public class BitmapByteArray
{
private static const PALETTE_ALPHA_OFFSET:int = 25;
private static const SHADOW_GRADIENT_SCALE:int = 3;
private const TRANS:int = 0;
private var _palette:Array;
private var _h:int;
private var _w:int;
private var _offX:int;
private var _offY:int;
private var _ba:Vector.<int>;
public function BitmapByteArray()
{
super();
this._palette = PaletteHelper.getAnimalPalette();
}
public static function scaleAndPackImage(param1:BitmapData) : Object
{
var _loc2_:BitmapByteArray = new BitmapByteArray();
_loc2_.loadBitmap(param1);
_loc2_.halfImage();
_loc2_.crop();
return _loc2_.processPackImage();
}
public static function scaleAndPackShadow(param1:BitmapData, param2:int, param3:int, param4:int, param5:int) : Object
{
var _loc6_:BitmapByteArray = new BitmapByteArray();
return _loc6_.scaleShadow(param1,param2,param3,param4,param5);
}
private function loadBitmap(param1:BitmapData) : void
{
var _loc2_:uint = 0;
var _loc3_:uint = 0;
var _loc7_:uint = 0;
this._w = param1.width;
this._h = param1.height;
this._ba = new Vector.<int>(this._w * this._h,true);
var _loc4_:uint = 0;
var _loc5_:int = -1;
var _loc6_:* = 0;
_loc3_ = 0;
while(_loc3_ < this._h)
{
_loc2_ = 0;
while(_loc2_ < this._w)
{
_loc7_ = param1.getPixel32(_loc2_,_loc3_);
if(_loc4_ != _loc7_ || _loc5_ < 0)
{
_loc4_ = _loc7_;
_loc5_ = int(this.findPaletteColor(_loc7_));
}
var _loc8_:Number;
this._ba[_loc8_ = _loc6_++] = _loc5_;
_loc2_++;
}
_loc3_++;
}
}
private function scaleShadow(param1:BitmapData, param2:int, param3:int, param4:int, param5:int) : Object
{
var _loc7_:uint = 0;
var _loc8_:uint = 0;
var _loc9_:uint = 0;
var _loc10_:uint = 0;
var _loc16_:int = 0;
var _loc17_:* = 0;
this._w = param1.width;
this._h = param1.height;
var _loc6_:Vector.<uint> = param1.getVector(new Rectangle(0,0,this._w,this._h));
var _loc11_:Vector.<int> = new Vector.<int>(this._w * this._h * 0.25,true);
var _loc12_:int = 0;
var _loc13_:* = 0;
var _loc14_:int = 0;
while(_loc14_ < this._h)
{
_loc16_ = 0;
while(_loc16_ < this._w)
{
_loc12_ = _loc16_ + _loc14_ * this._w;
_loc7_ = _loc6_[_loc12_];
_loc8_ = _loc6_[_loc12_ + 1];
_loc12_ += this._w;
_loc9_ = _loc6_[_loc12_];
_loc10_ = _loc6_[_loc12_ + 1];
var _loc18_:Number;
_loc11_[_loc18_ = _loc13_++] = this.blendShadowColors(_loc7_,_loc8_,_loc9_,_loc10_);
_loc16_ += 2;
}
_loc14_ += 2;
}
this._ba = _loc11_;
this._h /= 2;
this._w /= 2;
if(param4 != this._w || param5 != this._h)
{
_loc13_ = 0;
_loc11_ = new Vector.<int>(param4 * param5,true);
_loc14_ = param3;
while(_loc14_ < param3 + param5)
{
_loc17_ = int(_loc14_ * this._w + param2);
_loc16_ = 0;
while(_loc16_ < param4)
{
_loc12_ = this._ba[_loc17_++];
_loc11_[_loc18_ = _loc13_++] = _loc12_;
_loc16_++;
}
_loc14_++;
}
this._w = param4;
this._h = param5;
this._offX = param2;
this._offY = param3;
this._ba = _loc11_;
}
var _loc15_:Object = this.processPackImage();
_loc15_.sm = SHADOW_GRADIENT_SCALE;
return _loc15_;
}
private function halfImage() : void
{
var _loc1_:int = 0;
var _loc2_:int = 0;
var _loc3_:int = 0;
var _loc4_:int = 0;
var _loc9_:int = 0;
var _loc5_:Vector.<int> = new Vector.<int>(this._w * this._h * 0.25,true);
var _loc6_:int = 0;
var _loc7_:* = 0;
var _loc8_:int = 0;
while(_loc8_ < this._h)
{
_loc9_ = 0;
while(_loc9_ < this._w)
{
_loc6_ = _loc9_ + _loc8_ * this._w;
_loc1_ = this._ba[_loc6_];
_loc2_ = this._ba[_loc6_ + 1];
_loc6_ += this._w;
_loc3_ = this._ba[_loc6_];
_loc4_ = this._ba[_loc6_ + 1];
var _loc10_:Number;
_loc5_[_loc10_ = _loc7_++] = this.blendColors(_loc1_,_loc2_,_loc3_,_loc4_);
_loc9_ += 2;
}
_loc8_ += 2;
}
this._ba = _loc5_;
this._h /= 2;
this._w /= 2;
}
private function crop() : void
{
var _loc1_:uint = 0;
var _loc2_:int = 0;
var _loc3_:int = 0;
var _loc11_:Vector.<int> = null;
var _loc12_:* = 0;
var _loc4_:int = this._w;
var _loc5_:int = 0;
var _loc6_:int = this._h;
var _loc7_:int = 0;
var _loc8_:* = 0;
_loc3_ = 0;
while(_loc3_ < this._h)
{
_loc2_ = 0;
while(_loc2_ < this._w)
{
_loc1_ = uint(this._ba[_loc8_++]);
if(_loc1_ > 0)
{
if(_loc2_ < _loc4_)
{
_loc4_ = _loc2_;
}
if(_loc2_ > _loc5_)
{
_loc5_ = _loc2_;
}
if(_loc3_ < _loc6_)
{
_loc6_ = _loc3_;
}
if(_loc3_ > _loc7_)
{
_loc7_ = _loc3_;
}
}
_loc2_++;
}
_loc3_++;
}
this._offX = _loc4_;
this._offY = _loc6_;
var _loc9_:uint = _loc5_ - _loc4_ + 1;
var _loc10_:uint = _loc7_ - _loc6_ + 1;
if(_loc4_ == this._w && _loc6_ == this._h)
{
this._w = 0;
this._h = 0;
this._ba = null;
return;
}
_loc8_ = 0;
if(_loc9_ != this._w || _loc10_ != this._h)
{
_loc11_ = new Vector.<int>(_loc9_ * _loc10_,true);
_loc3_ = _loc6_;
while(_loc3_ < _loc6_ + _loc10_)
{
_loc12_ = int(_loc3_ * this._w + this._offX);
_loc2_ = 0;
while(_loc2_ < _loc9_)
{
_loc1_ = uint(this._ba[_loc12_++]);
var _loc13_:Number;
_loc11_[_loc13_ = _loc8_++] = _loc1_;
_loc2_++;
}
_loc3_++;
}
this._w = _loc9_;
this._h = _loc10_;
this._ba = _loc11_;
}
}
private function processPackImage() : Object
{
var _loc2_:int = 0;
var _loc3_:int = 0;
var _loc4_:String = null;
var _loc10_:uint = 0;
if(this._ba == null)
{
return null;
}
var _loc1_:Object = {
"x":this._offX,
"y":this._offY,
"w":this._w,
"h":this._h
};
var _loc5_:ByteArray = new ByteArray();
_loc1_.b = _loc5_;
var _loc6_:int = int(this._ba.length);
var _loc7_:uint = 256;
var _loc8_:uint = 0;
var _loc9_:* = 0;
while(_loc9_ < _loc6_)
{
_loc10_ = uint(this._ba[_loc9_++]);
if(_loc7_ == 256)
{
_loc7_ = _loc10_;
}
else if(_loc10_ != _loc7_)
{
if(_loc8_)
{
_loc7_ |= 128;
while(_loc8_ > 255)
{
_loc5_.writeByte(_loc7_);
_loc5_.writeByte(uint(255));
_loc8_ -= 256;
}
if(_loc8_ > 0)
{
_loc5_.writeByte(_loc7_);
_loc5_.writeByte(_loc8_);
}
else
{
_loc5_.writeByte(uint(_loc7_ & 0x7F));
}
}
else
{
_loc5_.writeByte(_loc7_);
}
_loc7_ = _loc10_;
_loc8_ = 0;
}
else
{
_loc8_++;
}
}
if(Boolean(_loc8_) || _loc6_ == 1)
{
_loc7_ |= 128;
while(_loc8_ > 255)
{
_loc5_.writeByte(_loc7_);
_loc5_.writeByte(uint(255));
_loc8_ -= 256;
}
if(_loc8_ > 0)
{
_loc5_.writeByte(_loc7_);
_loc5_.writeByte(_loc8_);
}
else
{
_loc5_.writeByte(uint(_loc7_ & 0x7F));
}
}
return _loc1_;
}
private function findPaletteColor(param1:uint) : uint
{
var _loc2_:uint = uint((param1 & 0xFF000000) >> 24);
if(_loc2_ < 160)
{
return this.TRANS;
}
param1 |= 4278190080;
var _loc3_:uint = 0;
while(_loc3_ < PALETTE_ALPHA_OFFSET)
{
if(this._palette[_loc3_] == param1)
{
return _loc3_;
}
_loc3_++;
}
var _loc4_:int = param1 >> 16 & 0xFF;
var _loc5_:int = param1 >> 8 & 0xFF;
var _loc6_:int = param1 & 0xFF;
return this.findClosetPaletteIndex(_loc4_,_loc5_,_loc6_);
}
private function findClosetPaletteIndex(param1:int, param2:int, param3:int) : int
{
var _loc6_:int = 0;
var _loc7_:int = 0;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc12_:uint = 0;
var _loc4_:int = 10000000;
var _loc5_:int = 0;
var _loc11_:uint = 0;
while(_loc11_ < PALETTE_ALPHA_OFFSET)
{
_loc12_ = uint(this._palette[_loc11_]);
_loc7_ = (_loc12_ >> 16 & 0xFF) - param1;
_loc8_ = (_loc12_ >> 8 & 0xFF) - param2;
_loc9_ = (_loc12_ & 0xFF) - param3;
_loc10_ = _loc7_ * _loc7_ + _loc8_ * _loc8_ + _loc9_ * _loc9_;
if(_loc10_ < _loc4_)
{
_loc4_ = _loc10_;
_loc5_ = int(_loc11_);
}
_loc11_++;
}
return _loc5_;
}
private function blendColors(param1:uint, param2:uint, param3:uint, param4:uint) : uint
{
var _loc5_:uint = 0;
var _loc6_:int = 0;
var _loc7_:Array = null;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc11_:int = 0;
var _loc12_:int = 0;
if(param1 == this.TRANS)
{
_loc6_++;
}
if(param2 == this.TRANS)
{
_loc6_++;
}
if(param3 == this.TRANS)
{
_loc6_++;
}
if(param4 == this.TRANS)
{
_loc6_++;
}
if(_loc6_ == 4)
{
return 0;
}
if(param1 == param2 && param1 == param3 && param1 == param4)
{
_loc5_ = param1;
}
else
{
_loc7_ = [param1,param2,param3,param4];
while(_loc12_ < 4)
{
if(_loc7_[_loc12_] != this.TRANS)
{
param1 = uint(this._palette[_loc7_[_loc12_]]);
_loc9_ += param1 >> 16 & 0xFF;
_loc10_ += param1 >> 8 & 0xFF;
_loc11_ += param1 & 0xFF;
_loc8_++;
}
_loc12_++;
}
_loc9_ /= _loc8_;
_loc10_ /= _loc8_;
_loc11_ /= _loc8_;
_loc5_ = uint(this.findClosetPaletteIndex(_loc9_,_loc10_,_loc11_));
}
return uint(_loc5_ + _loc6_ * PALETTE_ALPHA_OFFSET);
}
private function blendShadowColors(param1:uint, param2:uint, param3:uint, param4:uint) : int
{
var _loc5_:uint = ((param1 >> 24 & 0xFF) + (param2 >> 24 & 0xFF) + (param3 >> 24 & 0xFF) + (param4 >> 24 & 0xFF)) / 4;
var _loc6_:uint = ((param1 & 0xFF & 0xFF) + (param2 & 0xFF & 0xFF) + (param3 & 0xFF & 0xFF) + (param4 & 0xFF & 0xFF)) / 4;
if(_loc5_)
{
_loc6_ += (255 - _loc6_) * ((255 - _loc5_) / 255);
_loc6_ = uint(_loc6_ >> BitmapByteArray.SHADOW_GRADIENT_SCALE);
if(_loc6_ == 0)
{
_loc6_ = 1;
}
}
else
{
_loc6_ = 0;
}
return _loc6_;
}
}
}
@@ -0,0 +1,100 @@
package com.sbi.graphics
{
import flash.display.BitmapData;
import flash.utils.ByteArray;
public class ImageArray
{
public static const VERSION:uint = 117967104;
private var _frames:Array;
public function ImageArray()
{
super();
this._frames = new Array();
}
public function get length() : int
{
return this._frames.length;
}
public function release() : void
{
this._frames.splice(0,this._frames.length);
}
public function addBitmap(param1:BitmapData) : void
{
var _loc2_:Object = BitmapByteArray.scaleAndPackImage(param1);
this._frames.push(_loc2_);
}
public function attachShadow(param1:BitmapData) : void
{
var _loc2_:Object = null;
var _loc3_:Object = null;
if(this._frames.length)
{
_loc2_ = this._frames[this._frames.length - 1];
_loc3_ = BitmapByteArray.scaleAndPackShadow(param1,_loc2_.x,_loc2_.y,_loc2_.w,_loc2_.h);
_loc2_.s = _loc3_.b;
_loc2_.sm = _loc3_.sm;
}
}
public function addFrame(param1:Object) : void
{
this._frames.push(param1);
}
public function loadPackage(param1:ByteArray) : void
{
this.release();
param1.position = 0;
try
{
param1.uncompress();
}
catch(err:Error)
{
}
var _loc2_:Object = param1.readObject();
if(_loc2_.v == ImageArray.VERSION)
{
this._frames = _loc2_.f;
return;
}
}
public function getFrame(param1:int) : Object
{
return this._frames[param1];
}
public function getPackage(param1:Boolean = true) : ByteArray
{
var _loc2_:int = 0;
var _loc3_:ByteArray = null;
var _loc4_:Object = null;
if(this._frames.length)
{
_loc4_ = {
"v":ImageArray.VERSION,
"f":this._frames
};
_loc3_ = new ByteArray();
_loc3_.writeObject(_loc4_);
_loc3_.position = 0;
if(param1)
{
_loc3_.compress();
}
}
return _loc3_;
}
}
}
@@ -0,0 +1,32 @@
package com.sbi.graphics
{
public class ImageArrayHelper
{
public function ImageArrayHelper()
{
super();
}
public static function packId(param1:int, param2:int, param3:int) : uint
{
return param1 << 24 | param2 << 16 | param3;
}
public static function avatarId(param1:uint) : int
{
return param1 >> 24 & 0xFF;
}
public static function categoryId(param1:uint) : int
{
return param1 >> 16 & 0xFF;
}
public static function layerId(param1:uint) : int
{
return param1 & 0xFFFF;
}
}
}
@@ -0,0 +1,20 @@
package com.sbi.graphics
{
import flash.events.Event;
import flash.utils.ByteArray;
public class JPEGAsyncCompleteEvent extends Event
{
public static const JPEGASYNC_COMPLETE:String = "JPEGAsyncComplete";
public var ImageData:ByteArray;
public function JPEGAsyncCompleteEvent(param1:ByteArray)
{
this.ImageData = param1;
super(JPEGASYNC_COMPLETE);
}
}
}
@@ -0,0 +1,756 @@
package com.sbi.graphics
{
import flash.display.BitmapData;
import flash.events.EventDispatcher;
import flash.events.ProgressEvent;
import flash.utils.ByteArray;
import flash.utils.setTimeout;
public class JpegAsynchEncoder extends EventDispatcher
{
public static const CONTENT_TYPE:String = "image/jpeg";
private var ZigZag:Array = [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];
private var std_dc_luminance_nrcodes:Array = [0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0];
private var std_dc_luminance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11];
private var std_ac_luminance_nrcodes:Array = [0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125];
private var std_ac_luminance_values:Array = [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];
private var std_dc_chrominance_nrcodes:Array = [0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0];
private var std_dc_chrominance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11];
private var std_ac_chrominance_nrcodes:Array = [0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119];
private var std_ac_chrominance_values:Array = [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];
private var YTable:Array = new Array(64);
private var UVTable:Array = new Array(64);
private var fdtbl_Y:Array = new Array(64);
private var fdtbl_UV:Array = new Array(64);
private var YDC_HT:Array;
private var UVDC_HT:Array;
private var YAC_HT:Array;
private var UVAC_HT:Array;
private var YDU:Array = new Array(64);
private var UDU:Array = new Array(64);
private var VDU:Array = new Array(64);
private var DU:Array = new Array(64);
private var bitcode:Array = new Array(65535);
private var category:Array = new Array(65535);
private var byteout:ByteArray;
private var bytenew:int = 0;
private var bytepos:int = 7;
private var DCY:Number = 0;
private var DCU:Number = 0;
private var DCV:Number = 0;
private var SrcWidth:int = 0;
private var SrcHeight:int = 0;
private var Source:Object = null;
private var TotalSize:int = 0;
private var PixelsPerIter:int = 128;
private var PercentageInc:int = 0;
private var NextProgressAt:int = 0;
private var CurrentTotalPos:int = 0;
private var Working:Boolean = false;
public function JpegAsynchEncoder()
{
super();
}
public function JPEGAsyncEncoder(param1:Number = 50) : void
{
if(param1 <= 0)
{
param1 = 1;
}
if(param1 > 100)
{
param1 = 100;
}
var _loc2_:int = 0;
if(param1 < 50)
{
_loc2_ = int(5000 / param1);
}
else
{
_loc2_ = int(200 - param1 * 2);
}
this.initHuffmanTbl();
this.initCategoryNumber();
this.initQuantTables(_loc2_);
}
public function get contentType() : String
{
return CONTENT_TYPE;
}
public function get PixelsPerIteration() : int
{
return this.PixelsPerIter;
}
public function set PixelsPerIteration(param1:int) : void
{
this.PixelsPerIter = param1;
}
public function get ImageData() : ByteArray
{
return this.byteout;
}
public function encodeByteArray(param1:ByteArray, param2:int, param3:int) : Boolean
{
return this.internalEncode(param1,param2,param3);
}
public function encode(param1:BitmapData) : Boolean
{
return this.internalEncode(param1,param1.width,param1.height);
}
private function internalEncode(param1:Object, param2:int, param3:int) : Boolean
{
if(this.Working)
{
return false;
}
this.Working = true;
this.Source = param1;
this.SrcWidth = param2;
this.SrcHeight = param3;
this.TotalSize = param2 * param3;
this.PercentageInc = this.TotalSize / 100;
this.NextProgressAt = this.PercentageInc;
this.CurrentTotalPos = 0;
setTimeout(this.StartEncode,10);
return true;
}
private function StartEncode() : void
{
this.byteout = new ByteArray();
this.bytenew = 0;
this.bytepos = 7;
this.writeWord(65496);
this.writeAPP0();
this.writeDQT();
this.writeSOF0(this.SrcWidth,this.SrcHeight);
this.writeDHT();
this.writeSOS();
this.DCY = 0;
this.DCV = 0;
this.DCU = 0;
this.bytenew = 0;
this.bytepos = 7;
this.dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS,false,false,0,this.TotalSize));
setTimeout(this.AsyncLoop,10,0,0);
}
private function AsyncLoop(param1:int, param2:int) : void
{
var _loc3_:int = 0;
while(_loc3_ < this.PixelsPerIter)
{
this.RGB2YUV(this.Source,param1,param2,this.SrcWidth,this.SrcHeight);
this.DCY = this.processDU(this.YDU,this.fdtbl_Y,this.DCY,this.YDC_HT,this.YAC_HT);
this.DCU = this.processDU(this.UDU,this.fdtbl_UV,this.DCU,this.UVDC_HT,this.UVAC_HT);
this.DCV = this.processDU(this.VDU,this.fdtbl_UV,this.DCV,this.UVDC_HT,this.UVAC_HT);
param1 += 8;
if(param1 >= this.SrcWidth)
{
param1 = 0;
param2 += 8;
}
if(param2 >= this.SrcHeight)
{
setTimeout(this.FinishEncode,10);
return;
}
this.CurrentTotalPos += 64;
if(this.CurrentTotalPos >= this.NextProgressAt)
{
this.dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS,false,false,this.CurrentTotalPos,this.TotalSize));
this.NextProgressAt += this.PercentageInc;
}
_loc3_++;
}
setTimeout(this.AsyncLoop,10,param1,param2);
}
private function FinishEncode() : void
{
var _loc1_:BitString = null;
if(this.bytepos >= 0)
{
_loc1_ = new BitString();
_loc1_.len = this.bytepos + 1;
_loc1_.val = (1 << this.bytepos + 1) - 1;
this.writeBits(_loc1_);
}
this.writeWord(65497);
this.dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS,false,false,this.TotalSize,this.TotalSize));
this.dispatchEvent(new JPEGAsyncCompleteEvent(this.byteout));
this.Working = false;
}
private function initQuantTables(param1:int) : void
{
var _loc3_:Number = NaN;
var _loc8_:int = 0;
var _loc2_:int = 0;
var _loc4_:Array = [16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99];
_loc2_ = 0;
while(_loc2_ < 64)
{
_loc3_ = Math.floor((_loc4_[_loc2_] * param1 + 50) / 100);
if(_loc3_ < 1)
{
_loc3_ = 1;
}
else if(_loc3_ > 255)
{
_loc3_ = 255;
}
this.YTable[this.ZigZag[_loc2_]] = _loc3_;
_loc2_++;
}
var _loc5_:Array = [17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99];
_loc2_ = 0;
while(_loc2_ < 64)
{
_loc3_ = Math.floor((_loc5_[_loc2_] * param1 + 50) / 100);
if(_loc3_ < 1)
{
_loc3_ = 1;
}
else if(_loc3_ > 255)
{
_loc3_ = 255;
}
this.UVTable[this.ZigZag[_loc2_]] = _loc3_;
_loc2_++;
}
var _loc6_:Array = [1,1.387039845,1.306562965,1.175875602,1,0.785694958,0.5411961,0.275899379];
_loc2_ = 0;
var _loc7_:int = 0;
while(_loc7_ < 8)
{
_loc8_ = 0;
while(_loc8_ < 8)
{
this.fdtbl_Y[_loc2_] = 1 / (this.YTable[this.ZigZag[_loc2_]] * _loc6_[_loc7_] * _loc6_[_loc8_] * 8);
this.fdtbl_UV[_loc2_] = 1 / (this.UVTable[this.ZigZag[_loc2_]] * _loc6_[_loc7_] * _loc6_[_loc8_] * 8);
_loc2_++;
_loc8_++;
}
_loc7_++;
}
}
private function computeHuffmanTbl(param1:Array, param2:Array) : Array
{
var _loc7_:int = 0;
var _loc3_:int = 0;
var _loc4_:int = 0;
var _loc5_:Array = new Array();
var _loc6_:int = 1;
while(_loc6_ <= 16)
{
_loc7_ = 1;
while(_loc7_ <= param1[_loc6_])
{
_loc5_[param2[_loc4_]] = new BitString();
_loc5_[param2[_loc4_]].val = _loc3_;
_loc5_[param2[_loc4_]].len = _loc6_;
_loc4_++;
_loc3_++;
_loc7_++;
}
_loc3_ *= 2;
_loc6_++;
}
return _loc5_;
}
private 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);
}
private function initCategoryNumber() : void
{
var _loc1_:int = 0;
var _loc2_:int = 1;
var _loc3_:int = 2;
var _loc4_:int = 1;
while(_loc4_ <= 15)
{
_loc1_ = _loc2_;
while(_loc1_ < _loc3_)
{
this.category[32767 + _loc1_] = _loc4_;
this.bitcode[32767 + _loc1_] = new BitString();
this.bitcode[32767 + _loc1_].len = _loc4_;
this.bitcode[32767 + _loc1_].val = _loc1_;
_loc1_++;
}
_loc1_ = -(_loc3_ - 1);
while(_loc1_ <= -_loc2_)
{
this.category[32767 + _loc1_] = _loc4_;
this.bitcode[32767 + _loc1_] = new BitString();
this.bitcode[32767 + _loc1_].len = _loc4_;
this.bitcode[32767 + _loc1_].val = _loc3_ - 1 + _loc1_;
_loc1_++;
}
_loc2_ <<= 1;
_loc3_ <<= 1;
_loc4_++;
}
}
private function writeBits(param1:BitString) : void
{
var _loc2_:int = param1.val;
var _loc3_:* = int(param1.len - 1);
while(_loc3_ >= 0)
{
if(_loc2_ & uint(1 << _loc3_))
{
this.bytenew |= uint(1 << this.bytepos);
}
_loc3_--;
--this.bytepos;
if(this.bytepos < 0)
{
if(this.bytenew == 255)
{
this.writeByte(255);
this.writeByte(0);
}
else
{
this.writeByte(this.bytenew);
}
this.bytepos = 7;
this.bytenew = 0;
}
}
}
private function writeByte(param1:int) : void
{
this.byteout.writeByte(param1);
}
private function writeWord(param1:int) : void
{
this.writeByte(param1 >> 8 & 0xFF);
this.writeByte(param1 & 0xFF);
}
private function fDCTQuant(param1:Array, param2:Array) : Array
{
var _loc4_:int = 0;
var _loc5_:Number = NaN;
var _loc6_:Number = NaN;
var _loc7_:Number = NaN;
var _loc8_:Number = NaN;
var _loc9_:Number = NaN;
var _loc10_:Number = NaN;
var _loc11_:Number = NaN;
var _loc12_:Number = NaN;
var _loc13_:Number = NaN;
var _loc14_:Number = NaN;
var _loc15_:Number = NaN;
var _loc16_:Number = NaN;
var _loc17_:Number = NaN;
var _loc18_:Number = NaN;
var _loc19_:Number = NaN;
var _loc20_:Number = NaN;
var _loc21_:Number = NaN;
var _loc22_:Number = NaN;
var _loc23_:Number = NaN;
var _loc3_:int = 0;
_loc4_ = 0;
while(_loc4_ < 8)
{
_loc5_ = param1[_loc3_ + 0] + param1[_loc3_ + 7];
_loc6_ = param1[_loc3_ + 0] - param1[_loc3_ + 7];
_loc7_ = param1[_loc3_ + 1] + param1[_loc3_ + 6];
_loc8_ = param1[_loc3_ + 1] - param1[_loc3_ + 6];
_loc9_ = param1[_loc3_ + 2] + param1[_loc3_ + 5];
_loc10_ = param1[_loc3_ + 2] - param1[_loc3_ + 5];
_loc11_ = param1[_loc3_ + 3] + param1[_loc3_ + 4];
_loc12_ = param1[_loc3_ + 3] - param1[_loc3_ + 4];
_loc13_ = _loc5_ + _loc11_;
_loc14_ = _loc5_ - _loc11_;
_loc15_ = _loc7_ + _loc9_;
_loc16_ = _loc7_ - _loc9_;
param1[_loc3_ + 0] = _loc13_ + _loc15_;
param1[_loc3_ + 4] = _loc13_ - _loc15_;
_loc17_ = (_loc16_ + _loc14_) * 0.707106781;
param1[_loc3_ + 2] = _loc14_ + _loc17_;
param1[_loc3_ + 6] = _loc14_ - _loc17_;
_loc13_ = _loc12_ + _loc10_;
_loc15_ = _loc10_ + _loc8_;
_loc16_ = _loc8_ + _loc6_;
_loc18_ = (_loc13_ - _loc16_) * 0.382683433;
_loc19_ = 0.5411961 * _loc13_ + _loc18_;
_loc20_ = 1.306562965 * _loc16_ + _loc18_;
_loc21_ = _loc15_ * 0.707106781;
_loc22_ = _loc6_ + _loc21_;
_loc23_ = _loc6_ - _loc21_;
param1[_loc3_ + 5] = _loc23_ + _loc19_;
param1[_loc3_ + 3] = _loc23_ - _loc19_;
param1[_loc3_ + 1] = _loc22_ + _loc20_;
param1[_loc3_ + 7] = _loc22_ - _loc20_;
_loc3_ += 8;
_loc4_++;
}
_loc3_ = 0;
_loc4_ = 0;
while(_loc4_ < 8)
{
_loc5_ = param1[_loc3_ + 0] + param1[_loc3_ + 56];
_loc6_ = param1[_loc3_ + 0] - param1[_loc3_ + 56];
_loc7_ = param1[_loc3_ + 8] + param1[_loc3_ + 48];
_loc8_ = param1[_loc3_ + 8] - param1[_loc3_ + 48];
_loc9_ = param1[_loc3_ + 16] + param1[_loc3_ + 40];
_loc10_ = param1[_loc3_ + 16] - param1[_loc3_ + 40];
_loc11_ = param1[_loc3_ + 24] + param1[_loc3_ + 32];
_loc12_ = param1[_loc3_ + 24] - param1[_loc3_ + 32];
_loc13_ = _loc5_ + _loc11_;
_loc14_ = _loc5_ - _loc11_;
_loc15_ = _loc7_ + _loc9_;
_loc16_ = _loc7_ - _loc9_;
param1[_loc3_ + 0] = _loc13_ + _loc15_;
param1[_loc3_ + 32] = _loc13_ - _loc15_;
_loc17_ = (_loc16_ + _loc14_) * 0.707106781;
param1[_loc3_ + 16] = _loc14_ + _loc17_;
param1[_loc3_ + 48] = _loc14_ - _loc17_;
_loc13_ = _loc12_ + _loc10_;
_loc15_ = _loc10_ + _loc8_;
_loc16_ = _loc8_ + _loc6_;
_loc18_ = (_loc13_ - _loc16_) * 0.382683433;
_loc19_ = 0.5411961 * _loc13_ + _loc18_;
_loc20_ = 1.306562965 * _loc16_ + _loc18_;
_loc21_ = _loc15_ * 0.707106781;
_loc22_ = _loc6_ + _loc21_;
_loc23_ = _loc6_ - _loc21_;
param1[_loc3_ + 40] = _loc23_ + _loc19_;
param1[_loc3_ + 24] = _loc23_ - _loc19_;
param1[_loc3_ + 8] = _loc22_ + _loc20_;
param1[_loc3_ + 56] = _loc22_ - _loc20_;
_loc3_++;
_loc4_++;
}
_loc4_ = 0;
while(_loc4_ < 64)
{
param1[_loc4_] = Math.round(param1[_loc4_] * param2[_loc4_]);
_loc4_++;
}
return param1;
}
private 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);
}
private function writeSOF0(param1:int, param2:int) : void
{
this.writeWord(65472);
this.writeWord(17);
this.writeByte(8);
this.writeWord(param2);
this.writeWord(param1);
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);
}
private function writeDQT() : void
{
var _loc1_:int = 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_++;
}
}
private function writeDHT() : void
{
var _loc1_:int = 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_++;
}
}
private 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);
}
private function processDU(param1:Array, param2:Array, param3:Number, param4:Array, param5:Array) : Number
{
var _loc8_:int = 0;
var _loc12_:int = 0;
var _loc13_:int = 0;
var _loc14_:int = 0;
var _loc6_:BitString = param5[0];
var _loc7_:BitString = param5[240];
var _loc9_:Array = this.fDCTQuant(param1,param2);
_loc8_ = 0;
while(_loc8_ < 64)
{
this.DU[this.ZigZag[_loc8_]] = _loc9_[_loc8_];
_loc8_++;
}
var _loc10_:int = this.DU[0] - param3;
param3 = Number(this.DU[0]);
if(_loc10_ == 0)
{
this.writeBits(param4[0]);
}
else
{
this.writeBits(param4[this.category[32767 + _loc10_]]);
this.writeBits(this.bitcode[32767 + _loc10_]);
}
var _loc11_:* = 63;
while(_loc11_ > 0 && this.DU[_loc11_] == 0)
{
_loc11_--;
}
if(_loc11_ == 0)
{
this.writeBits(_loc6_);
return param3;
}
_loc8_ = 1;
while(_loc8_ <= _loc11_)
{
_loc12_ = _loc8_;
while(this.DU[_loc8_] == 0 && _loc8_ <= _loc11_)
{
_loc8_++;
}
_loc13_ = _loc8_ - _loc12_;
if(_loc13_ >= 16)
{
_loc14_ = 1;
while(_loc14_ <= _loc13_ / 16)
{
this.writeBits(_loc7_);
_loc14_++;
}
_loc13_ = int(_loc13_ & 0x0F);
}
this.writeBits(param5[_loc13_ * 16 + this.category[32767 + this.DU[_loc8_]]]);
this.writeBits(this.bitcode[32767 + this.DU[_loc8_]]);
_loc8_++;
}
if(_loc11_ != 63)
{
this.writeBits(_loc6_);
}
return param3;
}
private function RGB2YUV(param1:Object, param2:int, param3:int, param4:int = 0, param5:int = 0) : void
{
var _loc8_:int = 0;
var _loc9_:uint = 0;
var _loc10_:Number = NaN;
var _loc11_:Number = NaN;
var _loc12_:Number = NaN;
var _loc6_:int = 0;
var _loc7_:int = 0;
while(_loc7_ < 8)
{
_loc8_ = 0;
while(_loc8_ < 8)
{
_loc9_ = this.getPixel32(param1,param2 + _loc8_,param3 + _loc7_,param4,param5);
_loc10_ = Number(_loc9_ >> 16 & 0xFF);
_loc11_ = Number(_loc9_ >> 8 & 0xFF);
_loc12_ = Number(_loc9_ & 0xFF);
this.YDU[_loc6_] = 0.299 * _loc10_ + 0.587 * _loc11_ + 0.114 * _loc12_ - 128;
this.UDU[_loc6_] = -0.16874 * _loc10_ + -0.33126 * _loc11_ + 0.5 * _loc12_;
this.VDU[_loc6_] = 0.5 * _loc10_ + -0.41869 * _loc11_ + -0.08131 * _loc12_;
_loc6_++;
_loc8_++;
}
_loc7_++;
}
}
private function getPixel32(param1:Object, param2:int, param3:int, param4:int = 0, param5:int = 0) : uint
{
var _loc6_:BitmapData = null;
var _loc7_:ByteArray = null;
if(param1 is BitmapData)
{
_loc6_ = param1 as BitmapData;
return _loc6_.getPixel32(param2,param3);
}
if(param1 is ByteArray)
{
_loc7_ = param1 as ByteArray;
_loc7_.position = param3 * param4 * 4 + param2 * 4;
return _loc7_.readUnsignedInt();
}
throw new ArgumentError("The source argument must be an instance of flash.display.BitmapData or flash.utils.ByteArray.");
}
}
}
class BitString
{
public var len:int = 0;
public var val:int = 0;
public function BitString()
{
super();
}
}
@@ -0,0 +1,705 @@
package com.sbi.graphics
{
import com.sbi.loader.ImageServerEvent;
import com.sbi.loader.ImageServerURL;
import flash.display.DisplayObjectContainer;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
public class LayerAnim
{
private static var _activePool:Array;
private static var _freePool:Array;
private static var _avOffsets:Array;
private static var _lastEntry:int;
private static var _useMaxThrottle:Function;
public static const PLAY_LOOP:int = 0;
public static const PLAY_ONE_SHOT:int = 1;
public static const PLAY_LOOP__KEEP_CURRENT_FRAME:int = 2;
public static const AN_SIT_NNE:int = 1;
public static const AN_SIT_NE:int = 2;
public static const AN_SIT_E:int = 3;
public static const AN_SIT_SE:int = 4;
public static const AN_SIT_SSE:int = 5;
public static const AN_MOVE_NNE:int = 7;
public static const AN_MOVE_NE:int = 8;
public static const AN_MOVE_E:int = 9;
public static const AN_MOVE_SE:int = 10;
public static const AN_MOVE_SSE:int = 11;
public static const AN_BBCARD:int = 13;
public static const AN_IDLE_SE:int = 14;
public static const AN_HUD_AVT:int = 15;
public static const AN_IDLE_NE:int = 16;
public static const AN_HOP:int = 17;
public static const AN_SLEEP:int = 22;
public static const AN_DANCE:int = 23;
public static const AN_PLAY:int = 6;
public static const AN_SWIM_N:int = 36;
public static const AN_SWIM_NE:int = 34;
public static const AN_SWIM_E:int = 29;
public static const AN_SWIM_SE:int = 35;
public static const AN_SWIM_S:int = 37;
public static const AN_FLOAT:int = 32;
public static const AN_WATER_DIVE:int = 41;
public static const AN_WATER_PLAY:int = 39;
public static const AN_WATER_SPIN:int = 33;
public static const AN_WATER_JIG:int = 38;
public static const AN_WATER_POSE:int = 40;
public static const AN_PHOTO:int = 42;
public static const AN_PARACHUTE_IDLE:int = 19;
public static const AN_PARACHUTE_JUMP:int = 24;
public static const AN_PARACHUTE_DISTRESS:int = 20;
public static const AN_PARACHUTE_LAND:int = 21;
public static const AN_WINDRIDER_JUMP:int = 28;
public static const AN_WINDRIDER_IDLE:int = 29;
public static const AN_WINDRIDER_FALL:int = 30;
public static const AN_WINDRIDER_START:int = 31;
public static const AN_WINDRIDER_DISTRESS:int = 20;
public static const AVATAR_BITMAP_OFFSET_X:int = 375;
public static const AVATAR_BITMAP_OFFSET_Y:int = 365;
private static var _throttle:int = 8;
private var _bitmap:LayerBitmap;
private var _avDefId:int;
private var _animId:int;
private var _frame:int;
private var _hFlip:Boolean;
private var _totalFrames:int;
private var _x:int;
private var _y:int;
private var _rotation:int;
private var _xOff:int;
private var _yOff:int;
private var _bPause:Boolean;
private var _layers:Array;
private var _colors:Array;
private var _callback:Function;
private var _mode:int;
private var _tStep:int;
private var _bRedraw:Boolean;
private var _bReload:Boolean;
private var _bBaseLayer:Boolean;
private var _bNewAnim:Boolean;
private var _requestAnimId:int;
private var _receivedData:Array;
private var _requestedIds:Array;
private var _requestCallback:Function;
private var _requestMode:int;
private var _preloadRequestedIds:Array;
private var _preloadCallback:Function;
public function LayerAnim(param1:Class)
{
super();
if(param1 != SingletonLock)
{
throw new Error("Invalid access. Use LayerAnim.getNew");
}
this._requestedIds = new Array();
this._colors = new Array();
}
public static function set avOffsets(param1:Array) : void
{
_avOffsets = param1;
}
public static function getAvOffset(param1:int) : Point
{
if(_avOffsets[param1])
{
return _avOffsets[param1];
}
return new Point(-100,-100);
}
public static function set throttle(param1:int) : void
{
_throttle = param1;
}
public static function getNew() : LayerAnim
{
var _loc1_:LayerAnim = null;
if(!_activePool)
{
_activePool = new Array();
_freePool = new Array();
}
if(_freePool.length)
{
_loc1_ = _freePool.pop();
}
else
{
_loc1_ = new LayerAnim(SingletonLock);
}
_activePool.push(_loc1_);
_loc1_.init();
return _loc1_;
}
public static function destroy(param1:LayerAnim) : void
{
var _loc2_:int = _activePool.indexOf(param1);
if(_loc2_ >= 0)
{
_activePool.splice(_loc2_,1);
param1.destroy();
_freePool.push(param1);
}
}
public static function heartbeat() : void
{
var _loc1_:int = 0;
var _loc2_:* = 0;
var _loc3_:* = 0;
var _loc4_:* = 0;
var _loc5_:LayerAnim = null;
var _loc6_:int = 0;
if(Boolean(_activePool) && Boolean(_activePool.length))
{
_loc1_ = int(_activePool.length);
_loc2_ = _loc1_;
_loc3_ = int(_loc1_ * 0.5);
if(_loc3_ < 1 || Boolean(_useMaxThrottle) && Boolean(_useMaxThrottle()))
{
_loc3_ = 1;
}
if(_loc3_ > _throttle)
{
_loc3_ = _throttle;
}
_loc4_ = _lastEntry;
for each(_loc5_ in _activePool)
{
++_loc5_._tStep;
}
while(_loc3_ > 0 && _loc2_ > 0)
{
if(_loc4_ >= _loc1_)
{
_loc4_ = 0;
}
_loc5_ = _activePool[_loc4_++];
_loc6_ = _loc5_._tStep;
if(_loc6_ >= 2)
{
if((_loc5_._requestMode == PLAY_ONE_SHOT || isOnscreen(_loc5_)) && _loc5_.heartbeat())
{
_loc5_._tStep = 0;
_loc3_--;
}
}
_loc2_--;
}
_lastEntry = _loc4_;
}
}
private static function isOnscreen(param1:LayerAnim) : Boolean
{
var _loc3_:int = 0;
var _loc4_:int = 0;
var _loc5_:int = 0;
var _loc6_:int = 0;
var _loc7_:Rectangle = null;
var _loc2_:DisplayObjectContainer = param1.bitmap.parent;
if(_loc2_)
{
_loc3_ = 0;
_loc4_ = 900;
_loc5_ = 0;
_loc6_ = 550;
_loc7_ = _loc2_.getBounds(gMainFrame.stage);
return _loc7_.height == 0 || !(_loc6_ < _loc7_.top || _loc5_ > _loc7_.bottom || _loc4_ < _loc7_.left || _loc3_ > _loc7_.right);
}
return true;
}
public static function set useMaxThrottle(param1:Function) : void
{
_useMaxThrottle = param1;
}
private function init() : void
{
this._bitmap = new LayerBitmap();
this._layers = null;
this._requestAnimId = -1;
this._avDefId = -1;
this._animId = -1;
this._bNewAnim = false;
this._totalFrames = 0;
this._bReload = true;
this._tStep = 1;
}
private function destroy() : void
{
this._bitmap = null;
this._layers = null;
if(this._requestedIds.length != 0)
{
ImageServerURL.instance.removeEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
this._requestedIds.splice(0,this._requestedIds.length);
}
}
public function set avDefId(param1:int) : void
{
if(param1 != this._avDefId)
{
this._avDefId = param1;
this._xOff = -getAvOffset(this._avDefId).x - AVATAR_BITMAP_OFFSET_X;
this._yOff = -getAvOffset(this._avDefId).y - AVATAR_BITMAP_OFFSET_Y;
this._bReload = true;
}
}
public function get layers() : Array
{
return this._layers;
}
public function get avDefId() : int
{
return this._avDefId;
}
public function get animId() : int
{
return this._animId;
}
public function get hFlip() : Boolean
{
return this._hFlip;
}
public function get frame() : int
{
return this._frame;
}
public function set frame(param1:int) : void
{
this._frame = param1;
}
public function set layers(param1:Array) : void
{
var _loc2_:int = 0;
var _loc5_:Object = null;
var _loc6_:int = 0;
var _loc3_:Boolean = true;
var _loc4_:Boolean = false;
if(Boolean(this._layers) && this._layers.length == param1.length)
{
_loc3_ = false;
_loc2_ = 0;
while(_loc2_ < param1.length)
{
if(this._layers[_loc2_].l != param1[_loc2_].l)
{
_loc3_ = true;
break;
}
if(this._layers[_loc2_].c != param1[_loc2_].c)
{
_loc4_ = true;
}
_loc2_++;
}
if(!_loc3_ && !_loc4_)
{
return;
}
}
if(param1.length > 0)
{
this._layers = param1;
if(_loc3_)
{
this._bReload = true;
}
else if(_loc4_)
{
for each(_loc5_ in param1)
{
_loc6_ = ImageServerURL.instance.getLayerIndex(_loc5_.l);
this._bitmap.setLayerColor(_loc6_,_loc5_.c);
}
this._bRedraw = true;
}
}
}
public function get x() : int
{
return this._x;
}
public function get y() : int
{
return this._y;
}
public function set x(param1:int) : void
{
this._x = param1;
}
public function set y(param1:int) : void
{
this._y = param1;
}
public function set alpha(param1:Number) : void
{
this._bitmap.alpha = param1;
}
public function set rotation(param1:Number) : void
{
this._rotation = param1;
}
public function set hFlip(param1:Boolean) : void
{
if(param1 != this._hFlip)
{
this._hFlip = param1;
this._bRedraw = true;
}
}
public function set visible(param1:Boolean) : void
{
this._bitmap.visible = param1;
}
public function get visible() : Boolean
{
return this._bitmap.visible;
}
public function set pause(param1:Boolean) : void
{
this._bPause = param1;
}
public function get bitmap() : LayerBitmap
{
return this._bitmap;
}
public function playAnim(param1:int, param2:int = 0, param3:Function = null) : void
{
if(this._requestAnimId == -1 && param1 != this._animId || this._requestAnimId != param1)
{
this._requestCallback = param3;
this._requestMode = param2;
this._requestAnimId = param1;
this._bReload = true;
}
}
public function preload(param1:Array, param2:Function) : void
{
var _loc3_:int = 0;
this._preloadCallback = param2;
this._preloadRequestedIds = [];
while(_loc3_ < param1.length)
{
this.buildRequestArray(param1[_loc3_],this._preloadRequestedIds,null);
_loc3_++;
}
ImageServerURL.instance.addEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
ImageServerURL.instance.requestImages(this._preloadRequestedIds.slice());
}
private function heartbeat() : Boolean
{
var _loc1_:Boolean = false;
if(this._bReload)
{
this.loadAnim();
}
if(this._totalFrames == 0)
{
return false;
}
if(this._frame >= this._totalFrames)
{
if(this._mode == PLAY_ONE_SHOT)
{
this._frame = this._totalFrames > 0 ? int(this._totalFrames - 1) : 0;
}
else
{
this._frame = 0;
}
if(this._callback != null)
{
this._callback(this,this._animId);
if(this._mode == PLAY_ONE_SHOT)
{
this._callback = null;
}
}
}
if(this._bRedraw)
{
this._bitmap.invalidate();
this._bRedraw = false;
}
_loc1_ = this._bitmap.paint(this._frame,this._hFlip);
this.updateBitmapPos();
if(!this._bPause)
{
++this._frame;
}
return _loc1_;
}
private function loadAnim() : void
{
var _loc1_:int = 0;
if(this._layers != null && this._layers.length > 0)
{
_loc1_ = this._requestAnimId != -1 ? this._requestAnimId : this._animId;
if(_loc1_ >= 0)
{
this._requestAnimId = _loc1_;
this.requestAnim(_loc1_);
}
}
}
public function updateBitmapPos() : void
{
var _loc4_:Matrix = null;
var _loc1_:Point = this._bitmap.anchorPoint;
var _loc2_:int = this._x + _loc1_.x + this._xOff;
var _loc3_:int = this._y + _loc1_.y + this._yOff;
if(this._rotation)
{
_loc4_ = this._bitmap.transform.matrix;
_loc4_.identity();
_loc4_.translate(_loc1_.x + this._xOff,_loc1_.y + this._yOff);
_loc4_.rotate(this._rotation * (Math.PI / 180));
_loc4_.translate(_loc2_,_loc3_);
this._bitmap.transform.matrix = _loc4_;
}
else
{
if(this._bitmap.rotation != this._rotation)
{
this._bitmap.rotation = this._rotation;
}
this._bitmap.x = _loc2_;
this._bitmap.y = _loc3_;
}
}
private function requestAnim(param1:int) : void
{
this._bNewAnim = false;
this._requestedIds.splice(0,this._requestedIds.length);
this._colors = [];
this._receivedData = [];
this.buildRequestArray(param1,this._requestedIds,this._colors);
ImageServerURL.instance.addEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
ImageServerURL.instance.requestImages(this._requestedIds.slice());
this._bReload = false;
this._bBaseLayer = false;
}
private function buildRequestArray(param1:int, param2:Array, param3:Array) : void
{
var _loc4_:Object = null;
var _loc5_:uint = 0;
param2.push(ImageArrayHelper.packId(this._avDefId,param1,0));
for each(_loc4_ in this._layers)
{
_loc5_ = ImageArrayHelper.packId(this._avDefId,param1,_loc4_.l);
param2.push(_loc5_);
if(param3)
{
param3[_loc5_] = _loc4_.c;
}
}
}
private function onReceiveData(param1:ImageServerEvent) : void
{
var _loc2_:int = 0;
var _loc4_:uint = 0;
var _loc5_:Object = null;
var _loc3_:int = param1.layer;
if(Boolean(this._preloadRequestedIds) && Boolean(this._preloadRequestedIds.length))
{
_loc2_ = this._preloadRequestedIds.indexOf(param1.id);
if(_loc2_ >= 0)
{
this._preloadRequestedIds.splice(_loc2_,1);
if(this._preloadRequestedIds.length == 0)
{
this._preloadRequestedIds = null;
if(this._requestedIds.length == 0)
{
ImageServerURL.instance.removeEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
}
if(this._preloadCallback != null)
{
this._preloadCallback(this);
}
}
return;
}
}
_loc2_ = this._requestedIds.indexOf(param1.id);
if(_loc2_ >= 0)
{
this._requestedIds.splice(_loc2_,1);
if(_loc3_ > 0)
{
_loc4_ = uint(this._colors[param1.id]);
}
if(param1.success)
{
this._receivedData.push({
"l":_loc3_,
"d":param1.imageData,
"c":_loc4_
});
}
if(this._requestedIds.length == 0)
{
this._bNewAnim = true;
if(this._preloadRequestedIds == null)
{
ImageServerURL.instance.removeEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
}
}
if(_loc3_ == 1 || this._bNewAnim)
{
this._bBaseLayer = true;
if(this._mode == LayerAnim.PLAY_LOOP__KEEP_CURRENT_FRAME)
{
this._mode == LayerAnim.PLAY_LOOP;
}
else
{
this._frame = 0;
}
if(this._requestAnimId >= 0)
{
this._animId = this._requestAnimId;
}
this._callback = this._requestCallback;
this._mode = this._requestMode;
this._requestAnimId = -1;
this._bitmap.release();
}
if(this._bBaseLayer)
{
for each(_loc5_ in this._receivedData)
{
this._bitmap.setLayer(_loc5_.l,_loc5_.d,_loc5_.c);
}
this._totalFrames = this._bitmap.length;
}
}
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,651 @@
package com.sbi.graphics
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
public class LayerBitmap extends Bitmap
{
private const _backgroundColor:uint = 0;
private var _anchorPoint:Point;
private var _layers:Array;
private var _bmin:Point;
private var _bmax:Point;
private var _lastFrame:int;
private var _lastHFlip:Boolean;
private var _blendColor:uint;
private var _bColorChanged:Boolean;
public function LayerBitmap()
{
super();
this._layers = new Array();
this._anchorPoint = new Point();
this._bmin = new Point();
this._bmax = new Point();
}
public function get length() : int
{
var _loc1_:Object = this._layers[0];
if(!_loc1_)
{
_loc1_ = this._layers[1];
}
if(!_loc1_)
{
return 0;
}
return _loc1_.o.f.length;
}
public function release() : void
{
this._layers.splice(0,this._layers.length);
this._lastFrame = -1;
this._bColorChanged = false;
}
public function invalidate() : void
{
this._lastFrame = -1;
}
public function setLayer(param1:int, param2:Object, param3:uint) : void
{
if(param1 < 0 || param1 > 10)
{
return;
}
if(param2)
{
if(this._layers[param1] == null)
{
this._layers[param1] = {
"c":-1,
"lastColor":-1,
"blendColor":0
};
}
this._layers[param1].o = param2;
}
else
{
this._layers[param1] = null;
}
this.setLayerColor(param1,param3);
this._lastFrame = -1;
}
public function setLayerColor(param1:int, param2:uint) : void
{
var _loc3_:Object = this._layers[param1];
if(Boolean(_loc3_) && param2 != _loc3_.c)
{
_loc3_.c = param2;
this._bColorChanged = true;
}
}
public function setBlendColor(param1:uint) : void
{
if(this._blendColor != param1)
{
this._blendColor = param1;
this._bColorChanged = true;
}
}
public function get anchorPoint() : Point
{
return this._anchorPoint;
}
private function refreshLayerPalette(param1:int) : void
{
var _loc3_:uint = 0;
var _loc4_:Array = null;
var _loc5_:int = 0;
var _loc6_:int = 0;
var _loc7_:int = 0;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc2_:Object = this._layers[param1];
if(Boolean(_loc2_) && (_loc2_.lastColor != _loc2_.c || _loc2_.blendColor != this._blendColor))
{
_loc3_ = uint(_loc2_.c);
_loc4_ = PaletteHelper.gamePalette;
_loc5_ = _loc3_ >> 24 & 0xFF;
_loc6_ = _loc3_ >> 16 & 0xFF;
_loc7_ = _loc3_ >> 8 & 0xFF;
_loc8_ = _loc3_ & 0xFF;
if(!_loc2_.pal)
{
_loc2_.pal = [];
}
PaletteHelper.BuildAnimalPalette(_loc2_.pal,_loc4_[_loc5_],_loc4_[_loc6_],_loc4_[_loc7_],_loc4_[_loc8_]);
_loc9_ = this._blendColor >> 24 & 0xFF;
if(param1 != 3)
{
if(_loc9_ > 0)
{
PaletteHelper.adjustPaletteColor(_loc2_.pal,this._blendColor);
}
_loc2_.blendColor = this._blendColor;
}
_loc2_.lastColor = _loc3_;
this._lastFrame = -1;
}
}
private function refreshAllPalettes() : void
{
var _loc1_:int = 1;
while(_loc1_ <= 10)
{
this.refreshLayerPalette(_loc1_);
_loc1_++;
}
this._bColorChanged = false;
}
private function calcBounds(param1:int) : void
{
var _loc3_:Object = null;
var _loc4_:Object = null;
var _loc5_:int = 0;
var _loc6_:Object = null;
var _loc7_:int = 0;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
this._bmin.x = 1000;
this._bmin.y = 1000;
this._bmax.x = 0;
this._bmax.y = 0;
var _loc2_:int = 1;
while(_loc2_ < this._layers.length)
{
_loc3_ = this._layers[_loc2_];
if(_loc3_ != null)
{
_loc4_ = _loc3_.o;
if(_loc4_.v != ImageArray.VERSION)
{
return;
}
_loc5_ = int(_loc4_.f.length);
if(param1 < _loc5_)
{
_loc6_ = _loc4_.f[param1];
if(_loc6_)
{
_loc7_ = int(_loc6_.x);
_loc8_ = int(_loc6_.y);
_loc9_ = int(_loc6_.w);
_loc10_ = int(_loc6_.h);
if(_loc7_ < this._bmin.x)
{
this._bmin.x = _loc7_;
}
if(_loc8_ < this._bmin.y)
{
this._bmin.y = _loc8_;
}
if(_loc7_ + _loc9_ > this._bmax.x)
{
this._bmax.x = _loc7_ + _loc9_;
}
if(_loc8_ + _loc10_ > this._bmax.y)
{
this._bmax.y = _loc8_ + _loc10_;
}
}
}
}
_loc2_++;
}
if(this._bmin.x == 1000 || this._bmin.y == 1000)
{
if(this.bitmapData)
{
this.bitmapData = new BitmapData(1,1,true,this._backgroundColor);
}
return;
}
this.resizeBitmap(1 + this._bmax.x - this._bmin.x,1 + this._bmax.y - this._bmin.y,true);
this._anchorPoint.x = this._bmin.x;
this._anchorPoint.y = this._bmin.y;
}
public function paint(param1:int, param2:Boolean = false, param3:Boolean = true) : Boolean
{
var _loc4_:Object = null;
var _loc5_:Boolean = false;
var _loc6_:int = 0;
if(param3 && this._layers[0] != null)
{
_loc4_ = this._layers[0];
param1 = int(_loc4_.o.f[param1]);
}
if(param1 != this._lastFrame || param2 != this._lastHFlip || this._bColorChanged)
{
if(this._bColorChanged)
{
this.refreshAllPalettes();
}
this._lastFrame = param1;
this._lastHFlip = param2;
this.calcBounds(param1);
_loc6_ = 1;
while(_loc6_ < this._layers.length)
{
_loc4_ = this._layers[_loc6_];
if(_loc4_ != null)
{
this.paintFrame(_loc4_.o,param1,_loc4_.pal,param2);
}
_loc6_++;
}
_loc5_ = true;
if(param2)
{
this._anchorPoint.x = 500 - this._bmax.x;
}
}
return _loc5_;
}
private function paintFrame(param1:Object, param2:int, param3:Array, param4:Boolean) : void
{
var _loc15_:int = 0;
var _loc16_:int = 0;
var _loc17_:uint = 0;
var _loc18_:uint = 0;
var _loc19_:int = 0;
var _loc20_:int = 0;
var _loc21_:int = 0;
var _loc22_:int = 0;
var _loc23_:int = 0;
var _loc24_:int = 0;
var _loc25_:int = 0;
var _loc26_:int = 0;
var _loc28_:int = 0;
var _loc29_:Number = NaN;
var _loc30_:uint = 0;
var _loc31_:int = 0;
if(param2 >= param1.f.length)
{
return;
}
var _loc5_:Object = param1.f[param2];
if(!_loc5_)
{
return;
}
var _loc6_:BitmapData = this.bitmapData;
var _loc7_:ByteArray = _loc5_.b;
var _loc8_:int = int(_loc5_.x);
var _loc9_:int = int(_loc5_.y);
var _loc10_:int = int(_loc5_.w);
var _loc11_:int = int(_loc5_.h);
_loc8_ -= this._bmin.x;
_loc9_ -= this._bmin.y;
_loc10_ += _loc8_;
_loc7_.position = 0;
var _loc12_:int = int(_loc7_.length);
var _loc13_:* = _loc8_;
var _loc14_:int = _loc9_;
this.bitmapData.lock();
var _loc27_:int = _loc10_ - _loc8_;
if(!param4)
{
while(_loc7_.position < _loc12_)
{
_loc15_ = int(_loc7_.readUnsignedByte());
_loc16_ = 1;
if((_loc15_ & 0x80) == 128)
{
_loc15_ &= 127;
_loc16_ = _loc7_.readUnsignedByte() + 1;
}
if(_loc15_ == 0)
{
_loc13_ += _loc16_;
if(_loc13_ >= _loc10_)
{
_loc16_ = _loc13_ - _loc10_;
_loc13_ = int(_loc8_ + _loc16_ % _loc27_);
_loc14_ += _loc16_ / _loc27_ + 1;
}
}
else
{
_loc17_ = uint(param3[_loc15_]);
if(_loc17_ >= 4278190080)
{
if(_loc13_ + _loc16_ < _loc10_)
{
while(--_loc16_ > -1)
{
_loc6_.setPixel32(_loc13_++,_loc14_,_loc17_);
}
}
else
{
while(--_loc16_ > -1)
{
_loc6_.setPixel32(_loc13_++,_loc14_,_loc17_);
if(_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
else
{
while(--_loc16_ > -1)
{
_loc18_ = _loc6_.getPixel32(_loc13_,_loc14_);
if(_loc18_ != this._backgroundColor)
{
_loc19_ = _loc17_ >> 24 & 0xFF;
_loc20_ = _loc17_ >> 16 & 0xFF;
_loc21_ = _loc17_ >> 8 & 0xFF;
_loc22_ = _loc17_ & 0xFF;
_loc23_ = _loc18_ >> 24 & 0xFF;
_loc24_ = _loc18_ >> 16 & 0xFF;
_loc25_ = _loc18_ >> 8 & 0xFF;
_loc26_ = _loc18_ & 0xFF;
if(_loc19_ == 192)
{
_loc20_ = (_loc20_ + _loc20_ + _loc20_ + _loc24_) * 0.25;
_loc21_ = (_loc21_ + _loc21_ + _loc21_ + _loc25_) * 0.25;
_loc22_ = (_loc22_ + _loc22_ + _loc22_ + _loc26_) * 0.25;
}
else if(_loc19_ == 128)
{
_loc20_ = (_loc20_ + _loc24_) * 0.5;
_loc21_ = (_loc21_ + _loc25_) * 0.5;
_loc22_ = (_loc22_ + _loc26_) * 0.5;
}
else
{
_loc20_ = (_loc20_ + _loc24_ + _loc24_ + _loc24_) * 0.25;
_loc21_ = (_loc21_ + _loc25_ + _loc25_ + _loc25_) * 0.25;
_loc22_ = (_loc22_ + _loc26_ + _loc26_ + _loc26_) * 0.25;
}
if(_loc23_ > _loc19_)
{
_loc19_ = _loc23_;
}
_loc17_ = uint(_loc19_ << 24 | _loc20_ << 16 | _loc21_ << 8 | _loc22_);
}
_loc6_.setPixel32(_loc13_++,_loc14_,_loc17_);
if(_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
}
}
else
{
_loc28_ = this._bmax.x - this._bmin.x;
while(_loc7_.position < _loc12_)
{
_loc15_ = int(_loc7_.readUnsignedByte());
_loc16_ = 1;
if((_loc15_ & 0x80) == 128)
{
_loc15_ &= 127;
_loc16_ = _loc7_.readUnsignedByte() + 1;
}
if(_loc15_ == 0)
{
_loc13_ += _loc16_;
if(_loc13_ >= _loc10_)
{
_loc16_ = _loc13_ - _loc10_;
_loc13_ = int(_loc8_ + _loc16_ % _loc27_);
_loc14_ += _loc16_ / _loc27_ + 1;
}
}
else
{
_loc17_ = uint(param3[_loc15_]);
if(_loc17_ >= 4278190080)
{
if(_loc13_ + _loc16_ < _loc10_)
{
while(--_loc16_ > -1)
{
_loc6_.setPixel32(_loc28_ - _loc13_++,_loc14_,_loc17_);
}
}
else
{
while(--_loc16_ > -1)
{
_loc6_.setPixel32(_loc28_ - _loc13_++,_loc14_,_loc17_);
if(_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
else
{
while(--_loc16_ > -1)
{
_loc18_ = _loc6_.getPixel32(_loc28_ - _loc13_,_loc14_);
if(_loc18_ != this._backgroundColor)
{
_loc19_ = _loc17_ >> 24 & 0xFF;
_loc20_ = _loc17_ >> 16 & 0xFF;
_loc21_ = _loc17_ >> 8 & 0xFF;
_loc22_ = _loc17_ & 0xFF;
_loc23_ = _loc18_ >> 24 & 0xFF;
_loc24_ = _loc18_ >> 16 & 0xFF;
_loc25_ = _loc18_ >> 8 & 0xFF;
_loc26_ = _loc18_ & 0xFF;
switch(_loc19_)
{
case 192:
_loc20_ = (_loc20_ + _loc20_ + _loc20_ + _loc24_) * 0.25;
_loc21_ = (_loc21_ + _loc21_ + _loc21_ + _loc25_) * 0.25;
_loc22_ = (_loc22_ + _loc22_ + _loc22_ + _loc26_) * 0.25;
break;
case 128:
_loc20_ = (_loc20_ + _loc24_) * 0.5;
_loc21_ = (_loc21_ + _loc25_) * 0.5;
_loc22_ = (_loc22_ + _loc26_) * 0.5;
break;
case 64:
_loc20_ = (_loc20_ + _loc24_ + _loc24_ + _loc24_) * 0.25;
_loc21_ = (_loc21_ + _loc25_ + _loc25_ + _loc25_) * 0.25;
_loc22_ = (_loc22_ + _loc26_ + _loc26_ + _loc26_) * 0.25;
}
if(_loc23_ > _loc19_)
{
_loc19_ = _loc23_;
}
_loc17_ = uint(_loc19_ << 24 | _loc20_ << 16 | _loc21_ << 8 | _loc22_);
}
_loc6_.setPixel32(_loc28_ - _loc13_++,_loc14_,_loc17_);
if(_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
}
}
if(_loc5_.hasOwnProperty("s"))
{
_loc31_ = int(_loc5_.sm);
_loc7_ = _loc5_.s;
_loc12_ = int(_loc7_.length);
_loc7_.position = 0;
_loc13_ = _loc8_;
_loc14_ = _loc9_;
if(!param4)
{
while(_loc7_.position < _loc12_)
{
_loc15_ = int(_loc7_.readUnsignedByte());
_loc16_ = 1;
if((_loc15_ & 0x80) == 128)
{
_loc15_ &= 127;
_loc16_ = _loc7_.readUnsignedByte() + 1;
}
if(_loc15_ == 0)
{
_loc13_ += _loc16_;
if(_loc13_ >= _loc10_)
{
_loc16_ = _loc13_ - _loc10_;
_loc13_ = int(_loc8_ + _loc16_ % _loc27_);
_loc14_ += _loc16_ / _loc27_ + 1;
}
}
else
{
_loc17_ = uint(_loc15_ << _loc31_);
_loc17_ = _loc17_ + 24;
if(_loc17_ > 255)
{
_loc29_ = 1;
}
else
{
_loc29_ = _loc17_ / 255;
}
while(--_loc16_ > -1)
{
_loc18_ = _loc6_.getPixel32(_loc13_,_loc14_);
if(_loc18_ != this._backgroundColor)
{
_loc19_ = _loc18_ >> 24 & 0xFF;
_loc20_ = (_loc18_ >> 16 & 0xFF) * _loc29_;
_loc21_ = (_loc18_ >> 8 & 0xFF) * _loc29_;
_loc22_ = (_loc18_ & 0xFF) * _loc29_;
_loc30_ = uint(_loc19_ << 24 | _loc20_ << 16 | _loc21_ << 8 | _loc22_);
_loc6_.setPixel32(_loc13_,_loc14_,_loc30_);
}
if(++_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
}
else
{
_loc28_ = this._bmax.x - this._bmin.x;
while(_loc7_.position < _loc12_)
{
_loc15_ = int(_loc7_.readUnsignedByte());
_loc16_ = 1;
if((_loc15_ & 0x80) == 128)
{
_loc15_ &= 127;
_loc16_ = _loc7_.readUnsignedByte() + 1;
}
if(_loc15_ == 0)
{
_loc13_ += _loc16_;
if(_loc13_ >= _loc10_)
{
_loc16_ = _loc13_ - _loc10_;
_loc13_ = int(_loc8_ + _loc16_ % _loc27_);
_loc14_ += _loc16_ / _loc27_ + 1;
}
}
else
{
_loc17_ = uint(_loc15_ << _loc31_);
_loc17_ = _loc17_ + 24;
if(_loc17_ > 255)
{
_loc29_ = 1;
}
else
{
_loc29_ = _loc17_ / 255;
}
while(--_loc16_ > -1)
{
_loc18_ = _loc6_.getPixel32(_loc28_ - _loc13_,_loc14_);
if(_loc18_ != this._backgroundColor)
{
_loc19_ = _loc18_ >> 24 & 0xFF;
_loc20_ = (_loc18_ >> 16 & 0xFF) * _loc29_;
_loc21_ = (_loc18_ >> 8 & 0xFF) * _loc29_;
_loc22_ = (_loc18_ & 0xFF) * _loc29_;
_loc30_ = uint(_loc19_ << 24 | _loc20_ << 16 | _loc21_ << 8 | _loc22_);
_loc6_.setPixel32(_loc28_ - _loc13_,_loc14_,_loc30_);
}
if(++_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
}
}
_loc6_.unlock();
}
private function resizeBitmap(param1:int, param2:int, param3:Boolean) : void
{
var _loc4_:int = param1;
var _loc5_:int = param2;
if(!this.bitmapData)
{
param3 = true;
}
var _loc6_:Rectangle = new Rectangle(0,0,_loc4_,_loc5_);
var _loc7_:ByteArray = null;
if(!param3)
{
_loc7_ = this.bitmapData.getPixels(_loc6_);
}
if(this.bitmapData)
{
this.bitmapData.dispose();
}
this.bitmapData = new BitmapData(param1,param2,true,this._backgroundColor);
if(!param3)
{
this.bitmapData.setPixels(_loc6_,_loc7_);
}
}
}
}
@@ -0,0 +1,246 @@
package com.sbi.graphics
{
import flash.utils.ByteArray;
public class PaletteHelper
{
public static var gamePalette:Array;
public static var avatarPalette1:Array;
public static var avatarPalette2:Array;
private static const PALETTE_ALPHA_OFFSET:int = 25;
public function PaletteHelper()
{
super();
}
public static function setGamePalette(param1:ByteArray, param2:ByteArray = null, param3:ByteArray = null) : void
{
var _loc4_:int = param1.length / 4;
gamePalette = new Array(_loc4_);
var _loc5_:* = 0;
while(_loc5_ < _loc4_)
{
var _loc6_:Number;
gamePalette[_loc6_ = _loc5_++] = param1.readUnsignedInt();
}
if(param2)
{
_loc4_ = int(param2.length);
avatarPalette1 = new Array(_loc4_);
_loc5_ = 0;
while(_loc5_ < _loc4_)
{
avatarPalette1[_loc6_ = _loc5_++] = param2.readUnsignedByte();
}
}
if(param3)
{
param3.position = 0;
_loc4_ = int(param3.length);
avatarPalette2 = new Array(_loc4_);
_loc5_ = 0;
while(_loc5_ < _loc4_)
{
avatarPalette2[_loc6_ = _loc5_++] = param3.readUnsignedByte();
}
}
}
public static function mixColors(param1:uint, param2:uint) : uint
{
var _loc3_:uint = uint(param1 >> 16 & 0xFF);
var _loc4_:uint = uint(param1 >> 8 & 0xFF);
var _loc5_:uint = uint(param1 & 0xFF);
var _loc6_:uint = uint(param2 >> 16 & 0xFF);
var _loc7_:uint = uint(param2 >> 8 & 0xFF);
var _loc8_:uint = uint(param2 & 0xFF);
_loc3_ = (_loc3_ + _loc6_) / 2;
_loc4_ = (_loc4_ + _loc7_) / 2;
_loc5_ = (_loc5_ + _loc8_) / 2;
return _loc3_ << 16 | _loc4_ << 8 | _loc5_;
}
public static function setColorGradient(param1:Array, param2:uint, param3:uint, param4:uint) : void
{
var _loc13_:uint = 0;
var _loc5_:uint = uint(param2 >> 16 & 0xFF);
var _loc6_:uint = uint(param2 >> 8 & 0xFF);
var _loc7_:uint = uint(param2 & 0xFF);
var _loc8_:uint = _loc5_ / (param4 + 2);
var _loc9_:uint = _loc6_ / (param4 + 2);
var _loc10_:uint = _loc7_ / (param4 + 2);
var _loc11_:* = int(param3 + param4 - 1);
var _loc12_:uint = 0;
while(_loc12_ < param4)
{
_loc13_ = uint(_loc5_ << 16 | _loc6_ << 8 | _loc7_);
param1[_loc11_] = _loc13_ | 255 << 24;
param1[_loc11_ + PALETTE_ALPHA_OFFSET] = _loc13_ | 192 << 24;
param1[_loc11_ + PALETTE_ALPHA_OFFSET * 2] = _loc13_ | 128 << 24;
param1[_loc11_ + PALETTE_ALPHA_OFFSET * 3] = _loc13_ | 64 << 24;
_loc5_ -= _loc8_;
_loc6_ -= _loc9_;
_loc7_ -= _loc10_;
_loc11_--;
_loc12_++;
}
}
public static function AddRGB(param1:uint, param2:int, param3:int, param4:int) : uint
{
var _loc5_:int = param1 >> 24 & 0xFF;
var _loc6_:int = param1 >> 16 & 0xFF;
var _loc7_:int = param1 >> 8 & 0xFF;
var _loc8_:int = param1 & 0xFF;
_loc6_ += param2;
if(_loc6_ < 0)
{
_loc6_ = 0;
}
else if(_loc6_ > 255)
{
_loc6_ = 255;
}
_loc7_ += param3;
if(_loc7_ < 0)
{
_loc7_ = 0;
}
else if(_loc7_ > 255)
{
_loc7_ = 255;
}
_loc8_ += param4;
if(_loc8_ < 0)
{
_loc8_ = 0;
}
else if(_loc8_ > 255)
{
_loc8_ = 255;
}
return uint(_loc5_ << 24 | _loc6_ << 16 | _loc7_ << 8 | _loc8_);
}
public static function getAnimalPalette() : Array
{
var _loc4_:int = 0;
var _loc5_:uint = 0;
var _loc6_:uint = 0;
var _loc1_:Array = new Array(uint(4278255615),uint(4286513152),uint(4290707456),uint(4294901760),uint(4278222592),uint(4278238976),uint(4278255360),uint(4278190207),uint(4278190271),uint(4278190335),uint(4286545791),uint(4290756543),uint(4294967295),uint(4282400768),uint(4286611456),uint(4278206528),uint(4278222976),uint(4282384448),uint(4286578816),uint(4286595136),uint(4294934656),uint(4282417216),uint(4286644096),uint(4282400896),uint(4286611711),uint(4278190080));
var _loc2_:uint = uint(192 << 24);
var _loc3_:int = 0;
while(_loc3_ < 3)
{
_loc4_ = 1;
while(_loc4_ <= PALETTE_ALPHA_OFFSET)
{
_loc5_ = uint(_loc1_[_loc4_] & 0xFFFFFF);
_loc6_ = uint(_loc5_ | _loc2_);
_loc1_.push(_loc6_);
_loc4_++;
}
_loc2_ -= 64 << 24;
_loc3_++;
}
return _loc1_;
}
public static function BuildAnimalPalette(param1:Array, param2:uint, param3:uint, param4:uint, param5:uint) : void
{
setColorGradient(param1,param2,1,3);
setColorGradient(param1,param3,4,3);
setColorGradient(param1,param4,7,3);
setColorGradient(param1,param5,10,3);
setColorGradient(param1,PaletteHelper.mixColors(param2,param3),13,2);
setColorGradient(param1,PaletteHelper.mixColors(param3,param4),15,2);
setColorGradient(param1,PaletteHelper.mixColors(param2,param4),17,2);
setColorGradient(param1,PaletteHelper.mixColors(param2,param5),19,2);
setColorGradient(param1,PaletteHelper.mixColors(param3,param5),21,2);
setColorGradient(param1,PaletteHelper.mixColors(param4,param5),23,2);
}
public static function adjustPaletteColor(param1:Array, param2:uint) : void
{
var _loc7_:int = 0;
var _loc8_:uint = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc11_:int = 0;
var _loc12_:int = 0;
var _loc13_:Number = NaN;
var _loc3_:Number = (param2 >> 24 & 0xFF) / 255;
var _loc4_:int = param2 >> 16 & 0xFF;
var _loc5_:int = param2 >> 8 & 0xFF;
var _loc6_:int = param2 & 0xFF;
while(_loc7_ < param1.length)
{
_loc8_ = uint(param1[_loc7_]);
_loc9_ = _loc8_ >> 24 & 0xFF;
_loc10_ = _loc8_ >> 16 & 0xFF;
_loc11_ = _loc8_ >> 8 & 0xFF;
_loc12_ = _loc8_ & 0xFF;
_loc13_ = _loc4_ - _loc10_;
_loc13_ = _loc13_ * _loc3_;
_loc10_ += _loc13_;
if(_loc10_ < 0)
{
_loc10_ = 0;
}
else if(_loc10_ > 255)
{
_loc10_ = 255;
}
_loc13_ = _loc5_ - _loc11_;
_loc13_ = _loc13_ * _loc3_;
_loc11_ += _loc13_;
if(_loc11_ < 0)
{
_loc11_ = 0;
}
else if(_loc11_ > 255)
{
_loc11_ = 255;
}
_loc13_ = _loc6_ - _loc12_;
_loc13_ = _loc13_ * _loc3_;
_loc12_ += _loc13_;
if(_loc12_ < 0)
{
_loc12_ = 0;
}
else if(_loc12_ > 255)
{
_loc12_ = 255;
}
param1[_loc7_] = uint(_loc9_ << 24 | _loc10_ << 16 | _loc11_ << 8 | _loc12_);
_loc7_++;
}
}
public static function getRGBColors(param1:uint) : Array
{
var _loc2_:Array = [];
_loc2_[0] = decToRGBObj(gamePalette[param1 >> 24 & 0xFF]);
_loc2_[1] = decToRGBObj(gamePalette[param1 >> 16 & 0xFF]);
_loc2_[2] = decToRGBObj(gamePalette[param1 >> 8 & 0xFF]);
_loc2_[3] = decToRGBObj(gamePalette[param1 & 0xFF]);
return _loc2_;
}
private static function decToRGBObj(param1:uint) : Object
{
return {
"r":param1 >> 16 & 0xFF,
"g":param1 >> 8 & 0xFF,
"b":param1 & 0xFF
};
}
}
}
@@ -0,0 +1,194 @@
package com.sbi.graphics
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.geom.Rectangle;
import flash.utils.Dictionary;
public class SortLayer extends Sprite
{
private var _bottoms:Dictionary;
private var _nudge:Number = 0;
public function SortLayer()
{
super();
this._bottoms = new Dictionary(true);
}
override public function addChild(param1:DisplayObject) : DisplayObject
{
var _loc2_:int = int(param1.name);
param1.name = (this.getNudge() + _loc2_).toString();
return super.addChild(param1);
}
override public function addChildAt(param1:DisplayObject, param2:int) : DisplayObject
{
var _loc3_:int = int(param1.name);
param1.name = (this.getNudge() + _loc3_).toString();
return super.addChildAt(param1,param2);
}
public function release() : void
{
this._nudge = 0;
this._bottoms = new Dictionary(true);
}
public function depthSort(param1:DisplayObject, param2:DisplayObject) : int
{
return this._bottoms[param1] - this._bottoms[param2];
}
public function heartbeat() : void
{
var _loc1_:int = 0;
var _loc3_:Rectangle = null;
var _loc4_:Boolean = false;
var _loc7_:DisplayObject = null;
var _loc8_:Number = NaN;
var _loc9_:Number = NaN;
var _loc2_:int = this.numChildren;
var _loc5_:Number = -999999999;
if(_loc2_ < 2)
{
return;
}
var _loc6_:Array = [_loc2_];
_loc1_ = 0;
while(_loc1_ < _loc2_)
{
_loc7_ = this.getChildAt(_loc1_);
_loc6_[_loc1_] = _loc7_;
_loc3_ = _loc7_.getBounds(this);
_loc8_ = _loc3_.bottom;
_loc9_ = Number(_loc7_.name);
if(!_loc9_)
{
_loc9_ = this.getNudge();
_loc7_.name = _loc9_.toString();
}
_loc8_ -= _loc9_;
this._bottoms[_loc7_] = _loc8_;
if(!_loc4_)
{
if(_loc8_ < _loc5_)
{
_loc4_ = true;
}
_loc5_ = _loc8_;
}
_loc1_++;
}
if(_loc4_)
{
_loc6_.sort(this.depthSort);
_loc1_ = 0;
while(_loc1_ < _loc2_)
{
this.setChildIndex(_loc6_[_loc1_],_loc1_);
_loc1_++;
}
}
}
private function getNudge() : Number
{
this._nudge += 0.001;
if(this._nudge > 0.9)
{
this._nudge = 0;
}
return this._nudge;
}
private function sort(param1:Vector.<Number>) : void
{
this.quickSort(param1,0,param1.length - 1);
this.InsertionSort(param1,0,param1.length - 1);
}
private function quickSort(param1:Vector.<Number>, param2:int, param3:int) : void
{
var _loc5_:int = 0;
var _loc6_:int = 0;
var _loc7_:Number = NaN;
var _loc4_:int = 4;
if(param3 - param2 > _loc4_)
{
_loc5_ = (param3 + param2) / 2;
if(param1[param2] > param1[_loc5_])
{
this.swap(param1,param2,_loc5_);
}
if(param1[param2] > param1[param3])
{
this.swap(param1,param2,param3);
}
if(param1[_loc5_] > param1[param3])
{
this.swap(param1,_loc5_,param3);
}
_loc6_ = param3 - 1;
this.swap(param1,_loc5_,_loc6_);
_loc5_ = param2;
_loc7_ = param1[_loc6_];
while(true)
{
while(param1[++_loc5_] < _loc7_)
{
}
while(param1[--_loc6_] > _loc7_)
{
}
if(_loc6_ < _loc5_)
{
break;
}
this.swap(param1,_loc5_,_loc6_);
}
this.swap(param1,_loc5_,param3 - 1);
this.quickSort(param1,param2,_loc6_);
this.quickSort(param1,_loc5_ + 1,param3);
}
}
private function swap(param1:Vector.<Number>, param2:int, param3:int) : void
{
var _loc4_:Number = NaN;
_loc4_ = param1[param2];
param1[param2] = param1[param3];
param1[param3] = _loc4_;
swapChildrenAt(param2,param3);
}
private function move(param1:Vector.<Number>, param2:int, param3:int) : void
{
param1[param3] = param1[param2];
this.addChildAt(getChildAt(param2),param3);
}
private function InsertionSort(param1:Vector.<Number>, param2:int, param3:int) : void
{
var _loc4_:int = 0;
var _loc5_:* = 0;
var _loc6_:Number = NaN;
_loc4_ = param2 + 1;
while(_loc4_ <= param3)
{
_loc6_ = param1[_loc4_];
_loc5_ = _loc4_;
while(_loc5_ > param2 && param1[_loc5_ - 1] > _loc6_)
{
this.move(param1,_loc5_ - 1,_loc5_);
_loc5_--;
}
_loc4_++;
}
}
}
}
@@ -0,0 +1,181 @@
package com.sbi.graphics
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.system.System;
import flash.text.StyleSheet;
import flash.text.TextField;
import flash.utils.getTimer;
public class Stats extends Sprite
{
protected const WIDTH:uint = 70;
protected const HEIGHT:uint = 100;
protected var xml:XML;
protected var text:TextField;
protected var style:StyleSheet;
protected var timer:uint;
protected var fps:uint;
protected var ms:uint;
protected var ms_prev:uint;
protected var mem:Number;
protected var mem_max:Number;
protected var graph:Bitmap;
protected var rectangle:Rectangle;
protected var fps_graph:uint;
protected var mem_graph:uint;
protected var mem_max_graph:uint;
protected var theme:Object = {
"bg":51,
"fps":16776960,
"ms":65280,
"mem":65535,
"memmax":16711792
};
public function Stats(param1:Object = null)
{
super();
if(param1)
{
if(param1.bg != null)
{
this.theme.bg = param1.bg;
}
if(param1.fps != null)
{
this.theme.fps = param1.fps;
}
if(param1.ms != null)
{
this.theme.ms = param1.ms;
}
if(param1.mem != null)
{
this.theme.mem = param1.mem;
}
if(param1.memmax != null)
{
this.theme.memmax = param1.memmax;
}
}
this.mem_max = 0;
this.xml = <xml><fps>FPS:</fps><ms>MS:</ms><mem>MEM:</mem><memMax>MAX:</memMax></xml>;
this.style = new StyleSheet();
this.style.setStyle("xml",{
"fontSize":"9px",
"fontFamily":"_sans",
"leading":"-2px"
});
this.style.setStyle("fps",{"color":this.hex2css(this.theme.fps)});
this.style.setStyle("ms",{"color":this.hex2css(this.theme.ms)});
this.style.setStyle("mem",{"color":this.hex2css(this.theme.mem)});
this.style.setStyle("memMax",{"color":this.hex2css(this.theme.memmax)});
this.text = new TextField();
this.text.width = this.WIDTH;
this.text.height = 50;
this.text.styleSheet = this.style;
this.text.condenseWhite = true;
this.text.selectable = false;
this.text.mouseEnabled = false;
this.graph = new Bitmap();
this.graph.y = 50;
this.rectangle = new Rectangle(this.WIDTH - 1,0,1,this.HEIGHT - 50);
addEventListener(Event.ADDED_TO_STAGE,this.init,false,0,true);
addEventListener(Event.REMOVED_FROM_STAGE,this.destroy,false,0,true);
}
private function init(param1:Event) : void
{
graphics.beginFill(this.theme.bg);
graphics.drawRect(0,0,this.WIDTH,this.HEIGHT);
graphics.endFill();
addChild(this.text);
this.graph.bitmapData = new BitmapData(this.WIDTH,this.HEIGHT - 50,false,this.theme.bg);
addChild(this.graph);
addEventListener(MouseEvent.CLICK,this.onClick);
addEventListener(Event.ENTER_FRAME,this.update);
}
private function destroy(param1:Event) : void
{
graphics.clear();
while(numChildren > 0)
{
removeChildAt(0);
}
this.graph.bitmapData.dispose();
removeEventListener(MouseEvent.CLICK,this.onClick);
removeEventListener(Event.ENTER_FRAME,this.update);
}
private function update(param1:Event) : void
{
this.timer = getTimer();
if(this.timer - 1000 > this.ms_prev)
{
this.ms_prev = this.timer;
this.mem = Number((System.totalMemory * 9.54e-7).toFixed(3));
this.mem_max = this.mem_max > this.mem ? this.mem_max : this.mem;
this.fps_graph = Math.min(this.graph.height,this.fps / stage.frameRate * this.graph.height);
this.mem_graph = Math.min(this.graph.height,Math.sqrt(Math.sqrt(this.mem * 5000))) - 2;
this.mem_max_graph = Math.min(this.graph.height,Math.sqrt(Math.sqrt(this.mem_max * 5000))) - 2;
this.graph.bitmapData.scroll(-1,0);
this.graph.bitmapData.fillRect(this.rectangle,this.theme.bg);
this.graph.bitmapData.setPixel(this.graph.width - 1,this.graph.height - this.fps_graph,this.theme.fps);
this.graph.bitmapData.setPixel(this.graph.width - 1,this.graph.height - (this.timer - this.ms >> 1),this.theme.ms);
this.graph.bitmapData.setPixel(this.graph.width - 1,this.graph.height - this.mem_graph,this.theme.mem);
this.graph.bitmapData.setPixel(this.graph.width - 1,this.graph.height - this.mem_max_graph,this.theme.memmax);
this.xml.fps = "FPS: " + this.fps + " / " + stage.frameRate;
this.xml.mem = "MEM: " + this.mem;
this.xml.memMax = "MAX: " + this.mem_max;
this.fps = 0;
}
++this.fps;
this.xml.ms = "MS: " + (this.timer - this.ms);
this.ms = this.timer;
this.text.htmlText = this.xml;
}
private function onClick(param1:MouseEvent) : void
{
if(mouseY / height > 0.5)
{
--stage.frameRate;
}
else
{
++stage.frameRate;
}
this.xml.fps = "FPS: " + this.fps + " / " + stage.frameRate;
this.text.htmlText = this.xml;
}
private function hex2css(param1:int) : String
{
return "#" + param1.toString(16);
}
}
}