mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,174 @@
|
||||
package com.adobe.crypto
|
||||
{
|
||||
import com.adobe.utils.IntUtil;
|
||||
|
||||
public class MD5
|
||||
{
|
||||
|
||||
public function MD5()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function hash(param1:String) : String
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc12_:int = 0;
|
||||
var _loc6_:int = 1732584193;
|
||||
var _loc7_:int = -271733879;
|
||||
var _loc8_:int = -1732584194;
|
||||
var _loc9_:int = 271733878;
|
||||
var _loc11_:Array = createBlocks(param1);
|
||||
var _loc10_:int = int(_loc11_.length);
|
||||
_loc12_ = 0;
|
||||
while(_loc12_ < _loc10_)
|
||||
{
|
||||
_loc2_ = _loc6_;
|
||||
_loc3_ = _loc7_;
|
||||
_loc4_ = _loc8_;
|
||||
_loc5_ = _loc9_;
|
||||
_loc6_ = ff(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 0],7,-680876936);
|
||||
_loc9_ = ff(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 1],12,-389564586);
|
||||
_loc8_ = ff(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 2],17,606105819);
|
||||
_loc7_ = ff(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 3],22,-1044525330);
|
||||
_loc6_ = ff(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 4],7,-176418897);
|
||||
_loc9_ = ff(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 5],12,1200080426);
|
||||
_loc8_ = ff(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 6],17,-1473231341);
|
||||
_loc7_ = ff(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 7],22,-45705983);
|
||||
_loc6_ = ff(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 8],7,1770035416);
|
||||
_loc9_ = ff(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 9],12,-1958414417);
|
||||
_loc8_ = ff(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 10],17,-42063);
|
||||
_loc7_ = ff(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 11],22,-1990404162);
|
||||
_loc6_ = ff(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 12],7,1804603682);
|
||||
_loc9_ = ff(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 13],12,-40341101);
|
||||
_loc8_ = ff(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 14],17,-1502002290);
|
||||
_loc7_ = ff(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 15],22,1236535329);
|
||||
_loc6_ = gg(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 1],5,-165796510);
|
||||
_loc9_ = gg(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 6],9,-1069501632);
|
||||
_loc8_ = gg(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 11],14,643717713);
|
||||
_loc7_ = gg(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 0],20,-373897302);
|
||||
_loc6_ = gg(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 5],5,-701558691);
|
||||
_loc9_ = gg(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 10],9,38016083);
|
||||
_loc8_ = gg(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 15],14,-660478335);
|
||||
_loc7_ = gg(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 4],20,-405537848);
|
||||
_loc6_ = gg(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 9],5,568446438);
|
||||
_loc9_ = gg(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 14],9,-1019803690);
|
||||
_loc8_ = gg(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 3],14,-187363961);
|
||||
_loc7_ = gg(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 8],20,1163531501);
|
||||
_loc6_ = gg(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 13],5,-1444681467);
|
||||
_loc9_ = gg(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 2],9,-51403784);
|
||||
_loc8_ = gg(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 7],14,1735328473);
|
||||
_loc7_ = gg(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 12],20,-1926607734);
|
||||
_loc6_ = hh(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 5],4,-378558);
|
||||
_loc9_ = hh(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 8],11,-2022574463);
|
||||
_loc8_ = hh(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 11],16,1839030562);
|
||||
_loc7_ = hh(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 14],23,-35309556);
|
||||
_loc6_ = hh(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 1],4,-1530992060);
|
||||
_loc9_ = hh(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 4],11,1272893353);
|
||||
_loc8_ = hh(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 7],16,-155497632);
|
||||
_loc7_ = hh(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 10],23,-1094730640);
|
||||
_loc6_ = hh(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 13],4,681279174);
|
||||
_loc9_ = hh(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 0],11,-358537222);
|
||||
_loc8_ = hh(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 3],16,-722521979);
|
||||
_loc7_ = hh(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 6],23,76029189);
|
||||
_loc6_ = hh(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 9],4,-640364487);
|
||||
_loc9_ = hh(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 12],11,-421815835);
|
||||
_loc8_ = hh(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 15],16,530742520);
|
||||
_loc7_ = hh(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 2],23,-995338651);
|
||||
_loc6_ = ii(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 0],6,-198630844);
|
||||
_loc9_ = ii(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 7],10,1126891415);
|
||||
_loc8_ = ii(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 14],15,-1416354905);
|
||||
_loc7_ = ii(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 5],21,-57434055);
|
||||
_loc6_ = ii(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 12],6,1700485571);
|
||||
_loc9_ = ii(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 3],10,-1894986606);
|
||||
_loc8_ = ii(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 10],15,-1051523);
|
||||
_loc7_ = ii(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 1],21,-2054922799);
|
||||
_loc6_ = ii(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 8],6,1873313359);
|
||||
_loc9_ = ii(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 15],10,-30611744);
|
||||
_loc8_ = ii(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 6],15,-1560198380);
|
||||
_loc7_ = ii(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 13],21,1309151649);
|
||||
_loc6_ = ii(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_[_loc12_ + 4],6,-145523070);
|
||||
_loc9_ = ii(_loc9_,_loc6_,_loc7_,_loc8_,_loc11_[_loc12_ + 11],10,-1120210379);
|
||||
_loc8_ = ii(_loc8_,_loc9_,_loc6_,_loc7_,_loc11_[_loc12_ + 2],15,718787259);
|
||||
_loc7_ = ii(_loc7_,_loc8_,_loc9_,_loc6_,_loc11_[_loc12_ + 9],21,-343485551);
|
||||
_loc6_ += _loc2_;
|
||||
_loc7_ += _loc3_;
|
||||
_loc8_ += _loc4_;
|
||||
_loc9_ += _loc5_;
|
||||
_loc12_ += 16;
|
||||
}
|
||||
return IntUtil.toHex(_loc6_) + IntUtil.toHex(_loc7_) + IntUtil.toHex(_loc8_) + IntUtil.toHex(_loc9_);
|
||||
}
|
||||
|
||||
private static function f(param1:int, param2:int, param3:int) : int
|
||||
{
|
||||
return param1 & param2 | ~param1 & param3;
|
||||
}
|
||||
|
||||
private static function g(param1:int, param2:int, param3:int) : int
|
||||
{
|
||||
return param1 & param3 | param2 & ~param3;
|
||||
}
|
||||
|
||||
private static function h(param1:int, param2:int, param3:int) : int
|
||||
{
|
||||
return param1 ^ param2 ^ param3;
|
||||
}
|
||||
|
||||
private static function i(param1:int, param2:int, param3:int) : int
|
||||
{
|
||||
return param2 ^ (param1 | ~param3);
|
||||
}
|
||||
|
||||
private static function transform(param1:Function, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int, param8:int) : int
|
||||
{
|
||||
var _loc9_:int = param2 + int(param1(param3,param4,param5)) + param6 + param8;
|
||||
return IntUtil.rol(_loc9_,param7) + param3;
|
||||
}
|
||||
|
||||
private static function ff(param1:int, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int) : int
|
||||
{
|
||||
return transform(f,param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
private static function gg(param1:int, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int) : int
|
||||
{
|
||||
return transform(g,param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
private static function hh(param1:int, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int) : int
|
||||
{
|
||||
return transform(h,param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
private static function ii(param1:int, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int) : int
|
||||
{
|
||||
return transform(i,param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
private static function createBlocks(param1:String) : Array
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:Array = [];
|
||||
var _loc2_:int = param1.length * 8;
|
||||
var _loc5_:int = 255;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc2_)
|
||||
{
|
||||
var _loc6_:int = _loc4_ >> 5;
|
||||
var _loc7_:int = _loc3_[_loc6_] | (param1.charCodeAt(_loc4_ / 8) & _loc5_) << _loc4_ % 32;
|
||||
_loc3_[_loc6_] = _loc7_;
|
||||
_loc4_ += 8;
|
||||
}
|
||||
_loc7_ = _loc2_ >> 5;
|
||||
_loc6_ = _loc3_[_loc7_] | 128 << _loc2_ % 32;
|
||||
_loc3_[_loc7_] = _loc6_;
|
||||
_loc3_[(_loc2_ + 64 >>> 9 << 4) + 14] = _loc2_;
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.adobe.images
|
||||
{
|
||||
import flash.display.BitmapData;
|
||||
import flash.geom.*;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class PNGEncoder
|
||||
{
|
||||
|
||||
private static var crcTable:Array;
|
||||
|
||||
private static var crcTableComputed:Boolean = false;
|
||||
|
||||
public function PNGEncoder()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function encode(param1:BitmapData) : ByteArray
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:* = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
_loc3_.writeUnsignedInt(2303741511);
|
||||
_loc3_.writeUnsignedInt(218765834);
|
||||
var _loc7_:ByteArray = new ByteArray();
|
||||
_loc7_.writeInt(param1.width);
|
||||
_loc7_.writeInt(param1.height);
|
||||
_loc7_.writeUnsignedInt(134610944);
|
||||
_loc7_.writeByte(0);
|
||||
writeChunk(_loc3_,1229472850,_loc7_);
|
||||
var _loc6_:ByteArray = new ByteArray();
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.height)
|
||||
{
|
||||
_loc6_.writeByte(0);
|
||||
if(!param1.transparent)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < param1.width)
|
||||
{
|
||||
_loc2_ = param1.getPixel(_loc5_,_loc4_);
|
||||
_loc6_.writeUnsignedInt(uint((_loc2_ & 0xFFFFFF) << 8 | 0xFF));
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < param1.width)
|
||||
{
|
||||
_loc2_ = param1.getPixel32(_loc5_,_loc4_);
|
||||
_loc6_.writeUnsignedInt(uint((_loc2_ & 0xFFFFFF) << 8 | _loc2_ >>> 24));
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
_loc6_.compress();
|
||||
writeChunk(_loc3_,1229209940,_loc6_);
|
||||
writeChunk(_loc3_,1229278788,null);
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private static function writeChunk(param1:ByteArray, param2:uint, param3:ByteArray) : void
|
||||
{
|
||||
var _loc5_:* = 0;
|
||||
var _loc10_:* = 0;
|
||||
var _loc9_:* = 0;
|
||||
var _loc8_:int = 0;
|
||||
if(!crcTableComputed)
|
||||
{
|
||||
crcTableComputed = true;
|
||||
crcTable = [];
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < 256)
|
||||
{
|
||||
_loc5_ = _loc10_;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < 8)
|
||||
{
|
||||
if(_loc5_ & 1)
|
||||
{
|
||||
_loc5_ = uint(0xEDB88320 ^ uint(_loc5_ >>> 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ >>>= 1;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
crcTable[_loc10_] = _loc5_;
|
||||
_loc10_++;
|
||||
}
|
||||
}
|
||||
var _loc6_:uint = 0;
|
||||
if(param3 != null)
|
||||
{
|
||||
_loc6_ = param3.length;
|
||||
}
|
||||
param1.writeUnsignedInt(_loc6_);
|
||||
var _loc4_:uint = param1.position;
|
||||
param1.writeUnsignedInt(param2);
|
||||
if(param3 != null)
|
||||
{
|
||||
param1.writeBytes(param3);
|
||||
}
|
||||
var _loc7_:uint = param1.position;
|
||||
param1.position = _loc4_;
|
||||
_loc5_ = uint(4294967295);
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc7_ - _loc4_)
|
||||
{
|
||||
_loc5_ = uint(crcTable[(_loc5_ ^ param1.readUnsignedByte()) & 0xFF] ^ uint(_loc5_ >>> 8));
|
||||
_loc8_++;
|
||||
}
|
||||
_loc5_ ^= 4294967295;
|
||||
param1.position = _loc7_;
|
||||
param1.writeUnsignedInt(_loc5_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.adobe.utils
|
||||
{
|
||||
public class IntUtil
|
||||
{
|
||||
|
||||
private static var hexChars:String = "0123456789abcdef";
|
||||
|
||||
public function IntUtil()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function rol(param1:int, param2:int) : int
|
||||
{
|
||||
return param1 << param2 | param1 >>> 32 - param2;
|
||||
}
|
||||
|
||||
public static function ror(param1:int, param2:int) : uint
|
||||
{
|
||||
var _loc3_:int = 32 - param2;
|
||||
return param1 << _loc3_ | param1 >>> 32 - _loc3_;
|
||||
}
|
||||
|
||||
public static function toHex(param1:int, param2:Boolean = false) : String
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:String = "";
|
||||
if(param2)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 4)
|
||||
{
|
||||
_loc3_ += hexChars.charAt(param1 >> (3 - _loc5_) * 8 + 4 & 0x0F) + hexChars.charAt(param1 >> (3 - _loc5_) * 8 & 0x0F);
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 4)
|
||||
{
|
||||
_loc3_ += hexChars.charAt(param1 >> _loc4_ * 8 + 4 & 0x0F) + hexChars.charAt(param1 >> _loc4_ * 8 & 0x0F);
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.adobe.utils
|
||||
{
|
||||
public class StringUtil
|
||||
{
|
||||
|
||||
public function StringUtil()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function stringsAreEqual(param1:String, param2:String, param3:Boolean) : Boolean
|
||||
{
|
||||
if(param3)
|
||||
{
|
||||
return param1 == param2;
|
||||
}
|
||||
return param1.toUpperCase() == param2.toUpperCase();
|
||||
}
|
||||
|
||||
public static function trim(param1:String) : String
|
||||
{
|
||||
return StringUtil.ltrim(StringUtil.rtrim(param1));
|
||||
}
|
||||
|
||||
public static function ltrim(param1:String) : String
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc2_:Number = param1.length;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
if(param1.charCodeAt(_loc3_) > 32)
|
||||
{
|
||||
return param1.substring(_loc3_);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function rtrim(param1:String) : String
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc2_:Number = param1.length;
|
||||
_loc3_ = _loc2_;
|
||||
while(_loc3_ > 0)
|
||||
{
|
||||
if(param1.charCodeAt(_loc3_ - 1) > 32)
|
||||
{
|
||||
return param1.substring(0,_loc3_);
|
||||
}
|
||||
_loc3_--;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function beginsWith(param1:String, param2:String) : Boolean
|
||||
{
|
||||
return param2 == param1.substring(0,param2.length);
|
||||
}
|
||||
|
||||
public static function endsWith(param1:String, param2:String) : Boolean
|
||||
{
|
||||
return param2 == param1.substring(param1.length - param2.length);
|
||||
}
|
||||
|
||||
public static function remove(param1:String, param2:String) : String
|
||||
{
|
||||
return StringUtil.replace(param1,param2,"");
|
||||
}
|
||||
|
||||
public static function replace(param1:String, param2:String, param3:String) : String
|
||||
{
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc9_:String = new String();
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc5_:Number = param1.length;
|
||||
var _loc6_:Number = param2.length;
|
||||
_loc7_ = 0;
|
||||
for(; _loc7_ < _loc5_; _loc7_++)
|
||||
{
|
||||
if(param1.charAt(_loc7_) == param2.charAt(0))
|
||||
{
|
||||
_loc4_ = true;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc6_)
|
||||
{
|
||||
if(param1.charAt(_loc7_ + _loc8_) != param2.charAt(_loc8_))
|
||||
{
|
||||
_loc4_ = false;
|
||||
break;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc9_ += param3;
|
||||
_loc7_ += _loc6_ - 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
_loc9_ += param1.charAt(_loc7_);
|
||||
}
|
||||
return _loc9_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.baseoneonline.astar
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class AStar
|
||||
{
|
||||
|
||||
private var graph:Graph;
|
||||
|
||||
private var g:Vector.<Number>;
|
||||
|
||||
private var h:Vector.<Number>;
|
||||
|
||||
private var f:Vector.<Number>;
|
||||
|
||||
private var parent:Vector.<int>;
|
||||
|
||||
private var open:Vector.<int>;
|
||||
|
||||
private var closed:Vector.<int>;
|
||||
|
||||
private var closedDict:Dictionary;
|
||||
|
||||
private var goalReached:Boolean = false;
|
||||
|
||||
public function AStar(param1:Graph = null)
|
||||
{
|
||||
super();
|
||||
if(param1)
|
||||
{
|
||||
setGraph(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function setGraph(param1:Graph) : void
|
||||
{
|
||||
this.graph = param1;
|
||||
updateGraph();
|
||||
}
|
||||
|
||||
private function updateGraph() : void
|
||||
{
|
||||
var _loc1_:int = graph.size();
|
||||
g = new Vector.<Number>(_loc1_,true);
|
||||
h = new Vector.<Number>(_loc1_,true);
|
||||
f = new Vector.<Number>(_loc1_,true);
|
||||
parent = new Vector.<int>(_loc1_,true);
|
||||
}
|
||||
|
||||
public function solve(param1:int, param2:int) : Vector.<int>
|
||||
{
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc12_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc7_:Boolean = false;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc11_:Vector.<int> = new Vector.<int>();
|
||||
goalReached = false;
|
||||
open = new Vector.<int>();
|
||||
closed = new Vector.<int>();
|
||||
closedDict = new Dictionary(true);
|
||||
open.push(param1);
|
||||
g[param1] = 0;
|
||||
h[param1] = graph.distance(param1,param2);
|
||||
f[param1] = h[param1];
|
||||
parent[param1] = -1;
|
||||
graph.setStartGridPos(param1);
|
||||
while(open.length > 0)
|
||||
{
|
||||
_loc8_ = Infinity;
|
||||
_loc12_ = -1;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < open.length)
|
||||
{
|
||||
_loc4_ = open[_loc5_];
|
||||
if(f[_loc4_] < _loc8_)
|
||||
{
|
||||
_loc8_ = f[_loc4_];
|
||||
_loc12_ = _loc4_;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
if(_loc12_ == param2)
|
||||
{
|
||||
goalReached = true;
|
||||
return createPath(param2,param1);
|
||||
}
|
||||
open.splice(open.indexOf(_loc12_),1);
|
||||
closed.push(_loc12_);
|
||||
closedDict[_loc12_] = 1;
|
||||
for each(var _loc13_:int in graph.getNeighbors(_loc12_,_loc11_))
|
||||
{
|
||||
if(closedDict[_loc13_] != 1)
|
||||
{
|
||||
_loc9_ = g[_loc12_] + graph.distance(_loc12_,_loc13_);
|
||||
_loc7_ = false;
|
||||
if(open.indexOf(_loc13_) == -1)
|
||||
{
|
||||
open.push(_loc13_);
|
||||
_loc7_ = true;
|
||||
}
|
||||
else if(_loc9_ < g[_loc13_])
|
||||
{
|
||||
_loc7_ = true;
|
||||
}
|
||||
if(_loc7_)
|
||||
{
|
||||
parent[_loc13_] = _loc12_;
|
||||
g[_loc13_] = _loc9_;
|
||||
h[_loc13_] = graph.distance(_loc13_,param2);
|
||||
f[_loc13_] = g[_loc13_] + h[_loc13_];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var _loc10_:Number = Infinity;
|
||||
var _loc14_:int = -1;
|
||||
for each(var _loc6_:int in closed)
|
||||
{
|
||||
_loc3_ = h[_loc6_];
|
||||
if(_loc3_ < _loc10_)
|
||||
{
|
||||
_loc10_ = _loc3_;
|
||||
_loc14_ = _loc6_;
|
||||
}
|
||||
}
|
||||
return createPath(_loc14_,param1);
|
||||
}
|
||||
|
||||
public function hasReachedGoal() : Boolean
|
||||
{
|
||||
return goalReached;
|
||||
}
|
||||
|
||||
private function createPath(param1:int, param2:int) : Vector.<int>
|
||||
{
|
||||
var _loc3_:Vector.<int> = new Vector.<int>();
|
||||
while(parent[param1] != -1)
|
||||
{
|
||||
_loc3_.push(param1);
|
||||
param1 = parent[param1];
|
||||
}
|
||||
_loc3_.push(param2);
|
||||
return _loc3_.reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.baseoneonline.astar
|
||||
{
|
||||
public interface Graph
|
||||
{
|
||||
|
||||
function getNeighbors(param1:int, param2:Vector.<int>) : Vector.<int>;
|
||||
|
||||
function distance(param1:int, param2:int) : Number;
|
||||
|
||||
function size() : int;
|
||||
|
||||
function setStartGridPos(param1:int) : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,811 @@
|
||||
package com.greensock
|
||||
{
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Graphics;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.ColorTransform;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.geom.Transform;
|
||||
|
||||
public class BlitMask extends Sprite
|
||||
{
|
||||
|
||||
public static var version:Number = 0.62;
|
||||
|
||||
protected static var _tempContainer:Sprite = new Sprite();
|
||||
|
||||
protected static var _sliceRect:Rectangle = new Rectangle();
|
||||
|
||||
protected static var _drawRect:Rectangle = new Rectangle();
|
||||
|
||||
protected static var _destPoint:Point = new Point();
|
||||
|
||||
protected static var _tempMatrix:Matrix = new Matrix();
|
||||
|
||||
protected static var _emptyArray:Array = [];
|
||||
|
||||
protected static var _colorTransform:ColorTransform = new ColorTransform();
|
||||
|
||||
protected static var _mouseEvents:Array = ["click","doubleClick","mouseDown","mouseMove","mouseOut","mouseOver","mouseUp","mouseWheel","rollOut","rollOver","gesturePressAndTap","gesturePan","gestureRotate","gestureSwipe","gestureZoom","gestureTwoFingerTap","touchBegin","touchEnd","touchMove","touchOut","touchOver","touchRollOut","touchRollOver","touchTap"];
|
||||
|
||||
protected var _target:DisplayObject;
|
||||
|
||||
protected var _fillColor:uint;
|
||||
|
||||
protected var _smoothing:Boolean;
|
||||
|
||||
protected var _width:Number;
|
||||
|
||||
protected var _height:Number;
|
||||
|
||||
protected var _bd:BitmapData;
|
||||
|
||||
protected var _gridSize:int = 2879;
|
||||
|
||||
protected var _grid:Array;
|
||||
|
||||
protected var _bounds:Rectangle;
|
||||
|
||||
protected var _clipRect:Rectangle;
|
||||
|
||||
protected var _bitmapMode:Boolean;
|
||||
|
||||
protected var _rows:int;
|
||||
|
||||
protected var _columns:int;
|
||||
|
||||
protected var _scaleX:Number;
|
||||
|
||||
protected var _scaleY:Number;
|
||||
|
||||
protected var _prevMatrix:Matrix;
|
||||
|
||||
protected var _transform:Transform;
|
||||
|
||||
protected var _prevRotation:Number;
|
||||
|
||||
protected var _autoUpdate:Boolean;
|
||||
|
||||
protected var _wrap:Boolean;
|
||||
|
||||
protected var _wrapOffsetX:Number = 0;
|
||||
|
||||
protected var _wrapOffsetY:Number = 0;
|
||||
|
||||
public function BlitMask(param1:DisplayObject, param2:Number = 0, param3:Number = 0, param4:Number = 100, param5:Number = 100, param6:Boolean = false, param7:Boolean = false, param8:uint = 0, param9:Boolean = false)
|
||||
{
|
||||
super();
|
||||
if(param4 < 0 || param5 < 0)
|
||||
{
|
||||
throw new Error("A FlexBlitMask cannot have a negative width or height.");
|
||||
}
|
||||
_width = param4;
|
||||
_height = param5;
|
||||
_scaleX = _scaleY = 1;
|
||||
_smoothing = param6;
|
||||
_fillColor = param8;
|
||||
_autoUpdate = param7;
|
||||
_wrap = param9;
|
||||
_grid = [];
|
||||
_bounds = new Rectangle();
|
||||
if(_smoothing)
|
||||
{
|
||||
super.x = param2;
|
||||
super.y = param3;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.x = param2 < 0 ? param2 - 0.5 >> 0 : param2 + 0.5 >> 0;
|
||||
super.y = param3 < 0 ? param3 - 0.5 >> 0 : param3 + 0.5 >> 0;
|
||||
}
|
||||
_clipRect = new Rectangle(0,0,_gridSize + 1,_gridSize + 1);
|
||||
_bd = new BitmapData(param4 + 1,param5 + 1,true,_fillColor);
|
||||
_bitmapMode = true;
|
||||
this.target = param1;
|
||||
}
|
||||
|
||||
protected function _captureTargetBitmap() : void
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
var _loc4_:BitmapData = null;
|
||||
var _loc12_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
if(_bd == null || _target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_disposeGrid();
|
||||
var _loc11_:DisplayObject = _target.mask;
|
||||
if(_loc11_ != null)
|
||||
{
|
||||
_target.mask = null;
|
||||
}
|
||||
var _loc2_:Rectangle = _target.scrollRect;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_target.scrollRect = null;
|
||||
}
|
||||
var _loc13_:Array = _target.filters;
|
||||
if(_loc13_.length != 0)
|
||||
{
|
||||
_target.filters = _emptyArray;
|
||||
}
|
||||
_grid = [];
|
||||
if(_target.parent == null)
|
||||
{
|
||||
_tempContainer.addChild(_target);
|
||||
}
|
||||
_bounds = _target.getBounds(_target.parent);
|
||||
var _loc10_:Number = 0;
|
||||
var _loc6_:Number = 0;
|
||||
_columns = Math.ceil(_bounds.width / _gridSize);
|
||||
_rows = Math.ceil(_bounds.height / _gridSize);
|
||||
var _loc8_:Number = 0;
|
||||
var _loc9_:Matrix = _transform.matrix;
|
||||
var _loc5_:Number = _loc9_.tx - _bounds.x;
|
||||
var _loc3_:Number = _loc9_.ty - _bounds.y;
|
||||
if(!_smoothing)
|
||||
{
|
||||
_loc5_ = _loc5_ + 0.5 >> 0;
|
||||
_loc3_ = _loc3_ + 0.5 >> 0;
|
||||
}
|
||||
_loc12_ = 0;
|
||||
while(_loc12_ < _rows)
|
||||
{
|
||||
_loc6_ = Number(_bounds.height - _loc8_ > _gridSize ? _gridSize : _bounds.height - _loc8_);
|
||||
_loc9_.ty = -_loc8_ + _loc3_;
|
||||
_loc1_ = 0;
|
||||
_grid[_loc12_] = [];
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _columns)
|
||||
{
|
||||
_loc10_ = Number(_bounds.width - _loc1_ > _gridSize ? _gridSize : _bounds.width - _loc1_);
|
||||
_grid[_loc12_][_loc7_] = _loc4_ = new BitmapData(_loc10_ + 1,_loc6_ + 1,true,_fillColor);
|
||||
_loc9_.tx = -_loc1_ + _loc5_;
|
||||
_loc4_.draw(_target,_loc9_,null,null,_clipRect,_smoothing);
|
||||
_loc1_ += _loc10_;
|
||||
_loc7_++;
|
||||
}
|
||||
_loc8_ += _loc6_;
|
||||
_loc12_++;
|
||||
}
|
||||
if(_target.parent == _tempContainer)
|
||||
{
|
||||
_tempContainer.removeChild(_target);
|
||||
}
|
||||
if(_loc11_ != null)
|
||||
{
|
||||
_target.mask = _loc11_;
|
||||
}
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_target.scrollRect = _loc2_;
|
||||
}
|
||||
if(_loc13_.length != 0)
|
||||
{
|
||||
_target.filters = _loc13_;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _disposeGrid() : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc1_:Array = null;
|
||||
var _loc2_:int = int(_grid.length);
|
||||
while(--_loc2_ > -1)
|
||||
{
|
||||
_loc1_ = _grid[_loc2_];
|
||||
_loc3_ = int(_loc1_.length);
|
||||
while(--_loc3_ > -1)
|
||||
{
|
||||
BitmapData(_loc1_[_loc3_]).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function update(param1:Event = null, param2:Boolean = false) : void
|
||||
{
|
||||
var _loc3_:Matrix = null;
|
||||
if(_bd == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_target == null)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
else if(_target.parent)
|
||||
{
|
||||
_bounds = _target.getBounds(_target.parent);
|
||||
if(this.parent != _target.parent)
|
||||
{
|
||||
_target.parent.addChildAt(this,_target.parent.getChildIndex(_target));
|
||||
}
|
||||
}
|
||||
if(_bitmapMode || param2)
|
||||
{
|
||||
_loc3_ = _transform.matrix;
|
||||
if(param2 || _prevMatrix == null || _loc3_.a != _prevMatrix.a || _loc3_.b != _prevMatrix.b || _loc3_.c != _prevMatrix.c || _loc3_.d != _prevMatrix.d)
|
||||
{
|
||||
_captureTargetBitmap();
|
||||
_render();
|
||||
}
|
||||
else if(_loc3_.tx != _prevMatrix.tx || _loc3_.ty != _prevMatrix.ty)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
else if(_bitmapMode && _target != null)
|
||||
{
|
||||
this.filters = _target.filters;
|
||||
this.transform.colorTransform = _transform.colorTransform;
|
||||
}
|
||||
_prevMatrix = _loc3_;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _render(param1:Number = 0, param2:Number = 0, param3:Boolean = true, param4:Boolean = false) : void
|
||||
{
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc16_:int = 0;
|
||||
var _loc5_:BitmapData = null;
|
||||
if(param3)
|
||||
{
|
||||
_sliceRect.x = _sliceRect.y = 0;
|
||||
_sliceRect.width = _width + 1;
|
||||
_sliceRect.height = _height + 1;
|
||||
_bd.fillRect(_sliceRect,_fillColor);
|
||||
if(_bitmapMode && _target != null)
|
||||
{
|
||||
this.filters = _target.filters;
|
||||
this.transform.colorTransform = _transform.colorTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.filters = _emptyArray;
|
||||
this.transform.colorTransform = _colorTransform;
|
||||
}
|
||||
}
|
||||
if(_bd == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_rows == 0)
|
||||
{
|
||||
_captureTargetBitmap();
|
||||
}
|
||||
var _loc13_:Number = super.x + param1;
|
||||
var _loc15_:Number = super.y + param2;
|
||||
var _loc10_:int = _bounds.width + _wrapOffsetX + 0.5 >> 0;
|
||||
var _loc12_:int = _bounds.height + _wrapOffsetY + 0.5 >> 0;
|
||||
var _loc8_:Graphics = this.graphics;
|
||||
if(_bounds.width == 0 || _bounds.height == 0 || _wrap && (_loc10_ == 0 || _loc12_ == 0) || !_wrap && (_loc13_ + _width < _bounds.x || _loc15_ + _height < _bounds.y || _loc13_ > _bounds.right || _loc15_ > _bounds.bottom))
|
||||
{
|
||||
_loc8_.clear();
|
||||
_loc8_.beginBitmapFill(_bd);
|
||||
_loc8_.drawRect(0,0,_width,_height);
|
||||
_loc8_.endFill();
|
||||
return;
|
||||
}
|
||||
var _loc9_:int = (_loc13_ - _bounds.x) / _gridSize;
|
||||
if(_loc9_ < 0)
|
||||
{
|
||||
_loc9_ = 0;
|
||||
}
|
||||
var _loc17_:int = (_loc15_ - _bounds.y) / _gridSize;
|
||||
if(_loc17_ < 0)
|
||||
{
|
||||
_loc17_ = 0;
|
||||
}
|
||||
var _loc18_:int = (_loc13_ + _width - _bounds.x) / _gridSize;
|
||||
if(_loc18_ >= _columns)
|
||||
{
|
||||
_loc18_ = _columns - 1;
|
||||
}
|
||||
var _loc14_:uint = uint(int((_loc15_ + _height - _bounds.y) / _gridSize));
|
||||
if(_loc14_ >= _rows)
|
||||
{
|
||||
_loc14_ = _rows - 1;
|
||||
}
|
||||
var _loc6_:Number = (_bounds.x - _loc13_) % 1;
|
||||
var _loc19_:Number = (_bounds.y - _loc15_) % 1;
|
||||
if(_loc15_ <= _bounds.y)
|
||||
{
|
||||
_destPoint.y = _bounds.y - _loc15_ >> 0;
|
||||
_sliceRect.y = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_destPoint.y = 0;
|
||||
_sliceRect.y = Math.ceil(_loc15_ - _bounds.y) - _loc17_ * _gridSize - 1;
|
||||
if(param3 && _loc19_ != 0)
|
||||
{
|
||||
_loc19_ += 1;
|
||||
}
|
||||
}
|
||||
if(_loc13_ <= _bounds.x)
|
||||
{
|
||||
_destPoint.x = _bounds.x - _loc13_ >> 0;
|
||||
_sliceRect.x = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_destPoint.x = 0;
|
||||
_sliceRect.x = Math.ceil(_loc13_ - _bounds.x) - _loc9_ * _gridSize - 1;
|
||||
if(param3 && _loc6_ != 0)
|
||||
{
|
||||
_loc6_ += 1;
|
||||
}
|
||||
}
|
||||
if(_wrap && param3)
|
||||
{
|
||||
_render(Math.ceil((_bounds.x - _loc13_) / _loc10_) * _loc10_,Math.ceil((_bounds.y - _loc15_) / _loc12_) * _loc12_,false,false);
|
||||
}
|
||||
else if(_rows != 0)
|
||||
{
|
||||
_loc11_ = _destPoint.x;
|
||||
_loc7_ = _sliceRect.x;
|
||||
_loc16_ = _loc9_;
|
||||
while(_loc17_ <= _loc14_)
|
||||
{
|
||||
_loc5_ = _grid[_loc17_][0];
|
||||
_sliceRect.height = _loc5_.height - _sliceRect.y;
|
||||
_destPoint.x = _loc11_;
|
||||
_sliceRect.x = _loc7_;
|
||||
_loc9_ = _loc16_;
|
||||
while(_loc9_ <= _loc18_)
|
||||
{
|
||||
_loc5_ = _grid[_loc17_][_loc9_];
|
||||
_sliceRect.width = _loc5_.width - _sliceRect.x;
|
||||
_bd.copyPixels(_loc5_,_sliceRect,_destPoint);
|
||||
_destPoint.x += _sliceRect.width - 1;
|
||||
_sliceRect.x = 0;
|
||||
_loc9_++;
|
||||
}
|
||||
_destPoint.y += _sliceRect.height - 1;
|
||||
_sliceRect.y = 0;
|
||||
_loc17_++;
|
||||
}
|
||||
}
|
||||
if(param3)
|
||||
{
|
||||
_tempMatrix.tx = _loc6_ - 1;
|
||||
_tempMatrix.ty = _loc19_ - 1;
|
||||
_loc8_.clear();
|
||||
_loc8_.beginBitmapFill(_bd,_tempMatrix,false,_smoothing);
|
||||
_loc8_.drawRect(0,0,_width,_height);
|
||||
_loc8_.endFill();
|
||||
}
|
||||
else if(_wrap)
|
||||
{
|
||||
if(_loc13_ + _width > _bounds.right)
|
||||
{
|
||||
_render(param1 - _loc10_,param2,false,true);
|
||||
}
|
||||
if(!param4 && _loc15_ + _height > _bounds.bottom)
|
||||
{
|
||||
_render(param1,param2 - _loc12_,false,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setSize(param1:Number, param2:Number) : void
|
||||
{
|
||||
if(_width == param1 && _height == param2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(param1 < 0 || param2 < 0)
|
||||
{
|
||||
throw new Error("A BlitMask cannot have a negative width or height.");
|
||||
}
|
||||
if(_bd != null)
|
||||
{
|
||||
_bd.dispose();
|
||||
}
|
||||
_width = param1;
|
||||
_height = param2;
|
||||
_bd = new BitmapData(param1 + 1,param2 + 1,true,_fillColor);
|
||||
_render();
|
||||
}
|
||||
|
||||
protected function _mouseEventPassthrough(param1:Event) : void
|
||||
{
|
||||
if(this.mouseEnabled && (!_bitmapMode || param1 is MouseEvent && this.hitTestPoint(MouseEvent(param1).stageX,MouseEvent(param1).stageY,false)))
|
||||
{
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function enableBitmapMode(param1:Event = null) : void
|
||||
{
|
||||
this.bitmapMode = true;
|
||||
}
|
||||
|
||||
public function disableBitmapMode(param1:Event = null) : void
|
||||
{
|
||||
this.bitmapMode = false;
|
||||
}
|
||||
|
||||
public function normalizePosition() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
if(_target && _bounds)
|
||||
{
|
||||
_loc1_ = _bounds.width + _wrapOffsetX + 0.5 >> 0;
|
||||
_loc4_ = _bounds.height + _wrapOffsetY + 0.5 >> 0;
|
||||
_loc2_ = (_bounds.x - this.x) % _loc1_;
|
||||
_loc3_ = (_bounds.y - this.y) % _loc4_;
|
||||
if(_loc2_ > (_width + _wrapOffsetX) / 2)
|
||||
{
|
||||
_loc2_ -= _loc1_;
|
||||
}
|
||||
else if(_loc2_ < (_width + _wrapOffsetX) / -2)
|
||||
{
|
||||
_loc2_ += _loc1_;
|
||||
}
|
||||
if(_loc3_ > (_height + _wrapOffsetY) / 2)
|
||||
{
|
||||
_loc3_ -= _loc4_;
|
||||
}
|
||||
else if(_loc3_ < (_height + _wrapOffsetY) / -2)
|
||||
{
|
||||
_loc3_ += _loc4_;
|
||||
}
|
||||
_target.x += this.x + _loc2_ - _bounds.x;
|
||||
_target.y += this.y + _loc3_ - _bounds.y;
|
||||
}
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
if(_bd == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_disposeGrid();
|
||||
_bd.dispose();
|
||||
_bd = null;
|
||||
this.bitmapMode = false;
|
||||
this.autoUpdate = false;
|
||||
if(_target != null)
|
||||
{
|
||||
_target.mask = null;
|
||||
}
|
||||
if(this.parent != null)
|
||||
{
|
||||
this.parent.removeChild(this);
|
||||
}
|
||||
this.target = null;
|
||||
}
|
||||
|
||||
public function get bitmapMode() : Boolean
|
||||
{
|
||||
return _bitmapMode;
|
||||
}
|
||||
|
||||
public function set bitmapMode(param1:Boolean) : void
|
||||
{
|
||||
if(_bitmapMode != param1)
|
||||
{
|
||||
_bitmapMode = param1;
|
||||
if(_target != null)
|
||||
{
|
||||
_target.visible = !_bitmapMode;
|
||||
update(null);
|
||||
if(_bitmapMode)
|
||||
{
|
||||
this.filters = _target.filters;
|
||||
this.transform.colorTransform = _transform.colorTransform;
|
||||
this.blendMode = _target.blendMode;
|
||||
_target.mask = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.filters = _emptyArray;
|
||||
this.transform.colorTransform = _colorTransform;
|
||||
this.blendMode = "normal";
|
||||
this.cacheAsBitmap = false;
|
||||
_target.mask = this;
|
||||
if(_wrap)
|
||||
{
|
||||
normalizePosition();
|
||||
}
|
||||
}
|
||||
if(_bitmapMode && _autoUpdate)
|
||||
{
|
||||
this.addEventListener("enterFrame",update,false,-10,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.removeEventListener("enterFrame",update);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get autoUpdate() : Boolean
|
||||
{
|
||||
return _autoUpdate;
|
||||
}
|
||||
|
||||
public function set autoUpdate(param1:Boolean) : void
|
||||
{
|
||||
if(_autoUpdate != param1)
|
||||
{
|
||||
_autoUpdate = param1;
|
||||
if(_bitmapMode && _autoUpdate)
|
||||
{
|
||||
this.addEventListener("enterFrame",update,false,-10,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.removeEventListener("enterFrame",update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get target() : DisplayObject
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public function set target(param1:DisplayObject) : void
|
||||
{
|
||||
if(_target != param1)
|
||||
{
|
||||
_target = param1;
|
||||
if(_target != null)
|
||||
{
|
||||
_prevMatrix = null;
|
||||
_transform = _target.transform;
|
||||
_bitmapMode = !_bitmapMode;
|
||||
this.bitmapMode = !_bitmapMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
_bounds = new Rectangle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function get x() : Number
|
||||
{
|
||||
return super.x;
|
||||
}
|
||||
|
||||
override public function set x(param1:Number) : void
|
||||
{
|
||||
if(_smoothing)
|
||||
{
|
||||
super.x = param1;
|
||||
}
|
||||
else if(param1 >= 0)
|
||||
{
|
||||
super.x = param1 + 0.5 >> 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.x = param1 - 0.5 >> 0;
|
||||
}
|
||||
if(_bitmapMode)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
}
|
||||
|
||||
override public function get y() : Number
|
||||
{
|
||||
return super.y;
|
||||
}
|
||||
|
||||
override public function set y(param1:Number) : void
|
||||
{
|
||||
if(_smoothing)
|
||||
{
|
||||
super.y = param1;
|
||||
}
|
||||
else if(param1 >= 0)
|
||||
{
|
||||
super.y = param1 + 0.5 >> 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.y = param1 - 0.5 >> 0;
|
||||
}
|
||||
if(_bitmapMode)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
}
|
||||
|
||||
override public function get width() : Number
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
override public function set width(param1:Number) : void
|
||||
{
|
||||
setSize(param1,_height);
|
||||
}
|
||||
|
||||
override public function get height() : Number
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
override public function set height(param1:Number) : void
|
||||
{
|
||||
setSize(_width,param1);
|
||||
}
|
||||
|
||||
override public function get scaleX() : Number
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
override public function set scaleX(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = _scaleX;
|
||||
_scaleX = param1;
|
||||
setSize(_width * (_scaleX / _loc2_),_height);
|
||||
}
|
||||
|
||||
override public function get scaleY() : Number
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
override public function set scaleY(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = _scaleY;
|
||||
_scaleY = param1;
|
||||
setSize(_width,_height * (_scaleY / _loc2_));
|
||||
}
|
||||
|
||||
override public function set rotation(param1:Number) : void
|
||||
{
|
||||
if(param1 != 0)
|
||||
{
|
||||
throw new Error("Cannot set the rotation of a BlitMask to a non-zero number. BlitMasks should remain unrotated.");
|
||||
}
|
||||
}
|
||||
|
||||
public function get scrollX() : Number
|
||||
{
|
||||
return (super.x - _bounds.x) / (_bounds.width - _width);
|
||||
}
|
||||
|
||||
public function set scrollX(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
if(_target != null && _target.parent)
|
||||
{
|
||||
_bounds = _target.getBounds(_target.parent);
|
||||
_loc2_ = super.x - (_bounds.width - _width) * param1 - _bounds.x;
|
||||
_target.x += _loc2_;
|
||||
_bounds.x += _loc2_;
|
||||
if(_bitmapMode)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get scrollY() : Number
|
||||
{
|
||||
return (super.y - _bounds.y) / (_bounds.height - _height);
|
||||
}
|
||||
|
||||
public function set scrollY(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
if(_target != null && _target.parent)
|
||||
{
|
||||
_bounds = _target.getBounds(_target.parent);
|
||||
_loc2_ = super.y - (_bounds.height - _height) * param1 - _bounds.y;
|
||||
_target.y += _loc2_;
|
||||
_bounds.y += _loc2_;
|
||||
if(_bitmapMode)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get smoothing() : Boolean
|
||||
{
|
||||
return _smoothing;
|
||||
}
|
||||
|
||||
public function set smoothing(param1:Boolean) : void
|
||||
{
|
||||
if(_smoothing != param1)
|
||||
{
|
||||
_smoothing = param1;
|
||||
_captureTargetBitmap();
|
||||
if(_bitmapMode)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get fillColor() : uint
|
||||
{
|
||||
return _fillColor;
|
||||
}
|
||||
|
||||
public function set fillColor(param1:uint) : void
|
||||
{
|
||||
if(_fillColor != param1)
|
||||
{
|
||||
_fillColor = param1;
|
||||
if(_bitmapMode)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get wrap() : Boolean
|
||||
{
|
||||
return _wrap;
|
||||
}
|
||||
|
||||
public function set wrap(param1:Boolean) : void
|
||||
{
|
||||
if(_wrap != param1)
|
||||
{
|
||||
_wrap = param1;
|
||||
if(_bitmapMode)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get wrapOffsetX() : Number
|
||||
{
|
||||
return _wrapOffsetX;
|
||||
}
|
||||
|
||||
public function set wrapOffsetX(param1:Number) : void
|
||||
{
|
||||
if(_wrapOffsetX != param1)
|
||||
{
|
||||
_wrapOffsetX = param1;
|
||||
if(_bitmapMode)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get wrapOffsetY() : Number
|
||||
{
|
||||
return _wrapOffsetY;
|
||||
}
|
||||
|
||||
public function set wrapOffsetY(param1:Number) : void
|
||||
{
|
||||
if(_wrapOffsetY != param1)
|
||||
{
|
||||
_wrapOffsetY = param1;
|
||||
if(_bitmapMode)
|
||||
{
|
||||
_render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,852 @@
|
||||
package com.greensock
|
||||
{
|
||||
import com.greensock.core.Animation;
|
||||
import com.greensock.core.SimpleTimeline;
|
||||
|
||||
public class TimelineLite extends SimpleTimeline
|
||||
{
|
||||
|
||||
public static const version:String = "12.1.5";
|
||||
|
||||
protected var _labels:Object;
|
||||
|
||||
public function TimelineLite(param1:Object = null)
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:Object = null;
|
||||
super(param1);
|
||||
_labels = {};
|
||||
autoRemoveChildren = this.vars.autoRemoveChildren == true;
|
||||
smoothChildTiming = this.vars.smoothChildTiming == true;
|
||||
_sortChildren = true;
|
||||
_onUpdate = this.vars.onUpdate;
|
||||
for(_loc2_ in this.vars)
|
||||
{
|
||||
_loc3_ = this.vars[_loc2_];
|
||||
if(_loc3_ is Array)
|
||||
{
|
||||
if(_loc3_.join("").indexOf("{self}") !== -1)
|
||||
{
|
||||
this.vars[_loc2_] = _swapSelfInParams(_loc3_ as Array);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.vars.tweens is Array)
|
||||
{
|
||||
this.add(this.vars.tweens,0,this.vars.align || "normal",this.vars.stagger || 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected static function _prepVars(param1:Object) : Object
|
||||
{
|
||||
return param1._isGSVars ? param1.vars : param1;
|
||||
}
|
||||
|
||||
protected static function _copy(param1:Object) : Object
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:Object = {};
|
||||
for(_loc2_ in param1)
|
||||
{
|
||||
_loc3_[_loc2_] = param1[_loc2_];
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public static function exportRoot(param1:Object = null, param2:Boolean = true) : TimelineLite
|
||||
{
|
||||
var _loc6_:TimelineLite = null;
|
||||
var _loc3_:Animation = null;
|
||||
param1 ||= {};
|
||||
if(!("smoothChildTiming" in param1))
|
||||
{
|
||||
param1.smoothChildTiming = true;
|
||||
}
|
||||
_loc6_ = new TimelineLite(param1);
|
||||
var _loc5_:SimpleTimeline = _loc6_._timeline;
|
||||
_loc5_._remove(_loc6_,true);
|
||||
_loc6_._startTime = 0;
|
||||
_loc6_._rawPrevTime = _loc6_._time = _loc6_._totalTime = _loc5_._time;
|
||||
var _loc4_:Animation = _loc5_._first;
|
||||
while(_loc4_)
|
||||
{
|
||||
_loc3_ = _loc4_._next;
|
||||
if(!param2 || !(_loc4_ is TweenLite && TweenLite(_loc4_).target == _loc4_.vars.onComplete))
|
||||
{
|
||||
_loc6_.add(_loc4_,_loc4_._startTime - _loc4_._delay);
|
||||
}
|
||||
_loc4_ = _loc3_;
|
||||
}
|
||||
_loc5_.add(_loc6_,0);
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
public function to(param1:Object, param2:Number, param3:Object, param4:* = "+=0") : *
|
||||
{
|
||||
return param2 ? add(new TweenLite(param1,param2,param3),param4) : this.set(param1,param3,param4);
|
||||
}
|
||||
|
||||
public function from(param1:Object, param2:Number, param3:Object, param4:* = "+=0") : *
|
||||
{
|
||||
return add(TweenLite.from(param1,param2,param3),param4);
|
||||
}
|
||||
|
||||
public function fromTo(param1:Object, param2:Number, param3:Object, param4:Object, param5:* = "+=0") : *
|
||||
{
|
||||
return param2 ? add(TweenLite.fromTo(param1,param2,param3,param4),param5) : this.set(param1,param4,param5);
|
||||
}
|
||||
|
||||
public function staggerTo(param1:Array, param2:Number, param3:Object, param4:Number, param5:* = "+=0", param6:Function = null, param7:Array = null) : *
|
||||
{
|
||||
var _loc9_:int = 0;
|
||||
var _loc8_:TimelineLite = new TimelineLite({
|
||||
"onComplete":param6,
|
||||
"onCompleteParams":param7,
|
||||
"smoothChildTiming":this.smoothChildTiming
|
||||
});
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < param1.length)
|
||||
{
|
||||
if(param3.startAt != null)
|
||||
{
|
||||
param3.startAt = _copy(param3.startAt);
|
||||
}
|
||||
_loc8_.to(param1[_loc9_],param2,_copy(param3),_loc9_ * param4);
|
||||
_loc9_++;
|
||||
}
|
||||
return add(_loc8_,param5);
|
||||
}
|
||||
|
||||
public function staggerFrom(param1:Array, param2:Number, param3:Object, param4:Number = 0, param5:* = "+=0", param6:Function = null, param7:Array = null) : *
|
||||
{
|
||||
param3 = _prepVars(param3);
|
||||
if(!("immediateRender" in param3))
|
||||
{
|
||||
param3.immediateRender = true;
|
||||
}
|
||||
param3.runBackwards = true;
|
||||
return staggerTo(param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
public function staggerFromTo(param1:Array, param2:Number, param3:Object, param4:Object, param5:Number = 0, param6:* = "+=0", param7:Function = null, param8:Array = null) : *
|
||||
{
|
||||
param4 = _prepVars(param4);
|
||||
param3 = _prepVars(param3);
|
||||
param4.startAt = param3;
|
||||
param4.immediateRender = param4.immediateRender != false && param3.immediateRender != false;
|
||||
return staggerTo(param1,param2,param4,param5,param6,param7,param8);
|
||||
}
|
||||
|
||||
public function call(param1:Function, param2:Array = null, param3:* = "+=0") : *
|
||||
{
|
||||
return add(TweenLite.delayedCall(0,param1,param2),param3);
|
||||
}
|
||||
|
||||
public function set(param1:Object, param2:Object, param3:* = "+=0") : *
|
||||
{
|
||||
param3 = _parseTimeOrLabel(param3,0,true);
|
||||
param2 = _prepVars(param2);
|
||||
if(param2.immediateRender == null)
|
||||
{
|
||||
param2.immediateRender = param3 === _time && !_paused;
|
||||
}
|
||||
return add(new TweenLite(param1,0,param2),param3);
|
||||
}
|
||||
|
||||
public function addPause(param1:* = "+=0", param2:Function = null, param3:Array = null) : *
|
||||
{
|
||||
return call(_pauseCallback,["{self}",param2,param3],param1);
|
||||
}
|
||||
|
||||
protected function _pauseCallback(param1:TweenLite, param2:Function = null, param3:Array = null) : void
|
||||
{
|
||||
pause(param1._startTime);
|
||||
if(param2 != null)
|
||||
{
|
||||
param2.apply(null,param3);
|
||||
}
|
||||
}
|
||||
|
||||
override public function insert(param1:*, param2:* = 0) : *
|
||||
{
|
||||
return add(param1,param2 || 0);
|
||||
}
|
||||
|
||||
override public function add(param1:*, param2:* = "+=0", param3:String = "normal", param4:Number = 0) : *
|
||||
{
|
||||
var _loc10_:* = undefined;
|
||||
var _loc7_:int = 0;
|
||||
var _loc6_:SimpleTimeline = null;
|
||||
if(typeof param2 !== "number")
|
||||
{
|
||||
param2 = _parseTimeOrLabel(param2,0,true,param1);
|
||||
}
|
||||
if(!(param1 is Animation))
|
||||
{
|
||||
if(param1 is Array)
|
||||
{
|
||||
var _loc5_:Number = param2;
|
||||
var _loc9_:Number = Number(param1.length);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc9_)
|
||||
{
|
||||
_loc10_ = param1[_loc7_];
|
||||
if(_loc10_ is Array)
|
||||
{
|
||||
_loc10_ = new TimelineLite({"tweens":_loc10_});
|
||||
}
|
||||
add(_loc10_,_loc5_);
|
||||
if(!(typeof _loc10_ === "string" || typeof _loc10_ === "function"))
|
||||
{
|
||||
switch(param3)
|
||||
{
|
||||
case "sequence":
|
||||
_loc5_ = _loc10_._startTime + _loc10_.totalDuration() / _loc10_._timeScale;
|
||||
break;
|
||||
case "start":
|
||||
_loc10_._startTime -= _loc10_.delay();
|
||||
}
|
||||
}
|
||||
_loc5_ += param4;
|
||||
_loc7_++;
|
||||
}
|
||||
return _uncache(true);
|
||||
}
|
||||
if(typeof param1 === "string")
|
||||
{
|
||||
return addLabel(String(param1),param2);
|
||||
}
|
||||
if(typeof param1 !== "function")
|
||||
{
|
||||
trace("Cannot add " + param1 + " into the TimelineLite/Max: it is not a tween, timeline, function, or string.");
|
||||
return this;
|
||||
}
|
||||
param1 = TweenLite.delayedCall(0,param1);
|
||||
}
|
||||
super.add(param1,param2);
|
||||
if(_gc || _time === _duration)
|
||||
{
|
||||
if(!_paused)
|
||||
{
|
||||
if(_duration < duration())
|
||||
{
|
||||
_loc6_ = this;
|
||||
var _loc8_:Boolean = _loc6_.rawTime() > param1._startTime;
|
||||
while(_loc6_._timeline)
|
||||
{
|
||||
if(_loc8_ && _loc6_._timeline.smoothChildTiming)
|
||||
{
|
||||
_loc6_.totalTime(_loc6_._totalTime,true);
|
||||
}
|
||||
else if(_loc6_._gc)
|
||||
{
|
||||
_loc6_._enabled(true,false);
|
||||
}
|
||||
_loc6_ = _loc6_._timeline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public function remove(param1:*) : *
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
if(param1 is Animation)
|
||||
{
|
||||
return _remove(param1,false);
|
||||
}
|
||||
if(param1 is Array)
|
||||
{
|
||||
_loc2_ = Number(param1.length);
|
||||
while(--_loc2_ > -1)
|
||||
{
|
||||
remove(param1[_loc2_]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
if(typeof param1 == "string")
|
||||
{
|
||||
return removeLabel(String(param1));
|
||||
}
|
||||
return kill(null,param1);
|
||||
}
|
||||
|
||||
override public function _remove(param1:Animation, param2:Boolean = false) : *
|
||||
{
|
||||
super._remove(param1,param2);
|
||||
if(_last == null)
|
||||
{
|
||||
_time = _totalTime = _duration = _totalDuration = 0;
|
||||
}
|
||||
else if(_time > _last._startTime + _last._totalDuration / _last._timeScale)
|
||||
{
|
||||
_time = duration();
|
||||
_totalTime = _totalDuration;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public function append(param1:*, param2:* = 0) : *
|
||||
{
|
||||
return add(param1,_parseTimeOrLabel(null,param2,true,param1));
|
||||
}
|
||||
|
||||
public function insertMultiple(param1:Array, param2:* = 0, param3:String = "normal", param4:Number = 0) : *
|
||||
{
|
||||
return add(param1,param2 || 0,param3,param4);
|
||||
}
|
||||
|
||||
public function appendMultiple(param1:Array, param2:* = 0, param3:String = "normal", param4:Number = 0) : *
|
||||
{
|
||||
return add(param1,_parseTimeOrLabel(null,param2,true,param1),param3,param4);
|
||||
}
|
||||
|
||||
public function addLabel(param1:String, param2:* = "+=0") : *
|
||||
{
|
||||
_labels[param1] = _parseTimeOrLabel(param2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public function removeLabel(param1:String) : *
|
||||
{
|
||||
delete _labels[param1];
|
||||
return this;
|
||||
}
|
||||
|
||||
public function getLabelTime(param1:String) : Number
|
||||
{
|
||||
return param1 in _labels ? Number(_labels[param1]) : -1;
|
||||
}
|
||||
|
||||
protected function _parseTimeOrLabel(param1:*, param2:* = 0, param3:Boolean = false, param4:Object = null) : Number
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
if(param4 is Animation && param4.timeline === this)
|
||||
{
|
||||
remove(param4);
|
||||
}
|
||||
else if(param4 is Array)
|
||||
{
|
||||
_loc5_ = int(param4.length);
|
||||
while(--_loc5_ > -1)
|
||||
{
|
||||
if(param4[_loc5_] is Animation && param4[_loc5_].timeline === this)
|
||||
{
|
||||
remove(param4[_loc5_]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(typeof param2 === "string")
|
||||
{
|
||||
return _parseTimeOrLabel(param2,param3 && typeof param1 === "number" && !(param2 in _labels) ? param1 - duration() : 0,param3);
|
||||
}
|
||||
param2 ||= 0;
|
||||
if(typeof param1 === "string" && (isNaN(param1) || param1 in _labels))
|
||||
{
|
||||
_loc5_ = int(param1.indexOf("="));
|
||||
if(_loc5_ === -1)
|
||||
{
|
||||
if(!(param1 in _labels))
|
||||
{
|
||||
return param3 ? (_labels[param1] = duration() + param2) : param2;
|
||||
}
|
||||
return _labels[param1] + param2;
|
||||
}
|
||||
param2 = parseInt(param1.charAt(_loc5_ - 1) + "1",10) * Number(param1.substr(_loc5_ + 1));
|
||||
param1 = _loc5_ > 1 ? _parseTimeOrLabel(param1.substr(0,_loc5_ - 1),0,param3) : duration();
|
||||
}
|
||||
else if(param1 == null)
|
||||
{
|
||||
param1 = duration();
|
||||
}
|
||||
return Number(param1) + param2;
|
||||
}
|
||||
|
||||
override public function seek(param1:*, param2:Boolean = true) : *
|
||||
{
|
||||
return totalTime(typeof param1 === "number" ? Number(param1) : _parseTimeOrLabel(param1),param2);
|
||||
}
|
||||
|
||||
public function stop() : *
|
||||
{
|
||||
return paused(true);
|
||||
}
|
||||
|
||||
public function gotoAndPlay(param1:*, param2:Boolean = true) : *
|
||||
{
|
||||
return play(param1,param2);
|
||||
}
|
||||
|
||||
public function gotoAndStop(param1:*, param2:Boolean = true) : *
|
||||
{
|
||||
return pause(param1,param2);
|
||||
}
|
||||
|
||||
override public function render(param1:Number, param2:Boolean = false, param3:Boolean = false) : Boolean
|
||||
{
|
||||
var _loc10_:Animation = null;
|
||||
var _loc13_:Boolean = false;
|
||||
var _loc5_:Animation = null;
|
||||
var _loc12_:String = null;
|
||||
var _loc9_:Boolean = false;
|
||||
if(_gc)
|
||||
{
|
||||
_enabled(true,false);
|
||||
}
|
||||
var _loc8_:Number = Number(!_dirty ? _totalDuration : totalDuration());
|
||||
var _loc7_:Number = _time;
|
||||
var _loc4_:Number = _startTime;
|
||||
var _loc11_:Number = _timeScale;
|
||||
var _loc6_:Boolean = _paused;
|
||||
if(param1 >= _loc8_)
|
||||
{
|
||||
_totalTime = _time = _loc8_;
|
||||
if(!_reversed)
|
||||
{
|
||||
if(!_hasPausedChild())
|
||||
{
|
||||
_loc13_ = true;
|
||||
_loc12_ = "onComplete";
|
||||
if(_duration === 0)
|
||||
{
|
||||
if(param1 === 0 || _rawPrevTime < 0 || _rawPrevTime === _tinyNum)
|
||||
{
|
||||
if(_rawPrevTime !== param1 && _first != null)
|
||||
{
|
||||
_loc9_ = true;
|
||||
if(_rawPrevTime > _tinyNum)
|
||||
{
|
||||
_loc12_ = "onReverseComplete";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_rawPrevTime = _duration !== 0 || !param2 || param1 !== 0 || _rawPrevTime === param1 ? param1 : _tinyNum;
|
||||
param1 = _loc8_ + 0.0001;
|
||||
}
|
||||
else if(param1 < 1e-7)
|
||||
{
|
||||
_totalTime = _time = 0;
|
||||
if(_loc7_ !== 0 || _duration === 0 && _rawPrevTime !== _tinyNum && (_rawPrevTime > 0 || param1 < 0 && _rawPrevTime >= 0))
|
||||
{
|
||||
_loc12_ = "onReverseComplete";
|
||||
_loc13_ = _reversed;
|
||||
}
|
||||
if(param1 < 0)
|
||||
{
|
||||
_active = false;
|
||||
if(_rawPrevTime >= 0 && _first != null)
|
||||
{
|
||||
_loc9_ = true;
|
||||
}
|
||||
_rawPrevTime = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rawPrevTime = _duration || !param2 || param1 !== 0 || _rawPrevTime === param1 ? param1 : _tinyNum;
|
||||
param1 = 0;
|
||||
if(!_initted)
|
||||
{
|
||||
_loc9_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_totalTime = _time = _rawPrevTime = param1;
|
||||
}
|
||||
if((_time == _loc7_ || !_first) && !param3 && !_loc9_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!_initted)
|
||||
{
|
||||
_initted = true;
|
||||
}
|
||||
if(!_active)
|
||||
{
|
||||
if(!_paused && _time !== _loc7_ && param1 > 0)
|
||||
{
|
||||
_active = true;
|
||||
}
|
||||
}
|
||||
if(_loc7_ == 0)
|
||||
{
|
||||
if(vars.onStart)
|
||||
{
|
||||
if(_time != 0)
|
||||
{
|
||||
if(!param2)
|
||||
{
|
||||
vars.onStart.apply(null,vars.onStartParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_time >= _loc7_)
|
||||
{
|
||||
_loc10_ = _first;
|
||||
while(_loc10_)
|
||||
{
|
||||
_loc5_ = _loc10_._next;
|
||||
if(_paused && !_loc6_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(_loc10_._active || _loc10_._startTime <= _time && !_loc10_._paused && !_loc10_._gc)
|
||||
{
|
||||
if(!_loc10_._reversed)
|
||||
{
|
||||
_loc10_.render((param1 - _loc10_._startTime) * _loc10_._timeScale,param2,param3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc10_.render((!_loc10_._dirty ? _loc10_._totalDuration : _loc10_.totalDuration()) - (param1 - _loc10_._startTime) * _loc10_._timeScale,param2,param3);
|
||||
}
|
||||
}
|
||||
_loc10_ = _loc5_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc10_ = _last;
|
||||
while(_loc10_)
|
||||
{
|
||||
_loc5_ = _loc10_._prev;
|
||||
if(_paused && !_loc6_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(_loc10_._active || _loc10_._startTime <= _loc7_ && !_loc10_._paused && !_loc10_._gc)
|
||||
{
|
||||
if(!_loc10_._reversed)
|
||||
{
|
||||
_loc10_.render((param1 - _loc10_._startTime) * _loc10_._timeScale,param2,param3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc10_.render((!_loc10_._dirty ? _loc10_._totalDuration : _loc10_.totalDuration()) - (param1 - _loc10_._startTime) * _loc10_._timeScale,param2,param3);
|
||||
}
|
||||
}
|
||||
_loc10_ = _loc5_;
|
||||
}
|
||||
}
|
||||
if(_onUpdate != null)
|
||||
{
|
||||
if(!param2)
|
||||
{
|
||||
_onUpdate.apply(null,vars.onUpdateParams);
|
||||
}
|
||||
}
|
||||
if(_loc12_)
|
||||
{
|
||||
if(!_gc)
|
||||
{
|
||||
if(_loc4_ == _startTime || _loc11_ != _timeScale)
|
||||
{
|
||||
if(_time == 0 || _loc8_ >= totalDuration())
|
||||
{
|
||||
if(_loc13_)
|
||||
{
|
||||
if(_timeline.autoRemoveChildren)
|
||||
{
|
||||
_enabled(false,false);
|
||||
}
|
||||
_active = false;
|
||||
}
|
||||
if(!param2)
|
||||
{
|
||||
if(vars[_loc12_])
|
||||
{
|
||||
vars[_loc12_].apply(null,vars[_loc12_ + "Params"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function _hasPausedChild() : Boolean
|
||||
{
|
||||
var _loc1_:Animation = _first;
|
||||
while(_loc1_)
|
||||
{
|
||||
if(_loc1_._paused || _loc1_ is TimelineLite && Boolean(TimelineLite(_loc1_)._hasPausedChild()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc1_ = _loc1_._next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getChildren(param1:Boolean = true, param2:Boolean = true, param3:Boolean = true, param4:Number = -9999999999) : Array
|
||||
{
|
||||
var _loc6_:Array = [];
|
||||
var _loc5_:Animation = _first;
|
||||
var _loc7_:int = 0;
|
||||
while(_loc5_)
|
||||
{
|
||||
if(_loc5_._startTime >= param4)
|
||||
{
|
||||
if(_loc5_ is TweenLite)
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_loc6_[_loc7_++] = _loc5_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(param3)
|
||||
{
|
||||
_loc6_[_loc7_++] = _loc5_;
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
_loc6_ = _loc6_.concat(TimelineLite(_loc5_).getChildren(true,param2,param3));
|
||||
_loc7_ = int(_loc6_.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc5_ = _loc5_._next;
|
||||
}
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
public function getTweensOf(param1:Object, param2:Boolean = true) : Array
|
||||
{
|
||||
var _loc4_:Array = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:Boolean = this._gc;
|
||||
var _loc3_:Array = [];
|
||||
var _loc5_:int = 0;
|
||||
if(_loc7_)
|
||||
{
|
||||
_enabled(true,true);
|
||||
}
|
||||
_loc4_ = TweenLite.getTweensOf(param1);
|
||||
_loc6_ = int(_loc4_.length);
|
||||
while(--_loc6_ > -1)
|
||||
{
|
||||
if(_loc4_[_loc6_].timeline === this || param2 && _contains(_loc4_[_loc6_]))
|
||||
{
|
||||
_loc3_[_loc5_++] = _loc4_[_loc6_];
|
||||
}
|
||||
}
|
||||
if(_loc7_)
|
||||
{
|
||||
_enabled(false,true);
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function _contains(param1:Animation) : Boolean
|
||||
{
|
||||
var _loc2_:SimpleTimeline = param1.timeline;
|
||||
while(_loc2_)
|
||||
{
|
||||
if(_loc2_ == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc2_ = _loc2_.timeline;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function shiftChildren(param1:Number, param2:Boolean = false, param3:Number = 0) : *
|
||||
{
|
||||
var _loc5_:Animation = _first;
|
||||
while(_loc5_)
|
||||
{
|
||||
if(_loc5_._startTime >= param3)
|
||||
{
|
||||
_loc5_._startTime += param1;
|
||||
}
|
||||
_loc5_ = _loc5_._next;
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
for(var _loc4_:String in _labels)
|
||||
{
|
||||
if(_labels[_loc4_] >= param3)
|
||||
{
|
||||
var _loc6_:String = _loc4_;
|
||||
var _loc7_:Number = _labels[_loc6_] + param1;
|
||||
_labels[_loc6_] = _loc7_;
|
||||
}
|
||||
}
|
||||
}
|
||||
_uncache(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
override public function _kill(param1:Object = null, param2:Object = null) : Boolean
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
if(param2 == null)
|
||||
{
|
||||
return _enabled(false,false);
|
||||
}
|
||||
}
|
||||
_loc3_ = param2 == null ? getChildren(true,true,false) : getTweensOf(param2);
|
||||
var _loc4_:int = int(_loc3_.length);
|
||||
var _loc5_:Boolean = false;
|
||||
while(--_loc4_ > -1)
|
||||
{
|
||||
if(_loc3_[_loc4_]._kill(param1,param2))
|
||||
{
|
||||
_loc5_ = true;
|
||||
}
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
public function clear(param1:Boolean = true) : *
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
_loc2_ = getChildren(false,true,true);
|
||||
var _loc3_:int = int(_loc2_.length);
|
||||
_time = _totalTime = 0;
|
||||
while(--_loc3_ > -1)
|
||||
{
|
||||
_loc2_[_loc3_]._enabled(false,false);
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
_labels = {};
|
||||
}
|
||||
return _uncache(true);
|
||||
}
|
||||
|
||||
override public function invalidate() : *
|
||||
{
|
||||
var _loc1_:Animation = _first;
|
||||
while(_loc1_)
|
||||
{
|
||||
_loc1_.invalidate();
|
||||
_loc1_ = _loc1_._next;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
override public function _enabled(param1:Boolean, param2:Boolean = false) : Boolean
|
||||
{
|
||||
var _loc3_:Animation = null;
|
||||
if(param1 == _gc)
|
||||
{
|
||||
_loc3_ = _first;
|
||||
while(_loc3_)
|
||||
{
|
||||
_loc3_._enabled(param1,true);
|
||||
_loc3_ = _loc3_._next;
|
||||
}
|
||||
}
|
||||
return super._enabled(param1,param2);
|
||||
}
|
||||
|
||||
override public function duration(param1:Number = NaN) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
if(_dirty)
|
||||
{
|
||||
totalDuration();
|
||||
}
|
||||
return _duration;
|
||||
}
|
||||
if(duration() !== 0)
|
||||
{
|
||||
if(param1 !== 0)
|
||||
{
|
||||
timeScale(_duration / param1);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
override public function totalDuration(param1:Number = NaN) : *
|
||||
{
|
||||
var _loc6_:Animation = null;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
if(!arguments.length)
|
||||
{
|
||||
if(_dirty)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
var _loc4_:Animation = _last;
|
||||
var _loc3_:Number = Infinity;
|
||||
while(_loc4_)
|
||||
{
|
||||
_loc6_ = _loc4_._prev;
|
||||
if(_loc4_._dirty)
|
||||
{
|
||||
_loc4_.totalDuration();
|
||||
}
|
||||
if(_loc4_._startTime > _loc3_ && _sortChildren && !_loc4_._paused)
|
||||
{
|
||||
add(_loc4_,_loc4_._startTime - _loc4_._delay);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = _loc4_._startTime;
|
||||
}
|
||||
if(_loc4_._startTime < 0 && !_loc4_._paused)
|
||||
{
|
||||
_loc5_ -= _loc4_._startTime;
|
||||
if(_timeline.smoothChildTiming)
|
||||
{
|
||||
_startTime += _loc4_._startTime / _timeScale;
|
||||
}
|
||||
shiftChildren(-_loc4_._startTime,false,-9999999999);
|
||||
_loc3_ = 0;
|
||||
}
|
||||
_loc7_ = _loc4_._startTime + _loc4_._totalDuration / _loc4_._timeScale;
|
||||
if(_loc7_ > _loc5_)
|
||||
{
|
||||
_loc5_ = _loc7_;
|
||||
}
|
||||
_loc4_ = _loc6_;
|
||||
}
|
||||
_duration = _totalDuration = _loc5_;
|
||||
_dirty = false;
|
||||
}
|
||||
return _totalDuration;
|
||||
}
|
||||
if(totalDuration() != 0)
|
||||
{
|
||||
if(param1 != 0)
|
||||
{
|
||||
timeScale(_totalDuration / param1);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public function usesFrames() : Boolean
|
||||
{
|
||||
var _loc1_:SimpleTimeline = _timeline;
|
||||
while(_loc1_._timeline)
|
||||
{
|
||||
_loc1_ = _loc1_._timeline;
|
||||
}
|
||||
return _loc1_ == _rootFramesTimeline;
|
||||
}
|
||||
|
||||
override public function rawTime() : Number
|
||||
{
|
||||
return _paused ? _totalTime : (_timeline.rawTime() - _startTime) * _timeScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,937 @@
|
||||
package com.greensock
|
||||
{
|
||||
import com.greensock.core.Animation;
|
||||
import com.greensock.core.PropTween;
|
||||
import com.greensock.core.SimpleTimeline;
|
||||
import com.greensock.events.TweenEvent;
|
||||
import com.greensock.plugins.AutoAlphaPlugin;
|
||||
import com.greensock.plugins.BevelFilterPlugin;
|
||||
import com.greensock.plugins.BezierPlugin;
|
||||
import com.greensock.plugins.BezierThroughPlugin;
|
||||
import com.greensock.plugins.BlurFilterPlugin;
|
||||
import com.greensock.plugins.ColorMatrixFilterPlugin;
|
||||
import com.greensock.plugins.ColorTransformPlugin;
|
||||
import com.greensock.plugins.DropShadowFilterPlugin;
|
||||
import com.greensock.plugins.EndArrayPlugin;
|
||||
import com.greensock.plugins.FrameLabelPlugin;
|
||||
import com.greensock.plugins.FramePlugin;
|
||||
import com.greensock.plugins.GlowFilterPlugin;
|
||||
import com.greensock.plugins.HexColorsPlugin;
|
||||
import com.greensock.plugins.RemoveTintPlugin;
|
||||
import com.greensock.plugins.RoundPropsPlugin;
|
||||
import com.greensock.plugins.ShortRotationPlugin;
|
||||
import com.greensock.plugins.TintPlugin;
|
||||
import com.greensock.plugins.TweenPlugin;
|
||||
import com.greensock.plugins.VisiblePlugin;
|
||||
import com.greensock.plugins.VolumePlugin;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Shape;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IEventDispatcher;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
public class TweenMax extends TweenLite implements IEventDispatcher
|
||||
{
|
||||
|
||||
public static const version:String = "12.1.5";
|
||||
|
||||
protected static var _listenerLookup:Object = {
|
||||
"onCompleteListener":"complete",
|
||||
"onUpdateListener":"change",
|
||||
"onStartListener":"start",
|
||||
"onRepeatListener":"repeat",
|
||||
"onReverseCompleteListener":"reverseComplete"
|
||||
};
|
||||
|
||||
public static var ticker:Shape = Animation.ticker;
|
||||
|
||||
public static var allTo:Function = staggerTo;
|
||||
|
||||
public static var allFrom:Function = staggerFrom;
|
||||
|
||||
public static var allFromTo:Function = staggerFromTo;
|
||||
|
||||
TweenPlugin.activate([AutoAlphaPlugin,EndArrayPlugin,FramePlugin,RemoveTintPlugin,TintPlugin,VisiblePlugin,VolumePlugin,BevelFilterPlugin,BezierPlugin,BezierThroughPlugin,BlurFilterPlugin,ColorMatrixFilterPlugin,ColorTransformPlugin,DropShadowFilterPlugin,FrameLabelPlugin,GlowFilterPlugin,HexColorsPlugin,RoundPropsPlugin,ShortRotationPlugin]);
|
||||
|
||||
protected var _dispatcher:EventDispatcher;
|
||||
|
||||
protected var _hasUpdateListener:Boolean;
|
||||
|
||||
protected var _repeat:int = 0;
|
||||
|
||||
protected var _repeatDelay:Number = 0;
|
||||
|
||||
protected var _cycle:int = 0;
|
||||
|
||||
public var _yoyo:Boolean;
|
||||
|
||||
public function TweenMax(param1:Object, param2:Number, param3:Object)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_yoyo = this.vars.yoyo == true;
|
||||
_repeat = int(this.vars.repeat);
|
||||
_repeatDelay = this.vars.repeatDelay || 0;
|
||||
_dirty = true;
|
||||
if(this.vars.onCompleteListener || this.vars.onUpdateListener || this.vars.onStartListener || this.vars.onRepeatListener || this.vars.onReverseCompleteListener)
|
||||
{
|
||||
_initDispatcher();
|
||||
if(_duration == 0)
|
||||
{
|
||||
if(_delay == 0)
|
||||
{
|
||||
if(this.vars.immediateRender)
|
||||
{
|
||||
_dispatcher.dispatchEvent(new TweenEvent("change"));
|
||||
_dispatcher.dispatchEvent(new TweenEvent("complete"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function killTweensOf(param1:*, param2:* = false, param3:Object = null) : void
|
||||
{
|
||||
TweenLite.killTweensOf(param1,param2,param3);
|
||||
}
|
||||
|
||||
public static function killDelayedCallsTo(param1:Function) : void
|
||||
{
|
||||
TweenLite.killTweensOf(param1);
|
||||
}
|
||||
|
||||
public static function getTweensOf(param1:*, param2:Boolean = false) : Array
|
||||
{
|
||||
return TweenLite.getTweensOf(param1,param2);
|
||||
}
|
||||
|
||||
public static function to(param1:Object, param2:Number, param3:Object) : TweenMax
|
||||
{
|
||||
return new TweenMax(param1,param2,param3);
|
||||
}
|
||||
|
||||
public static function from(param1:Object, param2:Number, param3:Object) : TweenMax
|
||||
{
|
||||
param3 = _prepVars(param3,true);
|
||||
param3.runBackwards = true;
|
||||
return new TweenMax(param1,param2,param3);
|
||||
}
|
||||
|
||||
public static function fromTo(param1:Object, param2:Number, param3:Object, param4:Object) : TweenMax
|
||||
{
|
||||
param4 = _prepVars(param4,false);
|
||||
param3 = _prepVars(param3,false);
|
||||
param4.startAt = param3;
|
||||
param4.immediateRender = param4.immediateRender != false && param3.immediateRender != false;
|
||||
return new TweenMax(param1,param2,param4);
|
||||
}
|
||||
|
||||
public static function staggerTo(param1:Array, param2:Number, param3:Object, param4:Number = 0, param5:Function = null, param6:Array = null) : Array
|
||||
{
|
||||
var copy:Object;
|
||||
var p:String;
|
||||
var targets:Array = param1;
|
||||
var duration:Number = param2;
|
||||
var vars:Object = param3;
|
||||
var stagger:Number = param4;
|
||||
var onCompleteAll:Function = param5;
|
||||
var onCompleteAllParams:Array = param6;
|
||||
vars = _prepVars(vars,false);
|
||||
var a:Array = [];
|
||||
var l:int = int(targets.length);
|
||||
var delay:Number = Number(vars.delay || 0);
|
||||
var i:int = 0;
|
||||
while(i < l)
|
||||
{
|
||||
copy = {};
|
||||
for(p in vars)
|
||||
{
|
||||
copy[p] = vars[p];
|
||||
}
|
||||
copy.delay = delay;
|
||||
if(i == l - 1)
|
||||
{
|
||||
if(onCompleteAll != null)
|
||||
{
|
||||
copy.onComplete = function():void
|
||||
{
|
||||
if(vars.onComplete)
|
||||
{
|
||||
vars.onComplete.apply(null,arguments);
|
||||
}
|
||||
onCompleteAll.apply(null,onCompleteAllParams);
|
||||
};
|
||||
}
|
||||
}
|
||||
a[i] = new TweenMax(targets[i],duration,copy);
|
||||
delay += stagger;
|
||||
i = i + 1;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public static function staggerFrom(param1:Array, param2:Number, param3:Object, param4:Number = 0, param5:Function = null, param6:Array = null) : Array
|
||||
{
|
||||
param3 = _prepVars(param3,true);
|
||||
param3.runBackwards = true;
|
||||
if(param3.immediateRender != false)
|
||||
{
|
||||
param3.immediateRender = true;
|
||||
}
|
||||
return staggerTo(param1,param2,param3,param4,param5,param6);
|
||||
}
|
||||
|
||||
public static function staggerFromTo(param1:Array, param2:Number, param3:Object, param4:Object, param5:Number = 0, param6:Function = null, param7:Array = null) : Array
|
||||
{
|
||||
param4 = _prepVars(param4,false);
|
||||
param3 = _prepVars(param3,false);
|
||||
param4.startAt = param3;
|
||||
param4.immediateRender = param4.immediateRender != false && param3.immediateRender != false;
|
||||
return staggerTo(param1,param2,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
public static function delayedCall(param1:Number, param2:Function, param3:Array = null, param4:Boolean = false) : TweenMax
|
||||
{
|
||||
return new TweenMax(param2,0,{
|
||||
"delay":param1,
|
||||
"onComplete":param2,
|
||||
"onCompleteParams":param3,
|
||||
"onReverseComplete":param2,
|
||||
"onReverseCompleteParams":param3,
|
||||
"immediateRender":false,
|
||||
"useFrames":param4,
|
||||
"overwrite":0
|
||||
});
|
||||
}
|
||||
|
||||
public static function set(param1:Object, param2:Object) : TweenMax
|
||||
{
|
||||
return new TweenMax(param1,0,param2);
|
||||
}
|
||||
|
||||
public static function isTweening(param1:Object) : Boolean
|
||||
{
|
||||
return TweenLite.getTweensOf(param1,true).length > 0;
|
||||
}
|
||||
|
||||
public static function getAllTweens(param1:Boolean = false) : Array
|
||||
{
|
||||
var _loc2_:Array = _getChildrenOf(_rootTimeline,param1);
|
||||
return _loc2_.concat(_getChildrenOf(_rootFramesTimeline,param1));
|
||||
}
|
||||
|
||||
protected static function _getChildrenOf(param1:SimpleTimeline, param2:Boolean) : Array
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
var _loc4_:Array = [];
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:Animation = param1._first;
|
||||
while(_loc3_)
|
||||
{
|
||||
if(_loc3_ is TweenLite)
|
||||
{
|
||||
_loc4_[_loc5_++] = _loc3_;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_loc4_[_loc5_++] = _loc3_;
|
||||
}
|
||||
_loc4_ = _loc4_.concat(_getChildrenOf(SimpleTimeline(_loc3_),param2));
|
||||
_loc5_ = int(_loc4_.length);
|
||||
}
|
||||
_loc3_ = _loc3_._next;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
public static function killAll(param1:Boolean = false, param2:Boolean = true, param3:Boolean = true, param4:Boolean = true) : void
|
||||
{
|
||||
var _loc7_:Boolean = false;
|
||||
var _loc6_:Animation = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc5_:Array = null;
|
||||
_loc5_ = getAllTweens(param4);
|
||||
var _loc9_:int = int(_loc5_.length);
|
||||
var _loc10_:Boolean = param2 && param3 && param4;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc9_)
|
||||
{
|
||||
_loc6_ = _loc5_[_loc8_];
|
||||
if(_loc10_ || _loc6_ is SimpleTimeline || _loc7_ == (TweenLite(_loc6_).target == TweenLite(_loc6_).vars.onComplete) && param3 || param2 && !_loc7_)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_loc6_.totalTime(_loc6_._reversed ? 0 : _loc6_.totalDuration());
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_._enabled(false,false);
|
||||
}
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
|
||||
public static function killChildTweensOf(param1:DisplayObjectContainer, param2:Boolean = false) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:Array = null;
|
||||
_loc3_ = getAllTweens(false);
|
||||
var _loc5_:int = int(_loc3_.length);
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc5_)
|
||||
{
|
||||
if(_containsChildOf(param1,_loc3_[_loc4_].target))
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_loc3_[_loc4_].totalTime(_loc3_[_loc4_].totalDuration());
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_[_loc4_]._enabled(false,false);
|
||||
}
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
|
||||
private static function _containsChildOf(param1:DisplayObjectContainer, param2:Object) : Boolean
|
||||
{
|
||||
var _loc4_:DisplayObjectContainer = null;
|
||||
var _loc3_:int = 0;
|
||||
if(param2 is Array)
|
||||
{
|
||||
_loc3_ = int(param2.length);
|
||||
while(--_loc3_ > -1)
|
||||
{
|
||||
if(_containsChildOf(param1,param2[_loc3_]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(param2 is DisplayObject)
|
||||
{
|
||||
_loc4_ = param2.parent;
|
||||
while(_loc4_)
|
||||
{
|
||||
if(_loc4_ == param1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc4_ = _loc4_.parent;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function pauseAll(param1:Boolean = true, param2:Boolean = true, param3:Boolean = true) : void
|
||||
{
|
||||
_changePause(true,param1,param2,param3);
|
||||
}
|
||||
|
||||
public static function resumeAll(param1:Boolean = true, param2:Boolean = true, param3:Boolean = true) : void
|
||||
{
|
||||
_changePause(false,param1,param2,param3);
|
||||
}
|
||||
|
||||
private static function _changePause(param1:Boolean, param2:Boolean = true, param3:Boolean = false, param4:Boolean = true) : void
|
||||
{
|
||||
var _loc7_:Boolean = false;
|
||||
var _loc5_:Animation = null;
|
||||
var _loc6_:Array = null;
|
||||
_loc6_ = getAllTweens(param4);
|
||||
var _loc9_:Boolean = param2 && param3 && param4;
|
||||
var _loc8_:int = int(_loc6_.length);
|
||||
while(--_loc8_ > -1)
|
||||
{
|
||||
_loc5_ = _loc6_[_loc8_];
|
||||
_loc7_ = _loc5_ is TweenLite && TweenLite(_loc5_).target == _loc5_.vars.onComplete;
|
||||
if(_loc9_ || _loc5_ is SimpleTimeline || _loc7_ && param3 || param2 && !_loc7_)
|
||||
{
|
||||
_loc5_.paused(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function globalTimeScale(param1:Number = NaN) : Number
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _rootTimeline == null ? 1 : _rootTimeline._timeScale;
|
||||
}
|
||||
param1 ||= 0.0001;
|
||||
if(_rootTimeline == null)
|
||||
{
|
||||
TweenLite.to({},0,{});
|
||||
}
|
||||
var _loc4_:SimpleTimeline = _rootTimeline;
|
||||
var _loc3_:Number = getTimer() / 1000;
|
||||
_loc4_._startTime = _loc3_ - (_loc3_ - _loc4_._startTime) * _loc4_._timeScale / param1;
|
||||
_loc4_ = _rootFramesTimeline;
|
||||
_loc3_ = _rootFrame;
|
||||
_loc4_._startTime = _loc3_ - (_loc3_ - _loc4_._startTime) * _loc4_._timeScale / param1;
|
||||
_rootFramesTimeline._timeScale = _rootTimeline._timeScale = param1;
|
||||
return param1;
|
||||
}
|
||||
|
||||
override public function invalidate() : *
|
||||
{
|
||||
_yoyo = this.vars.yoyo == true;
|
||||
_repeat = this.vars.repeat || 0;
|
||||
_repeatDelay = this.vars.repeatDelay || 0;
|
||||
_hasUpdateListener = false;
|
||||
_initDispatcher();
|
||||
_uncache(true);
|
||||
return super.invalidate();
|
||||
}
|
||||
|
||||
public function updateTo(param1:Object, param2:Boolean = false) : *
|
||||
{
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc8_:Number = ratio;
|
||||
if(param2)
|
||||
{
|
||||
if(_startTime < _timeline._time)
|
||||
{
|
||||
_startTime = _timeline._time;
|
||||
_uncache(false);
|
||||
if(_gc)
|
||||
{
|
||||
_enabled(true,false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_timeline.insert(this,_startTime - _delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(var _loc3_:String in param1)
|
||||
{
|
||||
this.vars[_loc3_] = param1[_loc3_];
|
||||
}
|
||||
if(_initted)
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_initted = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_gc)
|
||||
{
|
||||
_enabled(true,false);
|
||||
}
|
||||
if(_notifyPluginsOfEnabled)
|
||||
{
|
||||
if(_firstPT != null)
|
||||
{
|
||||
_onPluginEvent("_onDisable",this);
|
||||
}
|
||||
}
|
||||
if(_time / _duration > 0.998)
|
||||
{
|
||||
_loc7_ = _time;
|
||||
render(0,true,false);
|
||||
_initted = false;
|
||||
render(_loc7_,true,false);
|
||||
}
|
||||
else if(_time > 0)
|
||||
{
|
||||
_initted = false;
|
||||
_init();
|
||||
_loc4_ = 1 / (1 - _loc8_);
|
||||
var _loc5_:PropTween = _firstPT;
|
||||
while(_loc5_)
|
||||
{
|
||||
_loc6_ = _loc5_.s + _loc5_.c;
|
||||
_loc5_.c *= _loc4_;
|
||||
_loc5_.s = _loc6_ - _loc5_.c;
|
||||
_loc5_ = _loc5_._next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
override public function render(param1:Number, param2:Boolean = false, param3:Boolean = false) : Boolean
|
||||
{
|
||||
var _loc15_:Boolean = false;
|
||||
var _loc13_:String = null;
|
||||
var _loc5_:PropTween = null;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
if(!_initted)
|
||||
{
|
||||
if(_duration === 0 && vars.repeat)
|
||||
{
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
var _loc7_:Number = Number(!_dirty ? _totalDuration : totalDuration());
|
||||
var _loc6_:Number = _time;
|
||||
var _loc9_:Number = _totalTime;
|
||||
var _loc4_:Number = _cycle;
|
||||
if(param1 >= _loc7_)
|
||||
{
|
||||
_totalTime = _loc7_;
|
||||
_cycle = _repeat;
|
||||
if(_yoyo && (_cycle & 1) != 0)
|
||||
{
|
||||
_time = 0;
|
||||
ratio = _ease._calcEnd ? _ease.getRatio(0) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_time = _duration;
|
||||
ratio = _ease._calcEnd ? _ease.getRatio(1) : 1;
|
||||
}
|
||||
if(!_reversed)
|
||||
{
|
||||
_loc15_ = true;
|
||||
_loc13_ = "onComplete";
|
||||
}
|
||||
if(_duration == 0)
|
||||
{
|
||||
_loc12_ = _rawPrevTime;
|
||||
if(_startTime === _timeline._duration)
|
||||
{
|
||||
param1 = 0;
|
||||
}
|
||||
if(param1 === 0 || _loc12_ < 0 || _loc12_ === _tinyNum)
|
||||
{
|
||||
if(_loc12_ !== param1)
|
||||
{
|
||||
param3 = true;
|
||||
if(_loc12_ > _tinyNum)
|
||||
{
|
||||
_loc13_ = "onReverseComplete";
|
||||
}
|
||||
}
|
||||
}
|
||||
_rawPrevTime = _loc12_ = !param2 || param1 !== 0 || _rawPrevTime === param1 ? param1 : _tinyNum;
|
||||
}
|
||||
}
|
||||
else if(param1 < 1e-7)
|
||||
{
|
||||
_totalTime = _time = _cycle = 0;
|
||||
ratio = _ease._calcEnd ? _ease.getRatio(0) : 0;
|
||||
if(_loc9_ !== 0 || _duration === 0 && _rawPrevTime > 0 && _rawPrevTime !== _tinyNum)
|
||||
{
|
||||
_loc13_ = "onReverseComplete";
|
||||
_loc15_ = _reversed;
|
||||
}
|
||||
if(param1 < 0)
|
||||
{
|
||||
_active = false;
|
||||
if(_duration == 0)
|
||||
{
|
||||
if(_rawPrevTime >= 0)
|
||||
{
|
||||
param3 = true;
|
||||
}
|
||||
_rawPrevTime = _loc12_ = !param2 || param1 !== 0 || _rawPrevTime === param1 ? param1 : _tinyNum;
|
||||
}
|
||||
}
|
||||
else if(!_initted)
|
||||
{
|
||||
param3 = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_totalTime = _time = param1;
|
||||
if(_repeat != 0)
|
||||
{
|
||||
_loc11_ = _duration + _repeatDelay;
|
||||
_cycle = _totalTime / _loc11_ >> 0;
|
||||
if(_cycle !== 0)
|
||||
{
|
||||
if(_cycle === _totalTime / _loc11_)
|
||||
{
|
||||
_cycle = _cycle - 1;
|
||||
}
|
||||
}
|
||||
_time = _totalTime - _cycle * _loc11_;
|
||||
if(_yoyo)
|
||||
{
|
||||
if((_cycle & 1) != 0)
|
||||
{
|
||||
_time = _duration - _time;
|
||||
}
|
||||
}
|
||||
if(_time > _duration)
|
||||
{
|
||||
_time = _duration;
|
||||
}
|
||||
else if(_time < 0)
|
||||
{
|
||||
_time = 0;
|
||||
}
|
||||
}
|
||||
if(_easeType)
|
||||
{
|
||||
_loc10_ = _time / _duration;
|
||||
var _loc8_:int = _easeType;
|
||||
var _loc14_:int = _easePower;
|
||||
if(_loc8_ == 1 || _loc8_ == 3 && _loc10_ >= 0.5)
|
||||
{
|
||||
_loc10_ = 1 - _loc10_;
|
||||
}
|
||||
if(_loc8_ == 3)
|
||||
{
|
||||
_loc10_ *= 2;
|
||||
}
|
||||
if(_loc14_ == 1)
|
||||
{
|
||||
_loc10_ *= _loc10_;
|
||||
}
|
||||
else if(_loc14_ == 2)
|
||||
{
|
||||
_loc10_ *= _loc10_ * _loc10_;
|
||||
}
|
||||
else if(_loc14_ == 3)
|
||||
{
|
||||
_loc10_ *= _loc10_ * _loc10_ * _loc10_;
|
||||
}
|
||||
else if(_loc14_ == 4)
|
||||
{
|
||||
_loc10_ *= _loc10_ * _loc10_ * _loc10_ * _loc10_;
|
||||
}
|
||||
if(_loc8_ == 1)
|
||||
{
|
||||
ratio = 1 - _loc10_;
|
||||
}
|
||||
else if(_loc8_ == 2)
|
||||
{
|
||||
ratio = _loc10_;
|
||||
}
|
||||
else if(_time / _duration < 0.5)
|
||||
{
|
||||
ratio = _loc10_ / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
ratio = 1 - _loc10_ / 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ratio = _ease.getRatio(_time / _duration);
|
||||
}
|
||||
}
|
||||
if(_loc6_ == _time && !param3 && _cycle === _loc4_)
|
||||
{
|
||||
if(_loc9_ !== _totalTime)
|
||||
{
|
||||
if(_onUpdate != null)
|
||||
{
|
||||
if(!param2)
|
||||
{
|
||||
_onUpdate.apply(vars.onUpdateScope || this,vars.onUpdateParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(!_initted)
|
||||
{
|
||||
_init();
|
||||
if(!_initted || _gc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(_time && !_loc15_)
|
||||
{
|
||||
ratio = _ease.getRatio(_time / _duration);
|
||||
}
|
||||
else if(_loc15_ && _ease._calcEnd)
|
||||
{
|
||||
ratio = _ease.getRatio(_time === 0 ? 0 : 1);
|
||||
}
|
||||
}
|
||||
if(!_active)
|
||||
{
|
||||
if(!_paused && _time !== _loc6_ && param1 >= 0)
|
||||
{
|
||||
_active = true;
|
||||
}
|
||||
}
|
||||
if(_loc9_ == 0)
|
||||
{
|
||||
if(_startAt != null)
|
||||
{
|
||||
if(param1 >= 0)
|
||||
{
|
||||
_startAt.render(param1,param2,param3);
|
||||
}
|
||||
else if(!_loc13_)
|
||||
{
|
||||
_loc13_ = "_dummyGS";
|
||||
}
|
||||
}
|
||||
if(_totalTime != 0 || _duration == 0)
|
||||
{
|
||||
if(!param2)
|
||||
{
|
||||
if(vars.onStart)
|
||||
{
|
||||
vars.onStart.apply(null,vars.onStartParams);
|
||||
}
|
||||
if(_dispatcher)
|
||||
{
|
||||
_dispatcher.dispatchEvent(new TweenEvent("start"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc5_ = _firstPT;
|
||||
while(_loc5_)
|
||||
{
|
||||
if(_loc5_.f)
|
||||
{
|
||||
_loc5_.t[_loc5_.p](_loc5_.c * ratio + _loc5_.s);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_.t[_loc5_.p] = _loc5_.c * ratio + _loc5_.s;
|
||||
}
|
||||
_loc5_ = _loc5_._next;
|
||||
}
|
||||
if(_onUpdate != null)
|
||||
{
|
||||
if(param1 < 0 && _startAt != null && _startTime != 0)
|
||||
{
|
||||
_startAt.render(param1,param2,param3);
|
||||
}
|
||||
if(!param2)
|
||||
{
|
||||
if(_totalTime !== _loc9_ || _loc15_)
|
||||
{
|
||||
_onUpdate.apply(null,vars.onUpdateParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_hasUpdateListener)
|
||||
{
|
||||
if(param1 < 0 && _startAt != null && _onUpdate == null && _startTime != 0)
|
||||
{
|
||||
_startAt.render(param1,param2,param3);
|
||||
}
|
||||
if(!param2)
|
||||
{
|
||||
_dispatcher.dispatchEvent(new TweenEvent("change"));
|
||||
}
|
||||
}
|
||||
if(_cycle != _loc4_)
|
||||
{
|
||||
if(!param2)
|
||||
{
|
||||
if(!_gc)
|
||||
{
|
||||
if(vars.onRepeat)
|
||||
{
|
||||
vars.onRepeat.apply(null,vars.onRepeatParams);
|
||||
}
|
||||
if(_dispatcher)
|
||||
{
|
||||
_dispatcher.dispatchEvent(new TweenEvent("repeat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_loc13_)
|
||||
{
|
||||
if(!_gc)
|
||||
{
|
||||
if(param1 < 0 && _startAt != null && _onUpdate == null && !_hasUpdateListener && _startTime != 0)
|
||||
{
|
||||
_startAt.render(param1,param2,true);
|
||||
}
|
||||
if(_loc15_)
|
||||
{
|
||||
if(_timeline.autoRemoveChildren)
|
||||
{
|
||||
_enabled(false,false);
|
||||
}
|
||||
_active = false;
|
||||
}
|
||||
if(!param2)
|
||||
{
|
||||
if(vars[_loc13_])
|
||||
{
|
||||
vars[_loc13_].apply(null,vars[_loc13_ + "Params"]);
|
||||
}
|
||||
if(_dispatcher)
|
||||
{
|
||||
_dispatcher.dispatchEvent(new TweenEvent(_loc13_ == "onComplete" ? "complete" : "reverseComplete"));
|
||||
}
|
||||
}
|
||||
if(_duration === 0 && _rawPrevTime === _tinyNum && _loc12_ !== _tinyNum)
|
||||
{
|
||||
_rawPrevTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function _initDispatcher() : Boolean
|
||||
{
|
||||
var _loc1_:String = null;
|
||||
var _loc2_:Boolean = false;
|
||||
for(_loc1_ in _listenerLookup)
|
||||
{
|
||||
if(_loc1_ in vars)
|
||||
{
|
||||
if(vars[_loc1_] is Function)
|
||||
{
|
||||
if(_dispatcher == null)
|
||||
{
|
||||
_dispatcher = new EventDispatcher(this);
|
||||
}
|
||||
_dispatcher.addEventListener(_listenerLookup[_loc1_],vars[_loc1_],false,0,true);
|
||||
_loc2_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function addEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
|
||||
{
|
||||
if(_dispatcher == null)
|
||||
{
|
||||
_dispatcher = new EventDispatcher(this);
|
||||
}
|
||||
if(param1 == "change")
|
||||
{
|
||||
_hasUpdateListener = true;
|
||||
}
|
||||
_dispatcher.addEventListener(param1,param2,param3,param4,param5);
|
||||
}
|
||||
|
||||
public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
|
||||
{
|
||||
if(_dispatcher)
|
||||
{
|
||||
_dispatcher.removeEventListener(param1,param2,param3);
|
||||
}
|
||||
}
|
||||
|
||||
public function hasEventListener(param1:String) : Boolean
|
||||
{
|
||||
return _dispatcher == null ? false : _dispatcher.hasEventListener(param1);
|
||||
}
|
||||
|
||||
public function willTrigger(param1:String) : Boolean
|
||||
{
|
||||
return _dispatcher == null ? false : _dispatcher.willTrigger(param1);
|
||||
}
|
||||
|
||||
public function dispatchEvent(param1:Event) : Boolean
|
||||
{
|
||||
return _dispatcher == null ? false : _dispatcher.dispatchEvent(param1);
|
||||
}
|
||||
|
||||
override public function progress(param1:Number = NaN, param2:Boolean = false) : *
|
||||
{
|
||||
return !arguments.length ? _time / duration() : totalTime(duration() * (_yoyo && (_cycle & 1) !== 0 ? 1 - param1 : param1) + _cycle * (_duration + _repeatDelay),param2);
|
||||
}
|
||||
|
||||
override public function totalProgress(param1:Number = NaN, param2:Boolean = false) : *
|
||||
{
|
||||
return !arguments.length ? _totalTime / totalDuration() : totalTime(totalDuration() * param1,param2);
|
||||
}
|
||||
|
||||
override public function time(param1:Number = NaN, param2:Boolean = false) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
if(_dirty)
|
||||
{
|
||||
totalDuration();
|
||||
}
|
||||
if(param1 > _duration)
|
||||
{
|
||||
param1 = _duration;
|
||||
}
|
||||
if(_yoyo && (_cycle & 1) !== 0)
|
||||
{
|
||||
param1 = _duration - param1 + _cycle * (_duration + _repeatDelay);
|
||||
}
|
||||
else if(_repeat != 0)
|
||||
{
|
||||
param1 += _cycle * (_duration + _repeatDelay);
|
||||
}
|
||||
return totalTime(param1,param2);
|
||||
}
|
||||
|
||||
override public function duration(param1:Number = NaN) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return this._duration;
|
||||
}
|
||||
return super.duration(param1);
|
||||
}
|
||||
|
||||
override public function totalDuration(param1:Number = NaN) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
if(_dirty)
|
||||
{
|
||||
_totalDuration = _repeat == -1 ? 999999999999 : _duration * (_repeat + 1) + _repeatDelay * _repeat;
|
||||
_dirty = false;
|
||||
}
|
||||
return _totalDuration;
|
||||
}
|
||||
return _repeat == -1 ? this : duration((param1 - _repeat * _repeatDelay) / (_repeat + 1));
|
||||
}
|
||||
|
||||
public function repeat(param1:int = 0) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _repeat;
|
||||
}
|
||||
_repeat = param1;
|
||||
return _uncache(true);
|
||||
}
|
||||
|
||||
public function repeatDelay(param1:Number = NaN) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _repeatDelay;
|
||||
}
|
||||
_repeatDelay = param1;
|
||||
return _uncache(true);
|
||||
}
|
||||
|
||||
public function yoyo(param1:Boolean = false) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _yoyo;
|
||||
}
|
||||
_yoyo = param1;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,480 @@
|
||||
package com.greensock.core
|
||||
{
|
||||
import flash.display.Shape;
|
||||
import flash.events.Event;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
public class Animation
|
||||
{
|
||||
|
||||
public static const version:String = "12.1.1";
|
||||
|
||||
public static var _rootTimeline:SimpleTimeline;
|
||||
|
||||
public static var _rootFramesTimeline:SimpleTimeline;
|
||||
|
||||
protected static var _rootFrame:Number = -1;
|
||||
|
||||
protected static var _tinyNum:Number = 1e-10;
|
||||
|
||||
public static var ticker:Shape = new Shape();
|
||||
|
||||
protected static var _tickEvent:Event = new Event("tick");
|
||||
|
||||
protected var _onUpdate:Function;
|
||||
|
||||
public var _delay:Number;
|
||||
|
||||
public var _rawPrevTime:Number;
|
||||
|
||||
public var _active:Boolean;
|
||||
|
||||
public var _gc:Boolean;
|
||||
|
||||
public var _initted:Boolean;
|
||||
|
||||
public var _startTime:Number;
|
||||
|
||||
public var _time:Number;
|
||||
|
||||
public var _totalTime:Number;
|
||||
|
||||
public var _duration:Number;
|
||||
|
||||
public var _totalDuration:Number;
|
||||
|
||||
public var _pauseTime:Number;
|
||||
|
||||
public var _timeScale:Number;
|
||||
|
||||
public var _reversed:Boolean;
|
||||
|
||||
public var _timeline:SimpleTimeline;
|
||||
|
||||
public var _dirty:Boolean;
|
||||
|
||||
public var _paused:Boolean;
|
||||
|
||||
public var _next:Animation;
|
||||
|
||||
public var _prev:Animation;
|
||||
|
||||
public var vars:Object;
|
||||
|
||||
public var timeline:SimpleTimeline;
|
||||
|
||||
public var data:*;
|
||||
|
||||
public function Animation(param1:Number = 0, param2:Object = null)
|
||||
{
|
||||
super();
|
||||
this.vars = param2 || {};
|
||||
if(this.vars._isGSVars)
|
||||
{
|
||||
this.vars = this.vars.vars;
|
||||
}
|
||||
_duration = _totalDuration = param1 || 0;
|
||||
_delay = Number(this.vars.delay) || 0;
|
||||
_timeScale = 1;
|
||||
_totalTime = _time = 0;
|
||||
data = this.vars.data;
|
||||
_rawPrevTime = -1;
|
||||
if(_rootTimeline == null)
|
||||
{
|
||||
if(_rootFrame != -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_rootFrame = 0;
|
||||
_rootFramesTimeline = new SimpleTimeline();
|
||||
_rootTimeline = new SimpleTimeline();
|
||||
_rootTimeline._startTime = getTimer() / 1000;
|
||||
_rootFramesTimeline._startTime = 0;
|
||||
_rootTimeline._active = _rootFramesTimeline._active = true;
|
||||
ticker.addEventListener("enterFrame",_updateRoot,false,0,true);
|
||||
}
|
||||
var _loc3_:SimpleTimeline = this.vars.useFrames ? _rootFramesTimeline : _rootTimeline;
|
||||
_loc3_.add(this,_loc3_._time);
|
||||
_reversed = this.vars.reversed == true;
|
||||
if(this.vars.paused)
|
||||
{
|
||||
paused(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static function _updateRoot(param1:Event = null) : void
|
||||
{
|
||||
_rootFrame = _rootFrame + 1;
|
||||
if(_rootTimeline.renderCreateTime(_rootTimeline._startTime,_rootTimeline._timeScale,false,false) && _rootFramesTimeline.render((_rootFrame - _rootFramesTimeline._startTime) * _rootFramesTimeline._timeScale,false,false))
|
||||
{
|
||||
ticker.dispatchEvent(_tickEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public function play(param1:* = null, param2:Boolean = true) : *
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
seek(param1,param2);
|
||||
}
|
||||
reversed(false);
|
||||
return paused(false);
|
||||
}
|
||||
|
||||
public function pause(param1:* = null, param2:Boolean = true) : *
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
seek(param1,param2);
|
||||
}
|
||||
return paused(true);
|
||||
}
|
||||
|
||||
public function resume(param1:* = null, param2:Boolean = true) : *
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
seek(param1,param2);
|
||||
}
|
||||
return paused(false);
|
||||
}
|
||||
|
||||
public function seek(param1:*, param2:Boolean = true) : *
|
||||
{
|
||||
return totalTime(Number(param1),param2);
|
||||
}
|
||||
|
||||
public function restart(param1:Boolean = false, param2:Boolean = true) : *
|
||||
{
|
||||
reversed(false);
|
||||
paused(false);
|
||||
return totalTime(param1 ? -_delay : 0,param2,true);
|
||||
}
|
||||
|
||||
public function reverse(param1:* = null, param2:Boolean = true) : *
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
seek(param1 || totalDuration(),param2);
|
||||
}
|
||||
reversed(true);
|
||||
return paused(false);
|
||||
}
|
||||
|
||||
public function render(param1:Number, param2:Boolean = false, param3:Boolean = false) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function renderCreateTime(param1:Number, param2:Number, param3:Boolean = false, param4:Boolean = false) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function invalidate() : *
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public function isActive() : Boolean
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
var _loc2_:SimpleTimeline = _timeline;
|
||||
return _loc2_ == null || !_gc && !_paused && _loc2_.isActive() && (_loc1_ = _loc2_.rawTime()) >= _startTime && _loc1_ < _startTime + totalDuration() / _timeScale;
|
||||
}
|
||||
|
||||
public function _enabled(param1:Boolean, param2:Boolean = false) : Boolean
|
||||
{
|
||||
_gc = !param1;
|
||||
_active = param1 && !_paused && _totalTime > 0 && _totalTime < _totalDuration;
|
||||
if(!param2)
|
||||
{
|
||||
if(param1 && timeline == null)
|
||||
{
|
||||
_timeline.add(this,_startTime - _delay);
|
||||
}
|
||||
else if(!param1 && timeline != null)
|
||||
{
|
||||
_timeline._remove(this,true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _kill(param1:Object = null, param2:Object = null) : Boolean
|
||||
{
|
||||
return _enabled(false,false);
|
||||
}
|
||||
|
||||
public function kill(param1:Object = null, param2:Object = null) : *
|
||||
{
|
||||
_kill(param1,param2);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected function _uncache(param1:Boolean) : *
|
||||
{
|
||||
var _loc2_:Animation = param1 ? this : timeline;
|
||||
while(_loc2_)
|
||||
{
|
||||
_loc2_._dirty = true;
|
||||
_loc2_ = _loc2_.timeline;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
protected function _swapSelfInParams(param1:Array) : Array
|
||||
{
|
||||
var _loc2_:int = int(param1.length);
|
||||
var _loc3_:Array = param1.concat();
|
||||
while(--_loc2_ > -1)
|
||||
{
|
||||
if(param1[_loc2_] === "{self}")
|
||||
{
|
||||
_loc3_[_loc2_] = this;
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function eventCallback(param1:String, param2:Function = null, param3:Array = null) : *
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(param1.substr(0,2) == "on")
|
||||
{
|
||||
if(arguments.length == 1)
|
||||
{
|
||||
return vars[param1];
|
||||
}
|
||||
if(param2 == null)
|
||||
{
|
||||
delete vars[param1];
|
||||
}
|
||||
else
|
||||
{
|
||||
vars[param1] = param2;
|
||||
vars[param1 + "Params"] = param3 is Array && param3.join("").indexOf("{self}") !== -1 ? _swapSelfInParams(param3) : param3;
|
||||
}
|
||||
if(param1 == "onUpdate")
|
||||
{
|
||||
_onUpdate = param2;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public function delay(param1:Number = NaN) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _delay;
|
||||
}
|
||||
if(_timeline.smoothChildTiming)
|
||||
{
|
||||
startTime(_startTime + param1 - _delay);
|
||||
}
|
||||
_delay = param1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public function duration(param1:Number = NaN) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
_dirty = false;
|
||||
return _duration;
|
||||
}
|
||||
_duration = _totalDuration = param1;
|
||||
_uncache(true);
|
||||
if(_timeline.smoothChildTiming)
|
||||
{
|
||||
if(_time > 0)
|
||||
{
|
||||
if(_time < _duration)
|
||||
{
|
||||
if(param1 != 0)
|
||||
{
|
||||
totalTime(_totalTime * (param1 / _duration),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public function totalDuration(param1:Number = NaN) : *
|
||||
{
|
||||
_dirty = false;
|
||||
return !arguments.length ? _totalDuration : duration(param1);
|
||||
}
|
||||
|
||||
public function time(param1:Number = NaN, param2:Boolean = false) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
if(_dirty)
|
||||
{
|
||||
totalDuration();
|
||||
}
|
||||
if(param1 > _duration)
|
||||
{
|
||||
param1 = _duration;
|
||||
}
|
||||
return totalTime(param1,param2);
|
||||
}
|
||||
|
||||
public function totalTime(param1:Number = NaN, param2:Boolean = false, param3:Boolean = false) : *
|
||||
{
|
||||
var _loc5_:SimpleTimeline = null;
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _totalTime;
|
||||
}
|
||||
if(_timeline)
|
||||
{
|
||||
if(param1 < 0 && !param3)
|
||||
{
|
||||
param1 += totalDuration();
|
||||
}
|
||||
if(_timeline.smoothChildTiming)
|
||||
{
|
||||
if(_dirty)
|
||||
{
|
||||
totalDuration();
|
||||
}
|
||||
if(param1 > _totalDuration && !param3)
|
||||
{
|
||||
param1 = _totalDuration;
|
||||
}
|
||||
_loc5_ = _timeline;
|
||||
_startTime = (_paused ? _pauseTime : _loc5_._time) - (!_reversed ? param1 : _totalDuration - param1) / _timeScale;
|
||||
if(!_timeline._dirty)
|
||||
{
|
||||
_uncache(false);
|
||||
}
|
||||
if(_loc5_._timeline != null)
|
||||
{
|
||||
while(_loc5_._timeline)
|
||||
{
|
||||
if(_loc5_._timeline._time !== (_loc5_._startTime + _loc5_._totalTime) / _loc5_._timeScale)
|
||||
{
|
||||
_loc5_.totalTime(_loc5_._totalTime,true);
|
||||
}
|
||||
_loc5_ = _loc5_._timeline;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_gc)
|
||||
{
|
||||
_enabled(true,false);
|
||||
}
|
||||
if(_totalTime != param1 || _duration === 0)
|
||||
{
|
||||
render(param1,param2,false);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public function progress(param1:Number = NaN, param2:Boolean = false) : *
|
||||
{
|
||||
return !arguments.length ? _time / duration() : totalTime(duration() * param1,param2);
|
||||
}
|
||||
|
||||
public function totalProgress(param1:Number = NaN, param2:Boolean = false) : *
|
||||
{
|
||||
return !arguments.length ? _time / duration() : totalTime(duration() * param1,param2);
|
||||
}
|
||||
|
||||
public function startTime(param1:Number = NaN) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _startTime;
|
||||
}
|
||||
if(param1 != _startTime)
|
||||
{
|
||||
_startTime = param1;
|
||||
if(timeline)
|
||||
{
|
||||
if(timeline._sortChildren)
|
||||
{
|
||||
timeline.add(this,param1 - _delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public function timeScale(param1:Number = NaN) : *
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _timeScale;
|
||||
}
|
||||
param1 ||= 0.000001;
|
||||
if(_timeline && _timeline.smoothChildTiming)
|
||||
{
|
||||
_loc3_ = _pauseTime || _pauseTime == 0 ? _pauseTime : _timeline._totalTime;
|
||||
_startTime = _loc3_ - (_loc3_ - _startTime) * _timeScale / param1;
|
||||
}
|
||||
_timeScale = param1;
|
||||
return _uncache(false);
|
||||
}
|
||||
|
||||
public function reversed(param1:Boolean = false) : *
|
||||
{
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _reversed;
|
||||
}
|
||||
if(param1 != _reversed)
|
||||
{
|
||||
_reversed = param1;
|
||||
totalTime(_timeline && !_timeline.smoothChildTiming ? totalDuration() - _totalTime : _totalTime,true);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public function paused(param1:Boolean = false) : *
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
if(!arguments.length)
|
||||
{
|
||||
return _paused;
|
||||
}
|
||||
if(param1 != _paused)
|
||||
{
|
||||
if(_timeline)
|
||||
{
|
||||
_loc4_ = _timeline.rawTime();
|
||||
var _loc3_:Number = _loc4_ - _pauseTime;
|
||||
if(!param1 && _timeline.smoothChildTiming)
|
||||
{
|
||||
_startTime += _loc3_;
|
||||
_uncache(false);
|
||||
}
|
||||
_pauseTime = param1 ? _loc4_ : NaN;
|
||||
_paused = param1;
|
||||
_active = !param1 && _totalTime > 0 && _totalTime < _totalDuration;
|
||||
if(!param1 && _loc3_ != 0 && _initted && duration() !== 0)
|
||||
{
|
||||
render(_timeline.smoothChildTiming ? _totalTime : (_loc4_ - _startTime) / _timeScale,true,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_gc && !param1)
|
||||
{
|
||||
_enabled(true,false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.greensock.core
|
||||
{
|
||||
public final class PropTween
|
||||
{
|
||||
|
||||
public var t:Object;
|
||||
|
||||
public var p:String;
|
||||
|
||||
public var s:Number;
|
||||
|
||||
public var c:Number;
|
||||
|
||||
public var f:Boolean;
|
||||
|
||||
public var pr:int;
|
||||
|
||||
public var pg:Boolean;
|
||||
|
||||
public var n:String;
|
||||
|
||||
public var r:Boolean;
|
||||
|
||||
public var _next:PropTween;
|
||||
|
||||
public var _prev:PropTween;
|
||||
|
||||
public function PropTween(param1:Object, param2:String, param3:Number, param4:Number, param5:String, param6:Boolean, param7:PropTween = null, param8:int = 0)
|
||||
{
|
||||
super();
|
||||
this.t = param1;
|
||||
this.p = param2;
|
||||
this.s = param3;
|
||||
this.c = param4;
|
||||
this.n = param5;
|
||||
this.f = param1[param2] is Function;
|
||||
this.pg = param6;
|
||||
if(param7)
|
||||
{
|
||||
param7._prev = this;
|
||||
this._next = param7;
|
||||
}
|
||||
this.pr = param8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.greensock.core
|
||||
{
|
||||
import flash.utils.getTimer;
|
||||
|
||||
public class SimpleTimeline extends Animation
|
||||
{
|
||||
|
||||
public var autoRemoveChildren:Boolean;
|
||||
|
||||
public var smoothChildTiming:Boolean;
|
||||
|
||||
public var _sortChildren:Boolean;
|
||||
|
||||
public var _first:Animation;
|
||||
|
||||
public var _last:Animation;
|
||||
|
||||
public function SimpleTimeline(param1:Object = null)
|
||||
{
|
||||
super(0,param1);
|
||||
this.autoRemoveChildren = this.smoothChildTiming = true;
|
||||
}
|
||||
|
||||
public function insert(param1:*, param2:* = 0) : *
|
||||
{
|
||||
return add(param1,param2 || 0);
|
||||
}
|
||||
|
||||
public function add(param1:*, param2:* = "+=0", param3:String = "normal", param4:Number = 0) : *
|
||||
{
|
||||
var _loc5_:Number = NaN;
|
||||
param1._startTime = (Number(param2 || 0)) + param1._delay;
|
||||
if(param1._paused)
|
||||
{
|
||||
if(this != param1._timeline)
|
||||
{
|
||||
param1._pauseTime = param1._startTime + (rawTime() - param1._startTime) / param1._timeScale;
|
||||
}
|
||||
}
|
||||
if(param1.timeline)
|
||||
{
|
||||
param1.timeline._remove(param1,true);
|
||||
}
|
||||
param1.timeline = param1._timeline = this;
|
||||
if(param1._gc)
|
||||
{
|
||||
param1._enabled(true,true);
|
||||
}
|
||||
var _loc6_:Animation = _last;
|
||||
if(_sortChildren)
|
||||
{
|
||||
_loc5_ = Number(param1._startTime);
|
||||
while(_loc6_ && _loc6_._startTime > _loc5_)
|
||||
{
|
||||
_loc6_ = _loc6_._prev;
|
||||
}
|
||||
}
|
||||
if(_loc6_)
|
||||
{
|
||||
param1._next = _loc6_._next;
|
||||
_loc6_._next = Animation(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1._next = _first;
|
||||
_first = Animation(param1);
|
||||
}
|
||||
if(param1._next)
|
||||
{
|
||||
param1._next._prev = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_last = Animation(param1);
|
||||
}
|
||||
param1._prev = _loc6_;
|
||||
if(_timeline)
|
||||
{
|
||||
_uncache(true);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public function _remove(param1:Animation, param2:Boolean = false) : *
|
||||
{
|
||||
if(param1.timeline == this)
|
||||
{
|
||||
if(!param2)
|
||||
{
|
||||
param1._enabled(false,true);
|
||||
}
|
||||
if(param1._prev)
|
||||
{
|
||||
param1._prev._next = param1._next;
|
||||
}
|
||||
else if(_first === param1)
|
||||
{
|
||||
_first = param1._next;
|
||||
}
|
||||
if(param1._next)
|
||||
{
|
||||
param1._next._prev = param1._prev;
|
||||
}
|
||||
else if(_last === param1)
|
||||
{
|
||||
_last = param1._prev;
|
||||
}
|
||||
param1._next = param1._prev = param1.timeline = null;
|
||||
if(_timeline)
|
||||
{
|
||||
_uncache(true);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
override public function render(param1:Number, param2:Boolean = false, param3:Boolean = false) : Boolean
|
||||
{
|
||||
var _loc4_:Animation = null;
|
||||
var _loc5_:Animation = _first;
|
||||
if(_loc5_)
|
||||
{
|
||||
_totalTime = _time = _rawPrevTime = param1;
|
||||
while(_loc5_)
|
||||
{
|
||||
_loc4_ = _loc5_._next;
|
||||
if(_loc5_._active || param1 >= _loc5_._startTime && !_loc5_._paused)
|
||||
{
|
||||
if(!_loc5_._reversed)
|
||||
{
|
||||
_loc5_.render((param1 - _loc5_._startTime) * _loc5_._timeScale,param2,param3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_.render((!_loc5_._dirty ? _loc5_._totalDuration : _loc5_.totalDuration()) - (param1 - _loc5_._startTime) * _loc5_._timeScale,param2,param3);
|
||||
}
|
||||
}
|
||||
_loc5_ = _loc4_;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public function renderCreateTime(param1:Number, param2:Number, param3:Boolean = false, param4:Boolean = false) : Boolean
|
||||
{
|
||||
var _loc5_:Animation = null;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc6_:Animation = _first;
|
||||
if(_loc6_)
|
||||
{
|
||||
_totalTime = _time = _rawPrevTime = _loc7_ = (getTimer() / 1000 - param1) * param2;
|
||||
while(_loc6_)
|
||||
{
|
||||
_loc5_ = _loc6_._next;
|
||||
if(_loc6_._active || _loc7_ >= _loc6_._startTime && !_loc6_._paused)
|
||||
{
|
||||
if(!_loc6_._reversed)
|
||||
{
|
||||
_loc6_.render((_loc7_ - _loc6_._startTime) * _loc6_._timeScale,param3,param4);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_.render((!_loc6_._dirty ? _loc6_._totalDuration : _loc6_.totalDuration()) - (_loc7_ - _loc6_._startTime) * _loc6_._timeScale,param3,param4);
|
||||
}
|
||||
}
|
||||
_loc6_ = _loc5_;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function rawTime() : Number
|
||||
{
|
||||
return _totalTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class Back
|
||||
{
|
||||
|
||||
public static var easeOut:BackOut = new BackOut();
|
||||
|
||||
public static var easeIn:BackIn = new BackIn();
|
||||
|
||||
public static var easeInOut:BackInOut = new BackInOut();
|
||||
|
||||
public function Back()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class BackIn extends Ease
|
||||
{
|
||||
|
||||
public static var ease:BackIn = new BackIn();
|
||||
|
||||
public function BackIn(param1:Number = 1.70158)
|
||||
{
|
||||
super();
|
||||
_p1 = param1;
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
return param1 * param1 * ((_p1 + 1) * param1 - _p1);
|
||||
}
|
||||
|
||||
public function config(param1:Number = 1.70158) : BackIn
|
||||
{
|
||||
return new BackIn(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class BackInOut extends Ease
|
||||
{
|
||||
|
||||
public static var ease:BackInOut = new BackInOut();
|
||||
|
||||
public function BackInOut(param1:Number = 1.70158)
|
||||
{
|
||||
super();
|
||||
_p1 = param1;
|
||||
_p2 = _p1 * 1.525;
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
param1 *= 2;
|
||||
return param1 < 1 ? 0.5 * param1 * param1 * ((_p2 + 1) * param1 - _p2) : 0.5 * ((param1 -= 2) * param1 * ((_p2 + 1) * param1 + _p2) + 2);
|
||||
}
|
||||
|
||||
public function config(param1:Number = 1.70158) : BackInOut
|
||||
{
|
||||
return new BackInOut(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class BackOut extends Ease
|
||||
{
|
||||
|
||||
public static var ease:BackOut = new BackOut();
|
||||
|
||||
public function BackOut(param1:Number = 1.70158)
|
||||
{
|
||||
super();
|
||||
_p1 = param1;
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
param1 -= 1;
|
||||
return param1 * param1 * ((_p1 + 1) * param1 + _p1) + 1;
|
||||
}
|
||||
|
||||
public function config(param1:Number = 1.70158) : BackOut
|
||||
{
|
||||
return new BackOut(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class Circ
|
||||
{
|
||||
|
||||
public static var easeOut:CircOut = new CircOut();
|
||||
|
||||
public static var easeIn:CircIn = new CircIn();
|
||||
|
||||
public static var easeInOut:CircInOut = new CircInOut();
|
||||
|
||||
public function Circ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class CircIn extends Ease
|
||||
{
|
||||
|
||||
public static var ease:CircIn = new CircIn();
|
||||
|
||||
public function CircIn()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
return -(Math.sqrt(1 - param1 * param1) - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class CircInOut extends Ease
|
||||
{
|
||||
|
||||
public static var ease:CircInOut = new CircInOut();
|
||||
|
||||
public function CircInOut()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
param1 *= 2;
|
||||
return param1 < 1 ? -0.5 * (Math.sqrt(1 - param1 * param1) - 1) : 0.5 * (Math.sqrt(1 - (param1 -= 2) * param1) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class CircOut extends Ease
|
||||
{
|
||||
|
||||
public static var ease:CircOut = new CircOut();
|
||||
|
||||
public function CircOut()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
return Math.sqrt(1 - (param1 -= 1) * param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public class Ease
|
||||
{
|
||||
|
||||
protected static var _baseParams:Array = [0,0,1,1];
|
||||
|
||||
protected var _func:Function;
|
||||
|
||||
protected var _params:Array;
|
||||
|
||||
protected var _p1:Number;
|
||||
|
||||
protected var _p2:Number;
|
||||
|
||||
protected var _p3:Number;
|
||||
|
||||
public var _type:int;
|
||||
|
||||
public var _power:int;
|
||||
|
||||
public var _calcEnd:Boolean;
|
||||
|
||||
public function Ease(param1:Function = null, param2:Array = null, param3:Number = 0, param4:Number = 0)
|
||||
{
|
||||
super();
|
||||
_func = param1;
|
||||
_params = param2 ? _baseParams.concat(param2) : _baseParams;
|
||||
_type = param3;
|
||||
_power = param4;
|
||||
}
|
||||
|
||||
public function getRatio(param1:Number) : Number
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
if(_func != null)
|
||||
{
|
||||
_params[0] = param1;
|
||||
return _func.apply(null,_params);
|
||||
}
|
||||
_loc2_ = _type == 1 ? 1 - param1 : (_type == 2 ? param1 : (param1 < 0.5 ? param1 * 2 : (1 - param1) * 2));
|
||||
if(_power == 1)
|
||||
{
|
||||
_loc2_ *= _loc2_;
|
||||
}
|
||||
else if(_power == 2)
|
||||
{
|
||||
_loc2_ *= _loc2_ * _loc2_;
|
||||
}
|
||||
else if(_power == 3)
|
||||
{
|
||||
_loc2_ *= _loc2_ * _loc2_ * _loc2_;
|
||||
}
|
||||
else if(_power == 4)
|
||||
{
|
||||
_loc2_ *= _loc2_ * _loc2_ * _loc2_ * _loc2_;
|
||||
}
|
||||
return _type == 1 ? 1 - _loc2_ : (_type == 2 ? _loc2_ : (param1 < 0.5 ? _loc2_ / 2 : 1 - _loc2_ / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class Expo
|
||||
{
|
||||
|
||||
public static var easeOut:ExpoOut = new ExpoOut();
|
||||
|
||||
public static var easeIn:ExpoIn = new ExpoIn();
|
||||
|
||||
public static var easeInOut:ExpoInOut = new ExpoInOut();
|
||||
|
||||
public function Expo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class ExpoIn extends Ease
|
||||
{
|
||||
|
||||
public static var ease:ExpoIn = new ExpoIn();
|
||||
|
||||
public function ExpoIn()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
return Math.pow(2,10 * (param1 - 1)) - 0.001;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class ExpoInOut extends Ease
|
||||
{
|
||||
|
||||
public static var ease:ExpoInOut = new ExpoInOut();
|
||||
|
||||
public function ExpoInOut()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
param1 *= 2;
|
||||
return param1 < 1 ? 0.5 * Math.pow(2,10 * (param1 - 1)) : 0.5 * (2 - Math.pow(2,-10 * (param1 - 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class ExpoOut extends Ease
|
||||
{
|
||||
|
||||
public static var ease:ExpoOut = new ExpoOut();
|
||||
|
||||
public function ExpoOut()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
return 1 - Math.pow(2,-10 * param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public final class Quad
|
||||
{
|
||||
|
||||
public static var easeOut:Ease = new Ease(null,null,1,1);
|
||||
|
||||
public static var easeIn:Ease = new Ease(null,null,2,1);
|
||||
|
||||
public static var easeInOut:Ease = new Ease(null,null,3,1);
|
||||
|
||||
public function Quad()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.greensock.easing
|
||||
{
|
||||
public class SlowMo extends Ease
|
||||
{
|
||||
|
||||
public static var ease:SlowMo = new SlowMo();
|
||||
|
||||
private var _p:Number;
|
||||
|
||||
public function SlowMo(param1:Number = 0.7, param2:Number = 0.7, param3:Boolean = false)
|
||||
{
|
||||
super();
|
||||
if(param1 > 1)
|
||||
{
|
||||
param1 = 1;
|
||||
}
|
||||
_p = param1 != 1 ? param2 : 0;
|
||||
_p1 = (1 - param1) / 2;
|
||||
_p2 = param1;
|
||||
_p3 = _p1 + _p2;
|
||||
_calcEnd = param3;
|
||||
}
|
||||
|
||||
override public function getRatio(param1:Number) : Number
|
||||
{
|
||||
var _loc2_:Number = param1 + (0.5 - param1) * _p;
|
||||
if(param1 < _p1)
|
||||
{
|
||||
return _calcEnd ? 1 - (param1 = 1 - param1 / _p1) * param1 : _loc2_ - (param1 = 1 - param1 / _p1) * param1 * param1 * param1 * _loc2_;
|
||||
}
|
||||
if(param1 > _p3)
|
||||
{
|
||||
return _calcEnd ? 1 - (param1 = (param1 - _p3) / _p1) * param1 : _loc2_ + (param1 - _loc2_) * (param1 = (param1 - _p3) / _p1) * param1 * param1 * param1;
|
||||
}
|
||||
return _calcEnd ? 1 : _loc2_;
|
||||
}
|
||||
|
||||
public function config(param1:Number = 0.7, param2:Number = 0.7, param3:Boolean = false) : SlowMo
|
||||
{
|
||||
return new SlowMo(param1,param2,param3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.greensock.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class TweenEvent extends Event
|
||||
{
|
||||
|
||||
public static const VERSION:Number = 12;
|
||||
|
||||
public static const START:String = "start";
|
||||
|
||||
public static const UPDATE:String = "change";
|
||||
|
||||
public static const COMPLETE:String = "complete";
|
||||
|
||||
public static const REVERSE_COMPLETE:String = "reverseComplete";
|
||||
|
||||
public static const REPEAT:String = "repeat";
|
||||
|
||||
public function TweenEvent(param1:String, param2:Boolean = false, param3:Boolean = false)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new TweenEvent(this.type,this.bubbles,this.cancelable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
|
||||
public class AutoAlphaPlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected var _target:Object;
|
||||
|
||||
protected var _ignoreVisible:Boolean;
|
||||
|
||||
public function AutoAlphaPlugin()
|
||||
{
|
||||
super("autoAlpha,alpha,visible");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
_target = param1;
|
||||
_addTween(param1,"alpha",param1.alpha,param2,"alpha");
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function _kill(param1:Object) : Boolean
|
||||
{
|
||||
_ignoreVisible = "visible" in param1;
|
||||
return super._kill(param1);
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
super.setRatio(param1);
|
||||
if(!_ignoreVisible)
|
||||
{
|
||||
_target.visible = _target.alpha != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.filters.BevelFilter;
|
||||
|
||||
public class BevelFilterPlugin extends FilterPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
private static var _propNames:Array = ["distance","angle","highlightColor","highlightAlpha","shadowColor","shadowAlpha","blurX","blurY","strength","quality"];
|
||||
|
||||
public function BevelFilterPlugin()
|
||||
{
|
||||
super("bevelFilter");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
return _initFilter(param1,param2,param3,BevelFilter,new BevelFilter(0,0,16777215,0.5,0,0.5,2,2,0,param2.quality || 2),_propNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,790 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.geom.Point;
|
||||
|
||||
public class BezierPlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected static const _RAD2DEG:Number = 57.29577951308232;
|
||||
|
||||
protected static var _r1:Array = [];
|
||||
|
||||
protected static var _r2:Array = [];
|
||||
|
||||
protected static var _r3:Array = [];
|
||||
|
||||
protected static var _corProps:Object = {};
|
||||
|
||||
protected var _target:Object;
|
||||
|
||||
protected var _autoRotate:Array;
|
||||
|
||||
protected var _round:Object;
|
||||
|
||||
protected var _lengths:Array;
|
||||
|
||||
protected var _segments:Array;
|
||||
|
||||
protected var _length:Number;
|
||||
|
||||
protected var _func:Object;
|
||||
|
||||
protected var _props:Array;
|
||||
|
||||
protected var _l1:Number;
|
||||
|
||||
protected var _l2:Number;
|
||||
|
||||
protected var _li:Number;
|
||||
|
||||
protected var _curSeg:Array;
|
||||
|
||||
protected var _s1:Number;
|
||||
|
||||
protected var _s2:Number;
|
||||
|
||||
protected var _si:Number;
|
||||
|
||||
protected var _beziers:Object;
|
||||
|
||||
protected var _segCount:int;
|
||||
|
||||
protected var _prec:Number;
|
||||
|
||||
protected var _timeRes:int;
|
||||
|
||||
protected var _initialRotations:Array;
|
||||
|
||||
protected var _startRatio:int;
|
||||
|
||||
public function BezierPlugin()
|
||||
{
|
||||
super("bezier");
|
||||
this._overwriteProps.pop();
|
||||
this._func = {};
|
||||
this._round = {};
|
||||
}
|
||||
|
||||
public static function bezierThrough(param1:Array, param2:Number = 1, param3:Boolean = false, param4:Boolean = false, param5:String = "x,y,z", param6:Object = null) : Object
|
||||
{
|
||||
var _loc13_:Array = null;
|
||||
var _loc10_:int = 0;
|
||||
var _loc14_:String = null;
|
||||
var _loc11_:int = 0;
|
||||
var _loc7_:Array = null;
|
||||
var _loc12_:int = 0;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc8_:Boolean = false;
|
||||
var _loc9_:Object = null;
|
||||
var _loc16_:Object = {};
|
||||
var _loc17_:Object = param6 || param1[0];
|
||||
param5 = "," + param5 + ",";
|
||||
if(_loc17_ is Point)
|
||||
{
|
||||
_loc13_ = ["x","y"];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = [];
|
||||
for(_loc14_ in _loc17_)
|
||||
{
|
||||
_loc13_.push(_loc14_);
|
||||
}
|
||||
}
|
||||
if(param1.length > 1)
|
||||
{
|
||||
_loc9_ = param1[param1.length - 1];
|
||||
_loc8_ = true;
|
||||
_loc10_ = int(_loc13_.length);
|
||||
while(--_loc10_ > -1)
|
||||
{
|
||||
_loc14_ = _loc13_[_loc10_];
|
||||
if(Math.abs(_loc17_[_loc14_] - _loc9_[_loc14_]) > 0.05)
|
||||
{
|
||||
_loc8_ = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(_loc8_)
|
||||
{
|
||||
param1 = param1.concat();
|
||||
if(param6)
|
||||
{
|
||||
param1.unshift(param6);
|
||||
}
|
||||
param1.push(param1[1]);
|
||||
param6 = param1[param1.length - 3];
|
||||
}
|
||||
}
|
||||
_r1.length = _r2.length = _r3.length = 0;
|
||||
_loc10_ = int(_loc13_.length);
|
||||
while(--_loc10_ > -1)
|
||||
{
|
||||
_loc14_ = _loc13_[_loc10_];
|
||||
_corProps[_loc14_] = param5.indexOf("," + _loc14_ + ",") !== -1;
|
||||
_loc16_[_loc14_] = _parseAnchors(param1,_loc14_,_corProps[_loc14_],param6);
|
||||
}
|
||||
_loc10_ = int(_r1.length);
|
||||
while(--_loc10_ > -1)
|
||||
{
|
||||
_r1[_loc10_] = Math.sqrt(_r1[_loc10_]);
|
||||
_r2[_loc10_] = Math.sqrt(_r2[_loc10_]);
|
||||
}
|
||||
if(!param4)
|
||||
{
|
||||
_loc10_ = int(_loc13_.length);
|
||||
while(--_loc10_ > -1)
|
||||
{
|
||||
if(_corProps[_loc14_])
|
||||
{
|
||||
_loc7_ = _loc16_[_loc13_[_loc10_]];
|
||||
_loc12_ = _loc7_.length - 1;
|
||||
_loc11_ = 0;
|
||||
while(_loc11_ < _loc12_)
|
||||
{
|
||||
_loc15_ = _loc7_[_loc11_ + 1].da / _r2[_loc11_] + _loc7_[_loc11_].da / _r1[_loc11_];
|
||||
_r3[_loc11_] = (_r3[_loc11_] || 0) + _loc15_ * _loc15_;
|
||||
_loc11_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc10_ = int(_r3.length);
|
||||
while(--_loc10_ > -1)
|
||||
{
|
||||
_r3[_loc10_] = Math.sqrt(_r3[_loc10_]);
|
||||
}
|
||||
}
|
||||
_loc10_ = int(_loc13_.length);
|
||||
_loc11_ = param3 ? 4 : 1;
|
||||
while(--_loc10_ > -1)
|
||||
{
|
||||
_loc14_ = _loc13_[_loc10_];
|
||||
_loc7_ = _loc16_[_loc14_];
|
||||
_calculateControlPoints(_loc7_,param2,param3,param4,_corProps[_loc14_]);
|
||||
if(_loc8_)
|
||||
{
|
||||
_loc7_.splice(0,_loc11_);
|
||||
_loc7_.splice(_loc7_.length - _loc11_,_loc11_);
|
||||
}
|
||||
}
|
||||
return _loc16_;
|
||||
}
|
||||
|
||||
public static function _parseBezierData(param1:Array, param2:String, param3:Object = null) : Object
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc5_:Array = null;
|
||||
var _loc13_:Array = null;
|
||||
var _loc10_:int = 0;
|
||||
var _loc11_:int = 0;
|
||||
var _loc12_:int = 0;
|
||||
var _loc14_:String = null;
|
||||
var _loc9_:int = 0;
|
||||
var _loc15_:Object = null;
|
||||
param2 ||= "soft";
|
||||
var _loc16_:Object = {};
|
||||
var _loc17_:int = param2 === "cubic" ? 3 : 2;
|
||||
var _loc18_:Boolean = param2 === "soft";
|
||||
if(_loc18_ && param3)
|
||||
{
|
||||
param1 = [param3].concat(param1);
|
||||
}
|
||||
if(param1 == null || param1.length < _loc17_ + 1)
|
||||
{
|
||||
throw new Error("invalid Bezier data");
|
||||
}
|
||||
if(param1[1] is Point)
|
||||
{
|
||||
_loc13_ = ["x","y"];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = [];
|
||||
for(_loc14_ in param1[0])
|
||||
{
|
||||
_loc13_.push(_loc14_);
|
||||
}
|
||||
}
|
||||
_loc10_ = int(_loc13_.length);
|
||||
while(--_loc10_ > -1)
|
||||
{
|
||||
_loc14_ = _loc13_[_loc10_];
|
||||
_loc16_[_loc14_] = _loc5_ = [];
|
||||
_loc9_ = 0;
|
||||
_loc12_ = int(param1.length);
|
||||
_loc11_ = 0;
|
||||
while(_loc11_ < _loc12_)
|
||||
{
|
||||
_loc15_ = param1[_loc11_][_loc14_];
|
||||
_loc4_ = Number(param3 == null ? param1[_loc11_][_loc14_] : (typeof _loc15_ === "string" && _loc15_.charAt(1) === "=" ? param3[_loc14_] + (_loc15_.charAt(0) + _loc15_.substr(2)) : Number(_loc15_)));
|
||||
if(_loc18_)
|
||||
{
|
||||
if(_loc11_ > 1)
|
||||
{
|
||||
if(_loc11_ < _loc12_ - 1)
|
||||
{
|
||||
_loc5_[_loc9_++] = (_loc4_ + _loc5_[_loc9_ - 2]) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc5_[_loc9_++] = _loc4_;
|
||||
_loc11_++;
|
||||
}
|
||||
_loc12_ = _loc9_ - _loc17_ + 1;
|
||||
_loc9_ = 0;
|
||||
_loc11_ = 0;
|
||||
while(_loc11_ < _loc12_)
|
||||
{
|
||||
_loc4_ = Number(_loc5_[_loc11_]);
|
||||
_loc6_ = Number(_loc5_[_loc11_ + 1]);
|
||||
_loc7_ = Number(_loc5_[_loc11_ + 2]);
|
||||
_loc8_ = Number(_loc17_ === 2 ? 0 : _loc5_[_loc11_ + 3]);
|
||||
_loc5_[_loc9_++] = _loc17_ === 3 ? new Segment(_loc4_,_loc6_,_loc7_,_loc8_) : new Segment(_loc4_,(2 * _loc6_ + _loc4_) / 3,(2 * _loc6_ + _loc7_) / 3,_loc7_);
|
||||
_loc11_ += _loc17_;
|
||||
}
|
||||
_loc5_.length = _loc9_;
|
||||
}
|
||||
return _loc16_;
|
||||
}
|
||||
|
||||
protected static function _parseAnchors(param1:Array, param2:String, param3:Boolean, param4:Object) : Array
|
||||
{
|
||||
var _loc11_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc9_:Object = null;
|
||||
var _loc6_:Array = [];
|
||||
if(param4)
|
||||
{
|
||||
param1 = [param4].concat(param1);
|
||||
_loc10_ = int(param1.length);
|
||||
while(--_loc10_ > -1)
|
||||
{
|
||||
_loc9_ = param1[_loc10_][param2];
|
||||
if(typeof _loc9_ === "string")
|
||||
{
|
||||
if(_loc9_.charAt(1) === "=")
|
||||
{
|
||||
param1[_loc10_][param2] = param4[param2] + (_loc9_.charAt(0) + _loc9_.substr(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc11_ = param1.length - 2;
|
||||
if(_loc11_ < 0)
|
||||
{
|
||||
_loc6_[0] = new Segment(param1[0][param2],0,0,param1[_loc11_ < -1 ? 0 : 1][param2]);
|
||||
return _loc6_;
|
||||
}
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < _loc11_)
|
||||
{
|
||||
_loc5_ = Number(param1[_loc10_][param2]);
|
||||
_loc7_ = Number(param1[_loc10_ + 1][param2]);
|
||||
_loc6_[_loc10_] = new Segment(_loc5_,0,0,_loc7_);
|
||||
if(param3)
|
||||
{
|
||||
_loc8_ = Number(param1[_loc10_ + 2][param2]);
|
||||
_r1[_loc10_] = (_r1[_loc10_] || 0) + (_loc7_ - _loc5_) * (_loc7_ - _loc5_);
|
||||
_r2[_loc10_] = (_r2[_loc10_] || 0) + (_loc8_ - _loc7_) * (_loc8_ - _loc7_);
|
||||
}
|
||||
_loc10_++;
|
||||
}
|
||||
_loc6_[_loc10_] = new Segment(param1[_loc10_][param2],0,0,param1[_loc10_ + 1][param2]);
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
protected static function _calculateControlPoints(param1:Array, param2:Number = 1, param3:Boolean = false, param4:Boolean = false, param5:Boolean = false) : void
|
||||
{
|
||||
var _loc16_:int = 0;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc19_:Segment = null;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc18_:Array = null;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc17_:int = param1.length - 1;
|
||||
var _loc6_:int = 0;
|
||||
var _loc14_:Number = Number(param1[0].a);
|
||||
_loc16_ = 0;
|
||||
while(_loc16_ < _loc17_)
|
||||
{
|
||||
_loc19_ = param1[_loc6_];
|
||||
_loc9_ = _loc19_.a;
|
||||
_loc10_ = _loc19_.d;
|
||||
_loc11_ = Number(param1[_loc6_ + 1].d);
|
||||
if(param5)
|
||||
{
|
||||
_loc21_ = Number(_r1[_loc16_]);
|
||||
_loc8_ = Number(_r2[_loc16_]);
|
||||
_loc20_ = (_loc8_ + _loc21_) * param2 * 0.25 / (param4 ? 0.5 : _r3[_loc16_] || 0.5);
|
||||
_loc12_ = _loc10_ - (_loc10_ - _loc9_) * (param4 ? param2 * 0.5 : (_loc21_ !== 0 ? _loc20_ / _loc21_ : 0));
|
||||
_loc15_ = _loc10_ + (_loc11_ - _loc10_) * (param4 ? param2 * 0.5 : (_loc8_ !== 0 ? _loc20_ / _loc8_ : 0));
|
||||
_loc7_ = _loc10_ - (_loc12_ + ((_loc15_ - _loc12_) * (_loc21_ * 3 / (_loc21_ + _loc8_) + 0.5) / 4 || 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc12_ = _loc10_ - (_loc10_ - _loc9_) * param2 * 0.5;
|
||||
_loc15_ = _loc10_ + (_loc11_ - _loc10_) * param2 * 0.5;
|
||||
_loc7_ = _loc10_ - (_loc12_ + _loc15_) / 2;
|
||||
}
|
||||
_loc12_ += _loc7_;
|
||||
_loc15_ += _loc7_;
|
||||
_loc19_.c = _loc13_ = _loc12_;
|
||||
if(_loc16_ != 0)
|
||||
{
|
||||
_loc19_.b = _loc14_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc19_.b = _loc14_ = _loc19_.a + (_loc19_.c - _loc19_.a) * 0.6;
|
||||
}
|
||||
_loc19_.da = _loc10_ - _loc9_;
|
||||
_loc19_.ca = _loc13_ - _loc9_;
|
||||
_loc19_.ba = _loc14_ - _loc9_;
|
||||
if(param3)
|
||||
{
|
||||
_loc18_ = cubicToQuadratic(_loc9_,_loc14_,_loc13_,_loc10_);
|
||||
param1.splice(_loc6_,1,_loc18_[0],_loc18_[1],_loc18_[2],_loc18_[3]);
|
||||
_loc6_ += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_++;
|
||||
}
|
||||
_loc14_ = _loc15_;
|
||||
_loc16_++;
|
||||
}
|
||||
_loc19_ = param1[_loc6_];
|
||||
_loc19_.b = _loc14_;
|
||||
_loc19_.c = _loc14_ + (_loc19_.d - _loc14_) * 0.4;
|
||||
_loc19_.da = _loc19_.d - _loc19_.a;
|
||||
_loc19_.ca = _loc19_.c - _loc19_.a;
|
||||
_loc19_.ba = _loc14_ - _loc19_.a;
|
||||
if(param3)
|
||||
{
|
||||
_loc18_ = cubicToQuadratic(_loc19_.a,_loc14_,_loc19_.c,_loc19_.d);
|
||||
param1.splice(_loc6_,1,_loc18_[0],_loc18_[1],_loc18_[2],_loc18_[3]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function cubicToQuadratic(param1:Number, param2:Number, param3:Number, param4:Number) : Array
|
||||
{
|
||||
var _loc5_:Object = {"a":param1};
|
||||
var _loc6_:Object = {};
|
||||
var _loc7_:Object = {};
|
||||
var _loc8_:Object = {"c":param4};
|
||||
var _loc12_:Number = (param1 + param2) / 2;
|
||||
var _loc13_:Number = (param2 + param3) / 2;
|
||||
var _loc14_:Number = (param3 + param4) / 2;
|
||||
var _loc10_:Number = (_loc12_ + _loc13_) / 2;
|
||||
var _loc9_:Number = (_loc13_ + _loc14_) / 2;
|
||||
var _loc11_:Number = (_loc9_ - _loc10_) / 8;
|
||||
_loc5_.b = _loc12_ + (param1 - _loc12_) / 4;
|
||||
_loc6_.b = _loc10_ + _loc11_;
|
||||
_loc5_.c = _loc6_.a = (_loc5_.b + _loc6_.b) / 2;
|
||||
_loc6_.c = _loc7_.a = (_loc10_ + _loc9_) / 2;
|
||||
_loc7_.b = _loc9_ - _loc11_;
|
||||
_loc8_.b = _loc14_ + (param4 - _loc14_) / 4;
|
||||
_loc7_.c = _loc8_.a = (_loc7_.b + _loc8_.b) / 2;
|
||||
return [_loc5_,_loc6_,_loc7_,_loc8_];
|
||||
}
|
||||
|
||||
public static function quadraticToCubic(param1:Number, param2:Number, param3:Number) : Object
|
||||
{
|
||||
return new Segment(param1,(2 * param2 + param1) / 3,(2 * param2 + param3) / 3,param3);
|
||||
}
|
||||
|
||||
protected static function _parseLengthData(param1:Object, param2:uint = 6) : Object
|
||||
{
|
||||
var _loc11_:String = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc3_:Array = [];
|
||||
var _loc13_:Array = [];
|
||||
var _loc4_:Number = 0;
|
||||
var _loc12_:Number = 0;
|
||||
var _loc7_:int = param2 - 1;
|
||||
var _loc10_:Array = [];
|
||||
var _loc9_:Array = [];
|
||||
for(_loc11_ in param1)
|
||||
{
|
||||
_addCubicLengths(param1[_loc11_],_loc3_,param2);
|
||||
}
|
||||
_loc8_ = int(_loc3_.length);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc8_)
|
||||
{
|
||||
_loc4_ += Math.sqrt(_loc3_[_loc5_]);
|
||||
_loc6_ = _loc5_ % param2;
|
||||
_loc9_[_loc6_] = _loc4_;
|
||||
if(_loc6_ == _loc7_)
|
||||
{
|
||||
_loc12_ += _loc4_;
|
||||
_loc6_ = _loc5_ / param2 >> 0;
|
||||
_loc10_[_loc6_] = _loc9_;
|
||||
_loc13_[_loc6_] = _loc12_;
|
||||
_loc4_ = 0;
|
||||
_loc9_ = [];
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return {
|
||||
"length":_loc12_,
|
||||
"lengths":_loc13_,
|
||||
"segments":_loc10_
|
||||
};
|
||||
}
|
||||
|
||||
private static function _addCubicLengths(param1:Array, param2:Array, param3:uint = 6) : void
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc5_:int = 0;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc12_:Segment = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc16_:Number = 1 / param3;
|
||||
var _loc7_:int = int(param1.length);
|
||||
while(--_loc7_ > -1)
|
||||
{
|
||||
_loc12_ = param1[_loc7_];
|
||||
_loc11_ = _loc12_.a;
|
||||
_loc13_ = _loc12_.d - _loc11_;
|
||||
_loc14_ = _loc12_.c - _loc11_;
|
||||
_loc15_ = _loc12_.b - _loc11_;
|
||||
_loc4_ = _loc8_ = 0;
|
||||
_loc5_ = 1;
|
||||
while(_loc5_ <= param3)
|
||||
{
|
||||
_loc9_ = _loc16_ * _loc5_;
|
||||
_loc10_ = 1 - _loc9_;
|
||||
_loc4_ = _loc8_ - (_loc8_ = (_loc9_ * _loc9_ * _loc13_ + 3 * _loc10_ * (_loc9_ * _loc14_ + _loc10_ * _loc15_)) * _loc9_);
|
||||
_loc6_ = _loc7_ * param3 + _loc5_ - 1;
|
||||
param2[_loc6_] = (param2[_loc6_] || 0) + _loc4_ * _loc4_;
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
var _loc10_:String = null;
|
||||
var _loc8_:Boolean = false;
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc11_:Array = null;
|
||||
var _loc5_:Object = null;
|
||||
var _loc4_:Array = null;
|
||||
var _loc12_:Object = null;
|
||||
this._target = param1;
|
||||
var _loc13_:Object = param2 is Array ? {"values":param2} : param2;
|
||||
this._props = [];
|
||||
this._timeRes = _loc13_.timeResolution == null ? 6 : int(_loc13_.timeResolution);
|
||||
_loc4_ = _loc13_.values || [];
|
||||
var _loc15_:Object = {};
|
||||
var _loc9_:Object = _loc4_[0];
|
||||
var _loc14_:Object = _loc13_.autoRotate || param3.vars.orientToBezier;
|
||||
this._autoRotate = _loc14_ ? (_loc14_ is Array ? _loc14_ as Array : [["x","y","rotation",_loc14_ === true ? 0 : Number(_loc14_)]]) : null;
|
||||
if(_loc9_ is Point)
|
||||
{
|
||||
this._props = ["x","y"];
|
||||
}
|
||||
else
|
||||
{
|
||||
for(_loc10_ in _loc9_)
|
||||
{
|
||||
this._props.push(_loc10_);
|
||||
}
|
||||
}
|
||||
_loc6_ = int(this._props.length);
|
||||
while(--_loc6_ > -1)
|
||||
{
|
||||
_loc10_ = this._props[_loc6_];
|
||||
this._overwriteProps.push(_loc10_);
|
||||
_loc8_ = Boolean(this._func[_loc10_] = param1[_loc10_] is Function);
|
||||
var _temp_4:*;
|
||||
_loc15_[_loc10_] = !_loc8_ ? param1[_loc10_] : (_temp_4 = param1,param1[_loc10_.indexOf("set") || !("get" + _loc10_.substr(3) in param1) ? _loc10_ : "get" + _loc10_.substr(3)]());
|
||||
if(!_loc5_)
|
||||
{
|
||||
if(_loc15_[_loc10_] !== _loc4_[0][_loc10_])
|
||||
{
|
||||
_loc5_ = _loc15_;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._beziers = _loc13_.type !== "cubic" && _loc13_.type !== "quadratic" && _loc13_.type !== "soft" ? bezierThrough(_loc4_,isNaN(_loc13_.curviness) ? 1 : _loc13_.curviness,false,_loc13_.type === "thruBasic",_loc13_.correlate || "x,y,z",_loc5_) : _parseBezierData(_loc4_,_loc13_.type,_loc15_);
|
||||
this._segCount = this._beziers[_loc10_].length;
|
||||
if(this._timeRes)
|
||||
{
|
||||
_loc12_ = _parseLengthData(this._beziers,this._timeRes);
|
||||
this._length = _loc12_.length;
|
||||
this._lengths = _loc12_.lengths;
|
||||
this._segments = _loc12_.segments;
|
||||
this._l1 = this._li = this._s1 = this._si = 0;
|
||||
this._l2 = this._lengths[0];
|
||||
this._curSeg = this._segments[0];
|
||||
this._s2 = this._curSeg[0];
|
||||
this._prec = 1 / this._curSeg.length;
|
||||
}
|
||||
if(_loc11_ == this._autoRotate)
|
||||
{
|
||||
this._initialRotations = [];
|
||||
if(!(_loc11_[0] is Array))
|
||||
{
|
||||
this._autoRotate = _loc11_ = [_loc11_];
|
||||
}
|
||||
_loc6_ = int(_loc11_.length);
|
||||
while(--_loc6_ > -1)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < 3)
|
||||
{
|
||||
_loc10_ = _loc11_[_loc6_][_loc7_];
|
||||
this._func[_loc10_] = param1[_loc10_] is Function ? param1[_loc10_.indexOf("set") || !("get" + _loc10_.substr(3) in param1) ? _loc10_ : "get" + _loc10_.substr(3)] : false;
|
||||
_loc7_++;
|
||||
}
|
||||
_loc10_ = _loc11_[_loc6_][2];
|
||||
this._initialRotations[_loc6_] = this._func[_loc10_] ? this._func[_loc10_]() : this._target[_loc10_];
|
||||
}
|
||||
}
|
||||
_startRatio = param3.vars.runBackwards ? 1 : 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function _kill(param1:Object) : Boolean
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:Array = this._props;
|
||||
for(_loc2_ in _beziers)
|
||||
{
|
||||
if(_loc2_ in param1)
|
||||
{
|
||||
delete _beziers[_loc2_];
|
||||
delete _func[_loc2_];
|
||||
_loc4_ = int(_loc3_.length);
|
||||
while(--_loc4_ > -1)
|
||||
{
|
||||
if(_loc3_[_loc4_] === _loc2_)
|
||||
{
|
||||
_loc3_.splice(_loc4_,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super._kill(param1);
|
||||
}
|
||||
|
||||
override public function _roundProps(param1:Object, param2:Boolean = true) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
_loc3_ = this._overwriteProps;
|
||||
var _loc4_:int = int(_loc3_.length);
|
||||
while(--_loc4_ > -1)
|
||||
{
|
||||
if(_loc3_[_loc4_] in param1 || "bezier" in param1 || "bezierThrough" in param1)
|
||||
{
|
||||
this._round[_loc3_[_loc4_]] = param2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
var _loc23_:* = 0;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc7_:int = 0;
|
||||
var _loc12_:String = null;
|
||||
var _loc6_:Segment = null;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc8_:int = 0;
|
||||
var _loc17_:Array = null;
|
||||
var _loc3_:Array = null;
|
||||
var _loc13_:Segment = null;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc14_:Array = null;
|
||||
var _loc10_:int = this._segCount;
|
||||
var _loc15_:Object = this._func;
|
||||
var _loc9_:Object = this._target;
|
||||
var _loc5_:Boolean = param1 !== this._startRatio;
|
||||
if(this._timeRes == 0)
|
||||
{
|
||||
_loc23_ = int(param1 < 0 ? 0 : (param1 >= 1 ? _loc10_ - 1 : _loc10_ * param1 >> 0));
|
||||
_loc16_ = (param1 - _loc23_ * (1 / _loc10_)) * _loc10_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc17_ = this._lengths;
|
||||
_loc3_ = this._curSeg;
|
||||
param1 *= this._length;
|
||||
_loc7_ = this._li;
|
||||
if(param1 > this._l2 && _loc7_ < _loc10_ - 1)
|
||||
{
|
||||
_loc8_ = _loc10_ - 1;
|
||||
while(_loc7_ < _loc8_ && (this._l2 = _loc17_[++_loc7_]) <= param1)
|
||||
{
|
||||
}
|
||||
this._l1 = _loc17_[_loc7_ - 1];
|
||||
this._li = _loc7_;
|
||||
this._curSeg = _loc3_ = this._segments[_loc7_];
|
||||
this._s2 = _loc3_[this._s1 = this._si = 0];
|
||||
}
|
||||
else if(param1 < this._l1 && _loc7_ > 0)
|
||||
{
|
||||
while(_loc7_ > 0 && (this._l1 = _loc17_[--_loc7_]) >= param1)
|
||||
{
|
||||
}
|
||||
if(_loc7_ === 0 && param1 < this._l1)
|
||||
{
|
||||
this._l1 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_++;
|
||||
}
|
||||
this._l2 = _loc17_[_loc7_];
|
||||
this._li = _loc7_;
|
||||
this._curSeg = _loc3_ = this._segments[_loc7_];
|
||||
this._s1 = _loc3_[(this._si = _loc3_.length - 1) - 1] || 0;
|
||||
this._s2 = _loc3_[this._si];
|
||||
}
|
||||
_loc23_ = _loc7_;
|
||||
param1 -= this._l1;
|
||||
_loc7_ = this._si;
|
||||
if(param1 > this._s2 && _loc7_ < _loc3_.length - 1)
|
||||
{
|
||||
_loc8_ = _loc3_.length - 1;
|
||||
while(_loc7_ < _loc8_ && (this._s2 = _loc3_[++_loc7_]) <= param1)
|
||||
{
|
||||
}
|
||||
this._s1 = _loc3_[_loc7_ - 1];
|
||||
this._si = _loc7_;
|
||||
}
|
||||
else if(param1 < this._s1 && _loc7_ > 0)
|
||||
{
|
||||
while(_loc7_ > 0 && (this._s1 = _loc3_[--_loc7_]) >= param1)
|
||||
{
|
||||
}
|
||||
if(_loc7_ === 0 && param1 < this._s1)
|
||||
{
|
||||
this._s1 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_++;
|
||||
}
|
||||
this._s2 = _loc3_[_loc7_];
|
||||
this._si = _loc7_;
|
||||
}
|
||||
_loc16_ = (_loc7_ + (param1 - this._s1) / (this._s2 - this._s1)) * this._prec;
|
||||
}
|
||||
_loc11_ = 1 - _loc16_;
|
||||
_loc7_ = int(this._props.length);
|
||||
while(--_loc7_ > -1)
|
||||
{
|
||||
_loc12_ = this._props[_loc7_];
|
||||
_loc6_ = this._beziers[_loc12_][_loc23_];
|
||||
_loc2_ = (_loc16_ * _loc16_ * _loc6_.da + 3 * _loc11_ * (_loc16_ * _loc6_.ca + _loc11_ * _loc6_.ba)) * _loc16_ + _loc6_.a;
|
||||
if(this._round[_loc12_])
|
||||
{
|
||||
_loc2_ = _loc2_ + (_loc2_ > 0 ? 0.5 : -0.5) >> 0;
|
||||
}
|
||||
if(_loc15_[_loc12_])
|
||||
{
|
||||
_loc9_[_loc12_](_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc9_[_loc12_] = _loc2_;
|
||||
}
|
||||
}
|
||||
if(this._autoRotate != null)
|
||||
{
|
||||
_loc14_ = this._autoRotate;
|
||||
_loc7_ = int(_loc14_.length);
|
||||
while(--_loc7_ > -1)
|
||||
{
|
||||
_loc12_ = _loc14_[_loc7_][2];
|
||||
_loc4_ = Number(_loc14_[_loc7_][3] || 0);
|
||||
_loc22_ = _loc14_[_loc7_][4] == true ? 1 : 57.29577951308232;
|
||||
_loc6_ = this._beziers[_loc14_[_loc7_][0]][_loc23_];
|
||||
_loc13_ = this._beziers[_loc14_[_loc7_][1]][_loc23_];
|
||||
_loc19_ = _loc6_.a + (_loc6_.b - _loc6_.a) * _loc16_;
|
||||
_loc21_ = _loc6_.b + (_loc6_.c - _loc6_.b) * _loc16_;
|
||||
_loc19_ += (_loc21_ - _loc19_) * _loc16_;
|
||||
_loc21_ += (_loc6_.c + (_loc6_.d - _loc6_.c) * _loc16_ - _loc21_) * _loc16_;
|
||||
_loc18_ = _loc13_.a + (_loc13_.b - _loc13_.a) * _loc16_;
|
||||
_loc20_ = _loc13_.b + (_loc13_.c - _loc13_.b) * _loc16_;
|
||||
_loc18_ += (_loc20_ - _loc18_) * _loc16_;
|
||||
_loc20_ += (_loc13_.c + (_loc13_.d - _loc13_.c) * _loc16_ - _loc20_) * _loc16_;
|
||||
_loc2_ = Number(_loc5_ ? Math.atan2(_loc20_ - _loc18_,_loc21_ - _loc19_) * _loc22_ + _loc4_ : this._initialRotations[_loc7_]);
|
||||
if(_loc15_[_loc12_])
|
||||
{
|
||||
_loc9_[_loc12_](_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc9_[_loc12_] = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Segment
|
||||
{
|
||||
|
||||
public var a:Number;
|
||||
|
||||
public var b:Number;
|
||||
|
||||
public var c:Number;
|
||||
|
||||
public var d:Number;
|
||||
|
||||
public var da:Number;
|
||||
|
||||
public var ca:Number;
|
||||
|
||||
public var ba:Number;
|
||||
|
||||
public function Segment(param1:Number, param2:Number, param3:Number, param4:Number)
|
||||
{
|
||||
super();
|
||||
this.a = param1;
|
||||
this.b = param2;
|
||||
this.c = param3;
|
||||
this.d = param4;
|
||||
this.da = param4 - param1;
|
||||
this.ca = param3 - param1;
|
||||
this.ba = param2 - param1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
|
||||
public class BezierThroughPlugin extends BezierPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
public function BezierThroughPlugin()
|
||||
{
|
||||
super();
|
||||
_propName = "bezierThrough";
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
if(param2 is Array)
|
||||
{
|
||||
param2 = {"values":param2};
|
||||
}
|
||||
param2.type = "thru";
|
||||
return super._onInitTween(param1,param2,param3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.filters.BlurFilter;
|
||||
|
||||
public class BlurFilterPlugin extends FilterPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
private static var _propNames:Array = ["blurX","blurY","quality"];
|
||||
|
||||
public function BlurFilterPlugin()
|
||||
{
|
||||
super("blurFilter");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
return _initFilter(param1,param2,param3,BlurFilter,new BlurFilter(0,0,param2.quality || 2),_propNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.filters.ColorMatrixFilter;
|
||||
|
||||
public class ColorMatrixFilterPlugin extends FilterPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected static var _lumR:Number = 0.212671;
|
||||
|
||||
protected static var _lumG:Number = 0.71516;
|
||||
|
||||
protected static var _lumB:Number = 0.072169;
|
||||
|
||||
private static var _propNames:Array = [];
|
||||
|
||||
protected static var _idMatrix:Array = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];
|
||||
|
||||
protected var _matrix:Array;
|
||||
|
||||
protected var _matrixTween:EndArrayPlugin;
|
||||
|
||||
public function ColorMatrixFilterPlugin()
|
||||
{
|
||||
super("colorMatrixFilter");
|
||||
}
|
||||
|
||||
public static function colorize(param1:Array, param2:Number, param3:Number = 1) : Array
|
||||
{
|
||||
var _loc6_:Number = NaN;
|
||||
if(isNaN(param2))
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
if(isNaN(param3))
|
||||
{
|
||||
param3 = 1;
|
||||
}
|
||||
_loc6_ = (param2 >> 16 & 0xFF) / 255;
|
||||
var _loc8_:Number = (param2 >> 8 & 0xFF) / 255;
|
||||
var _loc5_:Number = (param2 & 0xFF) / 255;
|
||||
var _loc4_:Number = 1 - param3;
|
||||
var _loc7_:Array = [_loc4_ + param3 * _loc6_ * _lumR,param3 * _loc6_ * _lumG,param3 * _loc6_ * _lumB,0,0,param3 * _loc8_ * _lumR,_loc4_ + param3 * _loc8_ * _lumG,param3 * _loc8_ * _lumB,0,0,param3 * _loc5_ * _lumR,param3 * _loc5_ * _lumG,_loc4_ + param3 * _loc5_ * _lumB,0,0,0,0,0,1,0];
|
||||
return applyMatrix(_loc7_,param1);
|
||||
}
|
||||
|
||||
public static function setThreshold(param1:Array, param2:Number) : Array
|
||||
{
|
||||
if(isNaN(param2))
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
var _loc3_:Array = [_lumR * 256,_lumG * 256,_lumB * 256,0,-256 * param2,_lumR * 256,_lumG * 256,_lumB * 256,0,-256 * param2,_lumR * 256,_lumG * 256,_lumB * 256,0,-256 * param2,0,0,0,1,0];
|
||||
return applyMatrix(_loc3_,param1);
|
||||
}
|
||||
|
||||
public static function setHue(param1:Array, param2:Number) : Array
|
||||
{
|
||||
var _loc5_:Number = NaN;
|
||||
if(isNaN(param2))
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
param2 *= 3.141592653589793 / 180;
|
||||
_loc5_ = Math.cos(param2);
|
||||
var _loc4_:Number = Math.sin(param2);
|
||||
var _loc3_:Array = [_lumR + _loc5_ * (1 - _lumR) + _loc4_ * -_lumR,_lumG + _loc5_ * -_lumG + _loc4_ * -_lumG,_lumB + _loc5_ * -_lumB + _loc4_ * (1 - _lumB),0,0,_lumR + _loc5_ * -_lumR + _loc4_ * 0.143,_lumG + _loc5_ * (1 - _lumG) + _loc4_ * 0.14,_lumB + _loc5_ * -_lumB + _loc4_ * -0.283,0,0,_lumR + _loc5_ * -_lumR + _loc4_ * -(1 - _lumR),_lumG + _loc5_ * -_lumG + _loc4_ * _lumG,_lumB + _loc5_ * (1 - _lumB) + _loc4_ * _lumB,0,0,0,0,0,1,0,0,0,0,0,1];
|
||||
return applyMatrix(_loc3_,param1);
|
||||
}
|
||||
|
||||
public static function setBrightness(param1:Array, param2:Number) : Array
|
||||
{
|
||||
if(isNaN(param2))
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
param2 = param2 * 100 - 100;
|
||||
return applyMatrix([1,0,0,0,param2,0,1,0,0,param2,0,0,1,0,param2,0,0,0,1,0,0,0,0,0,1],param1);
|
||||
}
|
||||
|
||||
public static function setSaturation(param1:Array, param2:Number) : Array
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
if(isNaN(param2))
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
_loc3_ = 1 - param2;
|
||||
var _loc4_:Number = _loc3_ * _lumR;
|
||||
var _loc7_:Number = _loc3_ * _lumG;
|
||||
var _loc5_:Number = _loc3_ * _lumB;
|
||||
var _loc6_:Array = [_loc4_ + param2,_loc7_,_loc5_,0,0,_loc4_,_loc7_ + param2,_loc5_,0,0,_loc4_,_loc7_,_loc5_ + param2,0,0,0,0,0,1,0];
|
||||
return applyMatrix(_loc6_,param1);
|
||||
}
|
||||
|
||||
public static function setContrast(param1:Array, param2:Number) : Array
|
||||
{
|
||||
if(isNaN(param2))
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
param2 += 0.01;
|
||||
var _loc3_:Array = [param2,0,0,0,128 * (1 - param2),0,param2,0,0,128 * (1 - param2),0,0,param2,0,128 * (1 - param2),0,0,0,1,0];
|
||||
return applyMatrix(_loc3_,param1);
|
||||
}
|
||||
|
||||
public static function applyMatrix(param1:Array, param2:Array) : Array
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
if(!(param1 is Array) || !(param2 is Array))
|
||||
{
|
||||
return param2;
|
||||
}
|
||||
var _loc3_:Array = [];
|
||||
var _loc5_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < 4)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 5)
|
||||
{
|
||||
_loc7_ = int(_loc4_ == 4 ? param1[_loc5_ + 4] : 0);
|
||||
_loc3_[_loc5_ + _loc4_] = param1[_loc5_] * param2[_loc4_] + param1[_loc5_ + 1] * param2[_loc4_ + 5] + param1[_loc5_ + 2] * param2[_loc4_ + 10] + param1[_loc5_ + 3] * param2[_loc4_ + 15] + _loc7_;
|
||||
_loc4_ += 1;
|
||||
}
|
||||
_loc5_ += 5;
|
||||
_loc6_ += 1;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
var _loc4_:Object = param2;
|
||||
_initFilter(param1,{
|
||||
"remove":param2.remove,
|
||||
"index":param2.index,
|
||||
"addFilter":param2.addFilter
|
||||
},param3,ColorMatrixFilter,new ColorMatrixFilter(_idMatrix.slice()),_propNames);
|
||||
if(_filter == null)
|
||||
{
|
||||
trace("FILTER NULL! ");
|
||||
return true;
|
||||
}
|
||||
_matrix = ColorMatrixFilter(_filter).matrix;
|
||||
var _loc5_:Array = [];
|
||||
if(_loc4_.matrix != null && _loc4_.matrix is Array)
|
||||
{
|
||||
_loc5_ = _loc4_.matrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc4_.relative == true)
|
||||
{
|
||||
_loc5_ = _matrix.slice();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _idMatrix.slice();
|
||||
}
|
||||
_loc5_ = setBrightness(_loc5_,_loc4_.brightness);
|
||||
_loc5_ = setContrast(_loc5_,_loc4_.contrast);
|
||||
_loc5_ = setHue(_loc5_,_loc4_.hue);
|
||||
_loc5_ = setSaturation(_loc5_,_loc4_.saturation);
|
||||
_loc5_ = setThreshold(_loc5_,_loc4_.threshold);
|
||||
if(!isNaN(_loc4_.colorize))
|
||||
{
|
||||
_loc5_ = colorize(_loc5_,_loc4_.colorize,_loc4_.amount);
|
||||
}
|
||||
}
|
||||
_matrixTween = new EndArrayPlugin();
|
||||
_matrixTween._init(_matrix,_loc5_);
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
_matrixTween.setRatio(param1);
|
||||
ColorMatrixFilter(_filter).matrix = _matrix;
|
||||
super.setRatio(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.geom.ColorTransform;
|
||||
|
||||
public class ColorTransformPlugin extends TintPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
public function ColorTransformPlugin()
|
||||
{
|
||||
super();
|
||||
_propName = "colorTransform";
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
var _loc5_:ColorTransform = null;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc6_:ColorTransform = new ColorTransform();
|
||||
if(param1 is DisplayObject)
|
||||
{
|
||||
_transform = DisplayObject(param1).transform;
|
||||
_loc5_ = _transform.colorTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!(param1 is ColorTransform))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc5_ = param1 as ColorTransform;
|
||||
}
|
||||
if(param2 is ColorTransform)
|
||||
{
|
||||
_loc6_.concat(param2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_.concat(_loc5_);
|
||||
}
|
||||
for(var _loc4_:String in param2)
|
||||
{
|
||||
if(_loc4_ == "tint" || _loc4_ == "color")
|
||||
{
|
||||
if(param2[_loc4_] != null)
|
||||
{
|
||||
_loc6_.color = int(param2[_loc4_]);
|
||||
}
|
||||
}
|
||||
else if(!(_loc4_ == "tintAmount" || _loc4_ == "exposure" || _loc4_ == "brightness"))
|
||||
{
|
||||
_loc6_[_loc4_] = param2[_loc4_];
|
||||
}
|
||||
}
|
||||
if(!(param2 is ColorTransform))
|
||||
{
|
||||
if(!isNaN(param2.tintAmount))
|
||||
{
|
||||
_loc7_ = param2.tintAmount / (1 - (_loc6_.redMultiplier + _loc6_.greenMultiplier + _loc6_.blueMultiplier) / 3);
|
||||
_loc6_.redOffset *= _loc7_;
|
||||
_loc6_.greenOffset *= _loc7_;
|
||||
_loc6_.blueOffset *= _loc7_;
|
||||
_loc6_.redMultiplier = _loc6_.greenMultiplier = _loc6_.blueMultiplier = 1 - param2.tintAmount;
|
||||
}
|
||||
else if(!isNaN(param2.exposure))
|
||||
{
|
||||
_loc6_.redOffset = _loc6_.greenOffset = _loc6_.blueOffset = 255 * (param2.exposure - 1);
|
||||
_loc6_.redMultiplier = _loc6_.greenMultiplier = _loc6_.blueMultiplier = 1;
|
||||
}
|
||||
else if(!isNaN(param2.brightness))
|
||||
{
|
||||
_loc6_.redOffset = _loc6_.greenOffset = _loc6_.blueOffset = Math.max(0,(param2.brightness - 1) * 255);
|
||||
_loc6_.redMultiplier = _loc6_.greenMultiplier = _loc6_.blueMultiplier = 1 - Math.abs(param2.brightness - 1);
|
||||
}
|
||||
}
|
||||
_init(_loc5_,_loc6_);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.filters.DropShadowFilter;
|
||||
|
||||
public class DropShadowFilterPlugin extends FilterPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
private static var _propNames:Array = ["distance","angle","color","alpha","blurX","blurY","strength","quality","inner","knockout","hideObject"];
|
||||
|
||||
public function DropShadowFilterPlugin()
|
||||
{
|
||||
super("dropShadowFilter");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
return _initFilter(param1,param2,param3,DropShadowFilter,new DropShadowFilter(0,45,0,0,0,0,1,param2.quality || 2,param2.inner,param2.knockout,param2.hideObject),_propNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
|
||||
public class EndArrayPlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected var _a:Array;
|
||||
|
||||
protected var _round:Boolean;
|
||||
|
||||
protected var _info:Array = [];
|
||||
|
||||
public function EndArrayPlugin()
|
||||
{
|
||||
super("endArray");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
if(!(param1 is Array) || !(param2 is Array))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_init(param1 as Array,param2);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function _init(param1:Array, param2:Array) : void
|
||||
{
|
||||
_a = param1;
|
||||
var _loc4_:int = int(param2.length);
|
||||
var _loc3_:int = 0;
|
||||
while(--_loc4_ > -1)
|
||||
{
|
||||
if(param1[_loc4_] != param2[_loc4_] && param1[_loc4_] != null)
|
||||
{
|
||||
_info[_loc3_++] = new ArrayTweenInfo(_loc4_,_a[_loc4_],param2[_loc4_] - _a[_loc4_]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function _roundProps(param1:Object, param2:Boolean = true) : void
|
||||
{
|
||||
if("endArray" in param1)
|
||||
{
|
||||
_round = param2;
|
||||
}
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
var _loc3_:ArrayTweenInfo = null;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc4_:int = int(_info.length);
|
||||
if(_round)
|
||||
{
|
||||
while(--_loc4_ > -1)
|
||||
{
|
||||
_loc3_ = _info[_loc4_];
|
||||
_a[_loc3_.i] = (_loc2_ = _loc3_.c * param1 + _loc3_.s) > 0 ? _loc2_ + 0.5 >> 0 : _loc2_ - 0.5 >> 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(--_loc4_ > -1)
|
||||
{
|
||||
_loc3_ = _info[_loc4_];
|
||||
_a[_loc3_.i] = _loc3_.c * param1 + _loc3_.s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ArrayTweenInfo
|
||||
{
|
||||
|
||||
public var i:uint;
|
||||
|
||||
public var s:Number;
|
||||
|
||||
public var c:Number;
|
||||
|
||||
public function ArrayTweenInfo(param1:uint, param2:Number, param3:Number)
|
||||
{
|
||||
super();
|
||||
this.i = param1;
|
||||
this.s = param2;
|
||||
this.c = param3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.filters.BitmapFilter;
|
||||
import flash.filters.BlurFilter;
|
||||
|
||||
public class FilterPlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected var _target:Object;
|
||||
|
||||
protected var _type:Class;
|
||||
|
||||
protected var _filter:BitmapFilter;
|
||||
|
||||
protected var _index:int;
|
||||
|
||||
protected var _remove:Boolean;
|
||||
|
||||
private var _tween:TweenLite;
|
||||
|
||||
public function FilterPlugin(param1:String = "", param2:Number = 0)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
protected function _initFilter(param1:*, param2:Object, param3:TweenLite, param4:Class, param5:BitmapFilter, param6:Array) : Boolean
|
||||
{
|
||||
var _loc7_:String = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc11_:HexColorsPlugin = null;
|
||||
_target = param1;
|
||||
_tween = param3;
|
||||
_type = param4;
|
||||
var _loc10_:Array = _target.filters;
|
||||
var _loc9_:Object = param2 is BitmapFilter ? {} : param2;
|
||||
if(_loc9_.index != null)
|
||||
{
|
||||
_index = _loc9_.index;
|
||||
}
|
||||
else
|
||||
{
|
||||
_index = _loc10_.length;
|
||||
if(_loc9_.addFilter != true)
|
||||
{
|
||||
while(--_index > -1 && !(_loc10_[_index] is _type))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_index < 0 || !(_loc10_[_index] is _type))
|
||||
{
|
||||
if(_index < 0)
|
||||
{
|
||||
_index = _loc10_.length;
|
||||
}
|
||||
if(_index > _loc10_.length)
|
||||
{
|
||||
_loc8_ = _loc10_.length - 1;
|
||||
while(++_loc8_ < _index)
|
||||
{
|
||||
_loc10_[_loc8_] = new BlurFilter(0,0,1);
|
||||
}
|
||||
}
|
||||
_loc10_[_index] = param5;
|
||||
_target.filters = _loc10_;
|
||||
}
|
||||
_filter = _loc10_[_index];
|
||||
_remove = _loc9_.remove == true;
|
||||
_loc8_ = int(param6.length);
|
||||
while(--_loc8_ > -1)
|
||||
{
|
||||
_loc7_ = param6[_loc8_];
|
||||
if(_loc7_ in param2 && _filter[_loc7_] != param2[_loc7_])
|
||||
{
|
||||
if(_loc7_ == "color" || _loc7_ == "highlightColor" || _loc7_ == "shadowColor")
|
||||
{
|
||||
_loc11_ = new HexColorsPlugin();
|
||||
_loc11_._initColor(_filter,_loc7_,param2[_loc7_]);
|
||||
_addTween(_loc11_,"setRatio",0,1,_propName);
|
||||
}
|
||||
else if(_loc7_ == "quality" || _loc7_ == "inner" || _loc7_ == "knockout" || _loc7_ == "hideObject")
|
||||
{
|
||||
_filter[_loc7_] = param2[_loc7_];
|
||||
}
|
||||
else
|
||||
{
|
||||
_addTween(_filter,_loc7_,_filter[_loc7_],param2[_loc7_],_propName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
super.setRatio(param1);
|
||||
var _loc2_:Array = _target.filters;
|
||||
if(!(_loc2_[_index] is _type))
|
||||
{
|
||||
_index = _loc2_.length;
|
||||
while(--_index > -1 && !(_loc2_[_index] is _type))
|
||||
{
|
||||
}
|
||||
if(_index == -1)
|
||||
{
|
||||
_index = _loc2_.length;
|
||||
}
|
||||
}
|
||||
if(param1 == 1 && _remove && _tween._time == _tween._duration && _tween.data != "isFromStart")
|
||||
{
|
||||
if(_index < _loc2_.length)
|
||||
{
|
||||
_loc2_.splice(_index,1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_[_index] = _filter;
|
||||
}
|
||||
_target.filters = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public class FrameLabelPlugin extends FramePlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
public function FrameLabelPlugin()
|
||||
{
|
||||
super();
|
||||
_propName = "frameLabel";
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
if(!param3.target is MovieClip)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_target = param1 as MovieClip;
|
||||
this.frame = _target.currentFrame;
|
||||
var _loc7_:Array = _target.currentLabels;
|
||||
var _loc6_:String = param2;
|
||||
var _loc5_:int = _target.currentFrame;
|
||||
var _loc4_:int = int(_loc7_.length);
|
||||
while(--_loc4_ > -1)
|
||||
{
|
||||
if(_loc7_[_loc4_].name == _loc6_)
|
||||
{
|
||||
_loc5_ = int(_loc7_[_loc4_].frame);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(this.frame != _loc5_)
|
||||
{
|
||||
_addTween(this,"frame",this.frame,_loc5_,"frame",true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public class FramePlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
public var frame:int;
|
||||
|
||||
protected var _target:MovieClip;
|
||||
|
||||
public function FramePlugin()
|
||||
{
|
||||
super("frame,frameLabel,frameForward,frameBackward");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
if(!(param1 is MovieClip) || isNaN(param2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_target = param1 as MovieClip;
|
||||
this.frame = _target.currentFrame;
|
||||
_addTween(this,"frame",this.frame,param2,"frame",true);
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
super.setRatio(param1);
|
||||
if(this.frame != _target.currentFrame)
|
||||
{
|
||||
_target.gotoAndStop(this.frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.filters.GlowFilter;
|
||||
|
||||
public class GlowFilterPlugin extends FilterPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
private static var _propNames:Array = ["color","alpha","blurX","blurY","strength","quality","inner","knockout"];
|
||||
|
||||
public function GlowFilterPlugin()
|
||||
{
|
||||
super("glowFilter");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
return _initFilter(param1,param2,param3,GlowFilter,new GlowFilter(16777215,0,0,0,param2.strength || 1,param2.quality || 2,param2.inner,param2.knockout),_propNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
|
||||
public class HexColorsPlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected var _colors:Array;
|
||||
|
||||
public function HexColorsPlugin()
|
||||
{
|
||||
super("hexColors");
|
||||
_overwriteProps = [];
|
||||
_colors = [];
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
for(var _loc4_:String in param2)
|
||||
{
|
||||
_initColor(param1,_loc4_,uint(param2[_loc4_]));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function _initColor(param1:Object, param2:String, param3:uint) : void
|
||||
{
|
||||
var _loc8_:Boolean = false;
|
||||
var _loc5_:* = 0;
|
||||
_loc8_ = typeof param1[param2] == "function";
|
||||
var _temp_2:*;
|
||||
var _loc7_:uint = uint(!_loc8_ ? param1[param2] : (_temp_2 = param1,param1[param2.indexOf("set") || !("get" + param2.substr(3) in param1) ? param2 : "get" + param2.substr(3)]()));
|
||||
var _temp_2:*;
|
||||
if(_loc7_ != param3)
|
||||
{
|
||||
_loc5_ = uint(_loc7_ >> 16);
|
||||
var _loc6_:uint = uint(_loc7_ >> 8 & 0xFF);
|
||||
var _loc4_:uint = uint(_loc7_ & 0xFF);
|
||||
_colors[_colors.length] = new ColorProp(param1,param2,_loc8_,_loc5_,(param3 >> 16) - _loc5_,_loc6_,(param3 >> 8 & 0xFF) - _loc6_,_loc4_,(param3 & 0xFF) - _loc4_);
|
||||
_overwriteProps[_overwriteProps.length] = param2;
|
||||
}
|
||||
}
|
||||
|
||||
override public function _kill(param1:Object) : Boolean
|
||||
{
|
||||
var _loc2_:int = int(_colors.length);
|
||||
while(_loc2_--)
|
||||
{
|
||||
if(param1[_colors[_loc2_].p] != null)
|
||||
{
|
||||
_colors.splice(_loc2_,1);
|
||||
}
|
||||
}
|
||||
return super._kill(param1);
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
var _loc3_:ColorProp = null;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc4_:int = int(_colors.length);
|
||||
while(--_loc4_ > -1)
|
||||
{
|
||||
_loc3_ = _colors[_loc4_];
|
||||
_loc2_ = _loc3_.rs + param1 * _loc3_.rc << 16 | _loc3_.gs + param1 * _loc3_.gc << 8 | _loc3_.bs + param1 * _loc3_.bc;
|
||||
if(_loc3_.f)
|
||||
{
|
||||
_loc3_.t[_loc3_.p](_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_.t[_loc3_.p] = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ColorProp
|
||||
{
|
||||
|
||||
public var t:Object;
|
||||
|
||||
public var p:String;
|
||||
|
||||
public var f:Boolean;
|
||||
|
||||
public var rs:int;
|
||||
|
||||
public var rc:int;
|
||||
|
||||
public var gs:int;
|
||||
|
||||
public var gc:int;
|
||||
|
||||
public var bs:int;
|
||||
|
||||
public var bc:int;
|
||||
|
||||
public function ColorProp(param1:Object, param2:String, param3:Boolean, param4:int, param5:int, param6:int, param7:int, param8:int, param9:int)
|
||||
{
|
||||
super();
|
||||
this.t = param1;
|
||||
this.p = param2;
|
||||
this.f = param3;
|
||||
this.rs = param4;
|
||||
this.rc = param5;
|
||||
this.gs = param6;
|
||||
this.gc = param7;
|
||||
this.bs = param8;
|
||||
this.bc = param9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
public class RemoveTintPlugin extends TintPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
public function RemoveTintPlugin()
|
||||
{
|
||||
super();
|
||||
_propName = "removeTint";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import com.greensock.core.PropTween;
|
||||
|
||||
public class RoundPropsPlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected var _tween:TweenLite;
|
||||
|
||||
public function RoundPropsPlugin()
|
||||
{
|
||||
super("roundProps",-1);
|
||||
_overwriteProps.length = 0;
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
_tween = param3;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function _onInitAllProps() : Boolean
|
||||
{
|
||||
var _loc5_:String = null;
|
||||
var _loc3_:PropTween = null;
|
||||
var _loc1_:PropTween = null;
|
||||
var _loc7_:Array = null;
|
||||
_loc7_ = _tween.vars.roundProps is Array ? _tween.vars.roundProps : _tween.vars.roundProps.split(",");
|
||||
var _loc6_:int = int(_loc7_.length);
|
||||
var _loc2_:Object = {};
|
||||
var _loc4_:PropTween = _tween._propLookup.roundProps;
|
||||
while(--_loc6_ > -1)
|
||||
{
|
||||
_loc2_[_loc7_[_loc6_]] = 1;
|
||||
}
|
||||
_loc6_ = int(_loc7_.length);
|
||||
while(--_loc6_ > -1)
|
||||
{
|
||||
_loc5_ = _loc7_[_loc6_];
|
||||
_loc3_ = _tween._firstPT;
|
||||
while(_loc3_)
|
||||
{
|
||||
_loc1_ = _loc3_._next;
|
||||
if(_loc3_.pg)
|
||||
{
|
||||
_loc3_.t._roundProps(_loc2_,true);
|
||||
}
|
||||
else if(_loc3_.n == _loc5_)
|
||||
{
|
||||
_add(_loc3_.t,_loc5_,_loc3_.s,_loc3_.c);
|
||||
if(_loc1_)
|
||||
{
|
||||
_loc1_._prev = _loc3_._prev;
|
||||
}
|
||||
if(_loc3_._prev)
|
||||
{
|
||||
_loc3_._prev._next = _loc1_;
|
||||
}
|
||||
else if(_tween._firstPT == _loc3_)
|
||||
{
|
||||
_tween._firstPT = _loc1_;
|
||||
}
|
||||
_loc3_._next = _loc3_._prev = null;
|
||||
_tween._propLookup[_loc5_] = _loc4_;
|
||||
}
|
||||
_loc3_ = _loc1_;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _add(param1:Object, param2:String, param3:Number, param4:Number) : void
|
||||
{
|
||||
_addTween(param1,param2,param3,param3 + param4,param2,true);
|
||||
_overwriteProps[_overwriteProps.length] = param2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
|
||||
public class ShortRotationPlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
public function ShortRotationPlugin()
|
||||
{
|
||||
super("shortRotation");
|
||||
_overwriteProps.pop();
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
var _loc6_:Number = NaN;
|
||||
if(typeof param2 == "number")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc5_:Boolean = param2.useRadians == true;
|
||||
for(var _loc4_:String in param2)
|
||||
{
|
||||
if(_loc4_ != "useRadians")
|
||||
{
|
||||
var _temp_2:*;
|
||||
_loc6_ = Number(param1[_loc4_] is Function ? (_temp_2 = param1,param1[_loc4_.indexOf("set") || !("get" + _loc4_.substr(3) in param1) ? _loc4_ : "get" + _loc4_.substr(3)]()) : param1[_loc4_]);
|
||||
_initRotation(param1,_loc4_,_loc6_,typeof param2[_loc4_] == "number" ? Number(param2[_loc4_]) : _loc6_ + Number(param2[_loc4_].split("=").join("")),_loc5_);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function _initRotation(param1:Object, param2:String, param3:Number, param4:Number, param5:Boolean = false) : void
|
||||
{
|
||||
var _loc7_:Number = NaN;
|
||||
_loc7_ = param5 ? 3.141592653589793 * 2 : 360;
|
||||
var _loc6_:Number = (param4 - param3) % _loc7_;
|
||||
if(_loc6_ != _loc6_ % (_loc7_ / 2))
|
||||
{
|
||||
_loc6_ = _loc6_ < 0 ? _loc6_ + _loc7_ : _loc6_ - _loc7_;
|
||||
}
|
||||
_addTween(param1,param2,param3,param3 + _loc6_,param2);
|
||||
_overwriteProps[_overwriteProps.length] = param2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import flash.display.Stage;
|
||||
|
||||
public class StageQualityPlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected var _stage:Stage;
|
||||
|
||||
protected var _during:String;
|
||||
|
||||
protected var _after:String;
|
||||
|
||||
protected var _tween:TweenLite;
|
||||
|
||||
public function StageQualityPlugin()
|
||||
{
|
||||
super("stageQuality");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
if(!(param2.stage is Stage))
|
||||
{
|
||||
trace("You must define a \'stage\' property for the stageQuality object in your tween.");
|
||||
return false;
|
||||
}
|
||||
_stage = param2.stage as Stage;
|
||||
_tween = param3;
|
||||
_during = "during" in param2 ? param2.during : "medium";
|
||||
_after = "after" in param2 ? param2.after : _stage.quality;
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
if(param1 == 1 && _tween._duration == _tween._time && _tween.data != "isFromStart" || param1 == 0 && _tween._time == 0)
|
||||
{
|
||||
_stage.quality = _after;
|
||||
}
|
||||
else if(_stage.quality != _during)
|
||||
{
|
||||
_stage.quality = _during;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.*;
|
||||
import com.greensock.core.*;
|
||||
import flash.display.*;
|
||||
import flash.geom.ColorTransform;
|
||||
import flash.geom.Transform;
|
||||
|
||||
public class TintPlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected static var _props:Array = ["redMultiplier","greenMultiplier","blueMultiplier","alphaMultiplier","redOffset","greenOffset","blueOffset","alphaOffset"];
|
||||
|
||||
protected var _transform:Transform;
|
||||
|
||||
public function TintPlugin()
|
||||
{
|
||||
super("tint,colorTransform,removeTint");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
if(!(param1 is DisplayObject))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc5_:ColorTransform = new ColorTransform();
|
||||
if(param2 != null && param3.vars.removeTint != true)
|
||||
{
|
||||
_loc5_.color = param2;
|
||||
}
|
||||
_transform = DisplayObject(param1).transform;
|
||||
var _loc4_:ColorTransform = _transform.colorTransform;
|
||||
_loc5_.alphaMultiplier = _loc4_.alphaMultiplier;
|
||||
_loc5_.alphaOffset = _loc4_.alphaOffset;
|
||||
_init(_loc4_,_loc5_);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function _init(param1:ColorTransform, param2:ColorTransform) : void
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:int = int(_props.length);
|
||||
while(--_loc4_ > -1)
|
||||
{
|
||||
_loc3_ = _props[_loc4_];
|
||||
if(param1[_loc3_] != param2[_loc3_])
|
||||
{
|
||||
_addTween(param1,_loc3_,param1[_loc3_],param2[_loc3_],"tint");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
var _loc2_:ColorTransform = _transform.colorTransform;
|
||||
var _loc3_:PropTween = _firstPT;
|
||||
while(_loc3_)
|
||||
{
|
||||
_loc2_[_loc3_.p] = _loc3_.c * param1 + _loc3_.s;
|
||||
_loc3_ = _loc3_._next;
|
||||
}
|
||||
_transform.colorTransform = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
import com.greensock.core.PropTween;
|
||||
|
||||
public class TweenPlugin
|
||||
{
|
||||
|
||||
public static const version:String = "12.1.5";
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
public var _propName:String;
|
||||
|
||||
public var _overwriteProps:Array;
|
||||
|
||||
public var _priority:int = 0;
|
||||
|
||||
protected var _firstPT:PropTween;
|
||||
|
||||
public function TweenPlugin(param1:String = "", param2:int = 0)
|
||||
{
|
||||
super();
|
||||
_overwriteProps = param1.split(",");
|
||||
_propName = _overwriteProps[0];
|
||||
_priority = param2 || 0;
|
||||
}
|
||||
|
||||
private static function _onTweenEvent(param1:String, param2:TweenLite) : Boolean
|
||||
{
|
||||
var _loc7_:Boolean = false;
|
||||
var _loc6_:PropTween = null;
|
||||
var _loc5_:PropTween = null;
|
||||
var _loc3_:PropTween = null;
|
||||
var _loc8_:PropTween = null;
|
||||
var _loc4_:PropTween = param2._firstPT;
|
||||
if(param1 == "_onInitAllProps")
|
||||
{
|
||||
while(_loc4_)
|
||||
{
|
||||
_loc3_ = _loc4_._next;
|
||||
_loc8_ = _loc6_;
|
||||
while(_loc8_ && _loc8_.pr > _loc4_.pr)
|
||||
{
|
||||
_loc8_ = _loc8_._next;
|
||||
}
|
||||
if(_loc4_._prev == _loc8_ ? _loc8_._prev : _loc5_)
|
||||
{
|
||||
_loc4_._prev._next = _loc4_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = _loc4_;
|
||||
}
|
||||
if(_loc4_._next == _loc8_)
|
||||
{
|
||||
_loc8_._prev = _loc4_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _loc4_;
|
||||
}
|
||||
_loc4_ = _loc3_;
|
||||
}
|
||||
_loc4_ = param2._firstPT = _loc6_;
|
||||
}
|
||||
while(_loc4_)
|
||||
{
|
||||
if(_loc4_.pg)
|
||||
{
|
||||
if(param1 in _loc4_.t)
|
||||
{
|
||||
if(_loc4_.t[param1]())
|
||||
{
|
||||
_loc7_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc4_ = _loc4_._next;
|
||||
}
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
public static function activate(param1:Array) : Boolean
|
||||
{
|
||||
TweenLite._onPluginEvent = TweenPlugin._onTweenEvent;
|
||||
var _loc2_:int = int(param1.length);
|
||||
while(--_loc2_ > -1)
|
||||
{
|
||||
if(param1[_loc2_].API == 2)
|
||||
{
|
||||
TweenLite._plugins[new (param1[_loc2_] as Class)()._propName] = param1[_loc2_];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function _addTween(param1:Object, param2:String, param3:Number, param4:*, param5:String = null, param6:Boolean = false) : PropTween
|
||||
{
|
||||
var _loc7_:Number = param4 == null ? 0 : (typeof param4 === "number" || param4.charAt(1) !== "=" ? Number(param4) - param3 : (int(param4.charAt(0) + "1")) * Number(param4.substr(2)));
|
||||
if(_loc7_ !== 0)
|
||||
{
|
||||
_firstPT = new PropTween(param1,param2,param3,_loc7_,param5 || param2,false,_firstPT);
|
||||
_firstPT.r = param6;
|
||||
return _firstPT;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setRatio(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:PropTween = _firstPT;
|
||||
while(_loc3_)
|
||||
{
|
||||
_loc2_ = _loc3_.c * param1 + _loc3_.s;
|
||||
if(_loc3_.r)
|
||||
{
|
||||
_loc2_ = _loc2_ + (_loc2_ > 0 ? 0.5 : -0.5) | 0;
|
||||
}
|
||||
if(_loc3_.f)
|
||||
{
|
||||
_loc3_.t[_loc3_.p](_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_.t[_loc3_.p] = _loc2_;
|
||||
}
|
||||
_loc3_ = _loc3_._next;
|
||||
}
|
||||
}
|
||||
|
||||
public function _roundProps(param1:Object, param2:Boolean = true) : void
|
||||
{
|
||||
var _loc3_:PropTween = _firstPT;
|
||||
while(_loc3_)
|
||||
{
|
||||
if(_propName in param1 || _loc3_.n != null && _loc3_.n.split(_propName + "_").join("") in param1)
|
||||
{
|
||||
_loc3_.r = param2;
|
||||
}
|
||||
_loc3_ = _loc3_._next;
|
||||
}
|
||||
}
|
||||
|
||||
public function _kill(param1:Object) : Boolean
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
if(_propName in param1)
|
||||
{
|
||||
_overwriteProps = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = int(_overwriteProps.length);
|
||||
while(--_loc3_ > -1)
|
||||
{
|
||||
if(_overwriteProps[_loc3_] in param1)
|
||||
{
|
||||
_overwriteProps.splice(_loc3_,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
var _loc2_:PropTween = _firstPT;
|
||||
while(_loc2_)
|
||||
{
|
||||
if(_loc2_.n in param1)
|
||||
{
|
||||
if(_loc2_._next)
|
||||
{
|
||||
_loc2_._next._prev = _loc2_._prev;
|
||||
}
|
||||
if(_loc2_._prev)
|
||||
{
|
||||
_loc2_._prev._next = _loc2_._next;
|
||||
_loc2_._prev = null;
|
||||
}
|
||||
else if(_firstPT == _loc2_)
|
||||
{
|
||||
_firstPT = _loc2_._next;
|
||||
}
|
||||
}
|
||||
_loc2_ = _loc2_._next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.TweenLite;
|
||||
|
||||
public class VisiblePlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected var _target:Object;
|
||||
|
||||
protected var _tween:TweenLite;
|
||||
|
||||
protected var _visible:Boolean;
|
||||
|
||||
protected var _initVal:Boolean;
|
||||
|
||||
protected var _progress:int;
|
||||
|
||||
public function VisiblePlugin()
|
||||
{
|
||||
super("visible");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
_target = param1;
|
||||
_tween = param3;
|
||||
_progress = _tween.vars.runBackwards ? 0 : 1;
|
||||
_initVal = _target.visible;
|
||||
_visible = param2;
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
_target.visible = param1 == 1 && (_tween._time / _tween._duration == _progress || _tween._duration == 0) ? _visible : _initVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.greensock.plugins
|
||||
{
|
||||
import com.greensock.*;
|
||||
import flash.media.SoundTransform;
|
||||
|
||||
public class VolumePlugin extends TweenPlugin
|
||||
{
|
||||
|
||||
public static const API:Number = 2;
|
||||
|
||||
protected var _target:Object;
|
||||
|
||||
protected var _st:SoundTransform;
|
||||
|
||||
public function VolumePlugin()
|
||||
{
|
||||
super("volume");
|
||||
}
|
||||
|
||||
override public function _onInitTween(param1:Object, param2:*, param3:TweenLite) : Boolean
|
||||
{
|
||||
if(isNaN(param2) || param1.hasOwnProperty("volume") || !param1.hasOwnProperty("soundTransform"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_target = param1;
|
||||
_st = _target.soundTransform;
|
||||
_addTween(_st,"volume",_st.volume,param2,"volume");
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function setRatio(param1:Number) : void
|
||||
{
|
||||
super.setRatio(param1);
|
||||
_target.soundTransform = _st;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
package com.hurlant.crypto
|
||||
{
|
||||
import com.hurlant.crypto.hash.HMAC;
|
||||
import com.hurlant.crypto.hash.IHash;
|
||||
import com.hurlant.crypto.hash.MD2;
|
||||
import com.hurlant.crypto.hash.MD5;
|
||||
import com.hurlant.crypto.hash.SHA1;
|
||||
import com.hurlant.crypto.hash.SHA224;
|
||||
import com.hurlant.crypto.hash.SHA256;
|
||||
import com.hurlant.crypto.prng.ARC4;
|
||||
import com.hurlant.crypto.rsa.RSAKey;
|
||||
import com.hurlant.crypto.symmetric.AESKey;
|
||||
import com.hurlant.crypto.symmetric.BlowFishKey;
|
||||
import com.hurlant.crypto.symmetric.CBCMode;
|
||||
import com.hurlant.crypto.symmetric.CFB8Mode;
|
||||
import com.hurlant.crypto.symmetric.CFBMode;
|
||||
import com.hurlant.crypto.symmetric.CTRMode;
|
||||
import com.hurlant.crypto.symmetric.DESKey;
|
||||
import com.hurlant.crypto.symmetric.ECBMode;
|
||||
import com.hurlant.crypto.symmetric.ICipher;
|
||||
import com.hurlant.crypto.symmetric.IMode;
|
||||
import com.hurlant.crypto.symmetric.IPad;
|
||||
import com.hurlant.crypto.symmetric.ISymmetricKey;
|
||||
import com.hurlant.crypto.symmetric.IVMode;
|
||||
import com.hurlant.crypto.symmetric.NullPad;
|
||||
import com.hurlant.crypto.symmetric.OFBMode;
|
||||
import com.hurlant.crypto.symmetric.PKCS5;
|
||||
import com.hurlant.crypto.symmetric.SimpleIVMode;
|
||||
import com.hurlant.crypto.symmetric.TripleDESKey;
|
||||
import com.hurlant.crypto.symmetric.XTeaKey;
|
||||
import com.hurlant.util.Base64;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class Crypto
|
||||
{
|
||||
|
||||
private var b64:Base64;
|
||||
|
||||
public function Crypto()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getCipher(param1:String, param2:ByteArray, param3:IPad = null) : ICipher
|
||||
{
|
||||
var _loc4_:ICipher = null;
|
||||
var _loc5_:Array;
|
||||
switch((_loc5_ = param1.split("-"))[0])
|
||||
{
|
||||
case "simple":
|
||||
_loc5_.shift();
|
||||
param1 = _loc5_.join("-");
|
||||
_loc4_ = getCipher(param1,param2,param3);
|
||||
if(_loc4_ is IVMode)
|
||||
{
|
||||
return new SimpleIVMode(_loc4_ as IVMode);
|
||||
}
|
||||
return _loc4_;
|
||||
break;
|
||||
case "aes":
|
||||
case "aes128":
|
||||
case "aes192":
|
||||
case "aes256":
|
||||
break;
|
||||
case "bf":
|
||||
case "blowfish":
|
||||
_loc5_.shift();
|
||||
return getMode(_loc5_[0],new BlowFishKey(param2),param3);
|
||||
case "des":
|
||||
_loc5_.shift();
|
||||
if(_loc5_[0] != "ede" && _loc5_[0] != "ede3")
|
||||
{
|
||||
return getMode(_loc5_[0],new DESKey(param2),param3);
|
||||
}
|
||||
if(_loc5_.length == 1)
|
||||
{
|
||||
_loc5_.push("ecb");
|
||||
}
|
||||
case "3des":
|
||||
case "des3":
|
||||
_loc5_.shift();
|
||||
return getMode(_loc5_[0],new TripleDESKey(param2),param3);
|
||||
case "xtea":
|
||||
_loc5_.shift();
|
||||
return getMode(_loc5_[0],new XTeaKey(param2),param3);
|
||||
case "rc4":
|
||||
_loc5_.shift();
|
||||
return new ARC4(param2);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
_loc5_.shift();
|
||||
if(param2.length * 8 == _loc5_[0])
|
||||
{
|
||||
_loc5_.shift();
|
||||
}
|
||||
return getMode(_loc5_[0],new AESKey(param2),param3);
|
||||
}
|
||||
|
||||
public static function getKeySize(param1:String) : uint
|
||||
{
|
||||
var _loc2_:Array = param1.split("-");
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "simple":
|
||||
_loc2_.shift();
|
||||
return getKeySize(_loc2_.join("-"));
|
||||
case "aes128":
|
||||
return 16;
|
||||
case "aes192":
|
||||
return 24;
|
||||
case "aes256":
|
||||
return 32;
|
||||
case "aes":
|
||||
_loc2_.shift();
|
||||
return parseInt(_loc2_[0]) / 8;
|
||||
case "bf":
|
||||
case "blowfish":
|
||||
break;
|
||||
case "des":
|
||||
_loc2_.shift();
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "ede":
|
||||
return 16;
|
||||
case "ede3":
|
||||
return 24;
|
||||
default:
|
||||
return 8;
|
||||
}
|
||||
break;
|
||||
case "3des":
|
||||
case "des3":
|
||||
return 24;
|
||||
case "xtea":
|
||||
return 8;
|
||||
case "rc4":
|
||||
if(parseInt(_loc2_[1]) > 0)
|
||||
{
|
||||
return parseInt(_loc2_[1]) / 8;
|
||||
}
|
||||
return 16;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 16;
|
||||
}
|
||||
|
||||
private static function getMode(param1:String, param2:ISymmetricKey, param3:IPad = null) : IMode
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case "ecb":
|
||||
return new ECBMode(param2,param3);
|
||||
case "cfb":
|
||||
return new CFBMode(param2,param3);
|
||||
case "cfb8":
|
||||
return new CFB8Mode(param2,param3);
|
||||
case "ofb":
|
||||
return new OFBMode(param2,param3);
|
||||
case "ctr":
|
||||
return new CTRMode(param2,param3);
|
||||
case "cbc":
|
||||
}
|
||||
return new CBCMode(param2,param3);
|
||||
}
|
||||
|
||||
public static function getHash(param1:String) : IHash
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case "md2":
|
||||
return new MD2();
|
||||
case "md5":
|
||||
return new MD5();
|
||||
case "sha":
|
||||
case "sha1":
|
||||
break;
|
||||
case "sha224":
|
||||
return new SHA224();
|
||||
case "sha256":
|
||||
return new SHA256();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return new SHA1();
|
||||
}
|
||||
|
||||
public static function getHMAC(param1:String) : HMAC
|
||||
{
|
||||
var _loc2_:Array = param1.split("-");
|
||||
if(_loc2_[0] == "hmac")
|
||||
{
|
||||
_loc2_.shift();
|
||||
}
|
||||
var _loc3_:uint = 0;
|
||||
if(_loc2_.length > 1)
|
||||
{
|
||||
_loc3_ = parseInt(_loc2_[1]);
|
||||
}
|
||||
return new HMAC(getHash(_loc2_[0]),_loc3_);
|
||||
}
|
||||
|
||||
public static function getPad(param1:String) : IPad
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case "null":
|
||||
return new NullPad();
|
||||
case "pkcs5":
|
||||
}
|
||||
return new PKCS5();
|
||||
}
|
||||
|
||||
public static function getRSA(param1:String, param2:String) : RSAKey
|
||||
{
|
||||
return RSAKey.parsePublicKey(param2,param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.hurlant.crypto.hash
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class HMAC
|
||||
{
|
||||
|
||||
private var hash:IHash;
|
||||
|
||||
private var bits:uint;
|
||||
|
||||
public function HMAC(param1:IHash, param2:uint = 0)
|
||||
{
|
||||
super();
|
||||
this.hash = param1;
|
||||
this.bits = param2;
|
||||
}
|
||||
|
||||
public function getHashSize() : uint
|
||||
{
|
||||
if(bits != 0)
|
||||
{
|
||||
return bits / 8;
|
||||
}
|
||||
return hash.getHashSize();
|
||||
}
|
||||
|
||||
public function compute(param1:ByteArray, param2:ByteArray) : ByteArray
|
||||
{
|
||||
var _loc3_:ByteArray = null;
|
||||
var _loc7_:* = 0;
|
||||
if(param1.length > hash.getInputSize())
|
||||
{
|
||||
_loc3_ = hash.hash(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = new ByteArray();
|
||||
_loc3_.writeBytes(param1);
|
||||
}
|
||||
while(_loc3_.length < hash.getInputSize())
|
||||
{
|
||||
_loc3_[_loc3_.length] = 0;
|
||||
}
|
||||
var _loc8_:ByteArray = new ByteArray();
|
||||
var _loc5_:ByteArray = new ByteArray();
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc3_.length)
|
||||
{
|
||||
_loc8_[_loc7_] = _loc3_[_loc7_] ^ 0x36;
|
||||
_loc5_[_loc7_] = _loc3_[_loc7_] ^ 0x5C;
|
||||
_loc7_++;
|
||||
}
|
||||
_loc8_.position = _loc3_.length;
|
||||
_loc8_.writeBytes(param2);
|
||||
var _loc6_:ByteArray = hash.hash(_loc8_);
|
||||
_loc5_.position = _loc3_.length;
|
||||
_loc5_.writeBytes(_loc6_);
|
||||
var _loc4_:ByteArray = hash.hash(_loc5_);
|
||||
if(bits > 0 && bits < 8 * _loc4_.length)
|
||||
{
|
||||
_loc4_.length = bits / 8;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
hash = null;
|
||||
bits = 0;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "hmac-" + (bits > 0 ? bits + "-" : "") + hash.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.hurlant.crypto.hash
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public interface IHash
|
||||
{
|
||||
|
||||
function getInputSize() : uint;
|
||||
|
||||
function getHashSize() : uint;
|
||||
|
||||
function hash(param1:ByteArray) : ByteArray;
|
||||
|
||||
function toString() : String;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.hurlant.crypto.hash
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class MD2 implements IHash
|
||||
{
|
||||
|
||||
public static const HASH_SIZE:int = 16;
|
||||
|
||||
private static const S:Array = [41,46,67,201,162,216,124,1,61,54,84,161,236,240,6,19,98,167,5,243,192,199,115,140,152,147,43,217,188,76,130,202,30,155,87,60,253,212,224,22,103,66,111,24,138,23,229,18,190,78,196,214,218,158,222,73,160,251,245,142,187,47,238,122,169,104,121,145,21,178,7,63,148,194,16,137,11,34,95,33,128,127,93,154,90,144,50,39,53,62,204,231,191,247,151,3,255,25,48,179,72,165,181,209,215,94,146,42,172,86,170,198,79,184,56,210,150,164,125,182,118,252,107,226,156,116,4,241,69,157,112,89,100,113,135,32,134,91,207,101,230,45,168,2,27,96,37,173,174,176,185,246,28,70,97,105,52,64,126,15,85,71,163,35,221,81,175,58,195,92,249,206,186,197,234,38,44,83,13,110,133,40,132,9,211,223,205,244,65,129,77,82,106,220,55,200,108,193,171,250,36,225,123,8,12,189,177,74,120,136,149,139,227,99,232,109,233,203,213,254,59,0,29,57,242,239,183,14,102,88,208,228,166,119,114,248,235,117,75,10,49,68,80,180,143,237,31,26,219,153,141,51,159,17,131,20];
|
||||
|
||||
public function MD2()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function getInputSize() : uint
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
public function getHashSize() : uint
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
public function hash(param1:ByteArray) : ByteArray
|
||||
{
|
||||
var _loc8_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc9_:* = 0;
|
||||
var _loc6_:uint = param1.length;
|
||||
var _loc7_:uint = uint(16 - param1.length % 16 || 16);
|
||||
do
|
||||
{
|
||||
param1[param1.length] = _loc7_;
|
||||
}
|
||||
while(param1.length % 16 != 0);
|
||||
var _loc2_:uint = param1.length;
|
||||
var _loc4_:ByteArray = new ByteArray();
|
||||
var _loc10_:uint = 0;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc2_)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 16)
|
||||
{
|
||||
var _loc11_:uint = _loc8_;
|
||||
var _loc12_:int = _loc4_[_loc11_] ^ S[param1[_loc7_ + _loc8_] ^ _loc10_];
|
||||
_loc4_[_loc11_] = _loc12_;
|
||||
_loc10_ = uint(_loc12_);
|
||||
_loc8_++;
|
||||
}
|
||||
_loc7_ += 16;
|
||||
}
|
||||
param1.position = param1.length;
|
||||
param1.writeBytes(_loc4_);
|
||||
_loc2_ += 16;
|
||||
var _loc5_:ByteArray = new ByteArray();
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc2_)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 16)
|
||||
{
|
||||
_loc5_[32 + _loc8_] = (_loc5_[16 + _loc8_] = param1[_loc7_ + _loc8_]) ^ _loc5_[_loc8_];
|
||||
_loc8_++;
|
||||
}
|
||||
_loc3_ = 0;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 18)
|
||||
{
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < 48)
|
||||
{
|
||||
_loc5_[_loc9_] = _loc3_ = uint(_loc5_[_loc9_] ^ S[_loc3_]);
|
||||
_loc9_++;
|
||||
}
|
||||
_loc3_ = uint(_loc3_ + _loc8_ & 0xFF);
|
||||
_loc8_++;
|
||||
}
|
||||
_loc7_ += 16;
|
||||
}
|
||||
_loc5_.length = 16;
|
||||
param1.length = _loc6_;
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "md2";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
package com.hurlant.crypto.hash
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class MD5 implements IHash
|
||||
{
|
||||
|
||||
public static const HASH_SIZE:int = 16;
|
||||
|
||||
public function MD5()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function getInputSize() : uint
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
public function getHashSize() : uint
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
public function hash(param1:ByteArray) : ByteArray
|
||||
{
|
||||
var _loc5_:* = 0;
|
||||
var _loc3_:uint = param1.length * 8;
|
||||
var _loc6_:String = param1.endian;
|
||||
while(param1.length % 4 != 0)
|
||||
{
|
||||
param1[param1.length] = 0;
|
||||
}
|
||||
param1.position = 0;
|
||||
var _loc2_:Array = [];
|
||||
param1.endian = "littleEndian";
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < param1.length)
|
||||
{
|
||||
_loc2_.push(param1.readUnsignedInt());
|
||||
_loc5_ += 4;
|
||||
}
|
||||
var _loc4_:Array = core_md5(_loc2_,_loc3_);
|
||||
var _loc7_:ByteArray = new ByteArray();
|
||||
_loc7_.endian = "littleEndian";
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 4)
|
||||
{
|
||||
_loc7_.writeUnsignedInt(_loc4_[_loc5_]);
|
||||
_loc5_++;
|
||||
}
|
||||
param1.length = _loc3_ / 8;
|
||||
param1.endian = _loc6_;
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
private function core_md5(param1:Array, param2:uint) : Array
|
||||
{
|
||||
var _loc8_:* = 0;
|
||||
var _loc10_:* = 0;
|
||||
var _loc11_:* = 0;
|
||||
var _loc7_:* = 0;
|
||||
var _loc9_:* = 0;
|
||||
param1[param2 >> 5] |= 128 << param2 % 32;
|
||||
param1[(param2 + 64 >>> 9 << 4) + 14] = param2;
|
||||
var _loc3_:* = 1732584193;
|
||||
var _loc4_:* = 4023233417;
|
||||
var _loc5_:* = 2562383102;
|
||||
var _loc6_:* = 271733878;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < param1.length)
|
||||
{
|
||||
var _loc13_:* = _loc8_;
|
||||
param1[_loc13_] ||= 0;
|
||||
var _loc12_:Number = _loc8_ + 1;
|
||||
param1[_loc12_] ||= 0;
|
||||
_loc13_ = _loc8_ + 2;
|
||||
param1[_loc13_] ||= 0;
|
||||
_loc12_ = _loc8_ + 3;
|
||||
param1[_loc12_] ||= 0;
|
||||
_loc13_ = _loc8_ + 4;
|
||||
param1[_loc13_] ||= 0;
|
||||
_loc12_ = _loc8_ + 5;
|
||||
param1[_loc12_] ||= 0;
|
||||
_loc13_ = _loc8_ + 6;
|
||||
param1[_loc13_] ||= 0;
|
||||
_loc12_ = _loc8_ + 7;
|
||||
param1[_loc12_] ||= 0;
|
||||
_loc13_ = _loc8_ + 8;
|
||||
param1[_loc13_] ||= 0;
|
||||
_loc12_ = _loc8_ + 9;
|
||||
param1[_loc12_] ||= 0;
|
||||
_loc13_ = _loc8_ + 10;
|
||||
param1[_loc13_] ||= 0;
|
||||
_loc12_ = _loc8_ + 11;
|
||||
param1[_loc12_] ||= 0;
|
||||
_loc13_ = _loc8_ + 12;
|
||||
param1[_loc13_] ||= 0;
|
||||
_loc12_ = _loc8_ + 13;
|
||||
param1[_loc12_] ||= 0;
|
||||
_loc13_ = _loc8_ + 14;
|
||||
param1[_loc13_] ||= 0;
|
||||
_loc12_ = _loc8_ + 15;
|
||||
param1[_loc12_] ||= 0;
|
||||
_loc10_ = _loc3_;
|
||||
_loc11_ = _loc4_;
|
||||
_loc7_ = _loc5_;
|
||||
_loc9_ = _loc6_;
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 0],7,3614090360);
|
||||
_loc6_ = ff(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 1],12,3905402710);
|
||||
_loc5_ = ff(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 2],17,606105819);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 3],22,3250441966);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 4],7,4118548399);
|
||||
_loc6_ = ff(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 5],12,1200080426);
|
||||
_loc5_ = ff(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 6],17,2821735955);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 7],22,4249261313);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 8],7,1770035416);
|
||||
_loc6_ = ff(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 9],12,2336552879);
|
||||
_loc5_ = ff(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 10],17,4294925233);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 11],22,2304563134);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 12],7,1804603682);
|
||||
_loc6_ = ff(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 13],12,4254626195);
|
||||
_loc5_ = ff(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 14],17,2792965006);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 15],22,1236535329);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 1],5,4129170786);
|
||||
_loc6_ = gg(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 6],9,3225465664);
|
||||
_loc5_ = gg(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 11],14,643717713);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 0],20,3921069994);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 5],5,3593408605);
|
||||
_loc6_ = gg(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 10],9,38016083);
|
||||
_loc5_ = gg(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 15],14,3634488961);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 4],20,3889429448);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 9],5,568446438);
|
||||
_loc6_ = gg(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 14],9,3275163606);
|
||||
_loc5_ = gg(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 3],14,4107603335);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 8],20,1163531501);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 13],5,2850285829);
|
||||
_loc6_ = gg(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 2],9,4243563512);
|
||||
_loc5_ = gg(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 7],14,1735328473);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 12],20,2368359562);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 5],4,4294588738);
|
||||
_loc6_ = hh(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 8],11,2272392833);
|
||||
_loc5_ = hh(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 11],16,1839030562);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 14],23,4259657740);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 1],4,2763975236);
|
||||
_loc6_ = hh(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 4],11,1272893353);
|
||||
_loc5_ = hh(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 7],16,4139469664);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 10],23,3200236656);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 13],4,681279174);
|
||||
_loc6_ = hh(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 0],11,3936430074);
|
||||
_loc5_ = hh(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 3],16,3572445317);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 6],23,76029189);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 9],4,3654602809);
|
||||
_loc6_ = hh(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 12],11,3873151461);
|
||||
_loc5_ = hh(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 15],16,530742520);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 2],23,3299628645);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 0],6,4096336452);
|
||||
_loc6_ = ii(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 7],10,1126891415);
|
||||
_loc5_ = ii(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 14],15,2878612391);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 5],21,4237533241);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 12],6,1700485571);
|
||||
_loc6_ = ii(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 3],10,2399980690);
|
||||
_loc5_ = ii(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 10],15,4293915773);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 1],21,2240044497);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 8],6,1873313359);
|
||||
_loc6_ = ii(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 15],10,4264355552);
|
||||
_loc5_ = ii(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 6],15,2734768916);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 13],21,1309151649);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc8_ + 4],6,4149444226);
|
||||
_loc6_ = ii(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc8_ + 11],10,3174756917);
|
||||
_loc5_ = ii(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc8_ + 2],15,718787259);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc8_ + 9],21,3951481745);
|
||||
_loc3_ += _loc10_;
|
||||
_loc4_ += _loc11_;
|
||||
_loc5_ += _loc7_;
|
||||
_loc6_ += _loc9_;
|
||||
_loc8_ += 16;
|
||||
}
|
||||
return [_loc3_,_loc4_,_loc5_,_loc6_];
|
||||
}
|
||||
|
||||
private function rol(param1:uint, param2:uint) : uint
|
||||
{
|
||||
return param1 << param2 | param1 >>> 32 - param2;
|
||||
}
|
||||
|
||||
private function cmn(param1:uint, param2:uint, param3:uint, param4:uint, param5:uint, param6:uint) : uint
|
||||
{
|
||||
return rol(param2 + param1 + param4 + param6,param5) + param3;
|
||||
}
|
||||
|
||||
private function ff(param1:uint, param2:uint, param3:uint, param4:uint, param5:uint, param6:uint, param7:uint) : uint
|
||||
{
|
||||
return cmn(param2 & param3 | ~param2 & param4,param1,param2,param5,param6,param7);
|
||||
}
|
||||
|
||||
private function gg(param1:uint, param2:uint, param3:uint, param4:uint, param5:uint, param6:uint, param7:uint) : uint
|
||||
{
|
||||
return cmn(param2 & param4 | param3 & ~param4,param1,param2,param5,param6,param7);
|
||||
}
|
||||
|
||||
private function hh(param1:uint, param2:uint, param3:uint, param4:uint, param5:uint, param6:uint, param7:uint) : uint
|
||||
{
|
||||
return cmn(param2 ^ param3 ^ param4,param1,param2,param5,param6,param7);
|
||||
}
|
||||
|
||||
private function ii(param1:uint, param2:uint, param3:uint, param4:uint, param5:uint, param6:uint, param7:uint) : uint
|
||||
{
|
||||
return cmn(param3 ^ (param2 | ~param4),param1,param2,param5,param6,param7);
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "md5";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.hurlant.crypto.hash
|
||||
{
|
||||
public class SHA1 extends SHABase implements IHash
|
||||
{
|
||||
|
||||
public static const HASH_SIZE:int = 20;
|
||||
|
||||
public function SHA1()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getHashSize() : uint
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
override protected function core(param1:Array, param2:uint) : Array
|
||||
{
|
||||
var _loc9_:* = 0;
|
||||
var _loc13_:* = 0;
|
||||
var _loc14_:* = 0;
|
||||
var _loc8_:* = 0;
|
||||
var _loc10_:* = 0;
|
||||
var _loc11_:* = 0;
|
||||
var _loc12_:* = 0;
|
||||
var _loc15_:* = 0;
|
||||
param1[param2 >> 5] |= 128 << 24 - param2 % 32;
|
||||
param1[(param2 + 64 >> 9 << 4) + 15] = param2;
|
||||
var _loc16_:Array = [];
|
||||
var _loc3_:* = 1732584193;
|
||||
var _loc4_:* = 4023233417;
|
||||
var _loc5_:* = 2562383102;
|
||||
var _loc6_:* = 271733878;
|
||||
var _loc7_:* = 3285377520;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < param1.length)
|
||||
{
|
||||
_loc13_ = _loc3_;
|
||||
_loc14_ = _loc4_;
|
||||
_loc8_ = _loc5_;
|
||||
_loc10_ = _loc6_;
|
||||
_loc11_ = _loc7_;
|
||||
_loc12_ = 0;
|
||||
while(_loc12_ < 80)
|
||||
{
|
||||
if(_loc12_ < 16)
|
||||
{
|
||||
_loc16_[_loc12_] = param1[_loc9_ + _loc12_] || 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc16_[_loc12_] = rol(_loc16_[_loc12_ - 3] ^ _loc16_[_loc12_ - 8] ^ _loc16_[_loc12_ - 14] ^ _loc16_[_loc12_ - 16],1);
|
||||
}
|
||||
_loc15_ = uint(rol(_loc3_,5) + ft(_loc12_,_loc4_,_loc5_,_loc6_) + _loc7_ + _loc16_[_loc12_] + kt(_loc12_));
|
||||
_loc7_ = _loc6_;
|
||||
_loc6_ = _loc5_;
|
||||
_loc5_ = rol(_loc4_,30);
|
||||
_loc4_ = _loc3_;
|
||||
_loc3_ = _loc15_;
|
||||
_loc12_++;
|
||||
}
|
||||
_loc3_ += _loc13_;
|
||||
_loc4_ += _loc14_;
|
||||
_loc5_ += _loc8_;
|
||||
_loc6_ += _loc10_;
|
||||
_loc7_ += _loc11_;
|
||||
_loc9_ += 16;
|
||||
}
|
||||
return [_loc3_,_loc4_,_loc5_,_loc6_,_loc7_];
|
||||
}
|
||||
|
||||
private function rol(param1:uint, param2:uint) : uint
|
||||
{
|
||||
return param1 << param2 | param1 >>> 32 - param2;
|
||||
}
|
||||
|
||||
private function ft(param1:uint, param2:uint, param3:uint, param4:uint) : uint
|
||||
{
|
||||
if(param1 < 20)
|
||||
{
|
||||
return param2 & param3 | ~param2 & param4;
|
||||
}
|
||||
if(param1 < 40)
|
||||
{
|
||||
return param2 ^ param3 ^ param4;
|
||||
}
|
||||
if(param1 < 60)
|
||||
{
|
||||
return param2 & param3 | param2 & param4 | param3 & param4;
|
||||
}
|
||||
return param2 ^ param3 ^ param4;
|
||||
}
|
||||
|
||||
private function kt(param1:uint) : uint
|
||||
{
|
||||
return param1 < 20 ? 1518500249 : (param1 < 40 ? 1859775393 : (param1 < 60 ? 2400959708 : 3395469782));
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "sha1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.hurlant.crypto.hash
|
||||
{
|
||||
public class SHA224 extends SHA256
|
||||
{
|
||||
|
||||
public function SHA224()
|
||||
{
|
||||
super();
|
||||
_h = [3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428];
|
||||
}
|
||||
|
||||
override public function getHashSize() : uint
|
||||
{
|
||||
return 28;
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "sha224";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.hurlant.crypto.hash
|
||||
{
|
||||
public class SHA256 extends SHABase implements IHash
|
||||
{
|
||||
|
||||
protected static const k:Array = [1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];
|
||||
|
||||
protected var _h:Array = [1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];
|
||||
|
||||
public function SHA256()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getHashSize() : uint
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
override protected function core(param1:Array, param2:uint) : Array
|
||||
{
|
||||
var _loc16_:* = 0;
|
||||
var _loc21_:* = 0;
|
||||
var _loc22_:* = 0;
|
||||
var _loc15_:* = 0;
|
||||
var _loc17_:* = 0;
|
||||
var _loc18_:* = 0;
|
||||
var _loc20_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc4_:* = 0;
|
||||
var _loc19_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
var _loc25_:* = 0;
|
||||
var _loc24_:* = 0;
|
||||
param1[param2 >> 5] |= 128 << 24 - param2 % 32;
|
||||
param1[(param2 + 64 >> 9 << 4) + 15] = param2;
|
||||
var _loc23_:Array = [];
|
||||
var _loc7_:uint = uint(_h[0]);
|
||||
var _loc8_:uint = uint(_h[1]);
|
||||
var _loc9_:uint = uint(_h[2]);
|
||||
var _loc10_:uint = uint(_h[3]);
|
||||
var _loc11_:uint = uint(_h[4]);
|
||||
var _loc12_:uint = uint(_h[5]);
|
||||
var _loc13_:uint = uint(_h[6]);
|
||||
var _loc14_:uint = uint(_h[7]);
|
||||
_loc16_ = 0;
|
||||
while(_loc16_ < param1.length)
|
||||
{
|
||||
_loc21_ = _loc7_;
|
||||
_loc22_ = _loc8_;
|
||||
_loc15_ = _loc9_;
|
||||
_loc17_ = _loc10_;
|
||||
_loc18_ = _loc11_;
|
||||
_loc20_ = _loc12_;
|
||||
_loc3_ = _loc13_;
|
||||
_loc4_ = _loc14_;
|
||||
_loc19_ = 0;
|
||||
while(_loc19_ < 64)
|
||||
{
|
||||
if(_loc19_ < 16)
|
||||
{
|
||||
_loc23_[_loc19_] = param1[_loc16_ + _loc19_] || 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = uint(rrol(_loc23_[_loc19_ - 15],7) ^ rrol(_loc23_[_loc19_ - 15],18) ^ _loc23_[_loc19_ - 15] >>> 3);
|
||||
_loc6_ = uint(rrol(_loc23_[_loc19_ - 2],17) ^ rrol(_loc23_[_loc19_ - 2],19) ^ _loc23_[_loc19_ - 2] >>> 10);
|
||||
_loc23_[_loc19_] = _loc23_[_loc19_ - 16] + _loc5_ + _loc23_[_loc19_ - 7] + _loc6_;
|
||||
}
|
||||
_loc25_ = uint((rrol(_loc7_,2) ^ rrol(_loc7_,13) ^ rrol(_loc7_,22)) + (_loc7_ & _loc8_ ^ _loc7_ & _loc9_ ^ _loc8_ & _loc9_));
|
||||
_loc24_ = uint(_loc14_ + (rrol(_loc11_,6) ^ rrol(_loc11_,11) ^ rrol(_loc11_,25)) + (_loc11_ & _loc12_ ^ _loc13_ & ~_loc11_) + k[_loc19_] + _loc23_[_loc19_]);
|
||||
_loc14_ = _loc13_;
|
||||
_loc13_ = _loc12_;
|
||||
_loc12_ = _loc11_;
|
||||
_loc11_ = _loc10_ + _loc24_;
|
||||
_loc10_ = _loc9_;
|
||||
_loc9_ = _loc8_;
|
||||
_loc8_ = _loc7_;
|
||||
_loc7_ = _loc24_ + _loc25_;
|
||||
_loc19_++;
|
||||
}
|
||||
_loc7_ += _loc21_;
|
||||
_loc8_ += _loc22_;
|
||||
_loc9_ += _loc15_;
|
||||
_loc10_ += _loc17_;
|
||||
_loc11_ += _loc18_;
|
||||
_loc12_ += _loc20_;
|
||||
_loc13_ += _loc3_;
|
||||
_loc14_ += _loc4_;
|
||||
_loc16_ += 16;
|
||||
}
|
||||
return [_loc7_,_loc8_,_loc9_,_loc10_,_loc11_,_loc12_,_loc13_,_loc14_];
|
||||
}
|
||||
|
||||
protected function rrol(param1:uint, param2:uint) : uint
|
||||
{
|
||||
return param1 << 32 - param2 | param1 >>> param2;
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "sha256";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.hurlant.crypto.hash
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class SHABase implements IHash
|
||||
{
|
||||
|
||||
public function SHABase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function getInputSize() : uint
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
public function getHashSize() : uint
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function hash(param1:ByteArray) : ByteArray
|
||||
{
|
||||
var _loc7_:* = 0;
|
||||
var _loc6_:uint = param1.length;
|
||||
var _loc8_:String = param1.endian;
|
||||
param1.endian = "bigEndian";
|
||||
var _loc3_:uint = _loc6_ * 8;
|
||||
while(param1.length % 4 != 0)
|
||||
{
|
||||
param1[param1.length] = 0;
|
||||
}
|
||||
param1.position = 0;
|
||||
var _loc2_:Array = [];
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < param1.length)
|
||||
{
|
||||
_loc2_.push(param1.readUnsignedInt());
|
||||
_loc7_ += 4;
|
||||
}
|
||||
var _loc4_:Array = core(_loc2_,_loc3_);
|
||||
var _loc9_:ByteArray = new ByteArray();
|
||||
var _loc5_:uint = getHashSize() / 4;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc5_)
|
||||
{
|
||||
_loc9_.writeUnsignedInt(_loc4_[_loc7_]);
|
||||
_loc7_++;
|
||||
}
|
||||
param1.length = _loc6_;
|
||||
param1.endian = _loc8_;
|
||||
return _loc9_;
|
||||
}
|
||||
|
||||
protected function core(param1:Array, param2:uint) : Array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "sha";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.hurlant.crypto.prng
|
||||
{
|
||||
import com.hurlant.crypto.symmetric.IStreamCipher;
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class ARC4 implements IPRNG, IStreamCipher
|
||||
{
|
||||
|
||||
private var i:int = 0;
|
||||
|
||||
private var j:int = 0;
|
||||
|
||||
private var S:ByteArray;
|
||||
|
||||
private const psize:uint = 256;
|
||||
|
||||
public function ARC4(param1:ByteArray = null)
|
||||
{
|
||||
super();
|
||||
S = new ByteArray();
|
||||
if(param1)
|
||||
{
|
||||
init(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPoolSize() : uint
|
||||
{
|
||||
return 256;
|
||||
}
|
||||
|
||||
public function init(param1:ByteArray) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 256)
|
||||
{
|
||||
S[_loc3_] = _loc3_;
|
||||
_loc3_++;
|
||||
}
|
||||
_loc4_ = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 256)
|
||||
{
|
||||
_loc4_ = _loc4_ + S[_loc3_] + param1[_loc3_ % param1.length] & 0xFF;
|
||||
_loc2_ = int(S[_loc3_]);
|
||||
S[_loc3_] = S[_loc4_];
|
||||
S[_loc4_] = _loc2_;
|
||||
_loc3_++;
|
||||
}
|
||||
this.i = 0;
|
||||
this.j = 0;
|
||||
}
|
||||
|
||||
public function next() : uint
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
i = i + 1 & 0xFF;
|
||||
j = j + S[i] & 0xFF;
|
||||
_loc1_ = int(S[i]);
|
||||
S[i] = S[j];
|
||||
S[j] = _loc1_;
|
||||
return S[_loc1_ + S[i] & 0xFF];
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:uint = 0;
|
||||
while(_loc2_ < param1.length)
|
||||
{
|
||||
var _loc3_:uint = _loc2_++;
|
||||
var _loc4_:int = param1[_loc3_] ^ next();
|
||||
param1[_loc3_] = _loc4_;
|
||||
}
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
encrypt(param1);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
if(S != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < S.length)
|
||||
{
|
||||
S[_loc1_] = Math.random() * 256;
|
||||
_loc1_++;
|
||||
}
|
||||
S.length = 0;
|
||||
S = null;
|
||||
}
|
||||
this.i = 0;
|
||||
this.j = 0;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "rc4";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.hurlant.crypto.prng
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public interface IPRNG
|
||||
{
|
||||
|
||||
function getPoolSize() : uint;
|
||||
|
||||
function init(param1:ByteArray) : void;
|
||||
|
||||
function next() : uint;
|
||||
|
||||
function dispose() : void;
|
||||
|
||||
function toString() : String;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.hurlant.crypto.prng
|
||||
{
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.system.Capabilities;
|
||||
import flash.system.System;
|
||||
import flash.text.Font;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
public class Random
|
||||
{
|
||||
|
||||
private var state:IPRNG;
|
||||
|
||||
private var ready:Boolean = false;
|
||||
|
||||
private var pool:ByteArray;
|
||||
|
||||
private var psize:int;
|
||||
|
||||
private var pptr:int;
|
||||
|
||||
private var seeded:Boolean = false;
|
||||
|
||||
public function Random(param1:Class = null)
|
||||
{
|
||||
var _loc2_:* = 0;
|
||||
super();
|
||||
if(param1 == null)
|
||||
{
|
||||
param1 = ARC4;
|
||||
}
|
||||
state = new param1() as IPRNG;
|
||||
psize = state.getPoolSize();
|
||||
pool = new ByteArray();
|
||||
pptr = 0;
|
||||
while(pptr < psize)
|
||||
{
|
||||
_loc2_ = uint(65536 * Math.random());
|
||||
pool[pptr++] = _loc2_ >>> 8;
|
||||
pool[pptr++] = _loc2_ & 0xFF;
|
||||
}
|
||||
pptr = 0;
|
||||
seed();
|
||||
}
|
||||
|
||||
public function seed(param1:int = 0) : void
|
||||
{
|
||||
if(param1 == 0)
|
||||
{
|
||||
param1 = new Date().getTime();
|
||||
}
|
||||
var _loc2_:Number = pptr++;
|
||||
var _loc3_:int = pool[_loc2_] ^ param1 & 0xFF;
|
||||
pool[_loc2_] = _loc3_;
|
||||
pool[pptr++] ^= param1 >> 8 & 0xFF;
|
||||
pool[pptr++] ^= param1 >> 16 & 0xFF;
|
||||
pool[pptr++] ^= param1 >> 24 & 0xFF;
|
||||
pptr %= psize;
|
||||
seeded = true;
|
||||
}
|
||||
|
||||
public function autoSeed() : void
|
||||
{
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc2_.writeUnsignedInt(System.totalMemory);
|
||||
_loc2_.writeUTF(Capabilities.serverString);
|
||||
_loc2_.writeUnsignedInt(getTimer());
|
||||
_loc2_.writeUnsignedInt(new Date().getTime());
|
||||
var _loc1_:Array = Font.enumerateFonts(true);
|
||||
for each(var _loc3_:Font in _loc1_)
|
||||
{
|
||||
_loc2_.writeUTF(_loc3_.fontName);
|
||||
_loc2_.writeUTF(_loc3_.fontStyle);
|
||||
_loc2_.writeUTF(_loc3_.fontType);
|
||||
}
|
||||
_loc2_.position = 0;
|
||||
while(_loc2_.bytesAvailable >= 4)
|
||||
{
|
||||
seed(_loc2_.readUnsignedInt());
|
||||
}
|
||||
}
|
||||
|
||||
public function nextBytes(param1:ByteArray, param2:int) : void
|
||||
{
|
||||
while(param2--)
|
||||
{
|
||||
param1.writeByte(nextByte());
|
||||
}
|
||||
}
|
||||
|
||||
public function nextByte() : int
|
||||
{
|
||||
if(!ready)
|
||||
{
|
||||
if(!seeded)
|
||||
{
|
||||
autoSeed();
|
||||
}
|
||||
state.init(pool);
|
||||
pool.length = 0;
|
||||
pptr = 0;
|
||||
ready = true;
|
||||
}
|
||||
return state.next();
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:* = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < pool.length)
|
||||
{
|
||||
pool[_loc1_] = Math.random() * 256;
|
||||
_loc1_++;
|
||||
}
|
||||
pool.length = 0;
|
||||
pool = null;
|
||||
state.dispose();
|
||||
state = null;
|
||||
psize = 0;
|
||||
pptr = 0;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "random-" + state.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
package com.hurlant.crypto.rsa
|
||||
{
|
||||
import com.hurlant.crypto.prng.Random;
|
||||
import com.hurlant.math.BigInteger;
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class RSAKey
|
||||
{
|
||||
|
||||
public var e:int;
|
||||
|
||||
public var n:BigInteger;
|
||||
|
||||
public var d:BigInteger;
|
||||
|
||||
public var p:BigInteger;
|
||||
|
||||
public var q:BigInteger;
|
||||
|
||||
public var dmp1:BigInteger;
|
||||
|
||||
public var dmq1:BigInteger;
|
||||
|
||||
public var coeff:BigInteger;
|
||||
|
||||
protected var canDecrypt:Boolean;
|
||||
|
||||
protected var canEncrypt:Boolean;
|
||||
|
||||
public function RSAKey(param1:BigInteger, param2:int, param3:BigInteger = null, param4:BigInteger = null, param5:BigInteger = null, param6:BigInteger = null, param7:BigInteger = null, param8:BigInteger = null)
|
||||
{
|
||||
super();
|
||||
this.n = param1;
|
||||
this.e = param2;
|
||||
this.d = param3;
|
||||
this.p = param4;
|
||||
this.q = param5;
|
||||
this.dmp1 = param6;
|
||||
this.dmq1 = param7;
|
||||
this.coeff = param8;
|
||||
canEncrypt = n != null && e != 0;
|
||||
canDecrypt = canEncrypt && d != null;
|
||||
}
|
||||
|
||||
public static function parsePublicKey(param1:String, param2:String) : RSAKey
|
||||
{
|
||||
return new RSAKey(new BigInteger(param1,16),parseInt(param2,16));
|
||||
}
|
||||
|
||||
public static function parsePrivateKey(param1:String, param2:String, param3:String, param4:String = null, param5:String = null, param6:String = null, param7:String = null, param8:String = null) : RSAKey
|
||||
{
|
||||
if(param4 == null)
|
||||
{
|
||||
return new RSAKey(new BigInteger(param1,16),parseInt(param2,16),new BigInteger(param3,16));
|
||||
}
|
||||
return new RSAKey(new BigInteger(param1,16),parseInt(param2,16),new BigInteger(param3,16),new BigInteger(param4,16),new BigInteger(param5,16),new BigInteger(param6,16),new BigInteger(param7),new BigInteger(param8));
|
||||
}
|
||||
|
||||
public static function generate(param1:uint, param2:String) : RSAKey
|
||||
{
|
||||
var _loc8_:BigInteger = null;
|
||||
var _loc6_:BigInteger = null;
|
||||
var _loc4_:BigInteger = null;
|
||||
var _loc5_:BigInteger = null;
|
||||
var _loc9_:Random = new Random();
|
||||
var _loc7_:uint = uint(param1 >> 1);
|
||||
var _loc10_:RSAKey = new RSAKey(null,0,null);
|
||||
_loc10_.e = parseInt(param2,16);
|
||||
var _loc3_:BigInteger = new BigInteger(param2,16);
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
_loc10_.p = bigRandom(param1 - _loc7_,_loc9_);
|
||||
}
|
||||
while(!(_loc10_.p.subtract(BigInteger.ONE).gcd(_loc3_).compareTo(BigInteger.ONE) == 0 && _loc10_.p.isProbablePrime(10)));
|
||||
do
|
||||
{
|
||||
_loc10_.q = bigRandom(_loc7_,_loc9_);
|
||||
}
|
||||
while(!(_loc10_.q.subtract(BigInteger.ONE).gcd(_loc3_).compareTo(BigInteger.ONE) == 0 && _loc10_.q.isProbablePrime(10)));
|
||||
if(_loc10_.p.compareTo(_loc10_.q) <= 0)
|
||||
{
|
||||
_loc8_ = _loc10_.p;
|
||||
_loc10_.p = _loc10_.q;
|
||||
_loc10_.q = _loc8_;
|
||||
}
|
||||
_loc6_ = _loc10_.p.subtract(BigInteger.ONE);
|
||||
_loc4_ = _loc10_.q.subtract(BigInteger.ONE);
|
||||
}
|
||||
while(_loc5_ = _loc6_.multiply(_loc4_), _loc5_.gcd(_loc3_).compareTo(BigInteger.ONE) != 0);
|
||||
_loc10_.n = _loc10_.p.multiply(_loc10_.q);
|
||||
_loc10_.d = _loc3_.modInverse(_loc5_);
|
||||
_loc10_.dmp1 = _loc10_.d.mod(_loc6_);
|
||||
_loc10_.dmq1 = _loc10_.d.mod(_loc4_);
|
||||
_loc10_.coeff = _loc10_.q.modInverse(_loc10_.p);
|
||||
return _loc10_;
|
||||
}
|
||||
|
||||
protected static function bigRandom(param1:int, param2:Random) : BigInteger
|
||||
{
|
||||
if(param1 < 2)
|
||||
{
|
||||
return BigInteger.nbv(1);
|
||||
}
|
||||
var _loc4_:ByteArray = new ByteArray();
|
||||
param2.nextBytes(_loc4_,param1 >> 3);
|
||||
_loc4_.position = 0;
|
||||
var _loc3_:BigInteger = new BigInteger(_loc4_);
|
||||
_loc3_.primify(param1,1);
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return (n.bitLength() + 7) / 8;
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
e = 0;
|
||||
n.dispose();
|
||||
n = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray, param2:ByteArray, param3:uint, param4:Function = null) : void
|
||||
{
|
||||
_encrypt(doPublic,param1,param2,param3,param4,2);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:ByteArray, param3:uint, param4:Function = null) : void
|
||||
{
|
||||
_decrypt(doPrivate2,param1,param2,param3,param4,2);
|
||||
}
|
||||
|
||||
public function sign(param1:ByteArray, param2:ByteArray, param3:uint, param4:Function = null) : void
|
||||
{
|
||||
_encrypt(doPrivate2,param1,param2,param3,param4,1);
|
||||
}
|
||||
|
||||
public function verify(param1:ByteArray, param2:ByteArray, param3:uint, param4:Function = null) : void
|
||||
{
|
||||
_decrypt(doPublic,param1,param2,param3,param4,1);
|
||||
}
|
||||
|
||||
private function _encrypt(param1:Function, param2:ByteArray, param3:ByteArray, param4:uint, param5:Function, param6:int) : void
|
||||
{
|
||||
var _loc10_:BigInteger = null;
|
||||
var _loc7_:BigInteger = null;
|
||||
if(param5 == null)
|
||||
{
|
||||
param5 = pkcs1pad;
|
||||
}
|
||||
if(param2.position >= param2.length)
|
||||
{
|
||||
param2.position = 0;
|
||||
}
|
||||
var _loc8_:uint = getBlockSize();
|
||||
var _loc9_:int = param2.position + param4;
|
||||
while(param2.position < _loc9_)
|
||||
{
|
||||
_loc10_ = new BigInteger(param5(param2,_loc9_,_loc8_,param6),_loc8_);
|
||||
_loc7_ = param1(_loc10_);
|
||||
_loc7_.toArray(param3);
|
||||
}
|
||||
}
|
||||
|
||||
private function _decrypt(param1:Function, param2:ByteArray, param3:ByteArray, param4:uint, param5:Function, param6:int) : void
|
||||
{
|
||||
var _loc11_:BigInteger = null;
|
||||
var _loc8_:BigInteger = null;
|
||||
var _loc7_:ByteArray = null;
|
||||
if(param5 == null)
|
||||
{
|
||||
param5 = pkcs1unpad;
|
||||
}
|
||||
if(param2.position >= param2.length)
|
||||
{
|
||||
param2.position = 0;
|
||||
}
|
||||
var _loc9_:uint = getBlockSize();
|
||||
var _loc10_:int = param2.position + param4;
|
||||
while(param2.position < _loc10_)
|
||||
{
|
||||
_loc11_ = new BigInteger(param2,param4);
|
||||
_loc8_ = param1(_loc11_);
|
||||
_loc7_ = param5(_loc8_,_loc9_);
|
||||
param3.writeBytes(_loc7_);
|
||||
}
|
||||
}
|
||||
|
||||
private function pkcs1pad(param1:ByteArray, param2:int, param3:uint, param4:uint = 2) : ByteArray
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc9_:ByteArray = new ByteArray();
|
||||
var _loc5_:int = int(param1.position);
|
||||
param2 = Math.min(param2,param1.length,_loc5_ + param3 - 11);
|
||||
param1.position = param2;
|
||||
var _loc7_:int = param2 - 1;
|
||||
while(_loc7_ >= _loc5_ && param3 > 11)
|
||||
{
|
||||
_loc9_[--param3] = param1[_loc7_--];
|
||||
}
|
||||
_loc9_[--param3] = 0;
|
||||
var _loc8_:Random = new Random();
|
||||
while(param3 > 2)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ == 0)
|
||||
{
|
||||
_loc6_ = int(param4 == 2 ? _loc8_.nextByte() : 255);
|
||||
}
|
||||
_loc9_[--param3] = _loc6_;
|
||||
}
|
||||
_loc9_[--param3] = param4;
|
||||
_loc9_[--param3] = 0;
|
||||
return _loc9_;
|
||||
}
|
||||
|
||||
private function pkcs1unpad(param1:BigInteger, param2:uint, param3:uint = 2) : ByteArray
|
||||
{
|
||||
var _loc4_:ByteArray = param1.toByteArray();
|
||||
var _loc6_:ByteArray = new ByteArray();
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc4_.length && _loc4_[_loc5_] == 0)
|
||||
{
|
||||
_loc5_++;
|
||||
}
|
||||
if(_loc4_.length - _loc5_ != param2 - 1 || _loc4_[_loc5_] > 2)
|
||||
{
|
||||
trace("PKCS#1 unpad: i=" + _loc5_ + ", expected b[i]==[0,1,2], got b[i]=" + _loc4_[_loc5_].toString(16));
|
||||
return null;
|
||||
}
|
||||
_loc5_++;
|
||||
while(_loc4_[_loc5_] != 0)
|
||||
{
|
||||
if(++_loc5_ >= _loc4_.length)
|
||||
{
|
||||
trace("PKCS#1 unpad: i=" + _loc5_ + ", b[i-1]!=0 (=" + _loc4_[_loc5_ - 1].toString(16) + ")");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
while(++_loc5_ < _loc4_.length)
|
||||
{
|
||||
_loc6_.writeByte(_loc4_[_loc5_]);
|
||||
}
|
||||
_loc6_.position = 0;
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
private function rawpad(param1:ByteArray, param2:int, param3:uint) : ByteArray
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "rsa";
|
||||
}
|
||||
|
||||
public function dump() : String
|
||||
{
|
||||
var _loc1_:String = "N=" + n.toString(16) + "\n" + "E=" + e.toString(16) + "\n";
|
||||
if(canDecrypt)
|
||||
{
|
||||
_loc1_ += "D=" + d.toString(16) + "\n";
|
||||
if(p != null && q != null)
|
||||
{
|
||||
_loc1_ += "P=" + p.toString(16) + "\n";
|
||||
_loc1_ += "Q=" + q.toString(16) + "\n";
|
||||
_loc1_ += "DMP1=" + dmp1.toString(16) + "\n";
|
||||
_loc1_ += "DMQ1=" + dmq1.toString(16) + "\n";
|
||||
_loc1_ += "IQMP=" + coeff.toString(16) + "\n";
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
protected function doPublic(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1.modPowInt(e,n);
|
||||
}
|
||||
|
||||
protected function doPrivate2(param1:BigInteger) : BigInteger
|
||||
{
|
||||
if(p == null && q == null)
|
||||
{
|
||||
return param1.modPow(d,n);
|
||||
}
|
||||
var _loc3_:BigInteger = param1.mod(p).modPow(dmp1,p);
|
||||
var _loc4_:BigInteger = param1.mod(q).modPow(dmq1,q);
|
||||
while(_loc3_.compareTo(_loc4_) < 0)
|
||||
{
|
||||
_loc3_ = _loc3_.add(p);
|
||||
}
|
||||
return _loc3_.subtract(_loc4_).multiply(coeff).mod(p).multiply(q).add(_loc4_);
|
||||
}
|
||||
|
||||
protected function doPrivate(param1:BigInteger) : BigInteger
|
||||
{
|
||||
if(p == null || q == null)
|
||||
{
|
||||
return param1.modPow(d,n);
|
||||
}
|
||||
var _loc2_:BigInteger = param1.mod(p).modPow(dmp1,p);
|
||||
var _loc3_:BigInteger = param1.mod(q).modPow(dmq1,q);
|
||||
while(_loc2_.compareTo(_loc3_) < 0)
|
||||
{
|
||||
_loc2_ = _loc2_.add(p);
|
||||
}
|
||||
return _loc2_.subtract(_loc3_).multiply(coeff).mod(p).multiply(q).add(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import com.hurlant.crypto.prng.Random;
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class AESKey implements ISymmetricKey
|
||||
{
|
||||
|
||||
private static const Nb:uint = 4;
|
||||
|
||||
private static const _Sbox:Array = [99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22];
|
||||
|
||||
private static const _InvSbox:Array = [82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125];
|
||||
|
||||
private static const _Xtime2Sbox:Array = [198,248,238,246,255,214,222,145,96,2,206,86,231,181,77,236,143,31,137,250,239,178,142,251,65,179,95,69,35,83,228,155,117,225,61,76,108,126,245,131,104,81,209,249,226,171,98,42,8,149,70,157,48,55,10,47,14,36,27,223,205,78,127,234,18,29,88,52,54,220,180,91,164,118,183,125,82,221,94,19,166,185,0,193,64,227,121,182,212,141,103,114,148,152,176,133,187,197,79,237,134,154,102,17,138,233,4,254,160,120,37,75,162,93,128,5,63,33,112,241,99,119,175,66,32,229,253,191,129,24,38,195,190,53,136,46,147,85,252,122,200,186,50,230,192,25,158,163,68,84,59,11,140,199,107,40,167,188,22,173,219,100,116,20,146,12,72,184,159,189,67,196,57,49,211,242,213,139,110,218,1,177,156,73,216,172,243,207,202,244,71,16,111,240,74,92,56,87,115,151,203,161,232,62,150,97,13,15,224,124,113,204,144,6,247,28,194,106,174,105,23,153,58,39,217,235,43,34,210,169,7,51,45,60,21,201,135,170,80,165,3,89,9,26,101,215,132,208,130,41,90,30,123,168,109,44];
|
||||
|
||||
private static const _Xtime3Sbox:Array = [165,132,153,141,13,189,177,84,80,3,169,125,25,98,230,154,69,157,64,135,21,235,201,11,236,103,253,234,191,247,150,91,194,28,174,106,90,65,2,79,92,244,52,8,147,115,83,63,12,82,101,94,40,161,15,181,9,54,155,61,38,105,205,159,27,158,116,46,45,178,238,251,246,77,97,206,123,62,113,151,245,104,0,44,96,31,200,237,190,70,217,75,222,212,232,74,107,42,229,22,197,215,85,148,207,16,6,129,240,68,186,227,243,254,192,138,173,188,72,4,223,193,117,99,48,26,14,109,76,20,53,47,225,162,204,57,87,242,130,71,172,231,43,149,160,152,209,127,102,126,171,131,202,41,211,60,121,226,29,118,59,86,78,30,219,10,108,228,93,110,239,166,168,164,55,139,50,67,89,183,140,100,210,224,180,250,7,37,175,142,233,24,213,136,111,114,36,241,199,81,35,124,156,33,221,220,134,133,144,66,196,170,216,5,1,18,163,95,249,208,145,88,39,185,56,19,179,51,187,112,137,167,182,34,146,32,73,255,120,122,143,248,128,23,218,49,198,184,195,176,119,17,203,252,214,58];
|
||||
|
||||
private static const _Xtime2:Array = [0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,27,25,31,29,19,17,23,21,11,9,15,13,3,1,7,5,59,57,63,61,51,49,55,53,43,41,47,45,35,33,39,37,91,89,95,93,83,81,87,85,75,73,79,77,67,65,71,69,123,121,127,125,115,113,119,117,107,105,111,109,99,97,103,101,155,153,159,157,147,145,151,149,139,137,143,141,131,129,135,133,187,185,191,189,179,177,183,181,171,169,175,173,163,161,167,165,219,217,223,221,211,209,215,213,203,201,207,205,195,193,199,197,251,249,255,253,243,241,247,245,235,233,239,237,227,225,231,229];
|
||||
|
||||
private static const _Xtime9:Array = [0,9,18,27,36,45,54,63,72,65,90,83,108,101,126,119,144,153,130,139,180,189,166,175,216,209,202,195,252,245,238,231,59,50,41,32,31,22,13,4,115,122,97,104,87,94,69,76,171,162,185,176,143,134,157,148,227,234,241,248,199,206,213,220,118,127,100,109,82,91,64,73,62,55,44,37,26,19,8,1,230,239,244,253,194,203,208,217,174,167,188,181,138,131,152,145,77,68,95,86,105,96,123,114,5,12,23,30,33,40,51,58,221,212,207,198,249,240,235,226,149,156,135,142,177,184,163,170,236,229,254,247,200,193,218,211,164,173,182,191,128,137,146,155,124,117,110,103,88,81,74,67,52,61,38,47,16,25,2,11,215,222,197,204,243,250,225,232,159,150,141,132,187,178,169,160,71,78,85,92,99,106,113,120,15,6,29,20,43,34,57,48,154,147,136,129,190,183,172,165,210,219,192,201,246,255,228,237,10,3,24,17,46,39,60,53,66,75,80,89,102,111,116,125,161,168,179,186,133,140,151,158,233,224,251,242,205,196,223,214,49,56,35,42,21,28,7,14,121,112,107,98,93,84,79,70];
|
||||
|
||||
private static const _XtimeB:Array = [0,11,22,29,44,39,58,49,88,83,78,69,116,127,98,105,176,187,166,173,156,151,138,129,232,227,254,245,196,207,210,217,123,112,109,102,87,92,65,74,35,40,53,62,15,4,25,18,203,192,221,214,231,236,241,250,147,152,133,142,191,180,169,162,246,253,224,235,218,209,204,199,174,165,184,179,130,137,148,159,70,77,80,91,106,97,124,119,30,21,8,3,50,57,36,47,141,134,155,144,161,170,183,188,213,222,195,200,249,242,239,228,61,54,43,32,17,26,7,12,101,110,115,120,73,66,95,84,247,252,225,234,219,208,205,198,175,164,185,178,131,136,149,158,71,76,81,90,107,96,125,118,31,20,9,2,51,56,37,46,140,135,154,145,160,171,182,189,212,223,194,201,248,243,238,229,60,55,42,33,16,27,6,13,100,111,114,121,72,67,94,85,1,10,23,28,45,38,59,48,89,82,79,68,117,126,99,104,177,186,167,172,157,150,139,128,233,226,255,244,197,206,211,216,122,113,108,103,86,93,64,75,34,41,52,63,14,5,24,19,202,193,220,215,230,237,240,251,146,153,132,143,190,181,168,163];
|
||||
|
||||
private static const _XtimeD:Array = [0,13,26,23,52,57,46,35,104,101,114,127,92,81,70,75,208,221,202,199,228,233,254,243,184,181,162,175,140,129,150,155,187,182,161,172,143,130,149,152,211,222,201,196,231,234,253,240,107,102,113,124,95,82,69,72,3,14,25,20,55,58,45,32,109,96,119,122,89,84,67,78,5,8,31,18,49,60,43,38,189,176,167,170,137,132,147,158,213,216,207,194,225,236,251,246,214,219,204,193,226,239,248,245,190,179,164,169,138,135,144,157,6,11,28,17,50,63,40,37,110,99,116,121,90,87,64,77,218,215,192,205,238,227,244,249,178,191,168,165,134,139,156,145,10,7,16,29,62,51,36,41,98,111,120,117,86,91,76,65,97,108,123,118,85,88,79,66,9,4,19,30,61,48,39,42,177,188,171,166,133,136,159,146,217,212,195,206,237,224,247,250,183,186,173,160,131,142,153,148,223,210,197,200,235,230,241,252,103,106,125,112,83,94,73,68,15,2,21,24,59,54,33,44,12,1,22,27,56,53,34,47,100,105,126,115,80,93,74,71,220,209,198,203,232,229,242,255,180,185,174,163,128,141,154,151];
|
||||
|
||||
private static const _XtimeE:Array = [0,14,28,18,56,54,36,42,112,126,108,98,72,70,84,90,224,238,252,242,216,214,196,202,144,158,140,130,168,166,180,186,219,213,199,201,227,237,255,241,171,165,183,185,147,157,143,129,59,53,39,41,3,13,31,17,75,69,87,89,115,125,111,97,173,163,177,191,149,155,137,135,221,211,193,207,229,235,249,247,77,67,81,95,117,123,105,103,61,51,33,47,5,11,25,23,118,120,106,100,78,64,82,92,6,8,26,20,62,48,34,44,150,152,138,132,174,160,178,188,230,232,250,244,222,208,194,204,65,79,93,83,121,119,101,107,49,63,45,35,9,7,21,27,161,175,189,179,153,151,133,139,209,223,205,195,233,231,245,251,154,148,134,136,162,172,190,176,234,228,246,248,210,220,206,192,122,116,102,104,66,76,94,80,10,4,22,24,50,60,46,32,236,226,240,254,212,218,200,198,156,146,128,142,164,170,184,182,12,2,16,30,52,58,40,38,124,114,96,110,68,74,88,86,55,57,43,37,15,1,19,29,71,73,91,85,127,113,99,109,215,217,203,197,239,225,243,253,167,169,187,181,159,145,131,141];
|
||||
|
||||
private static var _Rcon:Array = [0,1,2,4,8,16,32,64,128,27,54];
|
||||
|
||||
private static var Sbox:ByteArray = new ByteArray();
|
||||
|
||||
private static var InvSbox:ByteArray = new ByteArray();
|
||||
|
||||
private static var Xtime2Sbox:ByteArray = new ByteArray();
|
||||
|
||||
private static var Xtime3Sbox:ByteArray = new ByteArray();
|
||||
|
||||
private static var Xtime2:ByteArray = new ByteArray();
|
||||
|
||||
private static var Xtime9:ByteArray = new ByteArray();
|
||||
|
||||
private static var XtimeB:ByteArray = new ByteArray();
|
||||
|
||||
private static var XtimeD:ByteArray = new ByteArray();
|
||||
|
||||
private static var XtimeE:ByteArray = new ByteArray();
|
||||
|
||||
private static var i:uint = 0;
|
||||
|
||||
while(i < 256)
|
||||
{
|
||||
Sbox[i] = _Sbox[i];
|
||||
InvSbox[i] = _InvSbox[i];
|
||||
Xtime2Sbox[i] = _Xtime2Sbox[i];
|
||||
Xtime3Sbox[i] = _Xtime3Sbox[i];
|
||||
Xtime2[i] = _Xtime2[i];
|
||||
Xtime9[i] = _Xtime9[i];
|
||||
XtimeB[i] = _XtimeB[i];
|
||||
XtimeD[i] = _XtimeD[i];
|
||||
XtimeE[i] = _XtimeE[i];
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
private static var Rcon:ByteArray = new ByteArray();
|
||||
|
||||
i = 0;
|
||||
while(i < _Rcon.length)
|
||||
{
|
||||
Rcon[i] = _Rcon[i];
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
private var key:ByteArray;
|
||||
|
||||
private var keyLength:uint;
|
||||
|
||||
private var Nr:uint;
|
||||
|
||||
private var state:ByteArray;
|
||||
|
||||
private var tmp:ByteArray;
|
||||
|
||||
public function AESKey(param1:ByteArray)
|
||||
{
|
||||
super();
|
||||
tmp = new ByteArray();
|
||||
state = new ByteArray();
|
||||
keyLength = param1.length;
|
||||
this.key = new ByteArray();
|
||||
this.key.writeBytes(param1);
|
||||
expandKey();
|
||||
}
|
||||
|
||||
private function expandKey() : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc1_:* = 0;
|
||||
var _loc2_:* = 0;
|
||||
var _loc7_:* = 0;
|
||||
var _loc4_:* = 0;
|
||||
var _loc6_:uint = key.length / 4;
|
||||
Nr = _loc6_ + 6;
|
||||
_loc4_ = _loc6_;
|
||||
while(_loc4_ < 4 * (Nr + 1))
|
||||
{
|
||||
_loc7_ = uint(key[4 * _loc4_ - 4]);
|
||||
_loc3_ = uint(key[4 * _loc4_ - 3]);
|
||||
_loc5_ = uint(key[4 * _loc4_ - 2]);
|
||||
_loc1_ = uint(key[4 * _loc4_ - 1]);
|
||||
if(!(_loc4_ % _loc6_))
|
||||
{
|
||||
_loc2_ = _loc1_;
|
||||
_loc1_ = uint(Sbox[_loc7_]);
|
||||
_loc7_ = uint(Sbox[_loc3_] ^ Rcon[_loc4_ / _loc6_]);
|
||||
_loc3_ = uint(Sbox[_loc5_]);
|
||||
_loc5_ = uint(Sbox[_loc2_]);
|
||||
}
|
||||
else if(_loc6_ > 6 && _loc4_ % _loc6_ == 4)
|
||||
{
|
||||
_loc7_ = uint(Sbox[_loc7_]);
|
||||
_loc3_ = uint(Sbox[_loc3_]);
|
||||
_loc5_ = uint(Sbox[_loc5_]);
|
||||
_loc1_ = uint(Sbox[_loc1_]);
|
||||
}
|
||||
key[4 * _loc4_ + 0] = key[4 * _loc4_ - 4 * _loc6_ + 0] ^ _loc7_;
|
||||
key[4 * _loc4_ + 1] = key[4 * _loc4_ - 4 * _loc6_ + 1] ^ _loc3_;
|
||||
key[4 * _loc4_ + 2] = key[4 * _loc4_ - 4 * _loc6_ + 2] ^ _loc5_;
|
||||
key[4 * _loc4_ + 3] = key[4 * _loc4_ - 4 * _loc6_ + 3] ^ _loc1_;
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
state.position = 0;
|
||||
state.writeBytes(param1,param2,4 * 4);
|
||||
addRoundKey(key,0);
|
||||
_loc3_ = 1;
|
||||
while(_loc3_ < Nr + 1)
|
||||
{
|
||||
if(_loc3_ < Nr)
|
||||
{
|
||||
mixSubColumns();
|
||||
}
|
||||
else
|
||||
{
|
||||
shiftRows();
|
||||
}
|
||||
addRoundKey(key,_loc3_ * 4 * 4);
|
||||
_loc3_++;
|
||||
}
|
||||
param1.position = param2;
|
||||
param1.writeBytes(state);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
state.position = 0;
|
||||
state.writeBytes(param1,param2,4 * 4);
|
||||
addRoundKey(key,Nr * 4 * 4);
|
||||
invShiftRows();
|
||||
_loc3_ = Nr;
|
||||
while(_loc3_--)
|
||||
{
|
||||
addRoundKey(key,_loc3_ * 4 * 4);
|
||||
if(_loc3_)
|
||||
{
|
||||
invMixSubColumns();
|
||||
}
|
||||
}
|
||||
param1.position = param2;
|
||||
param1.writeBytes(state);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc2_:* = 0;
|
||||
var _loc1_:Random = new Random();
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < key.length)
|
||||
{
|
||||
key[_loc2_] = _loc1_.nextByte();
|
||||
_loc2_++;
|
||||
}
|
||||
Nr = _loc1_.nextByte();
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < state.length)
|
||||
{
|
||||
state[_loc2_] = _loc1_.nextByte();
|
||||
_loc2_++;
|
||||
}
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < tmp.length)
|
||||
{
|
||||
tmp[_loc2_] = _loc1_.nextByte();
|
||||
_loc2_++;
|
||||
}
|
||||
key.length = 0;
|
||||
keyLength = 0;
|
||||
state.length = 0;
|
||||
tmp.length = 0;
|
||||
key = null;
|
||||
state = null;
|
||||
tmp = null;
|
||||
Nr = 0;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
protected function shiftRows() : void
|
||||
{
|
||||
var _loc1_:* = 0;
|
||||
state[0] = Sbox[state[0]];
|
||||
state[4] = Sbox[state[4]];
|
||||
state[8] = Sbox[state[8]];
|
||||
state[12] = Sbox[state[12]];
|
||||
_loc1_ = uint(Sbox[state[1]]);
|
||||
state[1] = Sbox[state[5]];
|
||||
state[5] = Sbox[state[9]];
|
||||
state[9] = Sbox[state[13]];
|
||||
state[13] = _loc1_;
|
||||
_loc1_ = uint(Sbox[state[2]]);
|
||||
state[2] = Sbox[state[10]];
|
||||
state[10] = _loc1_;
|
||||
_loc1_ = uint(Sbox[state[6]]);
|
||||
state[6] = Sbox[state[14]];
|
||||
state[14] = _loc1_;
|
||||
_loc1_ = uint(Sbox[state[15]]);
|
||||
state[15] = Sbox[state[11]];
|
||||
state[11] = Sbox[state[7]];
|
||||
state[7] = Sbox[state[3]];
|
||||
state[3] = _loc1_;
|
||||
}
|
||||
|
||||
protected function invShiftRows() : void
|
||||
{
|
||||
var _loc1_:* = 0;
|
||||
state[0] = InvSbox[state[0]];
|
||||
state[4] = InvSbox[state[4]];
|
||||
state[8] = InvSbox[state[8]];
|
||||
state[12] = InvSbox[state[12]];
|
||||
_loc1_ = uint(InvSbox[state[13]]);
|
||||
state[13] = InvSbox[state[9]];
|
||||
state[9] = InvSbox[state[5]];
|
||||
state[5] = InvSbox[state[1]];
|
||||
state[1] = _loc1_;
|
||||
_loc1_ = uint(InvSbox[state[2]]);
|
||||
state[2] = InvSbox[state[10]];
|
||||
state[10] = _loc1_;
|
||||
_loc1_ = uint(InvSbox[state[6]]);
|
||||
state[6] = InvSbox[state[14]];
|
||||
state[14] = _loc1_;
|
||||
_loc1_ = uint(InvSbox[state[3]]);
|
||||
state[3] = InvSbox[state[7]];
|
||||
state[7] = InvSbox[state[11]];
|
||||
state[11] = InvSbox[state[15]];
|
||||
state[15] = _loc1_;
|
||||
}
|
||||
|
||||
protected function mixSubColumns() : void
|
||||
{
|
||||
tmp.length = 0;
|
||||
tmp[0] = Xtime2Sbox[state[0]] ^ Xtime3Sbox[state[5]] ^ Sbox[state[10]] ^ Sbox[state[15]];
|
||||
tmp[1] = Sbox[state[0]] ^ Xtime2Sbox[state[5]] ^ Xtime3Sbox[state[10]] ^ Sbox[state[15]];
|
||||
tmp[2] = Sbox[state[0]] ^ Sbox[state[5]] ^ Xtime2Sbox[state[10]] ^ Xtime3Sbox[state[15]];
|
||||
tmp[3] = Xtime3Sbox[state[0]] ^ Sbox[state[5]] ^ Sbox[state[10]] ^ Xtime2Sbox[state[15]];
|
||||
tmp[4] = Xtime2Sbox[state[4]] ^ Xtime3Sbox[state[9]] ^ Sbox[state[14]] ^ Sbox[state[3]];
|
||||
tmp[5] = Sbox[state[4]] ^ Xtime2Sbox[state[9]] ^ Xtime3Sbox[state[14]] ^ Sbox[state[3]];
|
||||
tmp[6] = Sbox[state[4]] ^ Sbox[state[9]] ^ Xtime2Sbox[state[14]] ^ Xtime3Sbox[state[3]];
|
||||
tmp[7] = Xtime3Sbox[state[4]] ^ Sbox[state[9]] ^ Sbox[state[14]] ^ Xtime2Sbox[state[3]];
|
||||
tmp[8] = Xtime2Sbox[state[8]] ^ Xtime3Sbox[state[13]] ^ Sbox[state[2]] ^ Sbox[state[7]];
|
||||
tmp[9] = Sbox[state[8]] ^ Xtime2Sbox[state[13]] ^ Xtime3Sbox[state[2]] ^ Sbox[state[7]];
|
||||
tmp[10] = Sbox[state[8]] ^ Sbox[state[13]] ^ Xtime2Sbox[state[2]] ^ Xtime3Sbox[state[7]];
|
||||
tmp[11] = Xtime3Sbox[state[8]] ^ Sbox[state[13]] ^ Sbox[state[2]] ^ Xtime2Sbox[state[7]];
|
||||
tmp[12] = Xtime2Sbox[state[12]] ^ Xtime3Sbox[state[1]] ^ Sbox[state[6]] ^ Sbox[state[11]];
|
||||
tmp[13] = Sbox[state[12]] ^ Xtime2Sbox[state[1]] ^ Xtime3Sbox[state[6]] ^ Sbox[state[11]];
|
||||
tmp[14] = Sbox[state[12]] ^ Sbox[state[1]] ^ Xtime2Sbox[state[6]] ^ Xtime3Sbox[state[11]];
|
||||
tmp[15] = Xtime3Sbox[state[12]] ^ Sbox[state[1]] ^ Sbox[state[6]] ^ Xtime2Sbox[state[11]];
|
||||
state.position = 0;
|
||||
state.writeBytes(tmp,0,4 * 4);
|
||||
}
|
||||
|
||||
protected function invMixSubColumns() : void
|
||||
{
|
||||
var _loc1_:* = 0;
|
||||
tmp.length = 0;
|
||||
tmp[0] = XtimeE[state[0]] ^ XtimeB[state[1]] ^ XtimeD[state[2]] ^ Xtime9[state[3]];
|
||||
tmp[5] = Xtime9[state[0]] ^ XtimeE[state[1]] ^ XtimeB[state[2]] ^ XtimeD[state[3]];
|
||||
tmp[10] = XtimeD[state[0]] ^ Xtime9[state[1]] ^ XtimeE[state[2]] ^ XtimeB[state[3]];
|
||||
tmp[15] = XtimeB[state[0]] ^ XtimeD[state[1]] ^ Xtime9[state[2]] ^ XtimeE[state[3]];
|
||||
tmp[4] = XtimeE[state[4]] ^ XtimeB[state[5]] ^ XtimeD[state[6]] ^ Xtime9[state[7]];
|
||||
tmp[9] = Xtime9[state[4]] ^ XtimeE[state[5]] ^ XtimeB[state[6]] ^ XtimeD[state[7]];
|
||||
tmp[14] = XtimeD[state[4]] ^ Xtime9[state[5]] ^ XtimeE[state[6]] ^ XtimeB[state[7]];
|
||||
tmp[3] = XtimeB[state[4]] ^ XtimeD[state[5]] ^ Xtime9[state[6]] ^ XtimeE[state[7]];
|
||||
tmp[8] = XtimeE[state[8]] ^ XtimeB[state[9]] ^ XtimeD[state[10]] ^ Xtime9[state[11]];
|
||||
tmp[13] = Xtime9[state[8]] ^ XtimeE[state[9]] ^ XtimeB[state[10]] ^ XtimeD[state[11]];
|
||||
tmp[2] = XtimeD[state[8]] ^ Xtime9[state[9]] ^ XtimeE[state[10]] ^ XtimeB[state[11]];
|
||||
tmp[7] = XtimeB[state[8]] ^ XtimeD[state[9]] ^ Xtime9[state[10]] ^ XtimeE[state[11]];
|
||||
tmp[12] = XtimeE[state[12]] ^ XtimeB[state[13]] ^ XtimeD[state[14]] ^ Xtime9[state[15]];
|
||||
tmp[1] = Xtime9[state[12]] ^ XtimeE[state[13]] ^ XtimeB[state[14]] ^ XtimeD[state[15]];
|
||||
tmp[6] = XtimeD[state[12]] ^ Xtime9[state[13]] ^ XtimeE[state[14]] ^ XtimeB[state[15]];
|
||||
tmp[11] = XtimeB[state[12]] ^ XtimeD[state[13]] ^ Xtime9[state[14]] ^ XtimeE[state[15]];
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 4 * 4)
|
||||
{
|
||||
state[_loc1_] = InvSbox[tmp[_loc1_]];
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
protected function addRoundKey(param1:ByteArray, param2:uint) : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 16)
|
||||
{
|
||||
var _loc4_:uint = _loc3_;
|
||||
var _loc5_:int = state[_loc4_] ^ param1[_loc3_ + param2];
|
||||
state[_loc4_] = _loc5_;
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "aes" + 8 * keyLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class BlowFishKey implements ISymmetricKey
|
||||
{
|
||||
|
||||
private static const ROUNDS:uint = 16;
|
||||
|
||||
private static const BLOCK_SIZE:uint = 8;
|
||||
|
||||
private static const SBOX_SK:uint = 256;
|
||||
|
||||
private static const P_SZ:uint = 18;
|
||||
|
||||
private static const KP:Array = [608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731];
|
||||
|
||||
private static const KS0:Array = [3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486
|
||||
,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737
|
||||
,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946];
|
||||
|
||||
private static const KS1:Array = [1266315497,3048417604,3681880366,3289982499,2909710000,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616
|
||||
,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670
|
||||
,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055];
|
||||
|
||||
private static const KS2:Array = [3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280
|
||||
,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629
|
||||
,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504];
|
||||
|
||||
private static const KS3:Array = [976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805
|
||||
,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409000,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506
|
||||
,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462];
|
||||
|
||||
private var S0:Array;
|
||||
|
||||
private var S1:Array;
|
||||
|
||||
private var S2:Array;
|
||||
|
||||
private var S3:Array;
|
||||
|
||||
private var P:Array;
|
||||
|
||||
private var key:ByteArray = null;
|
||||
|
||||
public function BlowFishKey(param1:ByteArray)
|
||||
{
|
||||
super();
|
||||
this.key = param1;
|
||||
setKey(param1);
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
decryptBlock(param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < S0.length)
|
||||
{
|
||||
S0[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < S1.length)
|
||||
{
|
||||
S1[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < S2.length)
|
||||
{
|
||||
S2[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < S3.length)
|
||||
{
|
||||
S3[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < P.length)
|
||||
{
|
||||
P[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
S0 = null;
|
||||
S1 = null;
|
||||
S2 = null;
|
||||
S3 = null;
|
||||
P = null;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < key.length)
|
||||
{
|
||||
key[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
key.length = 0;
|
||||
key = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
encryptBlock(param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
private function F(param1:uint) : uint
|
||||
{
|
||||
return (S0[param1 >>> 24] + S1[param1 >>> 16 & 0xFF] ^ S2[param1 >>> 8 & 0xFF]) + S3[param1 & 0xFF];
|
||||
}
|
||||
|
||||
private function processTable(param1:uint, param2:uint, param3:Array) : void
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
var _loc5_:uint = param3.length;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc5_)
|
||||
{
|
||||
param1 ^= P[0];
|
||||
_loc6_ = 1;
|
||||
while(_loc6_ < 16)
|
||||
{
|
||||
param2 ^= F(param1) ^ P[_loc6_];
|
||||
param1 ^= F(param2) ^ P[_loc6_ + 1];
|
||||
_loc6_ += 2;
|
||||
}
|
||||
param2 ^= P[16 + 1];
|
||||
param3[_loc4_] = param2;
|
||||
param3[_loc4_ + 1] = param1;
|
||||
param2 = param1;
|
||||
param1 = uint(param3[_loc4_]);
|
||||
_loc4_ += 2;
|
||||
}
|
||||
}
|
||||
|
||||
private function setKey(param1:ByteArray) : void
|
||||
{
|
||||
var _loc5_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
S0 = KS0.concat();
|
||||
S1 = KS1.concat();
|
||||
S2 = KS2.concat();
|
||||
S3 = KS3.concat();
|
||||
P = KP.concat();
|
||||
var _loc2_:uint = param1.length;
|
||||
var _loc4_:uint = 0;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 18)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < 4)
|
||||
{
|
||||
_loc3_ = uint(_loc3_ << 8 | param1[_loc4_++] & 0xFF);
|
||||
if(_loc4_ >= _loc2_)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
var _loc7_:uint = _loc5_;
|
||||
var _loc8_:int = P[_loc7_] ^ _loc3_;
|
||||
P[_loc7_] = _loc8_;
|
||||
_loc5_++;
|
||||
}
|
||||
processTable(0,0,P);
|
||||
processTable(P[18 - 2],P[18 - 1],S0);
|
||||
processTable(S0[256 - 2],S0[256 - 1],S1);
|
||||
processTable(S1[256 - 2],S1[256 - 1],S2);
|
||||
processTable(S2[256 - 2],S2[256 - 1],S3);
|
||||
}
|
||||
|
||||
private function encryptBlock(param1:ByteArray, param2:uint, param3:ByteArray, param4:uint) : void
|
||||
{
|
||||
var _loc6_:* = 0;
|
||||
var _loc5_:uint = BytesTo32bits(param1,param2);
|
||||
var _loc7_:uint = BytesTo32bits(param1,param2 + 4);
|
||||
_loc5_ ^= P[0];
|
||||
_loc6_ = 1;
|
||||
while(_loc6_ < 16)
|
||||
{
|
||||
_loc7_ ^= F(_loc5_) ^ P[_loc6_];
|
||||
_loc5_ ^= F(_loc7_) ^ P[_loc6_ + 1];
|
||||
_loc6_ += 2;
|
||||
}
|
||||
_loc7_ ^= P[16 + 1];
|
||||
Bits32ToBytes(_loc7_,param3,param4);
|
||||
Bits32ToBytes(_loc5_,param3,param4 + 4);
|
||||
}
|
||||
|
||||
private function decryptBlock(param1:ByteArray, param2:uint, param3:ByteArray, param4:uint) : void
|
||||
{
|
||||
var _loc6_:* = 0;
|
||||
var _loc5_:uint = BytesTo32bits(param1,param2);
|
||||
var _loc7_:uint = BytesTo32bits(param1,param2 + 4);
|
||||
_loc5_ ^= P[16 + 1];
|
||||
_loc6_ = 16;
|
||||
while(_loc6_ > 0)
|
||||
{
|
||||
_loc7_ ^= F(_loc5_) ^ P[_loc6_];
|
||||
_loc5_ ^= F(_loc7_) ^ P[_loc6_ - 1];
|
||||
_loc6_ -= 2;
|
||||
}
|
||||
_loc7_ ^= P[0];
|
||||
Bits32ToBytes(_loc7_,param3,param4);
|
||||
Bits32ToBytes(_loc5_,param3,param4 + 4);
|
||||
}
|
||||
|
||||
private function BytesTo32bits(param1:ByteArray, param2:uint) : uint
|
||||
{
|
||||
return (param1[param2] & 0xFF) << 24 | (param1[param2 + 1] & 0xFF) << 16 | (param1[param2 + 2] & 0xFF) << 8 | param1[param2 + 3] & 0xFF;
|
||||
}
|
||||
|
||||
private function Bits32ToBytes(param1:uint, param2:ByteArray, param3:uint) : void
|
||||
{
|
||||
param2[param3 + 3] = param1;
|
||||
param2[param3 + 2] = param1 >> 8;
|
||||
param2[param3 + 1] = param1 >> 16;
|
||||
param2[param3] = param1 >> 24;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "blowfish";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class CBCMode extends IVMode implements IMode
|
||||
{
|
||||
|
||||
public function CBCMode(param1:ISymmetricKey, param2:IPad = null)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:* = 0;
|
||||
var _loc4_:* = 0;
|
||||
padding.pad(param1);
|
||||
var _loc3_:ByteArray = getIV4e();
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < param1.length)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < blockSize)
|
||||
{
|
||||
var _loc5_:Number = _loc2_ + _loc4_;
|
||||
var _loc6_:int = param1[_loc5_] ^ _loc3_[_loc4_];
|
||||
param1[_loc5_] = _loc6_;
|
||||
_loc4_++;
|
||||
}
|
||||
key.encrypt(param1,_loc2_);
|
||||
_loc3_.position = 0;
|
||||
_loc3_.writeBytes(param1,_loc2_,blockSize);
|
||||
_loc2_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc4_:ByteArray = getIV4d();
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_loc2_.position = 0;
|
||||
_loc2_.writeBytes(param1,_loc3_,blockSize);
|
||||
key.decrypt(param1,_loc3_);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < blockSize)
|
||||
{
|
||||
var _loc6_:Number = _loc3_ + _loc5_;
|
||||
var _loc7_:int = param1[_loc6_] ^ _loc4_[_loc5_];
|
||||
param1[_loc6_] = _loc7_;
|
||||
_loc5_++;
|
||||
}
|
||||
_loc4_.position = 0;
|
||||
_loc4_.writeBytes(_loc2_,0,blockSize);
|
||||
_loc3_ += blockSize;
|
||||
}
|
||||
padding.unpad(param1);
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-cbc";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class CFB8Mode extends IVMode implements IMode
|
||||
{
|
||||
|
||||
public function CFB8Mode(param1:ISymmetricKey, param2:IPad = null)
|
||||
{
|
||||
super(param1,null);
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc4_:ByteArray = getIV4e();
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_loc2_.position = 0;
|
||||
_loc2_.writeBytes(_loc4_);
|
||||
key.encrypt(_loc4_);
|
||||
param1[_loc3_] ^= _loc4_[0];
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < blockSize - 1)
|
||||
{
|
||||
_loc4_[_loc5_] = _loc2_[_loc5_ + 1];
|
||||
_loc5_++;
|
||||
}
|
||||
_loc4_[blockSize - 1] = param1[_loc3_];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
var _loc2_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
var _loc5_:ByteArray = getIV4d();
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
_loc2_ = uint(param1[_loc4_]);
|
||||
_loc3_.position = 0;
|
||||
_loc3_.writeBytes(_loc5_);
|
||||
key.encrypt(_loc5_);
|
||||
param1[_loc4_] ^= _loc5_[0];
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < blockSize - 1)
|
||||
{
|
||||
_loc5_[_loc6_] = _loc3_[_loc6_ + 1];
|
||||
_loc6_++;
|
||||
}
|
||||
_loc5_[blockSize - 1] = _loc2_;
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-cfb8";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class CFBMode extends IVMode implements IMode
|
||||
{
|
||||
|
||||
public function CFBMode(param1:ISymmetricKey, param2:IPad = null)
|
||||
{
|
||||
super(param1,null);
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc6_:uint = param1.length;
|
||||
var _loc4_:ByteArray = getIV4e();
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < param1.length)
|
||||
{
|
||||
key.encrypt(_loc4_);
|
||||
_loc3_ = uint(_loc2_ + blockSize < _loc6_ ? blockSize : _loc6_ - _loc2_);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
var _loc7_:Number = _loc2_ + _loc5_;
|
||||
var _loc8_:int = param1[_loc7_] ^ _loc4_[_loc5_];
|
||||
param1[_loc7_] = _loc8_;
|
||||
_loc5_++;
|
||||
}
|
||||
_loc4_.position = 0;
|
||||
_loc4_.writeBytes(param1,_loc2_,_loc3_);
|
||||
_loc2_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc4_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
var _loc7_:uint = param1.length;
|
||||
var _loc5_:ByteArray = getIV4d();
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
key.encrypt(_loc5_);
|
||||
_loc4_ = uint(_loc3_ + blockSize < _loc7_ ? blockSize : _loc7_ - _loc3_);
|
||||
_loc2_.position = 0;
|
||||
_loc2_.writeBytes(param1,_loc3_,_loc4_);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc4_)
|
||||
{
|
||||
var _loc8_:Number = _loc3_ + _loc6_;
|
||||
var _loc9_:int = param1[_loc8_] ^ _loc5_[_loc6_];
|
||||
param1[_loc8_] = _loc9_;
|
||||
_loc6_++;
|
||||
}
|
||||
_loc5_.position = 0;
|
||||
_loc5_.writeBytes(_loc2_);
|
||||
_loc3_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-cfb";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class CTRMode extends IVMode implements IMode
|
||||
{
|
||||
|
||||
public function CTRMode(param1:ISymmetricKey, param2:IPad = null)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
padding.pad(param1);
|
||||
var _loc2_:ByteArray = getIV4e();
|
||||
core(param1,_loc2_);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:ByteArray = getIV4d();
|
||||
core(param1,_loc2_);
|
||||
padding.unpad(param1);
|
||||
}
|
||||
|
||||
private function core(param1:ByteArray, param2:ByteArray) : void
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
var _loc6_:ByteArray = new ByteArray();
|
||||
_loc3_.writeBytes(param2);
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
_loc6_.position = 0;
|
||||
_loc6_.writeBytes(_loc3_);
|
||||
key.encrypt(_loc6_);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < blockSize)
|
||||
{
|
||||
var _loc7_:Number = _loc4_ + _loc5_;
|
||||
var _loc8_:int = param1[_loc7_] ^ _loc6_[_loc5_];
|
||||
param1[_loc7_] = _loc8_;
|
||||
_loc5_++;
|
||||
}
|
||||
_loc5_ = uint(blockSize - 1);
|
||||
while(_loc5_ >= 0)
|
||||
{
|
||||
_loc3_[_loc5_]++;
|
||||
if(_loc3_[_loc5_] != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc5_--;
|
||||
}
|
||||
_loc4_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-ctr";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class DESKey implements ISymmetricKey
|
||||
{
|
||||
|
||||
private static const Df_Key:Array = [1,35,69,103,137,171,205,239,254,220,186,152,118,84,50,16,137,171,205,239,1,35,69,103];
|
||||
|
||||
private static const bytebit:Array = [128,64,32,16,8,4,2,1];
|
||||
|
||||
private static const bigbyte:Array = [8388608,4194304,2097152,1048576,524288,262144,131072,65536,32768,16384,8192,4096,2048,1024,512,256,128,64,32,16,8,4,2,1];
|
||||
|
||||
private static const pc1:Array = [56,48,40,32,24,16,8,0,57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,60,52,44,36,28,20,12,4,27,19,11,3];
|
||||
|
||||
private static const totrot:Array = [1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28];
|
||||
|
||||
private static const pc2:Array = [13,16,10,23,0,4,2,27,14,5,20,9,22,18,11,3,25,7,15,6,26,19,12,1,40,51,30,36,46,54,29,39,50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31];
|
||||
|
||||
private static const SP1:Array = [16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756];
|
||||
|
||||
private static const SP2:Array = [2148565024,2147516416,32768,1081376,1048576,32,2148532256,2147516448,2147483680,2148565024,2148564992,2147483648,2147516416,1048576,32,2148532256,1081344,1048608,2147516448,0,2147483648,32768,1081376,2148532224,1048608,2147483680,0,1081344,32800,2148564992,2148532224,32800,0,1081376,2148532256,1048576,2147516448,2148532224,2148564992,32768,2148532224,2147516416,32,2148565024,1081376,32,32768,2147483648,32800,2148564992,1048576,2147483680,1048608,2147516448,2147483680,1048608,1081344,0,2147516416,32800,2147483648,2148532256,2148565024,1081344];
|
||||
|
||||
private static const SP3:Array = [520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584];
|
||||
|
||||
private static const SP4:Array = [8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928];
|
||||
|
||||
private static const SP5:Array = [256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080];
|
||||
|
||||
private static const SP6:Array = [536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312];
|
||||
|
||||
private static const SP7:Array = [2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154];
|
||||
|
||||
private static const SP8:Array = [268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];
|
||||
|
||||
protected var key:ByteArray;
|
||||
|
||||
protected var encKey:Array;
|
||||
|
||||
protected var decKey:Array;
|
||||
|
||||
public function DESKey(param1:ByteArray)
|
||||
{
|
||||
super();
|
||||
this.key = param1;
|
||||
this.encKey = generateWorkingKey(true,param1,0);
|
||||
this.decKey = generateWorkingKey(false,param1,0);
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
desFunc(decKey,param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < encKey.length)
|
||||
{
|
||||
encKey[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < decKey.length)
|
||||
{
|
||||
decKey[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
encKey = null;
|
||||
decKey = null;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < key.length)
|
||||
{
|
||||
key[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
key.length = 0;
|
||||
key = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
desFunc(encKey,param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
protected function generateWorkingKey(param1:Boolean, param2:ByteArray, param3:uint) : Array
|
||||
{
|
||||
var _loc9_:* = 0;
|
||||
var _loc8_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
var _loc10_:* = 0;
|
||||
var _loc11_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc7_:* = 0;
|
||||
var _loc4_:Array = [];
|
||||
var _loc12_:ByteArray = new ByteArray();
|
||||
var _loc13_:ByteArray = new ByteArray();
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 56)
|
||||
{
|
||||
_loc9_ = uint(pc1[_loc8_]);
|
||||
_loc12_[_loc8_] = (param2[param3 + (_loc9_ >>> 3)] & bytebit[_loc9_ & 7]) != 0;
|
||||
_loc8_++;
|
||||
}
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < 16)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_loc10_ = uint(_loc6_ << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc10_ = uint(15 - _loc6_ << 1);
|
||||
}
|
||||
_loc11_ = uint(_loc10_ + 1);
|
||||
_loc4_[_loc10_] = _loc4_[_loc11_] = 0;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 28)
|
||||
{
|
||||
_loc9_ = uint(_loc8_ + totrot[_loc6_]);
|
||||
if(_loc9_ < 28)
|
||||
{
|
||||
_loc13_[_loc8_] = _loc12_[_loc9_];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_[_loc8_] = _loc12_[_loc9_ - 28];
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
_loc8_ = 28;
|
||||
while(_loc8_ < 56)
|
||||
{
|
||||
_loc9_ = uint(_loc8_ + totrot[_loc6_]);
|
||||
if(_loc9_ < 56)
|
||||
{
|
||||
_loc13_[_loc8_] = _loc12_[_loc9_];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_[_loc8_] = _loc12_[_loc9_ - 28];
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 24)
|
||||
{
|
||||
if(_loc13_[pc2[_loc8_]])
|
||||
{
|
||||
var _loc14_:* = _loc10_;
|
||||
var _loc15_:* = _loc4_[_loc14_] | bigbyte[_loc8_];
|
||||
_loc4_[_loc14_] = _loc15_;
|
||||
}
|
||||
if(_loc13_[pc2[_loc8_ + 24]])
|
||||
{
|
||||
_loc15_ = _loc11_;
|
||||
_loc14_ = _loc4_[_loc15_] | bigbyte[_loc8_];
|
||||
_loc4_[_loc15_] = _loc14_;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ != 32)
|
||||
{
|
||||
_loc5_ = uint(_loc4_[_loc6_]);
|
||||
_loc7_ = uint(_loc4_[_loc6_ + 1]);
|
||||
_loc4_[_loc6_] = (_loc5_ & 0xFC0000) << 6 | (_loc5_ & 0x0FC0) << 10 | (_loc7_ & 0xFC0000) >>> 10 | (_loc7_ & 0x0FC0) >>> 6;
|
||||
_loc4_[_loc6_ + 1] = (_loc5_ & 0x03F000) << 12 | (_loc5_ & 0x3F) << 16 | (_loc7_ & 0x03F000) >>> 4 | _loc7_ & 0x3F;
|
||||
_loc6_ += 2;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
protected function desFunc(param1:Array, param2:ByteArray, param3:uint, param4:ByteArray, param5:uint) : void
|
||||
{
|
||||
var _loc8_:* = 0;
|
||||
var _loc9_:* = 0;
|
||||
var _loc7_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
var _loc10_:* = 0;
|
||||
_loc7_ = uint((param2[param3 + 0] & 0xFF) << 24);
|
||||
_loc7_ = uint(_loc7_ | (param2[param3 + 1] & 0xFF) << 16);
|
||||
_loc7_ = uint(_loc7_ | (param2[param3 + 2] & 0xFF) << 8);
|
||||
_loc7_ = uint(_loc7_ | param2[param3 + 3] & 0xFF);
|
||||
_loc9_ = uint((param2[param3 + 4] & 0xFF) << 24);
|
||||
_loc9_ = uint(_loc9_ | (param2[param3 + 5] & 0xFF) << 16);
|
||||
_loc9_ = uint(_loc9_ | (param2[param3 + 6] & 0xFF) << 8);
|
||||
_loc9_ = uint(_loc9_ | param2[param3 + 7] & 0xFF);
|
||||
_loc8_ = uint((_loc7_ >>> 4 ^ _loc9_) & 0x0F0F0F0F);
|
||||
_loc9_ ^= _loc8_;
|
||||
_loc7_ ^= _loc8_ << 4;
|
||||
_loc8_ = uint((_loc7_ >>> 16 ^ _loc9_) & 0xFFFF);
|
||||
_loc9_ ^= _loc8_;
|
||||
_loc7_ ^= _loc8_ << 16;
|
||||
_loc8_ = uint((_loc9_ >>> 2 ^ _loc7_) & 0x33333333);
|
||||
_loc7_ ^= _loc8_;
|
||||
_loc9_ ^= _loc8_ << 2;
|
||||
_loc8_ = uint((_loc9_ >>> 8 ^ _loc7_) & 0xFF00FF);
|
||||
_loc7_ ^= _loc8_;
|
||||
_loc9_ ^= _loc8_ << 8;
|
||||
_loc9_ = uint((_loc9_ << 1 | _loc9_ >>> 31 & 1) & 0xFFFFFFFF);
|
||||
_loc8_ = uint((_loc7_ ^ _loc9_) & 0xAAAAAAAA);
|
||||
_loc7_ ^= _loc8_;
|
||||
_loc9_ ^= _loc8_;
|
||||
_loc7_ = uint((_loc7_ << 1 | _loc7_ >>> 31 & 1) & 0xFFFFFFFF);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < 8)
|
||||
{
|
||||
_loc8_ = uint(_loc9_ << 28 | _loc9_ >>> 4);
|
||||
_loc8_ = uint(_loc8_ ^ param1[_loc6_ * 4 + 0]);
|
||||
_loc10_ = uint(SP7[_loc8_ & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP5[_loc8_ >>> 8 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP3[_loc8_ >>> 16 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP1[_loc8_ >>> 24 & 0x3F]);
|
||||
_loc8_ = uint(_loc9_ ^ param1[_loc6_ * 4 + 1]);
|
||||
_loc10_ |= SP8[_loc8_ & 0x3F];
|
||||
_loc10_ = uint(_loc10_ | SP6[_loc8_ >>> 8 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP4[_loc8_ >>> 16 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP2[_loc8_ >>> 24 & 0x3F]);
|
||||
_loc7_ ^= _loc10_;
|
||||
_loc8_ = uint(_loc7_ << 28 | _loc7_ >>> 4);
|
||||
_loc8_ = uint(_loc8_ ^ param1[_loc6_ * 4 + 2]);
|
||||
_loc10_ = uint(SP7[_loc8_ & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP5[_loc8_ >>> 8 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP3[_loc8_ >>> 16 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP1[_loc8_ >>> 24 & 0x3F]);
|
||||
_loc8_ = uint(_loc7_ ^ param1[_loc6_ * 4 + 3]);
|
||||
_loc10_ |= SP8[_loc8_ & 0x3F];
|
||||
_loc10_ = uint(_loc10_ | SP6[_loc8_ >>> 8 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP4[_loc8_ >>> 16 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP2[_loc8_ >>> 24 & 0x3F]);
|
||||
_loc9_ ^= _loc10_;
|
||||
_loc6_++;
|
||||
}
|
||||
_loc9_ = uint(_loc9_ << 31 | _loc9_ >>> 1);
|
||||
_loc8_ = uint((_loc7_ ^ _loc9_) & 0xAAAAAAAA);
|
||||
_loc7_ ^= _loc8_;
|
||||
_loc9_ ^= _loc8_;
|
||||
_loc7_ = uint(_loc7_ << 31 | _loc7_ >>> 1);
|
||||
_loc8_ = uint((_loc7_ >>> 8 ^ _loc9_) & 0xFF00FF);
|
||||
_loc9_ ^= _loc8_;
|
||||
_loc7_ ^= _loc8_ << 8;
|
||||
_loc8_ = uint((_loc7_ >>> 2 ^ _loc9_) & 0x33333333);
|
||||
_loc9_ ^= _loc8_;
|
||||
_loc7_ ^= _loc8_ << 2;
|
||||
_loc8_ = uint((_loc9_ >>> 16 ^ _loc7_) & 0xFFFF);
|
||||
_loc7_ ^= _loc8_;
|
||||
_loc9_ ^= _loc8_ << 16;
|
||||
_loc8_ = uint((_loc9_ >>> 4 ^ _loc7_) & 0x0F0F0F0F);
|
||||
_loc7_ ^= _loc8_;
|
||||
_loc9_ ^= _loc8_ << 4;
|
||||
param4[param5 + 0] = _loc9_ >>> 24 & 0xFF;
|
||||
param4[param5 + 1] = _loc9_ >>> 16 & 0xFF;
|
||||
param4[param5 + 2] = _loc9_ >>> 8 & 0xFF;
|
||||
param4[param5 + 3] = _loc9_ & 0xFF;
|
||||
param4[param5 + 4] = _loc7_ >>> 24 & 0xFF;
|
||||
param4[param5 + 5] = _loc7_ >>> 16 & 0xFF;
|
||||
param4[param5 + 6] = _loc7_ >>> 8 & 0xFF;
|
||||
param4[param5 + 7] = _loc7_ & 0xFF;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "des";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class ECBMode implements IMode, ICipher
|
||||
{
|
||||
|
||||
private var key:ISymmetricKey;
|
||||
|
||||
private var padding:IPad;
|
||||
|
||||
public function ECBMode(param1:ISymmetricKey, param2:IPad = null)
|
||||
{
|
||||
super();
|
||||
this.key = param1;
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = new PKCS5(param1.getBlockSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
param2.setBlockSize(param1.getBlockSize());
|
||||
}
|
||||
this.padding = param2;
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return key.getBlockSize();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
padding.pad(param1);
|
||||
param1.position = 0;
|
||||
var _loc5_:uint = key.getBlockSize();
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
_loc3_.length = 0;
|
||||
param1.readBytes(_loc3_,0,_loc5_);
|
||||
key.encrypt(_loc3_);
|
||||
_loc2_.writeBytes(_loc3_);
|
||||
_loc4_ += _loc5_;
|
||||
}
|
||||
param1.length = 0;
|
||||
param1.writeBytes(_loc2_);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
param1.position = 0;
|
||||
var _loc5_:uint = key.getBlockSize();
|
||||
if(param1.length % _loc5_ != 0)
|
||||
{
|
||||
throw new Error("ECB mode cipher length must be a multiple of blocksize " + _loc5_);
|
||||
}
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
_loc3_.length = 0;
|
||||
param1.readBytes(_loc3_,0,_loc5_);
|
||||
key.decrypt(_loc3_);
|
||||
_loc2_.writeBytes(_loc3_);
|
||||
_loc4_ += _loc5_;
|
||||
}
|
||||
padding.unpad(_loc2_);
|
||||
param1.length = 0;
|
||||
param1.writeBytes(_loc2_);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
key.dispose();
|
||||
key = null;
|
||||
padding = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-ecb";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public interface ICipher
|
||||
{
|
||||
|
||||
function getBlockSize() : uint;
|
||||
|
||||
function encrypt(param1:ByteArray) : void;
|
||||
|
||||
function decrypt(param1:ByteArray) : void;
|
||||
|
||||
function dispose() : void;
|
||||
|
||||
function toString() : String;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
public interface IMode extends ICipher
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public interface IPad
|
||||
{
|
||||
|
||||
function pad(param1:ByteArray) : void;
|
||||
|
||||
function unpad(param1:ByteArray) : void;
|
||||
|
||||
function setBlockSize(param1:uint) : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
public interface IStreamCipher extends ICipher
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public interface ISymmetricKey
|
||||
{
|
||||
|
||||
function getBlockSize() : uint;
|
||||
|
||||
function encrypt(param1:ByteArray, param2:uint = 0) : void;
|
||||
|
||||
function decrypt(param1:ByteArray, param2:uint = 0) : void;
|
||||
|
||||
function dispose() : void;
|
||||
|
||||
function toString() : String;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import com.hurlant.crypto.prng.Random;
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class IVMode
|
||||
{
|
||||
|
||||
protected var key:ISymmetricKey;
|
||||
|
||||
protected var padding:IPad;
|
||||
|
||||
protected var prng:Random;
|
||||
|
||||
protected var iv:ByteArray;
|
||||
|
||||
protected var lastIV:ByteArray;
|
||||
|
||||
protected var blockSize:uint;
|
||||
|
||||
public function IVMode(param1:ISymmetricKey, param2:IPad = null)
|
||||
{
|
||||
super();
|
||||
this.key = param1;
|
||||
blockSize = param1.getBlockSize();
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = new PKCS5(blockSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
param2.setBlockSize(blockSize);
|
||||
}
|
||||
this.padding = param2;
|
||||
prng = new Random();
|
||||
iv = null;
|
||||
lastIV = new ByteArray();
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return key.getBlockSize();
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:* = 0;
|
||||
if(iv != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < iv.length)
|
||||
{
|
||||
iv[_loc1_] = prng.nextByte();
|
||||
_loc1_++;
|
||||
}
|
||||
iv.length = 0;
|
||||
iv = null;
|
||||
}
|
||||
if(lastIV != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < iv.length)
|
||||
{
|
||||
lastIV[_loc1_] = prng.nextByte();
|
||||
_loc1_++;
|
||||
}
|
||||
lastIV.length = 0;
|
||||
lastIV = null;
|
||||
}
|
||||
key.dispose();
|
||||
key = null;
|
||||
padding = null;
|
||||
prng.dispose();
|
||||
prng = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function set IV(param1:ByteArray) : void
|
||||
{
|
||||
iv = param1;
|
||||
lastIV.length = 0;
|
||||
lastIV.writeBytes(iv);
|
||||
}
|
||||
|
||||
public function get IV() : ByteArray
|
||||
{
|
||||
return lastIV;
|
||||
}
|
||||
|
||||
protected function getIV4e() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(iv)
|
||||
{
|
||||
_loc1_.writeBytes(iv);
|
||||
}
|
||||
else
|
||||
{
|
||||
prng.nextBytes(_loc1_,blockSize);
|
||||
}
|
||||
lastIV.length = 0;
|
||||
lastIV.writeBytes(_loc1_);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
protected function getIV4d() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(iv)
|
||||
{
|
||||
_loc1_.writeBytes(iv);
|
||||
return _loc1_;
|
||||
}
|
||||
throw new Error("an IV must be set before calling decrypt()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class NullPad implements IPad
|
||||
{
|
||||
|
||||
public function NullPad()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function unpad(param1:ByteArray) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function pad(param1:ByteArray) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function setBlockSize(param1:uint) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class OFBMode extends IVMode implements IMode
|
||||
{
|
||||
|
||||
public function OFBMode(param1:ISymmetricKey, param2:IPad = null)
|
||||
{
|
||||
super(param1,null);
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:ByteArray = getIV4e();
|
||||
core(param1,_loc2_);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:ByteArray = getIV4d();
|
||||
core(param1,_loc2_);
|
||||
}
|
||||
|
||||
private function core(param1:ByteArray, param2:ByteArray) : void
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
var _loc7_:uint = param1.length;
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
key.encrypt(param2);
|
||||
_loc3_.position = 0;
|
||||
_loc3_.writeBytes(param2);
|
||||
_loc5_ = uint(_loc4_ + blockSize < _loc7_ ? blockSize : _loc7_ - _loc4_);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc5_)
|
||||
{
|
||||
var _loc8_:Number = _loc4_ + _loc6_;
|
||||
var _loc9_:int = param1[_loc8_] ^ param2[_loc6_];
|
||||
param1[_loc8_] = _loc9_;
|
||||
_loc6_++;
|
||||
}
|
||||
param2.position = 0;
|
||||
param2.writeBytes(_loc3_);
|
||||
_loc4_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-ofb";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class PKCS5 implements IPad
|
||||
{
|
||||
|
||||
private var blockSize:uint;
|
||||
|
||||
public function PKCS5(param1:uint = 0)
|
||||
{
|
||||
super();
|
||||
this.blockSize = param1;
|
||||
}
|
||||
|
||||
public function pad(param1:ByteArray) : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc2_:uint = blockSize - param1.length % blockSize;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
param1[param1.length] = _loc2_;
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function unpad(param1:ByteArray) : void
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc2_:uint = param1.length % blockSize;
|
||||
if(_loc2_ != 0)
|
||||
{
|
||||
throw new Error("PKCS#5::unpad: ByteArray.length isn\'t a multiple of the blockSize");
|
||||
}
|
||||
_loc2_ = uint(param1[param1.length - 1]);
|
||||
_loc4_ = _loc2_;
|
||||
while(_loc4_ > 0)
|
||||
{
|
||||
_loc3_ = uint(param1[param1.length - 1]);
|
||||
param1.length--;
|
||||
if(_loc2_ != _loc3_)
|
||||
{
|
||||
throw new Error("PKCS#5:unpad: Invalid padding value. expected [" + _loc2_ + "], found [" + _loc3_ + "]");
|
||||
}
|
||||
_loc4_--;
|
||||
}
|
||||
}
|
||||
|
||||
public function setBlockSize(param1:uint) : void
|
||||
{
|
||||
blockSize = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class SimpleIVMode implements IMode, ICipher
|
||||
{
|
||||
|
||||
protected var mode:IVMode;
|
||||
|
||||
protected var cipher:ICipher;
|
||||
|
||||
public function SimpleIVMode(param1:IVMode)
|
||||
{
|
||||
super();
|
||||
this.mode = param1;
|
||||
cipher = param1 as ICipher;
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return mode.getBlockSize();
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
mode.dispose();
|
||||
mode = null;
|
||||
cipher = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
cipher.encrypt(param1);
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc2_.writeBytes(mode.IV);
|
||||
_loc2_.writeBytes(param1);
|
||||
param1.position = 0;
|
||||
param1.writeBytes(_loc2_);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc2_.writeBytes(param1,0,getBlockSize());
|
||||
mode.IV = _loc2_;
|
||||
_loc2_ = new ByteArray();
|
||||
_loc2_.writeBytes(param1,getBlockSize());
|
||||
cipher.decrypt(_loc2_);
|
||||
param1.length = 0;
|
||||
param1.writeBytes(_loc2_);
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "simple-" + cipher.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class TripleDESKey extends DESKey
|
||||
{
|
||||
|
||||
protected var encKey2:Array;
|
||||
|
||||
protected var encKey3:Array;
|
||||
|
||||
protected var decKey2:Array;
|
||||
|
||||
protected var decKey3:Array;
|
||||
|
||||
public function TripleDESKey(param1:ByteArray)
|
||||
{
|
||||
super(param1);
|
||||
encKey2 = generateWorkingKey(false,param1,8);
|
||||
decKey2 = generateWorkingKey(true,param1,8);
|
||||
if(param1.length > 16)
|
||||
{
|
||||
encKey3 = generateWorkingKey(true,param1,16);
|
||||
decKey3 = generateWorkingKey(false,param1,16);
|
||||
}
|
||||
else
|
||||
{
|
||||
encKey3 = encKey;
|
||||
decKey3 = decKey;
|
||||
}
|
||||
}
|
||||
|
||||
override public function dispose() : void
|
||||
{
|
||||
super.dispose();
|
||||
var _loc1_:uint = 0;
|
||||
if(encKey2 != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < encKey2.length)
|
||||
{
|
||||
encKey2[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
encKey2 = null;
|
||||
}
|
||||
if(encKey3 != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < encKey3.length)
|
||||
{
|
||||
encKey3[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
encKey3 = null;
|
||||
}
|
||||
if(decKey2 != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < decKey2.length)
|
||||
{
|
||||
decKey2[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
decKey2 = null;
|
||||
}
|
||||
if(decKey3 != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < decKey3.length)
|
||||
{
|
||||
decKey3[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
decKey3 = null;
|
||||
}
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
override public function encrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
desFunc(encKey,param1,param2,param1,param2);
|
||||
desFunc(encKey2,param1,param2,param1,param2);
|
||||
desFunc(encKey3,param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
override public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
desFunc(decKey3,param1,param2,param1,param2);
|
||||
desFunc(decKey2,param1,param2,param1,param2);
|
||||
desFunc(decKey,param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "3des";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import com.hurlant.crypto.prng.Random;
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class XTeaKey implements ISymmetricKey
|
||||
{
|
||||
|
||||
public const NUM_ROUNDS:uint = 64;
|
||||
|
||||
private var k:Array;
|
||||
|
||||
public function XTeaKey(param1:ByteArray)
|
||||
{
|
||||
super();
|
||||
param1.position = 0;
|
||||
k = [param1.readUnsignedInt(),param1.readUnsignedInt(),param1.readUnsignedInt(),param1.readUnsignedInt()];
|
||||
}
|
||||
|
||||
public static function parseKey(param1:String) : XTeaKey
|
||||
{
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc2_.writeUnsignedInt(parseInt(param1.substr(0,8),16));
|
||||
_loc2_.writeUnsignedInt(parseInt(param1.substr(8,8),16));
|
||||
_loc2_.writeUnsignedInt(parseInt(param1.substr(16,8),16));
|
||||
_loc2_.writeUnsignedInt(parseInt(param1.substr(24,8),16));
|
||||
_loc2_.position = 0;
|
||||
return new XTeaKey(_loc2_);
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
param1.position = param2;
|
||||
var _loc5_:uint = param1.readUnsignedInt();
|
||||
var _loc7_:uint = param1.readUnsignedInt();
|
||||
var _loc6_:uint = 0;
|
||||
var _loc3_:Number = 2654435769;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 64)
|
||||
{
|
||||
_loc5_ += (_loc7_ << 4 ^ _loc7_ >> 5) + _loc7_ ^ _loc6_ + k[_loc6_ & 3];
|
||||
_loc6_ += _loc3_;
|
||||
_loc7_ += (_loc5_ << 4 ^ _loc5_ >> 5) + _loc5_ ^ _loc6_ + k[_loc6_ >> 11 & 3];
|
||||
_loc4_++;
|
||||
}
|
||||
param1.position -= 8;
|
||||
param1.writeUnsignedInt(_loc5_);
|
||||
param1.writeUnsignedInt(_loc7_);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
param1.position = param2;
|
||||
var _loc5_:uint = param1.readUnsignedInt();
|
||||
var _loc7_:uint = param1.readUnsignedInt();
|
||||
var _loc3_:Number = 2654435769;
|
||||
var _loc6_:uint = _loc3_ * 64;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 64)
|
||||
{
|
||||
_loc7_ -= (_loc5_ << 4 ^ _loc5_ >> 5) + _loc5_ ^ _loc6_ + k[_loc6_ >> 11 & 3];
|
||||
_loc6_ -= _loc3_;
|
||||
_loc5_ -= (_loc7_ << 4 ^ _loc7_ >> 5) + _loc7_ ^ _loc6_ + k[_loc6_ & 3];
|
||||
_loc4_++;
|
||||
}
|
||||
param1.position -= 8;
|
||||
param1.writeUnsignedInt(_loc5_);
|
||||
param1.writeUnsignedInt(_loc7_);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc2_:* = 0;
|
||||
var _loc1_:Random = new Random();
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < k.length)
|
||||
{
|
||||
k[_loc2_] = _loc1_.nextByte();
|
||||
delete k[_loc2_];
|
||||
_loc2_++;
|
||||
}
|
||||
k = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "xtea";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
use namespace bi_internal;
|
||||
|
||||
internal class BarrettReduction implements IReduction
|
||||
{
|
||||
|
||||
private var m:BigInteger;
|
||||
|
||||
private var r2:BigInteger;
|
||||
|
||||
private var q3:BigInteger;
|
||||
|
||||
private var mu:BigInteger;
|
||||
|
||||
public function BarrettReduction(param1:BigInteger)
|
||||
{
|
||||
super();
|
||||
r2 = new BigInteger();
|
||||
q3 = new BigInteger();
|
||||
BigInteger.ONE.dlShiftTo(2 * param1.t,r2);
|
||||
mu = r2.divide(param1);
|
||||
this.m = param1;
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
reduce(param3);
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
reduce(param2);
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
var _loc2_:BigInteger = null;
|
||||
if(param1.s < 0 || param1.t > 2 * m.t)
|
||||
{
|
||||
return param1.mod(m);
|
||||
}
|
||||
if(param1.compareTo(m) < 0)
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
_loc2_ = new BigInteger();
|
||||
param1.copyTo(_loc2_);
|
||||
reduce(_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
var _loc2_:BigInteger = param1 as BigInteger;
|
||||
_loc2_.drShiftTo(m.t - 1,r2);
|
||||
if(_loc2_.t > m.t + 1)
|
||||
{
|
||||
_loc2_.t = m.t + 1;
|
||||
_loc2_.clamp();
|
||||
}
|
||||
mu.multiplyUpperTo(r2,m.t + 1,q3);
|
||||
m.multiplyLowerTo(q3,m.t + 1,r2);
|
||||
while(_loc2_.compareTo(r2) < 0)
|
||||
{
|
||||
_loc2_.dAddOffset(1,m.t + 1);
|
||||
}
|
||||
_loc2_.subTo(r2,_loc2_);
|
||||
while(_loc2_.compareTo(m) >= 0)
|
||||
{
|
||||
_loc2_.subTo(m,_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,48 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
use namespace bi_internal;
|
||||
|
||||
internal class ClassicReduction implements IReduction
|
||||
{
|
||||
|
||||
private var m:BigInteger;
|
||||
|
||||
public function ClassicReduction(param1:BigInteger)
|
||||
{
|
||||
super();
|
||||
this.m = param1;
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
if(param1.s < 0 || param1.compareTo(m) >= 0)
|
||||
{
|
||||
return param1.mod(m);
|
||||
}
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
param1.divRemTo(m,null,param1);
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
reduce(param3);
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
reduce(param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
internal interface IReduction
|
||||
{
|
||||
|
||||
function convert(param1:BigInteger) : BigInteger;
|
||||
|
||||
function revert(param1:BigInteger) : BigInteger;
|
||||
|
||||
function reduce(param1:BigInteger) : void;
|
||||
|
||||
function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void;
|
||||
|
||||
function sqrTo(param1:BigInteger, param2:BigInteger) : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
use namespace bi_internal;
|
||||
|
||||
internal class MontgomeryReduction implements IReduction
|
||||
{
|
||||
|
||||
private var m:BigInteger;
|
||||
|
||||
private var mp:int;
|
||||
|
||||
private var mpl:int;
|
||||
|
||||
private var mph:int;
|
||||
|
||||
private var um:int;
|
||||
|
||||
private var mt2:int;
|
||||
|
||||
public function MontgomeryReduction(param1:BigInteger)
|
||||
{
|
||||
super();
|
||||
this.m = param1;
|
||||
mp = param1.invDigit();
|
||||
mpl = mp & 0x7FFF;
|
||||
mph = mp >> 15;
|
||||
um = 32767;
|
||||
mt2 = 2 * param1.t;
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
var _loc2_:BigInteger = new BigInteger();
|
||||
param1.abs().dlShiftTo(m.t,_loc2_);
|
||||
_loc2_.divRemTo(m,null,_loc2_);
|
||||
if(param1.s < 0 && _loc2_.compareTo(BigInteger.ZERO) > 0)
|
||||
{
|
||||
m.subTo(_loc2_,_loc2_);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
var _loc2_:BigInteger = new BigInteger();
|
||||
param1.copyTo(_loc2_);
|
||||
reduce(_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
while(param1.t <= mt2)
|
||||
{
|
||||
param1.a[param1.t++] = 0;
|
||||
}
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < m.t)
|
||||
{
|
||||
_loc3_ = param1.a[_loc2_] & 0x7FFF;
|
||||
_loc4_ = _loc3_ * mpl + ((_loc3_ * mph + (param1.a[_loc2_] >> 15) * mpl & um) << 15) & 0x3FFFFFFF;
|
||||
_loc3_ = _loc2_ + m.t;
|
||||
param1.a[_loc3_] += m.am(0,_loc4_,param1,_loc2_,0,m.t);
|
||||
while(param1.a[_loc3_] >= 1073741824)
|
||||
{
|
||||
var _loc6_:int = _loc3_;
|
||||
var _loc5_:Number = param1.a[_loc6_] - 1073741824;
|
||||
param1.a[_loc6_] = _loc5_;
|
||||
param1.a[++_loc3_]++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
param1.clamp();
|
||||
param1.drShiftTo(m.t,param1);
|
||||
if(param1.compareTo(m) >= 0)
|
||||
{
|
||||
param1.subTo(m,param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
reduce(param2);
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
reduce(param3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
use namespace bi_internal;
|
||||
|
||||
public class NullReduction implements IReduction
|
||||
{
|
||||
|
||||
public function NullReduction()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
public namespace bi_internal = "http://crypto.hurlant.com/BigInteger";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.hurlant.util
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class Base64
|
||||
{
|
||||
|
||||
private static const _encodeChars:Vector.<int> = _initEncoreChar();
|
||||
|
||||
private static const _decodeChars:Vector.<int> = _initDecodeChar();
|
||||
|
||||
public function Base64()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function encode(param1:String) : String
|
||||
{
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc2_.writeUTFBytes(param1);
|
||||
return encodeByteArray(_loc2_);
|
||||
}
|
||||
|
||||
public static function decode(param1:String) : String
|
||||
{
|
||||
var _loc2_:ByteArray = decodeToByteArray(param1);
|
||||
return _loc2_.readUTFBytes(_loc2_.length);
|
||||
}
|
||||
|
||||
public static function encodeByteArray(param1:ByteArray) : String
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc7_:ByteArray = new ByteArray();
|
||||
_loc7_.length = (2 + param1.length - (param1.length + 2) % 3) * 4 / 3;
|
||||
var _loc6_:int = 0;
|
||||
var _loc2_:int = param1.length % 3;
|
||||
var _loc4_:int = param1.length - _loc2_;
|
||||
var _loc5_:int = 0;
|
||||
while(_loc6_ < _loc4_)
|
||||
{
|
||||
_loc3_ = uint(param1[_loc6_++] << 16 | param1[_loc6_++] << 8 | param1[_loc6_++]);
|
||||
_loc7_[_loc5_++] = _encodeChars[_loc3_ >>> 18];
|
||||
_loc7_[_loc5_++] = _encodeChars[_loc3_ >>> 12 & 0x3F];
|
||||
_loc7_[_loc5_++] = _encodeChars[_loc3_ >>> 6 & 0x3F];
|
||||
_loc7_[_loc5_++] = _encodeChars[_loc3_ & 0x3F];
|
||||
}
|
||||
if(_loc2_ == 1)
|
||||
{
|
||||
_loc3_ = uint(param1[_loc6_]);
|
||||
_loc7_[_loc5_++] = _encodeChars[_loc3_ >>> 2];
|
||||
_loc7_[_loc5_++] = _encodeChars[(_loc3_ & 3) << 4];
|
||||
_loc7_[_loc5_++] = 61;
|
||||
_loc7_[_loc5_++] = 61;
|
||||
}
|
||||
else if(_loc2_ == 2)
|
||||
{
|
||||
_loc3_ = uint(param1[_loc6_++] << 8 | param1[int(_loc6_)]);
|
||||
_loc7_[_loc5_++] = _encodeChars[_loc3_ >>> 10];
|
||||
_loc7_[_loc5_++] = _encodeChars[_loc3_ >>> 4 & 0x3F];
|
||||
_loc7_[_loc5_++] = _encodeChars[(_loc3_ & 0x0F) << 2];
|
||||
_loc7_[_loc5_++] = 61;
|
||||
}
|
||||
return _loc7_.readUTFBytes(_loc7_.length);
|
||||
}
|
||||
|
||||
public static function decodeToByteArray(param1:String) : ByteArray
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc4_:int = param1.length;
|
||||
var _loc5_:ByteArray = new ByteArray();
|
||||
_loc5_.writeUTFBytes(param1);
|
||||
var _loc6_:int = 0;
|
||||
while(_loc7_ < _loc4_)
|
||||
{
|
||||
_loc8_ = _decodeChars[int(_loc5_[_loc7_++])];
|
||||
if(_loc8_ == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc9_ = _decodeChars[int(_loc5_[_loc7_++])];
|
||||
if(_loc9_ == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc5_[_loc6_++] = _loc8_ << 2 | (_loc9_ & 0x30) >> 4;
|
||||
_loc2_ = int(_loc5_[_loc7_++]);
|
||||
if(_loc2_ == 61)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc2_ = _decodeChars[_loc2_];
|
||||
if(_loc2_ == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc5_[_loc6_++] = (_loc9_ & 0x0F) << 4 | (_loc2_ & 0x3C) >> 2;
|
||||
_loc3_ = int(_loc5_[_loc7_++]);
|
||||
if(_loc3_ == 61)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc3_ = _decodeChars[_loc3_];
|
||||
if(_loc3_ == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc5_[_loc6_++] = (_loc2_ & 3) << 6 | _loc3_;
|
||||
}
|
||||
_loc5_.length = _loc6_;
|
||||
_loc5_.position = 0;
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
public static function decodeToByteArrayB(param1:String) : ByteArray
|
||||
{
|
||||
return decodeToByteArray(param1);
|
||||
}
|
||||
|
||||
private static function _initEncoreChar() : Vector.<int>
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:Vector.<int> = new Vector.<int>(64,true);
|
||||
var _loc3_:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 64)
|
||||
{
|
||||
_loc2_[_loc1_] = _loc3_.charCodeAt(_loc1_);
|
||||
_loc1_++;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private static function _initDecodeChar() : Vector.<int>
|
||||
{
|
||||
return new <int>[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.hurlant.util
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class Hex
|
||||
{
|
||||
|
||||
public function Hex()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function toArray(param1:String) : ByteArray
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
param1 = param1.replace(/\s|:/gm,"");
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
if((param1.length & 1) == 1)
|
||||
{
|
||||
param1 = "0" + param1;
|
||||
}
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_loc2_[_loc3_ / 2] = parseInt(param1.substr(_loc3_,2),16);
|
||||
_loc3_ += 2;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function fromArray(param1:ByteArray, param2:Boolean = false) : String
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
var _loc3_:String = "";
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
_loc3_ += ("0" + param1[_loc4_].toString(16)).substr(-2,2);
|
||||
if(param2)
|
||||
{
|
||||
if(_loc4_ < param1.length - 1)
|
||||
{
|
||||
_loc3_ += ":";
|
||||
}
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public static function toString(param1:String) : String
|
||||
{
|
||||
var _loc2_:ByteArray = toArray(param1);
|
||||
return _loc2_.readUTFBytes(_loc2_.length);
|
||||
}
|
||||
|
||||
public static function fromString(param1:String, param2:Boolean = false) : String
|
||||
{
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
_loc3_.writeUTFBytes(param1);
|
||||
return fromArray(_loc3_,param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.hurlant.util
|
||||
{
|
||||
import flash.net.LocalConnection;
|
||||
import flash.system.System;
|
||||
|
||||
public class Memory
|
||||
{
|
||||
|
||||
public function Memory()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function gc() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
new LocalConnection().connect("foo");
|
||||
new LocalConnection().connect("foo");
|
||||
}
|
||||
catch(e:*)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static function get used() : uint
|
||||
{
|
||||
return System.totalMemory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.sbi.analytics
|
||||
{
|
||||
import libraries.uanalytics.tracker.WebTracker;
|
||||
import libraries.uanalytics.tracking.Configuration;
|
||||
|
||||
public class GATracker
|
||||
{
|
||||
|
||||
private static var _tracker:WebTracker;
|
||||
|
||||
private static var _eventTracker:WebTracker;
|
||||
|
||||
public function GATracker()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
var _loc3_:Configuration = new Configuration();
|
||||
_loc3_.enableThrottling = true;
|
||||
_loc3_.forcePOST = true;
|
||||
_loc3_.forceSSL = true;
|
||||
var _loc1_:String = (gMainFrame.clientInfo.websiteURL as String).indexOf("stage") != -1 ? "UA-55037062-1" : "UA-16265056-4";
|
||||
var _loc2_:String = (gMainFrame.clientInfo.websiteURL as String).indexOf("stage") != -1 ? "UA-55037062-1" : "UA-16265056-1";
|
||||
_tracker = new WebTracker(_loc1_,_loc3_);
|
||||
_eventTracker = new WebTracker(_loc2_,_loc3_);
|
||||
}
|
||||
|
||||
public static function trackError(param1:String, param2:Boolean) : Boolean
|
||||
{
|
||||
return _tracker.exception(param1,param2);
|
||||
}
|
||||
|
||||
public static function trackEvent(param1:String, param2:String, param3:String = "", param4:int = -1) : Boolean
|
||||
{
|
||||
return _eventTracker.event(param1,param2,param3,param4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,489 @@
|
||||
package com.sbi.analytics
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.events.DataEvent;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.net.Socket;
|
||||
import flash.utils.Dictionary;
|
||||
import flash.utils.Timer;
|
||||
|
||||
public class SBTracker
|
||||
{
|
||||
|
||||
public static const TYPE_NORMAL:int = 0;
|
||||
|
||||
public static const TYPE_EVENT:int = 1;
|
||||
|
||||
public static const TYPE_ERROR:int = 2;
|
||||
|
||||
private static var MAX_RETRIES:int = 3;
|
||||
|
||||
private static var _pageStack:Array;
|
||||
|
||||
private static var _batchTimer:Timer;
|
||||
|
||||
private static var _isExternalAvailable:Boolean;
|
||||
|
||||
private static var _couldNotConnect:Boolean;
|
||||
|
||||
private static var _pageView:String;
|
||||
|
||||
private static var _socket:Socket;
|
||||
|
||||
private static var _timeOffset:Number;
|
||||
|
||||
private static var _isFromLogin:Boolean;
|
||||
|
||||
private static var _retryLimit:int;
|
||||
|
||||
private static var _lastBatchCallback:Function;
|
||||
|
||||
private static var _trackingObjects:Dictionary;
|
||||
|
||||
private static var _latestTrackTimeStamp:Dictionary;
|
||||
|
||||
private static var _lastestDuration:Dictionary;
|
||||
|
||||
public function SBTracker()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function create() : void
|
||||
{
|
||||
if(ExternalInterface.available && gMainFrame.clientInfo.sbTrackerIp != -1)
|
||||
{
|
||||
_isExternalAvailable = true;
|
||||
ExternalInterface.addCallback("receiveClose",receiveClose);
|
||||
if(!isNaN(gMainFrame.clientInfo.currentTimestamp))
|
||||
{
|
||||
_timeOffset = gMainFrame.clientInfo.currentTimestamp - new Date().valueOf() / 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timeOffset = 0;
|
||||
}
|
||||
_pageView = null;
|
||||
_pageStack = [];
|
||||
_socket = new Socket();
|
||||
_socket.addEventListener("close",closeHandler);
|
||||
_socket.addEventListener("connect",connectHandler);
|
||||
_socket.addEventListener("data",dataHandler);
|
||||
_socket.addEventListener("ioError",ioErrorHandler);
|
||||
_socket.addEventListener("securityError",securityErrorHandler);
|
||||
_trackingObjects = new Dictionary();
|
||||
_trackingObjects[0] = [];
|
||||
_trackingObjects[1] = [];
|
||||
_trackingObjects[2] = [];
|
||||
_latestTrackTimeStamp = new Dictionary();
|
||||
_latestTrackTimeStamp[0] = 0;
|
||||
_lastestDuration = new Dictionary();
|
||||
_lastestDuration[0] = 0;
|
||||
_batchTimer = new Timer(10000);
|
||||
_batchTimer.addEventListener("timer",onBatchTimer,false,0,true);
|
||||
_batchTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
public static function receiveClose() : String
|
||||
{
|
||||
_batchTimer.stop();
|
||||
_batchTimer.removeEventListener("timer",onBatchTimer);
|
||||
if(_pageView != null)
|
||||
{
|
||||
setupPageView();
|
||||
return _pageView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function onError() : void
|
||||
{
|
||||
if(_isExternalAvailable)
|
||||
{
|
||||
ExternalInterface.call("reportAnalyticsError","Error Timeout",gMainFrame.clientInfo.sessionId);
|
||||
}
|
||||
DebugUtility.debugTrace("Sending analytics error");
|
||||
}
|
||||
|
||||
public static function trackPageview(param1:String, param2:int = -1, param3:int = 0, param4:Boolean = true) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc5_:Number = NaN;
|
||||
if(_isExternalAvailable && !_couldNotConnect)
|
||||
{
|
||||
_isFromLogin = param2 != -1;
|
||||
if(_isFromLogin)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
}
|
||||
else if(gMainFrame.clientInfo.dbUserId == undefined)
|
||||
{
|
||||
_loc6_ = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = int(gMainFrame.clientInfo.dbUserId);
|
||||
}
|
||||
if(_loc6_ > 0)
|
||||
{
|
||||
if(param4 && _loc6_ % gMainFrame.clientInfo.sbTrackerModulator != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
_loc5_ = Math.floor(new Date().valueOf() / 1000 + _timeOffset);
|
||||
if(gMainFrame.clientInfo.sessionId == undefined && _isFromLogin)
|
||||
{
|
||||
gMainFrame.clientInfo.sessionId = Math.floor(Math.random() * (2147483647 + 1));
|
||||
}
|
||||
_trackingObjects[param3].push(new URIObj(param1,_loc5_,_isFromLogin,param3,_trackingObjects[param3].length,param4));
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleErrorTracking(param1:int, param2:int, param3:int, param4:int, param5:Number, param6:String, param7:String, param8:int, param9:int) : void
|
||||
{
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc10_:Object = null;
|
||||
if(ExternalInterface.available && gMainFrame.clientInfo.sbTrackerIp != -1)
|
||||
{
|
||||
_loc11_ = Number(gMainFrame.clientInfo.sessionId);
|
||||
if(gMainFrame.clientInfo.sessionId == undefined)
|
||||
{
|
||||
_loc11_ = Math.round(Math.random() * (2147483647 + 1));
|
||||
}
|
||||
if(gMainFrame.clientInfo.dbUserId == undefined)
|
||||
{
|
||||
gMainFrame.clientInfo.dbUserId = param1;
|
||||
}
|
||||
_loc10_ = {
|
||||
"userId":(gMainFrame.clientInfo.dbUserId == undefined ? param1 : null),
|
||||
"order":param3,
|
||||
"duration":(param4 == -1 ? null : param4),
|
||||
"sessionId":(param5 == -1 ? _loc11_ : null)
|
||||
};
|
||||
_trackingObjects[2].push(new URIObj(param6 + "#" + param7 + "#" + param8 + "#" + param9,param2 == -1 ? Math.floor(new Date().valueOf() / 1000 + _timeOffset) : param2,_isFromLogin,2,_trackingObjects[2].length,false,_loc10_));
|
||||
onBatchTimer(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleOnKickOrLogout() : void
|
||||
{
|
||||
if(_isExternalAvailable && _pageView != null)
|
||||
{
|
||||
ExternalInterface.call("handleLogout",_pageView);
|
||||
}
|
||||
}
|
||||
|
||||
public static function push(param1:int = 0) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc3_:Object = null;
|
||||
if(_pageStack)
|
||||
{
|
||||
_loc2_ = _trackingObjects[param1];
|
||||
if(_loc2_.length > 0)
|
||||
{
|
||||
_loc3_ = _loc2_[_loc2_.length - 1].trackingObject;
|
||||
_pageStack.push(_loc3_.uri + "#" + _loc3_.uriParams + "#pop#" + _loc3_.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function pop() : void
|
||||
{
|
||||
if(_pageStack && _pageStack.length)
|
||||
{
|
||||
trackPageview(_pageStack.pop());
|
||||
}
|
||||
}
|
||||
|
||||
public static function flush(param1:Boolean = false) : void
|
||||
{
|
||||
if(_pageStack && _pageStack.length)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
trackPageview(_pageStack[0]);
|
||||
}
|
||||
_pageStack = [];
|
||||
}
|
||||
}
|
||||
|
||||
public static function completeLastTrackingBatch(param1:Function) : void
|
||||
{
|
||||
_lastBatchCallback = param1;
|
||||
if(_batchTimer)
|
||||
{
|
||||
_batchTimer.stop();
|
||||
if(_socket)
|
||||
{
|
||||
setupPageView(true);
|
||||
if(_pageView != null)
|
||||
{
|
||||
_batchTimer.reset();
|
||||
_socket.connect(gMainFrame.clientInfo.sbTrackerIp,5050);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_lastBatchCallback != null)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLastDuration(param1:int) : Number
|
||||
{
|
||||
return _lastestDuration[param1];
|
||||
}
|
||||
|
||||
public static function setLastDuration(param1:int, param2:Number) : void
|
||||
{
|
||||
_lastestDuration[param1] = param2;
|
||||
}
|
||||
|
||||
public static function getLastTimestamp(param1:int) : Number
|
||||
{
|
||||
return _latestTrackTimeStamp[param1];
|
||||
}
|
||||
|
||||
public static function setLastTimestamp(param1:int, param2:Number) : void
|
||||
{
|
||||
_latestTrackTimeStamp[param1] = param2;
|
||||
}
|
||||
|
||||
public static function getnextURIObjByType(param1:int, param2:int) : URIObj
|
||||
{
|
||||
var _loc3_:Array = _trackingObjects[param2];
|
||||
if(_loc3_.length > 0 && _loc3_.length > param1 + 1)
|
||||
{
|
||||
return _loc3_[param1 + 1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getPreviousURIObjByType(param1:int, param2:int) : URIObj
|
||||
{
|
||||
var _loc3_:Array = _trackingObjects[param2];
|
||||
if(_loc3_.length > 0 && _loc3_.length > param1 - 1)
|
||||
{
|
||||
return _loc3_[param1 - 1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function findLatestTrackedURIObjByThrottleType(param1:Array, param2:Boolean) : URIObj
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
if(param1)
|
||||
{
|
||||
_loc3_ = param1.length - 1;
|
||||
while(_loc3_ >= 0)
|
||||
{
|
||||
if(param1[_loc3_].throttled == param2)
|
||||
{
|
||||
return param1[_loc3_];
|
||||
}
|
||||
_loc3_--;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function onBatchTimer(param1:TimerEvent) : void
|
||||
{
|
||||
if(_socket)
|
||||
{
|
||||
setupPageView();
|
||||
if(_pageView != null)
|
||||
{
|
||||
_batchTimer.reset();
|
||||
_socket.connect(gMainFrame.clientInfo.sbTrackerIp,5050);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(_lastBatchCallback != null)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function setupPageView(param1:Boolean = false) : void
|
||||
{
|
||||
var _loc4_:String = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:URIObj = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc5_:Array = null;
|
||||
var _loc8_:Boolean = false;
|
||||
if(_pageView == null)
|
||||
{
|
||||
_loc4_ = "";
|
||||
for(var _loc7_:String in _trackingObjects)
|
||||
{
|
||||
_loc3_ = int(_loc7_);
|
||||
_loc5_ = _trackingObjects[_loc3_];
|
||||
if(_loc5_.length > 0)
|
||||
{
|
||||
if(gMainFrame.clientInfo.sessionId != undefined)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
for(; _loc6_ < _loc5_.length; _loc6_++)
|
||||
{
|
||||
_loc2_ = _loc5_[_loc6_];
|
||||
if(!_loc2_.hasTrackedLastOne)
|
||||
{
|
||||
if(_loc2_.throttled)
|
||||
{
|
||||
if(!_loc2_.isFromLogin)
|
||||
{
|
||||
if(gMainFrame.clientInfo.dbUserId % gMainFrame.clientInfo.sbTrackerModulator != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(gMainFrame.clientInfo.sessionId % gMainFrame.clientInfo.sbTrackerModulator != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
_loc4_ += _loc2_.pageView;
|
||||
}
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
if(_loc2_.throttled)
|
||||
{
|
||||
if(!_loc2_.isFromLogin)
|
||||
{
|
||||
if(gMainFrame.clientInfo.dbUserId % gMainFrame.clientInfo.sbTrackerModulator != 0)
|
||||
{
|
||||
_loc8_ = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = true;
|
||||
}
|
||||
}
|
||||
else if(gMainFrame.clientInfo.sessionId % gMainFrame.clientInfo.sbTrackerModulator != 0)
|
||||
{
|
||||
_loc8_ = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = true;
|
||||
}
|
||||
if(_loc8_)
|
||||
{
|
||||
_loc4_ += _loc2_.ownPageView;
|
||||
}
|
||||
_trackingObjects[_loc3_] = [];
|
||||
_loc5_ = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc3_ == 1)
|
||||
{
|
||||
_loc5_.splice(0,_loc5_.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_.splice(0,_loc5_.length - 1);
|
||||
if(_loc5_[0].pageView != "")
|
||||
{
|
||||
_loc5_[0].hasTrackedLastOne = true;
|
||||
}
|
||||
}
|
||||
_loc2_.index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_loc4_ != "")
|
||||
{
|
||||
_pageView = _loc4_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function closeHandler(param1:Event) : void
|
||||
{
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
private static function connectHandler(param1:Event) : void
|
||||
{
|
||||
DebugUtility.debugTrace(_pageView);
|
||||
_socket.writeUTFBytes(_pageView);
|
||||
_pageView = null;
|
||||
_socket.flush();
|
||||
_socket.close();
|
||||
_retryLimit = 0;
|
||||
_batchTimer.start();
|
||||
if(_lastBatchCallback != null)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function dataHandler(param1:DataEvent) : void
|
||||
{
|
||||
}
|
||||
|
||||
private static function ioErrorHandler(param1:IOErrorEvent) : void
|
||||
{
|
||||
if(_lastBatchCallback != null)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
if(_retryLimit < MAX_RETRIES)
|
||||
{
|
||||
_retryLimit = _retryLimit + 1;
|
||||
DebugUtility.debugTrace("IO error - retrying analytics connection");
|
||||
_socket.connect(gMainFrame.clientInfo.sbTrackerIp,5050);
|
||||
return;
|
||||
}
|
||||
_couldNotConnect = true;
|
||||
}
|
||||
|
||||
private static function securityErrorHandler(param1:SecurityErrorEvent) : void
|
||||
{
|
||||
if(_lastBatchCallback != null)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
if(_retryLimit < MAX_RETRIES)
|
||||
{
|
||||
DebugUtility.debugTrace("Security error - retrying analytics connection");
|
||||
_retryLimit = _retryLimit + 1;
|
||||
_socket.connect(gMainFrame.clientInfo.sbTrackerIp,5050);
|
||||
return;
|
||||
}
|
||||
if(_batchTimer)
|
||||
{
|
||||
_batchTimer.stop();
|
||||
_batchTimer.removeEventListener("timer",onBatchTimer);
|
||||
}
|
||||
_couldNotConnect = true;
|
||||
_pageView = null;
|
||||
_socket = null;
|
||||
onError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.sbi.analytics
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
public class URIObj
|
||||
{
|
||||
|
||||
private var _type:int;
|
||||
|
||||
private var _trackingObject:Object;
|
||||
|
||||
private var _containsAnUndefined:Boolean;
|
||||
|
||||
private var _pageView:String;
|
||||
|
||||
private var _userId:int;
|
||||
|
||||
private var _isFromLogin:Boolean;
|
||||
|
||||
private var _throttled:Boolean;
|
||||
|
||||
private var _index:int;
|
||||
|
||||
private var _hasTrackedLastOne:Boolean;
|
||||
|
||||
public function URIObj(param1:String, param2:Number, param3:Boolean, param4:int, param5:int, param6:Boolean, param7:Object = null)
|
||||
{
|
||||
var _loc12_:int = 0;
|
||||
var _loc10_:URIObj = null;
|
||||
super();
|
||||
param1 = param1.replace(/[',]/g,"");
|
||||
var _loc9_:Array = param1.split(/#/i);
|
||||
_isFromLogin = param3;
|
||||
_throttled = param6;
|
||||
_type = param4;
|
||||
_index = param5;
|
||||
if(param7 && param7.userId)
|
||||
{
|
||||
_userId = param7.userId;
|
||||
}
|
||||
else
|
||||
{
|
||||
_userId = param3 ? 0 : (gMainFrame.clientInfo.dbUserId == undefined ? -1 : gMainFrame.clientInfo.dbUserId);
|
||||
}
|
||||
if(param7 && param7.sessionId)
|
||||
{
|
||||
_loc12_ = int(param7.sessionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc12_ = int(gMainFrame.clientInfo.sessionId);
|
||||
}
|
||||
var _loc8_:int = -1;
|
||||
if(param7 && param7.duration)
|
||||
{
|
||||
_loc8_ = int(param7.duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc10_ = SBTracker.getPreviousURIObjByType(param5,param4);
|
||||
if(_loc10_)
|
||||
{
|
||||
_loc10_.setTimeAndDurationAndOrder();
|
||||
}
|
||||
}
|
||||
if(_loc8_ == -1 && param4 == 1)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
}
|
||||
_trackingObject = {
|
||||
"userId":_userId,
|
||||
"time":param2,
|
||||
"order":(param7 && param7.order ? param7.order : 0),
|
||||
"duration":_loc8_,
|
||||
"sessionId":_loc12_,
|
||||
"uri":_loc9_[0],
|
||||
"uriParams":(_loc9_[1] != null ? _loc9_[1] : ""),
|
||||
"pop":(_loc9_[2] != null && _loc9_[2] == "pop" ? 1 : 0),
|
||||
"value":(_loc9_[3] != null ? _loc9_[3] : ""),
|
||||
"type":param4
|
||||
};
|
||||
var _loc11_:String = "userId: " + _trackingObject.userId + "\n" + "time: " + _trackingObject.time + "\n" + "order: " + _trackingObject.order + "\n" + "duration: " + _trackingObject.duration + "\n" + "sessionId: " + _trackingObject.sessionId + "\n" + "URI: " + _trackingObject.uri + "\n" + "uriParams: " + _trackingObject.uriParams + "\n" + "pop: " + _trackingObject.pop + "\n" + "value: " + _trackingObject.value + "\ntype: " + _trackingObject.type;
|
||||
DebugUtility.debugTrace(_loc11_);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
_trackingObject = null;
|
||||
}
|
||||
|
||||
public function get isFromLogin() : Boolean
|
||||
{
|
||||
return _isFromLogin;
|
||||
}
|
||||
|
||||
public function get trackingObject() : Object
|
||||
{
|
||||
return _trackingObject;
|
||||
}
|
||||
|
||||
public function get throttled() : Boolean
|
||||
{
|
||||
return _throttled;
|
||||
}
|
||||
|
||||
public function set index(param1:int) : void
|
||||
{
|
||||
_index = param1;
|
||||
}
|
||||
|
||||
public function setTimeAndDurationAndOrder() : void
|
||||
{
|
||||
var _loc3_:URIObj = null;
|
||||
var _loc1_:Number = SBTracker.getLastTimestamp(_type);
|
||||
var _loc4_:Boolean = _trackingObject.time - _loc1_ == 0;
|
||||
SBTracker.setLastTimestamp(_type,_trackingObject.time);
|
||||
if(_loc4_ && _trackingObject.order == 0)
|
||||
{
|
||||
_loc3_ = SBTracker.getPreviousURIObjByType(_index,_type);
|
||||
if(_loc3_)
|
||||
{
|
||||
_trackingObject.order = _loc3_.trackingObject.order + 1;
|
||||
}
|
||||
}
|
||||
var _loc2_:Number = SBTracker.getLastDuration(_type);
|
||||
var _loc5_:Number = getTimer();
|
||||
SBTracker.setLastDuration(_type,_loc5_);
|
||||
if(_trackingObject.duration == -1)
|
||||
{
|
||||
_trackingObject.duration = Math.round((_loc5_ - _loc2_) / 100);
|
||||
}
|
||||
}
|
||||
|
||||
public function get pageView() : String
|
||||
{
|
||||
if(_trackingObject.duration != -1)
|
||||
{
|
||||
return (_isFromLogin ? _userId : gMainFrame.clientInfo.dbUserId) + "\n" + _trackingObject.time + "\n" + _trackingObject.order + "\n" + _trackingObject.duration + "\n" + _trackingObject.sessionId + "\n" + _trackingObject.uri + "\n" + _trackingObject.uriParams + "\n" + _trackingObject.pop + "\n" + _trackingObject.value + "\n" + _trackingObject.type + "\n";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function get ownPageView() : String
|
||||
{
|
||||
setTimeAndDurationAndOrder();
|
||||
return pageView;
|
||||
}
|
||||
|
||||
public function get hasTrackedLastOne() : Boolean
|
||||
{
|
||||
return _hasTrackedLastOne;
|
||||
}
|
||||
|
||||
public function set hasTrackedLastOne(param1:Boolean) : void
|
||||
{
|
||||
_hasTrackedLastOne = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.sbi.bit
|
||||
{
|
||||
public class BitField
|
||||
{
|
||||
|
||||
private var _bitField:uint;
|
||||
|
||||
public function BitField(param1:uint = 0)
|
||||
{
|
||||
super();
|
||||
_bitField = param1;
|
||||
}
|
||||
|
||||
public function updateBitField(param1:uint, param2:BitWiseOperator) : void
|
||||
{
|
||||
switch(param2)
|
||||
{
|
||||
case BitWiseOperator.AND:
|
||||
and(param1);
|
||||
break;
|
||||
case BitWiseOperator.OR:
|
||||
or(param1);
|
||||
break;
|
||||
case BitWiseOperator.XOR:
|
||||
xor(param1);
|
||||
break;
|
||||
case BitWiseOperator.NOT:
|
||||
not();
|
||||
}
|
||||
}
|
||||
|
||||
public function and(param1:int) : BitField
|
||||
{
|
||||
_bitField &= param1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public function or(param1:int) : BitField
|
||||
{
|
||||
_bitField |= param1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public function xor(param1:int) : BitField
|
||||
{
|
||||
_bitField ^= param1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public function not() : BitField
|
||||
{
|
||||
_bitField = ~_bitField;
|
||||
return this;
|
||||
}
|
||||
|
||||
public function toggleBit(param1:int) : BitField
|
||||
{
|
||||
if(param1 < 0 || param1 > 31)
|
||||
{
|
||||
throw new Error("Attempted to toggle bit outside of normal range. bit=" + param1);
|
||||
}
|
||||
return xor(1 << param1);
|
||||
}
|
||||
|
||||
public function setBit(param1:uint, param2:Boolean) : Boolean
|
||||
{
|
||||
if(param1 < 0 || param1 > 31)
|
||||
{
|
||||
throw new Error("Attempted to set bit outside of normal range. bit=" + param1);
|
||||
}
|
||||
var _loc3_:uint = _bitField;
|
||||
if(param2)
|
||||
{
|
||||
_bitField |= 1 << param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_bitField &= ~(1 << param1);
|
||||
}
|
||||
return _loc3_ != _bitField;
|
||||
}
|
||||
|
||||
public function isBitSet(param1:uint) : Boolean
|
||||
{
|
||||
if(param1 < 0 || param1 > 31)
|
||||
{
|
||||
throw new Error("Attempted to read bit outside of normal range. bit=" + param1);
|
||||
}
|
||||
return (_bitField & 1 << param1) != 0;
|
||||
}
|
||||
|
||||
public function getInt() : uint
|
||||
{
|
||||
return _bitField;
|
||||
}
|
||||
|
||||
public function getNumBitsSet() : int
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc1_:int = 0;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < 32)
|
||||
{
|
||||
if(isBitSet(_loc2_))
|
||||
{
|
||||
_loc1_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function getSetBits() : Array
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = getNumBitsSet();
|
||||
var _loc1_:Array = [];
|
||||
if(_loc2_ > 0)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 32)
|
||||
{
|
||||
if(isBitSet(_loc3_))
|
||||
{
|
||||
_loc1_[_loc4_++] = _loc3_;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return String(_bitField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.sbi.bit
|
||||
{
|
||||
public class BitUtility
|
||||
{
|
||||
|
||||
public function BitUtility()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function isBitSetForNumber(param1:int, param2:Number) : Boolean
|
||||
{
|
||||
if(param2 == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if((param2 >> param1 & 1) == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function leftShiftNumbers(param1:int) : Number
|
||||
{
|
||||
var _loc3_:Boolean = false;
|
||||
if(param1 == 31)
|
||||
{
|
||||
param1--;
|
||||
_loc3_ = true;
|
||||
}
|
||||
var _loc2_:Number = 1 << param1;
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc2_ *= 2;
|
||||
}
|
||||
if(param1 > 31)
|
||||
{
|
||||
_loc2_ = Number("0x" + _loc2_.toString(16) + "00000000");
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function rightShiftNumber(param1:Number) : Number
|
||||
{
|
||||
var _loc4_:String = null;
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:String = null;
|
||||
if(param1 > 4294967295)
|
||||
{
|
||||
_loc4_ = param1 == -1 ? "1111111111111111111111111111111111111111111111111111111111111111" : param1.toString(2);
|
||||
_loc2_ = _loc4_.substr(0,_loc4_.length - 32);
|
||||
_loc3_ = _loc4_.substr(_loc4_.length - 32);
|
||||
_loc3_ = _loc2_.charAt(_loc2_.length - 1) + _loc3_.substr(0,_loc3_.length - 1);
|
||||
_loc2_ = _loc2_.substr(0,_loc2_.length - 1);
|
||||
if(_loc2_ == "")
|
||||
{
|
||||
_loc2_ = "0";
|
||||
}
|
||||
return Number("0x" + _loc2_ + "00000000") + parseInt(_loc3_,2);
|
||||
}
|
||||
return param1 >>> 1;
|
||||
}
|
||||
|
||||
public static function bitwiseAnd(param1:Number, param2:Number) : Number
|
||||
{
|
||||
var _loc6_:String = null;
|
||||
var _loc4_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc8_:* = 0;
|
||||
var _loc7_:* = 0;
|
||||
var _loc9_:Number = NaN;
|
||||
if(param1 < 1073741824 && param2 < 1073741824)
|
||||
{
|
||||
return param1 & param2;
|
||||
}
|
||||
_loc6_ = param1 == -1 ? "1111111111111111111111111111111111111111111111111111111111111111" : param1.toString(2);
|
||||
_loc4_ = uint(_loc6_.length > 32 ? parseInt(_loc6_.substr(0,_loc6_.length - 32),2) : 0);
|
||||
_loc5_ = uint(parseInt(_loc6_.substr(_loc6_.length > 32 ? _loc6_.length - 32 : 0),2));
|
||||
_loc6_ = param2 == -1 ? "1111111111111111111111111111111111111111111111111111111111111111" : param2.toString(2);
|
||||
_loc3_ = uint(_loc6_.length > 32 ? parseInt(_loc6_.substr(0,_loc6_.length - 32),2) : 0);
|
||||
_loc8_ = uint(parseInt(_loc6_.substr(_loc6_.length > 32 ? _loc6_.length - 32 : 0),2));
|
||||
_loc7_ = uint(_loc5_ & _loc8_);
|
||||
_loc9_ = Number("0x" + (_loc4_ & _loc3_).toString(16) + "00000000");
|
||||
return _loc7_ + _loc9_;
|
||||
}
|
||||
|
||||
public static function bitwiseOr(param1:Number, param2:Number) : Number
|
||||
{
|
||||
var _loc6_:String = null;
|
||||
var _loc4_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc8_:* = 0;
|
||||
var _loc7_:* = 0;
|
||||
var _loc9_:Number = NaN;
|
||||
if(param1 < 1073741824 && param2 < 1073741824)
|
||||
{
|
||||
return param1 | param2;
|
||||
}
|
||||
_loc6_ = param1 == -1 ? "1111111111111111111111111111111111111111111111111111111111111111" : param1.toString(2);
|
||||
_loc4_ = uint(_loc6_.length > 32 ? parseInt(_loc6_.substr(0,_loc6_.length - 32),2) : 0);
|
||||
_loc5_ = uint(parseInt(_loc6_.substr(_loc6_.length > 32 ? _loc6_.length - 32 : 0),2));
|
||||
_loc6_ = param2 == -1 ? "1111111111111111111111111111111111111111111111111111111111111111" : param2.toString(2);
|
||||
_loc3_ = uint(_loc6_.length > 32 ? parseInt(_loc6_.substr(0,_loc6_.length - 32),2) : 0);
|
||||
_loc8_ = uint(parseInt(_loc6_.substr(_loc6_.length > 32 ? _loc6_.length - 32 : 0),2));
|
||||
_loc7_ = uint(_loc5_ | _loc8_);
|
||||
_loc9_ = Number("0x" + (_loc4_ | _loc3_).toString(16) + "00000000");
|
||||
return _loc7_ + _loc9_;
|
||||
}
|
||||
|
||||
public static function bitwiseNot(param1:Number) : Number
|
||||
{
|
||||
var _loc5_:String = param1 == -1 ? "1111111111111111111111111111111111111111111111111111111111111111" : param1.toString(2);
|
||||
var _loc2_:uint = _loc5_.length > 32 ? parseInt(_loc5_.substr(0,_loc5_.length - 32),2) : 0;
|
||||
var _loc4_:uint = parseInt(_loc5_.substr(_loc5_.length > 32 ? _loc5_.length - 32 : 0),2);
|
||||
_loc2_ = uint(~_loc2_);
|
||||
_loc4_ = uint(~_loc4_);
|
||||
var _loc6_:String = _loc2_.toString(2).substr(11);
|
||||
var _loc3_:String = _loc4_.toString(2);
|
||||
return parseInt(_loc6_ + _loc3_,2);
|
||||
}
|
||||
|
||||
public static function numberOfBitsSet(param1:Number) : int
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
if(param1 == 0 || param1 <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var _loc2_:int = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 64)
|
||||
{
|
||||
if(bitwiseAnd(param1,leftShiftNumbers(_loc3_)) != 0)
|
||||
{
|
||||
_loc2_++;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.sbi.bit
|
||||
{
|
||||
public class BitWiseOperator
|
||||
{
|
||||
|
||||
public static const AND:BitWiseOperator = new BitWiseOperator("&");
|
||||
|
||||
public static const OR:BitWiseOperator = new BitWiseOperator("|");
|
||||
|
||||
public static const XOR:BitWiseOperator = new BitWiseOperator("^");
|
||||
|
||||
public static const NOT:BitWiseOperator = new BitWiseOperator("~");
|
||||
|
||||
private var _op:String;
|
||||
|
||||
public function BitWiseOperator(param1:String)
|
||||
{
|
||||
super();
|
||||
_op = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 7925 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user