mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 09:37: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,509 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.corelib.Utils;
|
||||
import com.sbi.corelib.audio.SBAudio;
|
||||
import flash.net.SharedObject;
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class AJAudio
|
||||
{
|
||||
|
||||
private static var _hasLoadedDailySpinSfx:Boolean;
|
||||
|
||||
private static var _hasLoadedGiftUnwrapSfx:Boolean;
|
||||
|
||||
private static var _hasLoadedJourneyBookWorldSfx:Boolean;
|
||||
|
||||
private static var _hasLoadedJourneyBookBookSfx:Boolean;
|
||||
|
||||
private static var _hasLoadedTradeSfx:Boolean;
|
||||
|
||||
private static var _defaultVolumes:Dictionary;
|
||||
|
||||
public function AJAudio()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:Function = null) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
if(!SBAudio.isInitialized)
|
||||
{
|
||||
_loc2_ = {};
|
||||
_loc2_["HudBtnRollover"] = {
|
||||
"className":Utils.getDefByName("HudBtnRollover") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["HudBtnClick"] = {
|
||||
"className":Utils.getDefByName("HudBtnClick") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["SubMenuBtnRollover"] = {
|
||||
"className":Utils.getDefByName("SubMenuBtnRollover") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["SubMenuBtnClick"] = {
|
||||
"className":Utils.getDefByName("SubMenuBtnClick") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["ExitBtnRollover"] = {
|
||||
"className":Utils.getDefByName("ExitBtnRollover") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["ExitBtnClick"] = {
|
||||
"className":Utils.getDefByName("ExitBtnClick") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["ScrollUpDown"] = {
|
||||
"className":Utils.getDefByName("ScrollUpDown") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["ScrollLeftRight"] = {
|
||||
"className":Utils.getDefByName("ScrollLeftRight") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["TextType"] = {
|
||||
"className":Utils.getDefByName("TextType") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["TextEnter"] = {
|
||||
"className":Utils.getDefByName("TextEnter") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["IdleWarningSound"] = {
|
||||
"className":Utils.getDefByName("IdleWarningSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["ShopCachingSound"] = {
|
||||
"className":Utils.getDefByName("ShopCachingSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["GemsEarnedSound"] = {
|
||||
"className":Utils.getDefByName("GemsEarnedSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["ItemRecycledSound"] = {
|
||||
"className":Utils.getDefByName("ItemRecycledSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["MailReceivedSound"] = {
|
||||
"className":Utils.getDefByName("MailReceivedSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["BuddyOnlineOfflineSound"] = {
|
||||
"className":Utils.getDefByName("BuddyOnlineOfflineSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["NewspaperSound"] = {
|
||||
"className":Utils.getDefByName("NewspaperSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["MailSentSound"] = {
|
||||
"className":Utils.getDefByName("MailSentSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["AchievementSound"] = {
|
||||
"className":Utils.getDefByName("AchievementSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["BuddyCardOpen"] = {
|
||||
"className":Utils.getDefByName("BuddyCardOpen") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["BuddyCardClose"] = {
|
||||
"className":Utils.getDefByName("BuddyCardClose") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["LimitedChatErrorSound"] = {
|
||||
"className":Utils.getDefByName("LimitedChatErrorSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["ChatOpenSound"] = {
|
||||
"className":Utils.getDefByName("ChatOpenSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["ChatCloseSound"] = {
|
||||
"className":Utils.getDefByName("ChatCloseSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["RandomLever"] = {
|
||||
"className":Utils.getDefByName("RandomLever") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc2_["NameGenRotationSound"] = {
|
||||
"className":Utils.getDefByName("NameGenRotationSound") as Class,
|
||||
"volume":1
|
||||
};
|
||||
_loc2_["NameGenStopSound"] = {
|
||||
"className":Utils.getDefByName("NameGenStopSound") as Class,
|
||||
"volume":1
|
||||
};
|
||||
SBAudio.init(_loc2_,param1);
|
||||
_defaultVolumes = new Dictionary();
|
||||
_defaultVolumes["FW_TRAIL_1"] = 0.2;
|
||||
_defaultVolumes["FW_TRAIL_2"] = 0.2;
|
||||
_defaultVolumes["FW_TRAIL_3"] = 0.2;
|
||||
_defaultVolumes["FW_LAUNCH_1"] = 0.3;
|
||||
_defaultVolumes["FW_LAUNCH_2"] = 0.3;
|
||||
_defaultVolumes["FW_LAUNCH_3"] = 0.3;
|
||||
_defaultVolumes["FW_EXPLOSION_1"] = 0.3;
|
||||
_defaultVolumes["FW_EXPLOSION_2"] = 0.3;
|
||||
_defaultVolumes["FW_EXPLOSION_3"] = 0.3;
|
||||
_defaultVolumes["DOOR_WOOD_OPEN"] = 0.3;
|
||||
_defaultVolumes["DOOR_WOOD_CLOSE"] = 0.3;
|
||||
_defaultVolumes["DOOR_SLIDE"] = 0.3;
|
||||
_defaultVolumes["DOOR_STONE_SLIDE"] = 0.3;
|
||||
_defaultVolumes["aj_water_fs1"] = 0;
|
||||
_defaultVolumes["aj_water_fs2"] = 0;
|
||||
_defaultVolumes["aj_water_fs3"] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function loadSfx(param1:String, param2:Class, param3:Number = 0.3) : void
|
||||
{
|
||||
if(_defaultVolumes[param1])
|
||||
{
|
||||
param3 = Number(_defaultVolumes[param1]);
|
||||
}
|
||||
SBAudio.addCachedSound(param1,param2,param3);
|
||||
}
|
||||
|
||||
public static function setupSharedObject(param1:SharedObject) : void
|
||||
{
|
||||
SBAudio.setupSharedObject(param1);
|
||||
}
|
||||
|
||||
public static function playSfx(param1:String, param2:int = 1) : void
|
||||
{
|
||||
SBAudio.playCachedSound(param1,param2);
|
||||
}
|
||||
|
||||
public static function stopSfx(param1:String) : void
|
||||
{
|
||||
SBAudio.stopCachedSound(param1);
|
||||
}
|
||||
|
||||
public static function playHudBtnRollover() : void
|
||||
{
|
||||
playSfx("HudBtnRollover");
|
||||
}
|
||||
|
||||
public static function playHudBtnClick() : void
|
||||
{
|
||||
playSfx("HudBtnClick");
|
||||
}
|
||||
|
||||
public static function playSubMenuBtnRollover() : void
|
||||
{
|
||||
playSfx("SubMenuBtnRollover");
|
||||
}
|
||||
|
||||
public static function playSubMenuBtnClick() : void
|
||||
{
|
||||
playSfx("SubMenuBtnClick");
|
||||
}
|
||||
|
||||
public static function playExitBtnRollover() : void
|
||||
{
|
||||
playSfx("ExitBtnRollover");
|
||||
}
|
||||
|
||||
public static function playExitBtnClick() : void
|
||||
{
|
||||
playSfx("ExitBtnClick");
|
||||
}
|
||||
|
||||
public static function playScrollUpDown() : void
|
||||
{
|
||||
playSfx("ScrollUpDown");
|
||||
}
|
||||
|
||||
public static function playScrollLeftRight() : void
|
||||
{
|
||||
playSfx("ScrollLeftRight");
|
||||
}
|
||||
|
||||
public static function playTextType() : void
|
||||
{
|
||||
playSfx("TextType");
|
||||
}
|
||||
|
||||
public static function playTextEnter() : void
|
||||
{
|
||||
playSfx("TextEnter");
|
||||
}
|
||||
|
||||
public static function playIdleWarningSound() : void
|
||||
{
|
||||
playSfx("IdleWarningSound");
|
||||
}
|
||||
|
||||
public static function playShopCachingSound() : void
|
||||
{
|
||||
playSfx("ShopCachingSound");
|
||||
}
|
||||
|
||||
public static function playGemsEarnedSound() : void
|
||||
{
|
||||
playSfx("GemsEarnedSound");
|
||||
}
|
||||
|
||||
public static function playItemRecycledSound() : void
|
||||
{
|
||||
playSfx("ItemRecycledSound");
|
||||
}
|
||||
|
||||
public static function playMailReceivedSound() : void
|
||||
{
|
||||
playSfx("MailReceivedSound");
|
||||
}
|
||||
|
||||
public static function playMailSentSound() : void
|
||||
{
|
||||
playSfx("MailSentSound");
|
||||
}
|
||||
|
||||
public static function playBuddyOnlineOfflineSound() : void
|
||||
{
|
||||
playSfx("BuddyOnlineOfflineSound");
|
||||
}
|
||||
|
||||
public static function playNewspaperSound() : void
|
||||
{
|
||||
playSfx("NewspaperSound");
|
||||
}
|
||||
|
||||
public static function playAchievementSound() : void
|
||||
{
|
||||
playSfx("AchievementSound");
|
||||
}
|
||||
|
||||
public static function playBuddyCardOpen() : void
|
||||
{
|
||||
playSfx("BuddyCardOpen");
|
||||
}
|
||||
|
||||
public static function playBuddyCardClose() : void
|
||||
{
|
||||
playSfx("BuddyCardClose");
|
||||
}
|
||||
|
||||
public static function playLimitedChatErrorSound() : void
|
||||
{
|
||||
playSfx("LimitedChatErrorSound");
|
||||
}
|
||||
|
||||
public static function playChatOpenSound() : void
|
||||
{
|
||||
playSfx("ChatOpenSound");
|
||||
}
|
||||
|
||||
public static function playChatCloseSound() : void
|
||||
{
|
||||
playSfx("ChatCloseSound");
|
||||
}
|
||||
|
||||
public static function playRandomLever() : void
|
||||
{
|
||||
playSfx("RandomLever");
|
||||
}
|
||||
|
||||
public static function playNameGenRotationSound(param1:int = 1) : void
|
||||
{
|
||||
playSfx("NameGenRotationSound",param1);
|
||||
}
|
||||
|
||||
public static function playNameGenStopSound() : void
|
||||
{
|
||||
playSfx("NameGenStopSound");
|
||||
}
|
||||
|
||||
public static function stopNameGenRotationSound() : void
|
||||
{
|
||||
stopSfx("NameGenRotationSound");
|
||||
}
|
||||
|
||||
public static function stopRandomLever() : void
|
||||
{
|
||||
stopSfx("RandomLever");
|
||||
}
|
||||
|
||||
public static function get hasLoadedDailySpinSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedDailySpinSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedDailySpinSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedDailySpinSfx = param1;
|
||||
}
|
||||
|
||||
public static function playDailySpinSpin() : void
|
||||
{
|
||||
if(!_hasLoadedDailySpinSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("DailySpinSpin");
|
||||
}
|
||||
|
||||
public static function playDailySpinBub1() : void
|
||||
{
|
||||
if(!_hasLoadedDailySpinSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("DailySpinBub1");
|
||||
}
|
||||
|
||||
public static function playDailySpinBub2() : void
|
||||
{
|
||||
if(!_hasLoadedDailySpinSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("DailySpinBub2");
|
||||
}
|
||||
|
||||
public static function playDailySpinBub3() : void
|
||||
{
|
||||
if(!_hasLoadedDailySpinSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("DailySpinBub3");
|
||||
}
|
||||
|
||||
public static function get hasLoadedGiftUnwrapSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedGiftUnwrapSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedGiftUnwrapSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedGiftUnwrapSfx = param1;
|
||||
}
|
||||
|
||||
public static function playGiftUnwrap() : void
|
||||
{
|
||||
if(!_hasLoadedGiftUnwrapSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("GiftUnwrap");
|
||||
}
|
||||
|
||||
public static function playTreasureUnwrap() : void
|
||||
{
|
||||
if(!_hasLoadedGiftUnwrapSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TreasureUnwrap");
|
||||
}
|
||||
|
||||
public static function get hasLoadedJourneyBookWorldSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedJourneyBookWorldSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedJourneyBookWorldSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedJourneyBookWorldSfx = param1;
|
||||
}
|
||||
|
||||
public static function playJBPrizeEarned() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookWorldSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBPrizeEarned");
|
||||
}
|
||||
|
||||
public static function playJBWorldFactClose() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookWorldSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBWorldFactClose");
|
||||
}
|
||||
|
||||
public static function playJBWorldFactOpen() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookWorldSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBWorldFactOpen");
|
||||
}
|
||||
|
||||
public static function get hasLoadedJourneyBookBookSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedJourneyBookBookSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedJourneyBookBookSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedJourneyBookBookSfx = param1;
|
||||
}
|
||||
|
||||
public static function playJBBookFactClose() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookBookSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBBookFactClose");
|
||||
}
|
||||
|
||||
public static function playJBBookFactOpen() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookBookSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBBookFactOpen");
|
||||
}
|
||||
|
||||
public static function get hasLoadedTradeSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedTradeSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedTradeSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedTradeSfx = param1;
|
||||
}
|
||||
|
||||
public static function playTradeSuccessSound() : void
|
||||
{
|
||||
if(!_hasLoadedTradeSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TradeSuccessSound");
|
||||
}
|
||||
|
||||
public static function playTradeFailedSound() : void
|
||||
{
|
||||
if(!_hasLoadedTradeSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TradeFailedSound");
|
||||
}
|
||||
|
||||
public static function playTradeRequestSound() : void
|
||||
{
|
||||
if(!_hasLoadedTradeSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TradeRequestSound");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.loader.ResourceStack;
|
||||
import createAccountFlow.CreateAccount;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.UncaughtErrorEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.ui.Mouse;
|
||||
import gamePlayFlow.GamePlay;
|
||||
import gui.DarkenManager;
|
||||
import resource.FetchClientIPResourceStackable;
|
||||
import resource.LoadAvatarCarouselResourceStackable;
|
||||
import resource.LoadCursorResourceStackable;
|
||||
import resource.LoadIntro;
|
||||
import room.DebugGUITextbox;
|
||||
import waitingRoomFlow.WaitingRoom;
|
||||
|
||||
[SWF(width="900", height="550", backgroundColor="#393625", frameRate="24")]
|
||||
public class AJClient extends Sprite
|
||||
{
|
||||
|
||||
private static var _globalErrorDebugTxt:DebugGUITextbox;
|
||||
|
||||
private var _resourceStackLoader:ResourceStack;
|
||||
|
||||
private var _intro:LoadIntro;
|
||||
|
||||
private var _flashvars:Object;
|
||||
|
||||
public function AJClient()
|
||||
{
|
||||
super();
|
||||
addEventListener(Event.ADDED_TO_STAGE,this.addedToStageHandler);
|
||||
}
|
||||
|
||||
public static function get globalErrorDebugTxt() : DebugGUITextbox
|
||||
{
|
||||
return _globalErrorDebugTxt;
|
||||
}
|
||||
|
||||
private static function handleGlobalErrors(param1:UncaughtErrorEvent) : void
|
||||
{
|
||||
_globalErrorDebugTxt.text = GlobalErrorCatch.setupGlobalErrorListener(param1);
|
||||
}
|
||||
|
||||
private function addedToStageHandler(param1:Event) : void
|
||||
{
|
||||
removeEventListener(Event.ADDED_TO_STAGE,this.addedToStageHandler);
|
||||
var _loc2_:Boolean = ExternalInterface.available;
|
||||
if(_loc2_)
|
||||
{
|
||||
DebugUtility.debugTrace("addedToStageHandler extIntAvail is true");
|
||||
DebugUtility.debugTrace("mrc dm init ctor starting up call returned:" + ExternalInterface.call("mrc",["dm","AJClient addedToStageHandler starting up"]));
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("addedToStageHandler extIntAvail is false");
|
||||
}
|
||||
if(!MainFrame.isInitialized())
|
||||
{
|
||||
if(parent != null)
|
||||
{
|
||||
this._flashvars = parent.loaderInfo.parameters;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._flashvars = loaderInfo.parameters;
|
||||
}
|
||||
MainFrame.handleLocalExternalCall = GamePlay.handleLocalExternalCall;
|
||||
MainFrame.getInstance(this._flashvars,this.setupInit,"",this);
|
||||
_globalErrorDebugTxt = new DebugGUITextbox();
|
||||
_globalErrorDebugTxt.init(this,"Global Error Catcher Initialized",false,true,true,600);
|
||||
_globalErrorDebugTxt.txt.textColor = 2236962;
|
||||
_globalErrorDebugTxt.x = 222;
|
||||
_globalErrorDebugTxt.y = 300;
|
||||
if(loaderInfo.hasOwnProperty("uncaughtErrorEvents"))
|
||||
{
|
||||
loaderInfo["uncaughtErrorEvents"].addEventListener("uncaughtError",handleGlobalErrors);
|
||||
}
|
||||
}
|
||||
DebugUtility.debugTrace("AJClient addedToStageHandler finished");
|
||||
}
|
||||
|
||||
public function setupInit() : void
|
||||
{
|
||||
Utility.init(DarkenManager.showLoadingSpiral,DarkenManager.darken,DarkenManager.unDarken);
|
||||
this._resourceStackLoader = new ResourceStack(gMainFrame.path,gMainFrame.loaderCache.openFile);
|
||||
this._resourceStackLoader.pushClass(new FetchClientIPResourceStackable(),true);
|
||||
this._resourceStackLoader.pushFile("assets/sharedFonts.swf",true);
|
||||
this._resourceStackLoader.pushFile("assets/HUDAssets.swf",true);
|
||||
this._resourceStackLoader.pushClass(new LoadAvatarCarouselResourceStackable());
|
||||
if(Mouse["supportsNativeCursor"])
|
||||
{
|
||||
this._resourceStackLoader.pushClass(new LoadCursorResourceStackable());
|
||||
}
|
||||
if(gMainFrame.clientInfo.isCreateAccount)
|
||||
{
|
||||
this._resourceStackLoader.start(this.setupCreateAccount);
|
||||
}
|
||||
else if(gMainFrame.clientInfo.waitingMode)
|
||||
{
|
||||
this._resourceStackLoader.start(this.setupWaitingRoom);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._resourceStackLoader.start(this.setupGamePlay);
|
||||
}
|
||||
}
|
||||
|
||||
public function setupCreateAccount() : void
|
||||
{
|
||||
if(gMainFrame.clientInfo.landingPage != "undefined")
|
||||
{
|
||||
SBTracker.trackPageview("/game/play/homepage/" + gMainFrame.clientInfo.landingPage,0);
|
||||
}
|
||||
var _loc1_:CreateAccount = new CreateAccount(this._flashvars);
|
||||
addChild(_loc1_);
|
||||
gMainFrame.createAccount = _loc1_;
|
||||
_loc1_.loginCtorHelper();
|
||||
this._intro = new LoadIntro();
|
||||
this._intro.init(_loc1_.setIntro);
|
||||
}
|
||||
|
||||
public function setupWaitingRoom() : void
|
||||
{
|
||||
var _loc1_:WaitingRoom = new WaitingRoom(this._flashvars);
|
||||
addChild(_loc1_);
|
||||
gMainFrame.waitingRoom = _loc1_;
|
||||
_loc1_.waitCtorHelper();
|
||||
}
|
||||
|
||||
public function setupGamePlay(param1:Event = null, param2:Event = null) : void
|
||||
{
|
||||
if(gMainFrame.createAccount)
|
||||
{
|
||||
if(contains(gMainFrame.createAccount))
|
||||
{
|
||||
removeChild(gMainFrame.createAccount);
|
||||
}
|
||||
gMainFrame.createAccount = null;
|
||||
this._intro = null;
|
||||
this._resourceStackLoader = null;
|
||||
}
|
||||
var _loc3_:GamePlay = new GamePlay(this._flashvars,param1,param2);
|
||||
addChild(_loc3_);
|
||||
gMainFrame.gamePlay = _loc3_;
|
||||
_loc3_.worldCtorHelper();
|
||||
}
|
||||
|
||||
private function createAvatar() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function shardSelection() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function enterGame() : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
|
||||
public dynamic class DisplayLayer extends Sprite
|
||||
{
|
||||
|
||||
public function DisplayLayer()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
package
|
||||
{
|
||||
import flash.system.Capabilities;
|
||||
|
||||
public class FlashCapabilities
|
||||
{
|
||||
|
||||
private static const CAPABILITIES_AV_HARDWARE_DISABLE:uint = 0;
|
||||
|
||||
private static const CAPABILITIES_HAS_ACCESSIBILITY:uint = 1;
|
||||
|
||||
private static const CAPABILITIES_HAS_AUDIO:uint = 2;
|
||||
|
||||
private static const CAPABILITIES_HAS_AUDIO_ENCODER:uint = 3;
|
||||
|
||||
private static const CAPABILITIES_HAS_EMBEDDED_VIDEO:uint = 4;
|
||||
|
||||
private static const CAPABILITIES_HAS_IME:uint = 5;
|
||||
|
||||
private static const CAPABILITIES_HAS_MP3:uint = 6;
|
||||
|
||||
private static const CAPABILITIES_HAS_PRINTING:uint = 7;
|
||||
|
||||
private static const CAPABILITIES_HAS_SCREEN_BROADCAST:uint = 8;
|
||||
|
||||
private static const CAPABILITIES_HAS_SCREEN_PLAYBACK:uint = 9;
|
||||
|
||||
private static const CAPABILITIES_HAS_STREAMING_AUDIO:uint = 10;
|
||||
|
||||
private static const CAPABILITIES_HAS_STREAMING_VIDEO:uint = 11;
|
||||
|
||||
private static const CAPABILITIES_HAS_TLS:uint = 12;
|
||||
|
||||
private static const CAPABILITIES_HAS_VIDEO_ENCODER:uint = 13;
|
||||
|
||||
private static const CAPABILITIES_IS_DEBUGGER:uint = 14;
|
||||
|
||||
private static const CAPABILITIES_IS_EMBEDDED_IN_ACROBAT:uint = 15;
|
||||
|
||||
private static const CAPABILITIES_LOCAL_FILE_READ_DISABLE:uint = 16;
|
||||
|
||||
private static const CAPABILITIES_UNKNOWN_VALUE:int = -1;
|
||||
|
||||
private static const CAPABILITIES_PLAYER_TYPE_ACTIVEX:uint = 0;
|
||||
|
||||
private static const CAPABILITIES_PLAYER_TYPE_DESKTOP:uint = 1;
|
||||
|
||||
private static const CAPABILITIES_PLAYER_TYPE_EXTERNAL:uint = 2;
|
||||
|
||||
private static const CAPABILITIES_PLAYER_TYPE_PLUGIN:uint = 3;
|
||||
|
||||
private static const CAPABILITIES_PLAYER_TYPE_STANDALONE:uint = 4;
|
||||
|
||||
private static const CAPABILITIES_SCREEN_COLOR_COLOR:uint = 0;
|
||||
|
||||
private static const CAPABILITIES_SCREEN_COLOR_GRAY:uint = 1;
|
||||
|
||||
private static const CAPABILITIES_SCREEN_COLOR_BW:uint = 2;
|
||||
|
||||
private static const CAPABILITIES_VERSION_PLATFORM_WIN:uint = 0;
|
||||
|
||||
private static const CAPABILITIES_VERSION_PLATFORM_MAC:uint = 1;
|
||||
|
||||
private static const CAPABILITIES_VERSION_PLATFORM_UNIX:uint = 2;
|
||||
|
||||
public function FlashCapabilities()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function SendCapabilities() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(Capabilities.avHardwareDisable)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_AV_HARDWARE_DISABLE;
|
||||
}
|
||||
if(Capabilities.hasAccessibility)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_ACCESSIBILITY;
|
||||
}
|
||||
if(Capabilities.hasAudio)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_AUDIO;
|
||||
}
|
||||
if(Capabilities.hasAudioEncoder)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_AUDIO_ENCODER;
|
||||
}
|
||||
if(Capabilities.hasEmbeddedVideo)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_EMBEDDED_VIDEO;
|
||||
}
|
||||
if(Capabilities.hasIME)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_IME;
|
||||
}
|
||||
if(Capabilities.hasMP3)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_MP3;
|
||||
}
|
||||
if(Capabilities.hasPrinting)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_PRINTING;
|
||||
}
|
||||
if(Capabilities.hasScreenBroadcast)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_SCREEN_BROADCAST;
|
||||
}
|
||||
if(Capabilities.hasScreenPlayback)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_SCREEN_PLAYBACK;
|
||||
}
|
||||
if(Capabilities.hasStreamingAudio)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_STREAMING_AUDIO;
|
||||
}
|
||||
if(Capabilities.hasStreamingVideo)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_STREAMING_VIDEO;
|
||||
}
|
||||
if(Capabilities.hasTLS)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_TLS;
|
||||
}
|
||||
if(Capabilities.hasVideoEncoder)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_HAS_VIDEO_ENCODER;
|
||||
}
|
||||
if(Capabilities.isDebugger)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_IS_DEBUGGER;
|
||||
}
|
||||
if(Capabilities.isEmbeddedInAcrobat)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_IS_EMBEDDED_IN_ACROBAT;
|
||||
}
|
||||
if(Capabilities.localFileReadDisable)
|
||||
{
|
||||
_loc1_ |= 1 << CAPABILITIES_LOCAL_FILE_READ_DISABLE;
|
||||
}
|
||||
var _loc2_:int = CAPABILITIES_UNKNOWN_VALUE;
|
||||
switch(Capabilities.playerType)
|
||||
{
|
||||
case "ActiveX":
|
||||
_loc2_ = int(CAPABILITIES_PLAYER_TYPE_ACTIVEX);
|
||||
break;
|
||||
case "Desktop":
|
||||
_loc2_ = int(CAPABILITIES_PLAYER_TYPE_DESKTOP);
|
||||
break;
|
||||
case "External":
|
||||
_loc2_ = int(CAPABILITIES_PLAYER_TYPE_EXTERNAL);
|
||||
break;
|
||||
case "PlugIn":
|
||||
_loc2_ = int(CAPABILITIES_PLAYER_TYPE_PLUGIN);
|
||||
break;
|
||||
case "StandAlone":
|
||||
_loc2_ = int(CAPABILITIES_PLAYER_TYPE_STANDALONE);
|
||||
}
|
||||
var _loc3_:int = CAPABILITIES_UNKNOWN_VALUE;
|
||||
switch(Capabilities.screenColor)
|
||||
{
|
||||
case "color":
|
||||
_loc3_ = int(CAPABILITIES_SCREEN_COLOR_COLOR);
|
||||
break;
|
||||
case "gray":
|
||||
_loc3_ = int(CAPABILITIES_SCREEN_COLOR_GRAY);
|
||||
break;
|
||||
case "bw":
|
||||
_loc3_ = int(CAPABILITIES_SCREEN_COLOR_BW);
|
||||
}
|
||||
var _loc4_:Array = Capabilities.version.substring(Capabilities.version.indexOf(" ") + 1).split(",");
|
||||
var _loc5_:Array = [];
|
||||
_loc5_.push(_loc1_);
|
||||
_loc5_.push(Capabilities.language);
|
||||
_loc5_.push(Capabilities.manufacturer);
|
||||
_loc5_.push(Capabilities.os);
|
||||
_loc5_.push(Capabilities.pixelAspectRatio);
|
||||
_loc5_.push(_loc2_);
|
||||
_loc5_.push(_loc3_);
|
||||
_loc5_.push(Capabilities.screenDPI);
|
||||
_loc5_.push(Capabilities.screenResolutionX);
|
||||
_loc5_.push(Capabilities.screenResolutionY);
|
||||
var _loc6_:int = 0;
|
||||
while(_loc6_ < 4)
|
||||
{
|
||||
if(_loc6_ < _loc4_.length)
|
||||
{
|
||||
_loc5_.push(_loc4_[_loc6_]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_.push(0);
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("us",_loc5_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,570 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
import gui.GenericListGuiManager;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.DefPacksDefHelper;
|
||||
|
||||
public class GenericListXtCommManager
|
||||
{
|
||||
|
||||
private static var _requestCallbackQueue:Object;
|
||||
|
||||
private static var _streamQueue:Object;
|
||||
|
||||
private static var _requestPassback:Object;
|
||||
|
||||
private static var _cachedResponses:Object;
|
||||
|
||||
private static var _availDefs:Object;
|
||||
|
||||
private static var _availUniqueListId:int;
|
||||
|
||||
public static const AVAIL_LIST_ID:int = 1;
|
||||
|
||||
public static const AVAIL_TYPE_CLOTHING:int = 0;
|
||||
|
||||
public static const AVAIL_TYPE_DEN_ACC:int = 1;
|
||||
|
||||
public static const AVAIL_TYPE_PARTY:int = 2;
|
||||
|
||||
public static const AVAIL_TYPE_DEN_ROOM:int = 3;
|
||||
|
||||
public static const AVAIL_TYPE_ROOM:int = 4;
|
||||
|
||||
public static const AVAIL_TYPE_STREAM:int = 5;
|
||||
|
||||
public static const AVAIL_TYPE_DIAMOND:int = 6;
|
||||
|
||||
public static const ACC_JAMAA_SHOP_ID:int = 11;
|
||||
|
||||
public static const ACC_BAHARIBAY_SHOP_ID:int = 50;
|
||||
|
||||
public static const DEN_ITEM_MAIN_SHOP_ID:int = 12;
|
||||
|
||||
public static const DEN_ITEM_CRYSTALREEF_SHOP_ID:int = 51;
|
||||
|
||||
public static const DEN_ITEM_AUDIO_SHOP_ID:int = 56;
|
||||
|
||||
public static const DEN_ITEM_PET_LAND:int = 85;
|
||||
|
||||
public static const DEN_ITEM_PET_OCEAN:int = 89;
|
||||
|
||||
public static const REDEMPTION_STORE_LIST_ID:int = 172;
|
||||
|
||||
public static const DEN_ROOM_SHOP_ID:int = 13;
|
||||
|
||||
public static const MEDIA_EBOOK_1_ID:int = 23;
|
||||
|
||||
public static const AVATAR_LIST_ID:int = 64;
|
||||
|
||||
public static const MEDIA_JAG_CARD_LIST_ID:int = 10;
|
||||
|
||||
public static const MEDIA_JAG_STAMP_LIST_ID:int = 44;
|
||||
|
||||
private static var _availDefExpireTime:int = 0;
|
||||
|
||||
public function GenericListXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_cachedResponses = new Object();
|
||||
_requestCallbackQueue = new Object();
|
||||
_streamQueue = new Object();
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function requestGenericList(param1:int, param2:Function = null, param3:Object = null, param4:Boolean = true) : void
|
||||
{
|
||||
if(param2 != null)
|
||||
{
|
||||
_requestCallbackQueue[param1] = param2;
|
||||
}
|
||||
_requestPassback = param3;
|
||||
if(Boolean(_cachedResponses[param1]) && param1 != AVAIL_LIST_ID)
|
||||
{
|
||||
handleNewData(_cachedResponses[param1].concat());
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("gl",[param1],param4);
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestStreamList(param1:int, param2:Function, param3:Object = null) : void
|
||||
{
|
||||
_streamQueue[param1] = {
|
||||
"c":param2,
|
||||
"h":param3
|
||||
};
|
||||
if(_cachedResponses[param1])
|
||||
{
|
||||
handleNewData(_cachedResponses[param1].concat());
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("gl",[param1]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Array = param1.obj;
|
||||
if(_loc2_[0] == "gl")
|
||||
{
|
||||
_cachedResponses[int(_loc2_[2])] = _loc2_;
|
||||
}
|
||||
handleNewData(_loc2_.concat());
|
||||
}
|
||||
|
||||
public static function isAvailListExpired() : Boolean
|
||||
{
|
||||
var _loc1_:Date = new Date();
|
||||
var _loc2_:uint = _loc1_.getTime() / 1000;
|
||||
if(_availDefExpireTime == 0 || _availDefExpireTime > 0 && _loc2_ >= _availDefExpireTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getAvailListUniqueId() : int
|
||||
{
|
||||
return _availUniqueListId;
|
||||
}
|
||||
|
||||
public static function filterList(param1:int, param2:Array, param3:Object = null) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc6_:Boolean = false;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc10_:Array = null;
|
||||
switch(param1)
|
||||
{
|
||||
case DefPacksDefHelper.DEF_ITEM:
|
||||
_loc4_ = AVAIL_TYPE_CLOTHING;
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_DEN_ITEM:
|
||||
_loc4_ = AVAIL_TYPE_DEN_ACC;
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_DEN_ROOM:
|
||||
_loc4_ = AVAIL_TYPE_DEN_ROOM;
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_STREAM:
|
||||
_loc4_ = AVAIL_TYPE_STREAM;
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_DIAMOND:
|
||||
_loc4_ = AVAIL_TYPE_DIAMOND;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
var _loc5_:Array = _availDefs[_loc4_];
|
||||
if(!_loc5_ || _loc5_.length <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc7_:int = 0;
|
||||
while(_loc7_ < param2.length)
|
||||
{
|
||||
_loc6_ = false;
|
||||
switch(_loc4_)
|
||||
{
|
||||
case AVAIL_TYPE_CLOTHING:
|
||||
_loc8_ = int(param2[_loc7_].defId);
|
||||
break;
|
||||
case AVAIL_TYPE_DEN_ACC:
|
||||
_loc8_ = int(param2[_loc7_].itemDefId);
|
||||
break;
|
||||
case AVAIL_TYPE_DEN_ROOM:
|
||||
_loc8_ = int(param2[_loc7_].itemDefId);
|
||||
break;
|
||||
case AVAIL_TYPE_STREAM:
|
||||
_loc8_ = int(param2[_loc7_]);
|
||||
break;
|
||||
case AVAIL_TYPE_DIAMOND:
|
||||
break;
|
||||
default:
|
||||
throw new Error("ERROR: Availability type=" + _loc4_ + " is not yet implemented!");
|
||||
}
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc5_.length)
|
||||
{
|
||||
if(_loc8_ == _loc5_[_loc9_].defId)
|
||||
{
|
||||
if(!_loc5_[_loc9_].active)
|
||||
{
|
||||
param2.splice(_loc7_,1);
|
||||
if(param3)
|
||||
{
|
||||
if(_loc4_ == AVAIL_TYPE_STREAM)
|
||||
{
|
||||
for each(_loc10_ in param3)
|
||||
{
|
||||
_loc10_.splice(_loc7_,1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
param3.splice(_loc7_,1);
|
||||
}
|
||||
}
|
||||
_loc6_ = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
if(!_loc6_)
|
||||
{
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleNewData(param1:Array) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "gl")
|
||||
{
|
||||
_loc2_ = int(param1[3]);
|
||||
switch(_loc2_)
|
||||
{
|
||||
case DefPacksDefHelper.DEF_ITEM:
|
||||
case DefPacksDefHelper.DEF_DEN_ITEM:
|
||||
case DefPacksDefHelper.DEF_DEN_ROOM:
|
||||
case DefPacksDefHelper.DEF_CURRENCY_EXCHANGE:
|
||||
case DefPacksDefHelper.DEF_DIAMOND:
|
||||
handleItemResponse(param1,_loc2_);
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_LOCALIZATION:
|
||||
handleLocalizationResponse(param1);
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_MEDIA:
|
||||
handleMediaResponse(param1);
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_FACT:
|
||||
handleFactResponse(param1);
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_STREAM:
|
||||
handleStreamResponse(param1);
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_AVATAR:
|
||||
handleAvatarResponse(param1);
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_AVAILABILITY:
|
||||
handleAvailabilityResponse(param1);
|
||||
break;
|
||||
case DefPacksDefHelper.DEF_NAMEBAR_BADGE:
|
||||
handleNamebarBadgeResposne(param1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new Error("GenericListXtCommManager illegal data cmd:" + param1[0]);
|
||||
}
|
||||
|
||||
public static function genericListTypeResponse(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc5_:Object = null;
|
||||
var _loc2_:Object = param1.def;
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_GENERIC_LIST_TYPE] = null;
|
||||
var _loc3_:Object = new Object();
|
||||
for each(_loc4_ in _loc2_)
|
||||
{
|
||||
_loc5_ = {
|
||||
"defId":int(_loc4_.id),
|
||||
"typeId":int(_loc4_.typeId)
|
||||
};
|
||||
_loc3_[_loc4_.id] = _loc5_;
|
||||
}
|
||||
gMainFrame.userInfo.genericListDefs = _loc3_;
|
||||
}
|
||||
|
||||
private static function handleItemResponse(param1:Array, param2:int) : void
|
||||
{
|
||||
ItemXtCommManager.shopListResponse(param1,param2);
|
||||
}
|
||||
|
||||
private static function handleLocalizationResponse(param1:Array) : void
|
||||
{
|
||||
var _loc8_:Object = null;
|
||||
var _loc2_:* = 6;
|
||||
var _loc3_:int = int(param1[_loc2_++]);
|
||||
var _loc4_:Array = new Array(_loc3_);
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc4_[_loc5_] = param1[_loc2_++];
|
||||
_loc5_++;
|
||||
}
|
||||
var _loc6_:int = int(param1[2]);
|
||||
var _loc7_:Function = _requestCallbackQueue[_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_(_loc6_,_loc4_);
|
||||
for each(_loc8_ in _requestCallbackQueue)
|
||||
{
|
||||
if(_loc8_ == _loc7_)
|
||||
{
|
||||
delete _requestCallbackQueue[_loc6_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleMediaResponse(param1:Array) : void
|
||||
{
|
||||
var _loc9_:Object = null;
|
||||
var _loc2_:* = 6;
|
||||
var _loc3_:int = int(param1[_loc2_++]);
|
||||
var _loc4_:Array = new Array(_loc3_);
|
||||
var _loc5_:Array = new Array(_loc3_);
|
||||
var _loc6_:int = 0;
|
||||
while(_loc6_ < _loc3_)
|
||||
{
|
||||
_loc4_[_loc6_] = int(param1[_loc2_++]);
|
||||
_loc5_[_loc6_] = param1[_loc2_++];
|
||||
_loc6_++;
|
||||
}
|
||||
var _loc7_:int = int(param1[2]);
|
||||
var _loc8_:Function = _requestCallbackQueue[_loc7_];
|
||||
if(_loc8_ != null)
|
||||
{
|
||||
_loc8_(_loc7_,_loc4_,_loc5_);
|
||||
for each(_loc9_ in _requestCallbackQueue)
|
||||
{
|
||||
if(_loc9_ == _loc8_)
|
||||
{
|
||||
delete _requestCallbackQueue[_loc7_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleFactResponse(param1:Array) : void
|
||||
{
|
||||
var _loc8_:Object = null;
|
||||
var _loc9_:Object = null;
|
||||
var _loc2_:* = 6;
|
||||
var _loc3_:int = int(param1[_loc2_++]);
|
||||
var _loc4_:Array = new Array();
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc8_ = {
|
||||
"id":int(param1[_loc2_++]),
|
||||
"media":int(param1[_loc2_++]),
|
||||
"title":int(param1[_loc2_++]),
|
||||
"description":int(param1[_loc2_++]),
|
||||
"type":int(param1[_loc2_++]),
|
||||
"userVarId":int(param1[_loc2_++]),
|
||||
"bitIdx":int(param1[_loc2_++])
|
||||
};
|
||||
_loc4_.push(_loc8_);
|
||||
_loc5_++;
|
||||
}
|
||||
var _loc6_:int = int(param1[2]);
|
||||
var _loc7_:Function = _requestCallbackQueue[_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_(_loc4_);
|
||||
for each(_loc9_ in _requestCallbackQueue)
|
||||
{
|
||||
if(_loc9_ == _loc7_)
|
||||
{
|
||||
delete _requestCallbackQueue[_loc6_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleStreamResponse(param1:Array) : void
|
||||
{
|
||||
var _loc10_:Array = null;
|
||||
var _loc14_:Object = null;
|
||||
if(GenericListXtCommManager.isAvailListExpired())
|
||||
{
|
||||
if(Boolean(GenericListGuiManager) && Boolean(GenericListGuiManager.movieSelector))
|
||||
{
|
||||
GenericListGuiManager.movieSelector.destroy();
|
||||
GenericListGuiManager.movieSelector = null;
|
||||
}
|
||||
GenericListXtCommManager.requestGenericList(GenericListXtCommManager.AVAIL_LIST_ID,handleStreamResponse,param1);
|
||||
return;
|
||||
}
|
||||
var _loc2_:* = 6;
|
||||
var _loc3_:String = param1[4];
|
||||
var _loc4_:int = int(param1[_loc2_++]);
|
||||
var _loc5_:Array = new Array(_loc4_);
|
||||
var _loc6_:Array = new Array(_loc4_);
|
||||
var _loc7_:Array = new Array(_loc4_);
|
||||
var _loc8_:Array = new Array(_loc4_);
|
||||
var _loc9_:Array = new Array(_loc4_);
|
||||
var _loc11_:int = 0;
|
||||
while(_loc11_ < _loc4_)
|
||||
{
|
||||
_loc5_[_loc11_] = int(param1[_loc2_++]);
|
||||
_loc6_[_loc11_] = int(param1[_loc2_++]);
|
||||
_loc10_ = param1[_loc2_++].split("|");
|
||||
_loc7_[_loc11_] = _loc10_[0];
|
||||
if(_loc10_[1])
|
||||
{
|
||||
_loc8_[_loc11_] = _loc10_[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_[_loc11_] = _loc10_[0];
|
||||
}
|
||||
_loc9_[_loc11_] = int(param1[_loc2_++]);
|
||||
_loc11_++;
|
||||
}
|
||||
var _loc12_:int = int(param1[2]);
|
||||
var _loc13_:Object = _streamQueue[_loc12_];
|
||||
if(_loc13_)
|
||||
{
|
||||
if(_loc13_.h)
|
||||
{
|
||||
_loc13_.h.titleTxt = _loc3_;
|
||||
_loc13_.c(_loc12_,_loc5_,_loc6_,_loc7_,_loc8_,_loc9_,_loc13_.h);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_.c(_loc12_,_loc5_,_loc6_,_loc7_,_loc8_,_loc9_);
|
||||
}
|
||||
for each(_loc14_ in _streamQueue)
|
||||
{
|
||||
if(_loc14_ == _streamQueue[_loc12_])
|
||||
{
|
||||
delete _streamQueue[_loc12_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleAvatarResponse(param1:Array) : void
|
||||
{
|
||||
var _loc8_:Object = null;
|
||||
var _loc2_:* = 6;
|
||||
var _loc3_:int = int(param1[_loc2_++]);
|
||||
var _loc4_:Array = new Array(_loc3_);
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc4_[_loc5_] = int(param1[_loc2_++]);
|
||||
_loc5_++;
|
||||
}
|
||||
var _loc6_:int = int(param1[2]);
|
||||
var _loc7_:Function = _requestCallbackQueue[_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_(_loc4_);
|
||||
for each(_loc8_ in _requestCallbackQueue)
|
||||
{
|
||||
if(_loc8_ == _loc7_)
|
||||
{
|
||||
delete _requestCallbackQueue[_loc6_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleAvailabilityResponse(param1:Array) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc9_:Date = null;
|
||||
var _loc10_:Object = null;
|
||||
var _loc2_:int = int(param1[2]);
|
||||
var _loc3_:* = 4;
|
||||
_availUniqueListId = int(param1[_loc3_++]);
|
||||
var _loc4_:int = int(param1[_loc3_++]);
|
||||
var _loc5_:int = int(param1[_loc3_++]);
|
||||
if(_loc4_ < 0)
|
||||
{
|
||||
_availDefExpireTime = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc9_ = new Date();
|
||||
_availDefExpireTime = _loc9_.getTime() / 1000 + _loc4_;
|
||||
}
|
||||
_availDefs = new Object();
|
||||
var _loc7_:int = 0;
|
||||
while(_loc7_ < _loc5_)
|
||||
{
|
||||
_loc6_ = int(param1[_loc3_++]);
|
||||
if(!_availDefs[_loc6_])
|
||||
{
|
||||
_availDefs[_loc6_] = [];
|
||||
}
|
||||
_availDefs[_loc6_].push({
|
||||
"defId":int(param1[_loc3_++]),
|
||||
"active":param1[_loc3_++] == "1"
|
||||
});
|
||||
_loc7_++;
|
||||
}
|
||||
var _loc8_:Function = _requestCallbackQueue[_loc2_];
|
||||
if(_loc8_ != null)
|
||||
{
|
||||
if(_requestPassback)
|
||||
{
|
||||
_loc8_(_requestPassback);
|
||||
_requestPassback = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_();
|
||||
}
|
||||
for each(_loc10_ in _requestCallbackQueue)
|
||||
{
|
||||
if(_loc10_ == _loc8_)
|
||||
{
|
||||
delete _requestCallbackQueue[_loc2_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleNamebarBadgeResposne(param1:Array) : void
|
||||
{
|
||||
var _loc8_:Object = null;
|
||||
var _loc2_:* = 6;
|
||||
var _loc3_:int = int(param1[_loc2_++]);
|
||||
var _loc4_:Array = new Array(_loc3_);
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc4_[_loc5_] = int(param1[_loc2_++]);
|
||||
_loc5_++;
|
||||
}
|
||||
var _loc6_:int = int(param1[2]);
|
||||
var _loc7_:Function = _requestCallbackQueue[_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_(_loc4_);
|
||||
for each(_loc8_ in _requestCallbackQueue)
|
||||
{
|
||||
if(_loc8_ == _loc7_)
|
||||
{
|
||||
delete _requestCallbackQueue[_loc6_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package
|
||||
{
|
||||
import flash.events.ErrorEvent;
|
||||
import flash.events.UncaughtErrorEvent;
|
||||
import flash.system.Capabilities;
|
||||
|
||||
public class GlobalErrorCatch
|
||||
{
|
||||
|
||||
public function GlobalErrorCatch()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function setupGlobalErrorListener(param1:UncaughtErrorEvent) : String
|
||||
{
|
||||
var _loc4_:String = null;
|
||||
var _loc2_:UncaughtErrorEvent = UncaughtErrorEvent(param1);
|
||||
var _loc3_:Boolean = gMainFrame.clientInfo.accountType == Utility.INTERNAL;
|
||||
if(_loc2_)
|
||||
{
|
||||
if(!_loc3_)
|
||||
{
|
||||
_loc2_.preventDefault();
|
||||
}
|
||||
if(_loc2_.error is Error)
|
||||
{
|
||||
if(Capabilities.isDebugger)
|
||||
{
|
||||
_loc4_ = Error(_loc2_.error).getStackTrace();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = Error(_loc2_.error).message;
|
||||
}
|
||||
}
|
||||
else if(_loc2_.error is ErrorEvent)
|
||||
{
|
||||
_loc4_ = ErrorEvent(_loc2_.error).text;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = _loc2_.error.toString();
|
||||
}
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.loader.LoaderCacheEntry_Base;
|
||||
import com.sbi.loader.LoaderEvent;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Loader;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class LoadProgress
|
||||
{
|
||||
|
||||
private static var _entry:LoaderCacheEntry_Base;
|
||||
|
||||
private static var _loadScreen:Loader;
|
||||
|
||||
private static var _loadLayer:DisplayObjectContainer;
|
||||
|
||||
private static var _completeCallback:Function;
|
||||
|
||||
private static var _target:String;
|
||||
|
||||
private static var _displayTarget:String;
|
||||
|
||||
private static var _bChangeLoadingScreen:Boolean;
|
||||
|
||||
private static var _progressCounter:int;
|
||||
|
||||
public static const INITIALIZING:int = 1;
|
||||
|
||||
public static const LOADING_GAMES:int = 2;
|
||||
|
||||
public static const LOADING_ANIMALS:int = 3;
|
||||
|
||||
public static const LOADING_WORLDMAP:int = 4;
|
||||
|
||||
public static const FINDING_ROOM:int = 5;
|
||||
|
||||
public static const LOADING_ROOM:int = 6;
|
||||
|
||||
public static const JOINING_SERVER:int = 7;
|
||||
|
||||
private static const LoadScreenSWF:Class = LoadProgress_LoadScreenSWF;
|
||||
|
||||
public function LoadProgress()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function get loadScreen() : Loader
|
||||
{
|
||||
return _loadScreen;
|
||||
}
|
||||
|
||||
public static function get entry() : LoaderCacheEntry_Base
|
||||
{
|
||||
return _entry;
|
||||
}
|
||||
|
||||
public static function get loadLayer() : DisplayObjectContainer
|
||||
{
|
||||
return _loadLayer;
|
||||
}
|
||||
|
||||
public static function init(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
var _loc2_:ByteArray = null;
|
||||
if(_loadScreen == null)
|
||||
{
|
||||
_bChangeLoadingScreen = true;
|
||||
_progressCounter = 0;
|
||||
_loadLayer = param1;
|
||||
_loadScreen = new Loader();
|
||||
_loadScreen.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadScreenComplete);
|
||||
_loc2_ = ByteArray(new LoadScreenSWF());
|
||||
_loadScreen.loadBytes(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public static function show(param1:Boolean, param2:Object = null) : void
|
||||
{
|
||||
var _loc3_:MovieClip = null;
|
||||
if(param1)
|
||||
{
|
||||
_loc3_ = MovieClip(_loadScreen.content);
|
||||
if(Boolean(_loc3_) && _bChangeLoadingScreen)
|
||||
{
|
||||
_loc3_.showScreen(true);
|
||||
_loc3_.setProgress(_progressCounter);
|
||||
_bChangeLoadingScreen = false;
|
||||
}
|
||||
if(!loadLayer.contains(_loadScreen))
|
||||
{
|
||||
loadLayer.addChild(_loadScreen);
|
||||
}
|
||||
}
|
||||
else if(loadLayer.contains(_loadScreen))
|
||||
{
|
||||
loadLayer.removeChild(_loadScreen);
|
||||
_bChangeLoadingScreen = true;
|
||||
_progressCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function load(param1:String, param2:int, param3:Function) : void
|
||||
{
|
||||
_entry = null;
|
||||
_completeCallback = param3;
|
||||
_target = gMainFrame.path + param1;
|
||||
_progressCounter = param2;
|
||||
var _loc4_:MovieClip = MovieClip(_loadScreen.content);
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc4_.setProgress(param2);
|
||||
}
|
||||
DebugUtility.debugTrace("loading target:" + _target);
|
||||
if(_loadScreen)
|
||||
{
|
||||
startLoad();
|
||||
return;
|
||||
}
|
||||
throw new Error("preloader was not embedded?!");
|
||||
}
|
||||
|
||||
private static function onLoadScreenComplete(param1:Event) : void
|
||||
{
|
||||
show(true);
|
||||
}
|
||||
|
||||
private static function startLoad() : void
|
||||
{
|
||||
show(true);
|
||||
gMainFrame.loaderCache.openFile(_target,loadCompleteHandler,loadProgressHandler);
|
||||
}
|
||||
|
||||
private static function loadCompleteHandler(param1:LoaderEvent) : void
|
||||
{
|
||||
_entry = param1.entry;
|
||||
if(_completeCallback != null)
|
||||
{
|
||||
_completeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
private static function loadProgressHandler(param1:LoaderEvent) : void
|
||||
{
|
||||
if(param1.status && Boolean(_loadScreen))
|
||||
{
|
||||
return;
|
||||
}
|
||||
throw new Error("ERROR: Unable to show loading progress! status:" + param1.status + " preloader:" + _loadScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package
|
||||
{
|
||||
import mx.core.ByteArrayAsset;
|
||||
|
||||
[Embed(source="/_assets/7_LoadProgress_LoadScreenSWF.bin", mimeType="application/octet-stream")]
|
||||
public class LoadProgress_LoadScreenSWF extends ByteArrayAsset
|
||||
{
|
||||
|
||||
public function LoadProgress_LoadScreenSWF()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
import loader.LocalizationDefHelper;
|
||||
|
||||
public class LocalizationXtCommManager
|
||||
{
|
||||
|
||||
private static var _tsDefCache:Array;
|
||||
|
||||
private static var _tsDefQueue:Array;
|
||||
|
||||
public static var LANG_ENG:int = 1;
|
||||
|
||||
public static var LANG_SPA:int = 2;
|
||||
|
||||
public static var LANG_POR:int = 3;
|
||||
|
||||
public static var LANG_FRE:int = 4;
|
||||
|
||||
public function LocalizationXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_tsDefCache = [];
|
||||
_tsDefQueue = [];
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_tsDefQueue = null;
|
||||
_tsDefCache = null;
|
||||
}
|
||||
|
||||
public static function sendTranslateStringRequest(param1:int, param2:int, param3:Function, param4:Object = null) : void
|
||||
{
|
||||
var _loc5_:Object = null;
|
||||
var _loc6_:LocalizationDefHelper = null;
|
||||
if(param1 > 0)
|
||||
{
|
||||
_loc5_ = _tsDefCache[param1];
|
||||
if(!_loc5_)
|
||||
{
|
||||
_loc6_ = new LocalizationDefHelper();
|
||||
_loc6_.init(param1,onLocalizationDefReceived);
|
||||
_tsDefQueue[param1] = {
|
||||
"ldh":_loc6_,
|
||||
"c":param3,
|
||||
"lId":param2,
|
||||
"p":param4
|
||||
};
|
||||
}
|
||||
else if(param4)
|
||||
{
|
||||
param3(param1,textForDefAndLangId(_loc5_,param2),param4);
|
||||
}
|
||||
else
|
||||
{
|
||||
param3(param1,textForDefAndLangId(_loc5_,param2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onLocalizationDefReceived(param1:LocalizationDefHelper) : void
|
||||
{
|
||||
var _loc5_:Function = null;
|
||||
var _loc2_:Object = param1.def;
|
||||
var _loc3_:Object = {
|
||||
"id":int(_loc2_.id),
|
||||
"name":_loc2_.name,
|
||||
"eng":_loc2_.eng,
|
||||
"spa":_loc2_.spa,
|
||||
"por":_loc2_.por,
|
||||
"fre":_loc2_.fre
|
||||
};
|
||||
_tsDefCache[_loc3_.id] = _loc3_;
|
||||
var _loc4_:Object = _tsDefQueue[_loc3_.id];
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc5_ = _loc4_.c;
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
if(_loc4_.p)
|
||||
{
|
||||
_loc5_(_loc3_.id,textForDefAndLangId(_loc3_,_loc4_.lId),_loc4_.p);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_(_loc3_.id,textForDefAndLangId(_loc3_,_loc4_.lId));
|
||||
}
|
||||
}
|
||||
_tsDefQueue[_loc3_.id] = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function textForDefAndLangId(param1:Object, param2:int) : String
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
switch(param2)
|
||||
{
|
||||
case LANG_ENG:
|
||||
return param1.eng;
|
||||
case LANG_SPA:
|
||||
return param1.spa;
|
||||
case LANG_POR:
|
||||
return param1.por;
|
||||
case LANG_FRE:
|
||||
return param1.fre;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Array = param1.obj;
|
||||
var _loc3_:* = _loc2_[0];
|
||||
switch(0)
|
||||
{
|
||||
}
|
||||
throw new Error("LocalizationXtCommManager illegal data:" + _loc2_[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,484 @@
|
||||
package
|
||||
{
|
||||
import avatar.UserInfoCache;
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import com.sbi.client.SFClient;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import com.sbi.loader.ImageServerURL;
|
||||
import com.sbi.loader.LoaderCache;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Shape;
|
||||
import flash.display.Sprite;
|
||||
import flash.display.Stage;
|
||||
import flash.display.StageScaleMode;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.net.URLLoader;
|
||||
import flash.net.URLLoaderDataFormat;
|
||||
import flash.net.URLRequest;
|
||||
import gamePlayFlow.GamePlay;
|
||||
import room.LayerManager;
|
||||
|
||||
public class MainFrame extends Sprite
|
||||
{
|
||||
|
||||
public static var avatarCreationLogin:MovieClip;
|
||||
|
||||
public static var avatarCreationWorld:MovieClip;
|
||||
|
||||
public static var handleLocalExternalCall:Function;
|
||||
|
||||
private static var _configLoadedCallback:Function;
|
||||
|
||||
private static var m:MainFrame;
|
||||
|
||||
private static var _flashVarUserName:String;
|
||||
|
||||
public static const VIEW_WIDTH:int = 900;
|
||||
|
||||
public static const VIEW_HEIGHT:int = 550;
|
||||
|
||||
public static const ROOMS_FOLDER:String = "roomDefs/";
|
||||
|
||||
public static const CDN_SALT:String = "J@mnim4L";
|
||||
|
||||
public static const MSG_ID_LOGIN_IN_USE:int = -11;
|
||||
|
||||
public static const MSG_ID_LOGIN_ACCT_MAINT:int = -12;
|
||||
|
||||
public static const MSG_ID_LOGIN_CONNECTION:int = -14;
|
||||
|
||||
public static const MSG_ID_LOGIN_BANNED:int = -15;
|
||||
|
||||
public static const MSG_ID_LOGIN_SERVER_MAINT:int = -16;
|
||||
|
||||
private static const _configDebugFile:String = "clientdevtest.xml";
|
||||
|
||||
private static const _configDebugTemplateFile:String = "clientdevtest.template.xml";
|
||||
|
||||
private var _client:SFClient = null;
|
||||
|
||||
private var _path:String = null;
|
||||
|
||||
private var _stage:Stage;
|
||||
|
||||
private var _gamePlay:DisplayObjectContainer;
|
||||
|
||||
private var _waitingRoom:DisplayObjectContainer;
|
||||
|
||||
private var _createAccount:DisplayObjectContainer;
|
||||
|
||||
private var _loaderCache:LoaderCache;
|
||||
|
||||
public var userInfo:UserInfoCache;
|
||||
|
||||
public var clientInfo:Object;
|
||||
|
||||
public var classNames:Array;
|
||||
|
||||
private var _layerInfo:Object;
|
||||
|
||||
public function MainFrame()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getInstance(param1:Object = null, param2:Function = null, param3:String = "", param4:DisplayObjectContainer = null) : MainFrame
|
||||
{
|
||||
var stg:Stage = null;
|
||||
var extIntAvail:Boolean = false;
|
||||
var msk:Shape = null;
|
||||
var haveFlashVars:Boolean = false;
|
||||
var loadit:URLLoader = null;
|
||||
var flashVars:Object = param1;
|
||||
var configLoadedCallback:Function = param2;
|
||||
var path:String = param3;
|
||||
var main:DisplayObjectContainer = param4;
|
||||
if(m == null)
|
||||
{
|
||||
if(path == null || main == null || main.stage == null)
|
||||
{
|
||||
throw new Error("ERROR: Attempted to call initial getInstance on MainFrame without correct parameters!");
|
||||
}
|
||||
stg = main.stage;
|
||||
LoadProgress.init(stg);
|
||||
LoadProgress.show(true,LoadProgress.INITIALIZING);
|
||||
LoaderCache.cdnSalt = CDN_SALT;
|
||||
extIntAvail = ExternalInterface.available;
|
||||
if(extIntAvail)
|
||||
{
|
||||
DebugUtility.debugTrace("extIntAvail is true");
|
||||
DebugUtility.debugTrace("mrc dm init starting up call returned:" + ExternalInterface.call("mrc",["dm","init:starting up"]));
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("extIntAvail is false");
|
||||
}
|
||||
msk = new Shape();
|
||||
msk.graphics.clear();
|
||||
msk.graphics.lineStyle(1,16777215);
|
||||
msk.graphics.beginFill(16777215);
|
||||
msk.graphics.drawRect(0,0,VIEW_WIDTH,VIEW_HEIGHT);
|
||||
msk.graphics.endFill();
|
||||
main.addChild(msk);
|
||||
main.mask = msk;
|
||||
stg.scaleMode = StageScaleMode.NO_SCALE;
|
||||
m = new MainFrame();
|
||||
m.init(new Singleton(),path,stg);
|
||||
gMainFrame = m;
|
||||
if(extIntAvail)
|
||||
{
|
||||
try
|
||||
{
|
||||
DebugUtility.debugTrace("init:adding mec callback");
|
||||
ExternalInterface.addCallback("mec",handleLocalExternalCall);
|
||||
DebugUtility.debugTrace("init:mec added, calling lc...");
|
||||
ExternalInterface.call("mrc",["lc"]);
|
||||
DebugUtility.debugTrace("init:... lc called, waiting for ixm...");
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
DebugUtility.debugTrace("init:ERROR hit during AJC ext mod setup! msg:" + e.message + " stack:" + e.getStackTrace());
|
||||
}
|
||||
}
|
||||
DebugUtility.debugTrace("init: setting extCallsActive to false");
|
||||
gMainFrame.clientInfo.extCallsActive = false;
|
||||
DebugUtility.debugTrace("init: set extCallsActive to false");
|
||||
_configLoadedCallback = configLoadedCallback;
|
||||
haveFlashVars = Boolean(flashVars && flashVars.smartfoxServer);
|
||||
gMainFrame.clientInfo.devMode = !haveFlashVars;
|
||||
if(haveFlashVars)
|
||||
{
|
||||
_flashVarUserName = flashVars.username;
|
||||
if(!(Boolean(flashVars.smartfoxServer) && Boolean(flashVars.smartfoxPort) && Boolean(flashVars.blueboxServer) && Boolean(flashVars.blueboxPort) && Boolean(flashVars.content) && Boolean(flashVars.website)))
|
||||
{
|
||||
throw new Error("Invalid FlashVars!");
|
||||
}
|
||||
if(!flashVars.hasOwnProperty("startupRoom"))
|
||||
{
|
||||
flashVars.startupRoom = "jamaa_township.room_main";
|
||||
}
|
||||
if(!flashVars.hasOwnProperty("worldmapRoom"))
|
||||
{
|
||||
flashVars.worldmapRoom = "world_map/room_main.xroom";
|
||||
}
|
||||
if(!flashVars.hasOwnProperty("dangermapRoom"))
|
||||
{
|
||||
flashVars.dangermapRoom = "danger_map/room_main.xroom";
|
||||
}
|
||||
if(!flashVars.hasOwnProperty("clientDebug"))
|
||||
{
|
||||
flashVars.clientDebug = "false";
|
||||
}
|
||||
if(!flashVars.hasOwnProperty("build_version"))
|
||||
{
|
||||
flashVars.build_version = "0";
|
||||
}
|
||||
if(!flashVars.hasOwnProperty("deploy_version"))
|
||||
{
|
||||
flashVars.deploy_version = "0";
|
||||
}
|
||||
if(!flashVars.hasOwnProperty("sg_params"))
|
||||
{
|
||||
flashVars.sg_params = "";
|
||||
}
|
||||
if(String(flashVars.sg_params).indexOf("%") >= 0)
|
||||
{
|
||||
throw new Error("Invalid sg_params!");
|
||||
}
|
||||
gMainFrame.clientInfo.localMode = false;
|
||||
LoaderCache.localMode = false;
|
||||
applyConfigVars(flashVars);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadit = new URLLoader();
|
||||
loadit.dataFormat = URLLoaderDataFormat.TEXT;
|
||||
loadit.addEventListener(Event.COMPLETE,configDebugLoadCompleteHandler);
|
||||
loadit.addEventListener(IOErrorEvent.IO_ERROR,configDebugLoadIOErrorHandler);
|
||||
loadit.load(new URLRequest(_configDebugFile));
|
||||
}
|
||||
}
|
||||
SBTracker.create();
|
||||
return m;
|
||||
}
|
||||
|
||||
public static function isInitialized() : Boolean
|
||||
{
|
||||
return Boolean(m != null);
|
||||
}
|
||||
|
||||
private static function applyConfigVars(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Array = [param1.smartfoxServer];
|
||||
var _loc3_:int = 1;
|
||||
while(param1.hasOwnProperty("smartfoxServer" + _loc3_))
|
||||
{
|
||||
_loc2_.push(param1["smartfoxServer" + _loc3_]);
|
||||
_loc3_++;
|
||||
}
|
||||
var _loc4_:Array = [param1.blueboxServer];
|
||||
var _loc5_:int = 1;
|
||||
while(param1.hasOwnProperty("blueboxServer" + _loc5_))
|
||||
{
|
||||
_loc4_.push(param1["blueboxServer" + _loc5_]);
|
||||
_loc5_++;
|
||||
}
|
||||
gMainFrame.server.setServerConfig(_loc2_,param1.smartfoxPort,_loc4_,param1.blueboxPort,param1.clientDebug);
|
||||
var _loc6_:String = param1.build_version;
|
||||
gMainFrame.clientInfo.buildVersion = _loc6_;
|
||||
LoaderCache.buildVersion = _loc6_;
|
||||
var _loc7_:String = param1.deploy_version;
|
||||
gMainFrame.clientInfo.deployVersion = _loc7_;
|
||||
LoaderCache.deployVersion = _loc7_;
|
||||
var _loc8_:String = param1.myExternalIp;
|
||||
gMainFrame.clientInfo.clientIp = _loc8_;
|
||||
gMainFrame.clientInfo.websiteURL = param1.website;
|
||||
var _loc9_:String = param1.content;
|
||||
gMainFrame.clientInfo.contentURL = _loc9_;
|
||||
LoaderCache.contentURL = _loc9_;
|
||||
var _loc10_:Boolean = Boolean(param1.webRefPath == "create_account");
|
||||
gMainFrame.clientInfo.isCreateAccount = _loc10_;
|
||||
var _loc11_:Boolean = Boolean(param1.waitingMode == "true");
|
||||
gMainFrame.clientInfo.waitingMode = _loc11_;
|
||||
gMainFrame.clientInfo.startUpRoom = String(param1.startupRoom);
|
||||
gMainFrame.clientInfo.worldMapRoom = ROOMS_FOLDER + param1.worldmapRoom;
|
||||
gMainFrame.clientInfo.dangerMapRoom = ROOMS_FOLDER + param1.dangermapRoom;
|
||||
gMainFrame.clientInfo.clientDebug = param1.clientDebug;
|
||||
gMainFrame.clientInfo.sgParams = String(param1.sg_params);
|
||||
gMainFrame.clientInfo.mdUrl = String(param1.mdUrl);
|
||||
gMainFrame.clientInfo.currentTimestamp = Number(param1.currentTimestamp);
|
||||
gMainFrame.clientInfo.sbTrackerIp = String(param1.sbStatTrackerIp);
|
||||
gMainFrame.clientInfo.sbTrackerModulator = param1.sbStatModulator;
|
||||
gMainFrame.clientInfo.landingPage = String(param1.landingPage);
|
||||
gMainFrame.clientInfo.authToken = param1.auth_token;
|
||||
DebugUtility.debugTrace("-configXml/flashVars info-");
|
||||
DebugUtility.debugTrace("smartfoxAddress:" + param1.smartfoxServer);
|
||||
DebugUtility.debugTrace("smartfoxPort:" + param1.smartfoxPort);
|
||||
DebugUtility.debugTrace("blueboxAddress:" + param1.blueboxServer);
|
||||
DebugUtility.debugTrace("blueboxPort:" + param1.blueboxPort);
|
||||
DebugUtility.debugTrace("buildVersionStr:" + _loc6_);
|
||||
DebugUtility.debugTrace("deployVersionStr:" + _loc7_);
|
||||
DebugUtility.debugTrace("clientIpStr:" + _loc8_);
|
||||
DebugUtility.debugTrace("contentURL:" + gMainFrame.clientInfo.contentURL);
|
||||
DebugUtility.debugTrace("websiteURL:" + gMainFrame.clientInfo.websiteURL);
|
||||
DebugUtility.debugTrace("isCreateAccount:" + _loc10_ + " webRefPath:" + param1.webRefPath);
|
||||
DebugUtility.debugTrace("isWaitingMode:" + _loc11_ + " cfgVars.waitingMode:" + param1.waitingMode);
|
||||
DebugUtility.debugTrace("startUpRoom:" + gMainFrame.clientInfo.startUpRoom);
|
||||
DebugUtility.debugTrace("worldMapRoom:" + gMainFrame.clientInfo.worldMapRoom);
|
||||
DebugUtility.debugTrace("dangerMapRoom:" + gMainFrame.clientInfo.dangerMapRoom);
|
||||
DebugUtility.debugTrace("clientDebug:" + param1.clientDebug);
|
||||
DebugUtility.debugTrace("sgParams:" + gMainFrame.clientInfo.sgParams);
|
||||
m._loaderCache = new LoaderCache();
|
||||
_configLoadedCallback();
|
||||
}
|
||||
|
||||
private static function configDebugLoadIOErrorHandler(param1:IOErrorEvent) : void
|
||||
{
|
||||
var _loc2_:URLLoader = new URLLoader();
|
||||
_loc2_.dataFormat = URLLoaderDataFormat.TEXT;
|
||||
_loc2_.addEventListener(Event.COMPLETE,configDebugLoadCompleteHandler);
|
||||
_loc2_.addEventListener(IOErrorEvent.IO_ERROR,configDebugTemplateLoadIOErrorHandler);
|
||||
_loc2_.load(new URLRequest(_configDebugTemplateFile));
|
||||
}
|
||||
|
||||
private static function configDebugTemplateLoadIOErrorHandler(param1:IOErrorEvent) : void
|
||||
{
|
||||
throw new Error("IOError reading " + _configDebugFile + " or " + _configDebugTemplateFile + "! ioe:" + param1);
|
||||
}
|
||||
|
||||
private static function configDebugLoadCompleteHandler(param1:Event) : void
|
||||
{
|
||||
var _loc5_:XML = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc12_:String = null;
|
||||
var _loc2_:XML = new XML(param1.target.data);
|
||||
var _loc3_:XMLList = _loc2_.autoLogins.children();
|
||||
var _loc4_:int = 0;
|
||||
for each(_loc5_ in _loc3_)
|
||||
{
|
||||
gMainFrame.clientInfo["autoLogin" + ++_loc4_] = [String(_loc5_.name.text()),String(_loc5_.token.text())];
|
||||
}
|
||||
_loc6_ = _loc2_.local.text();
|
||||
if(_loc6_ == "false")
|
||||
{
|
||||
gMainFrame.clientInfo.localMode = false;
|
||||
LoaderCache.localMode = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.clientInfo.localMode = true;
|
||||
}
|
||||
var _loc7_:String = _loc2_.clientDebug.text();
|
||||
if(_loc7_ != "true")
|
||||
{
|
||||
_loc7_ = "false";
|
||||
}
|
||||
var _loc8_:String = "false";
|
||||
if(_loc2_.hasOwnProperty("waitingMode"))
|
||||
{
|
||||
_loc8_ = _loc2_.waitingMode.text();
|
||||
}
|
||||
var _loc9_:Object = {
|
||||
"smartfoxServer":_loc2_.smartfoxServer.text(),
|
||||
"smartfoxPort":_loc2_.smartfoxPort.text(),
|
||||
"blueboxServer":_loc2_.blueboxServer.text(),
|
||||
"blueboxPort":_loc2_.blueboxPort.text(),
|
||||
"content":_loc2_.content.text(),
|
||||
"website":_loc2_.website.text(),
|
||||
"startupRoom":_loc2_.startupRoom.text(),
|
||||
"worldmapRoom":_loc2_.worldmapRoom.text(),
|
||||
"dangermapRoom":_loc2_.dangermapRoom.text(),
|
||||
"clientDebug":_loc7_,
|
||||
"waitingMode":_loc8_,
|
||||
"sg_params":"",
|
||||
"mdUrl":_loc2_.mdUrl
|
||||
};
|
||||
var _loc10_:int = 1;
|
||||
while(_loc2_.hasOwnProperty("smartfoxServer" + _loc10_))
|
||||
{
|
||||
_loc9_["smartfoxServer" + _loc10_] = _loc2_["smartfoxServer" + _loc10_].text();
|
||||
_loc10_++;
|
||||
}
|
||||
var _loc11_:int = 1;
|
||||
while(_loc2_.hasOwnProperty("blueboxServer" + _loc11_))
|
||||
{
|
||||
_loc9_["blueboxServer" + _loc11_] = _loc2_["blueboxServer" + _loc11_].text();
|
||||
_loc11_++;
|
||||
}
|
||||
_loc9_["build_version"] = _loc2_.hasOwnProperty("build_version") ? _loc2_.build_version.text() : "0";
|
||||
_loc9_["deploy_version"] = _loc2_.hasOwnProperty("deploy_version") ? _loc2_.deploy_version.text() : "0";
|
||||
_loc9_["myExternalIp"] = _loc2_.hasOwnProperty("myExternalIp") ? _loc2_.myExternalIp.text() : "";
|
||||
_loc9_["webRefPath"] = _loc2_.hasOwnProperty("webRefPath") ? _loc2_.webRefPath.text() : "";
|
||||
for(_loc12_ in _loc9_)
|
||||
{
|
||||
if(_loc9_[_loc12_] is XMLList && XMLList(_loc9_[_loc12_]).length() > 1)
|
||||
{
|
||||
throw new Error("Invalid clientdevtest xml config! Found multiple tags of same name:" + _loc12_);
|
||||
}
|
||||
}
|
||||
applyConfigVars(_loc9_);
|
||||
}
|
||||
|
||||
public function init(param1:Singleton, param2:String, param3:Stage) : void
|
||||
{
|
||||
this._path = param2;
|
||||
this._stage = param3;
|
||||
this._client = new SFClient();
|
||||
this.userInfo = new UserInfoCache();
|
||||
this.userInfo.init();
|
||||
this.clientInfo = new Object();
|
||||
this.clientInfo.invisMode = false;
|
||||
this.classNames = null;
|
||||
}
|
||||
|
||||
public function get server() : SFClient
|
||||
{
|
||||
return this._client;
|
||||
}
|
||||
|
||||
public function get path() : String
|
||||
{
|
||||
return this._path;
|
||||
}
|
||||
|
||||
override public function get stage() : Stage
|
||||
{
|
||||
return this._stage;
|
||||
}
|
||||
|
||||
public function set createAccount(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
this._createAccount = param1;
|
||||
}
|
||||
|
||||
public function get createAccount() : DisplayObjectContainer
|
||||
{
|
||||
return this._createAccount;
|
||||
}
|
||||
|
||||
public function set waitingRoom(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
this._waitingRoom = param1;
|
||||
}
|
||||
|
||||
public function get waitingRoom() : DisplayObjectContainer
|
||||
{
|
||||
return this._waitingRoom;
|
||||
}
|
||||
|
||||
public function set gamePlay(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
this._gamePlay = param1;
|
||||
}
|
||||
|
||||
public function get gamePlay() : DisplayObjectContainer
|
||||
{
|
||||
return this._gamePlay;
|
||||
}
|
||||
|
||||
public function get layerManager() : LayerManager
|
||||
{
|
||||
return (this._gamePlay as GamePlay).layerManager;
|
||||
}
|
||||
|
||||
public function get loaderCache() : LoaderCache
|
||||
{
|
||||
return this._loaderCache;
|
||||
}
|
||||
|
||||
public function set layerInfo(param1:Object) : void
|
||||
{
|
||||
this._layerInfo = param1;
|
||||
ImageServerURL.instance.layerInfo = param1;
|
||||
}
|
||||
|
||||
public function get myFlashVarUserName() : String
|
||||
{
|
||||
return _flashVarUserName;
|
||||
}
|
||||
|
||||
public function set myFlashVarUserName(param1:String) : void
|
||||
{
|
||||
_flashVarUserName = param1;
|
||||
}
|
||||
|
||||
public function isInMinigame() : Boolean
|
||||
{
|
||||
return this._gamePlay != null && Boolean(this._gamePlay["isInMinigame"]());
|
||||
}
|
||||
|
||||
public function setAvatarOffsets(param1:Array) : void
|
||||
{
|
||||
LayerAnim.avOffsets = param1;
|
||||
}
|
||||
|
||||
public function switchServersIfNeeded(param1:String) : Boolean
|
||||
{
|
||||
DebugUtility.debugTrace("switchServersIfNeeded called with newNode:" + param1);
|
||||
var _loc2_:String = param1;
|
||||
DebugUtility.debugTrace("checking new node:" + _loc2_ + " vs old node:" + this._client.serverIp);
|
||||
if(this._client.serverIp == _loc2_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this._gamePlay["reconnecting"] = true;
|
||||
this._gamePlay["showLoadProgress"](true,LoadProgress.JOINING_SERVER);
|
||||
this._client.switchServerNode(_loc2_);
|
||||
this._client.disconnect();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Singleton
|
||||
{
|
||||
|
||||
public function Singleton()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package Party
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
import gui.PartyManager;
|
||||
|
||||
public class PartyXtCommManager
|
||||
{
|
||||
|
||||
public function PartyXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function sendJoinPartyRequest(param1:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("sj",[param1]);
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Object = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "sl":
|
||||
PartyManager.partyListResponse(_loc2_);
|
||||
break;
|
||||
case "sj":
|
||||
PartyManager.roomSoireeResponse(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,552 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import item.Item;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class Utility
|
||||
{
|
||||
|
||||
private static var _notEnoughGemsPopup:MovieClip;
|
||||
|
||||
private static var _loadingMediaHelper:MediaHelper;
|
||||
|
||||
private static var _showLoadingSpiral:Function;
|
||||
|
||||
private static var _darken:Function;
|
||||
|
||||
private static var _undarken:Function;
|
||||
|
||||
private static const AUDIO_TYPE:int = 4;
|
||||
|
||||
private static const NOT_ENOUGH_GEMS_POPUP_ID:int = 1245;
|
||||
|
||||
public static const ACCOUNT_TYPE_ARCHIVED:int = -2;
|
||||
|
||||
public static const ACCOUNT_TYPE_NEW:int = -1;
|
||||
|
||||
public static const ACCOUNT_TYPE_NONE:int = 0;
|
||||
|
||||
public static const NON_MEMBER:int = 1;
|
||||
|
||||
public static const PREMIUM_MEMBER:int = 2;
|
||||
|
||||
public static const BETA_MEMBER:int = 3;
|
||||
|
||||
public static const INTERNAL:int = 4;
|
||||
|
||||
public static const COMMUNITY:int = 5;
|
||||
|
||||
public static const ENVIRO_LAND:int = 0;
|
||||
|
||||
public static const ENVIRO_OCEAN:int = 1;
|
||||
|
||||
public static const ROOMTYPE_WORLD:int = 0;
|
||||
|
||||
public static const ROOMTYPE_GAME:int = 1;
|
||||
|
||||
public static const ROOMTYPE_DEN:int = 2;
|
||||
|
||||
public static const ROOMTYPE_LOBBY:int = 3;
|
||||
|
||||
public static const ROOMTYPE_FFM:int = 4;
|
||||
|
||||
public static const ROOMTYPE_PARTY:int = 5;
|
||||
|
||||
public static const ROOMTYPE_WORLDGAME:int = 6;
|
||||
|
||||
public static const ROOMTYPE_QUEST:int = 7;
|
||||
|
||||
public static const ROOMTYPE_QUEST_STAGING:int = 8;
|
||||
|
||||
public function Utility()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:Function, param2:Function, param3:Function) : void
|
||||
{
|
||||
_showLoadingSpiral = param1;
|
||||
_darken = param2;
|
||||
_undarken = param3;
|
||||
}
|
||||
|
||||
public static function isLand(param1:int) : Boolean
|
||||
{
|
||||
return (param1 & 1) == 1;
|
||||
}
|
||||
|
||||
public static function isOcean(param1:int) : Boolean
|
||||
{
|
||||
return (param1 >> ENVIRO_OCEAN & 1) == 1;
|
||||
}
|
||||
|
||||
public static function isSameEnviroType(param1:int, param2:int) : Boolean
|
||||
{
|
||||
if(param2 == ENVIRO_LAND)
|
||||
{
|
||||
return isLand(param1);
|
||||
}
|
||||
return isOcean(param1);
|
||||
}
|
||||
|
||||
public static function isRoomOfThisType(param1:int) : Boolean
|
||||
{
|
||||
return gMainFrame.clientInfo.roomType == param1;
|
||||
}
|
||||
|
||||
public static function sortItems(param1:Array, param2:int, param3:int, param4:int = -1, param5:int = -1) : Array
|
||||
{
|
||||
var _loc7_:Array = null;
|
||||
var _loc12_:Object = null;
|
||||
var _loc13_:int = 0;
|
||||
var _loc6_:Array = param1.concat();
|
||||
_loc7_ = [];
|
||||
var _loc8_:int = param2;
|
||||
var _loc9_:int = 0;
|
||||
var _loc10_:int = -1;
|
||||
var _loc11_:int = int(_loc6_.length);
|
||||
while(_loc8_ < _loc11_)
|
||||
{
|
||||
_loc12_ = _loc6_[_loc8_];
|
||||
if(_loc12_ is Item)
|
||||
{
|
||||
_loc13_ = int(_loc12_.layerId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = int(_loc12_.sortId);
|
||||
}
|
||||
if(_loc12_.isOcean)
|
||||
{
|
||||
if(_loc10_ == -1)
|
||||
{
|
||||
_loc10_ = convertOceanSortId(param3);
|
||||
}
|
||||
if(_loc13_ == _loc10_)
|
||||
{
|
||||
_loc7_[_loc9_] = _loc6_[_loc8_];
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
else if(_loc13_ == param3 || _loc13_ == param4 || _loc13_ == param5)
|
||||
{
|
||||
_loc7_[_loc9_] = _loc6_[_loc8_];
|
||||
_loc9_++;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
public static function sortItemsAll(param1:Array, param2:int, param3:int, param4:int = -1, param5:int = -1) : Array
|
||||
{
|
||||
var _loc7_:Array = null;
|
||||
var _loc11_:Boolean = false;
|
||||
var _loc12_:Object = null;
|
||||
var _loc13_:int = 0;
|
||||
var _loc6_:Array = param1.concat();
|
||||
_loc7_ = [];
|
||||
var _loc8_:int = param2;
|
||||
var _loc9_:int = 0;
|
||||
var _loc10_:int = -1;
|
||||
while(_loc8_ < _loc6_.length)
|
||||
{
|
||||
_loc11_ = false;
|
||||
_loc12_ = _loc6_[_loc8_];
|
||||
if(_loc12_ is Item)
|
||||
{
|
||||
_loc13_ = int(_loc12_.layerId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = int(_loc12_.sortId);
|
||||
}
|
||||
if(_loc12_.isOcean)
|
||||
{
|
||||
if(_loc10_ == -1)
|
||||
{
|
||||
_loc10_ = convertOceanSortId(param3);
|
||||
}
|
||||
if(_loc13_ == _loc10_)
|
||||
{
|
||||
_loc7_[_loc9_] = _loc6_[_loc8_];
|
||||
_loc11_ = true;
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
else if(_loc13_ == param3 || _loc13_ == param4 || _loc13_ == param5)
|
||||
{
|
||||
_loc7_[_loc9_] = _loc6_[_loc8_];
|
||||
_loc11_ = true;
|
||||
_loc9_++;
|
||||
}
|
||||
if(_loc11_)
|
||||
{
|
||||
_loc6_.splice(_loc8_,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
return _loc7_.concat(_loc6_);
|
||||
}
|
||||
|
||||
public static function sortByItem(param1:Array, param2:int) : Array
|
||||
{
|
||||
param1 = param1.concat();
|
||||
if(param1[0] is Item)
|
||||
{
|
||||
param1.sortOn(["accId","color"],Array.NUMERIC | Array.DESCENDING);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.sortOn(["sortId","itemDefId","version"],Array.NUMERIC);
|
||||
}
|
||||
return param1;
|
||||
}
|
||||
|
||||
private static function convertOceanSortId(param1:int) : int
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case Item.HEAD_LAYER_1:
|
||||
case Item.HEAD_LAYER_2:
|
||||
case Item.HEAD_LAYER_3:
|
||||
return Item.OCEAN_HEAD_LAYER;
|
||||
case Item.BACK_LAYER:
|
||||
return Item.OCEAN_BACK_LAYER;
|
||||
case Item.LEG_LAYER:
|
||||
return Item.OCEAN_LEG_LAYER;
|
||||
case Item.NECK_LAYER:
|
||||
return Item.OCEAN_NECK_LAYER;
|
||||
default:
|
||||
return param1;
|
||||
}
|
||||
}
|
||||
|
||||
public static function numDenItemsInList(param1:Array, param2:int, param3:Boolean = false) : int
|
||||
{
|
||||
return int(denItemsInList(param1,param2,true,param3));
|
||||
}
|
||||
|
||||
public static function denItemListByEnviroType(param1:Array, param2:int, param3:Boolean = false) : Array
|
||||
{
|
||||
return denItemsInList(param1,param2,false,param3) as Array;
|
||||
}
|
||||
|
||||
private static function denItemsInList(param1:Array, param2:int, param3:Boolean = false, param4:Boolean = false) : Object
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc5_:Array = [];
|
||||
if(param1)
|
||||
{
|
||||
_loc6_ = int(param1.length);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc6_)
|
||||
{
|
||||
if(param4)
|
||||
{
|
||||
if(param1[_loc7_].sortId == AUDIO_TYPE)
|
||||
{
|
||||
_loc5_.push(param1[_loc7_]);
|
||||
}
|
||||
}
|
||||
else if(param1[_loc7_].sortId != AUDIO_TYPE)
|
||||
{
|
||||
if(param2 == -1 || param1[_loc7_].enviroType == param2)
|
||||
{
|
||||
_loc5_.push(param1[_loc7_]);
|
||||
}
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
if(param3)
|
||||
{
|
||||
return _loc5_.length;
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
public static function numClothingItemsInList(param1:Array, param2:int) : int
|
||||
{
|
||||
return int(clothingItemsInList(param1,param2,true));
|
||||
}
|
||||
|
||||
public static function clothingItemListByEnviroType(param1:Array, param2:int) : Array
|
||||
{
|
||||
return clothingItemsInList(param1,param2,false) as Array;
|
||||
}
|
||||
|
||||
private static function clothingItemsInList(param1:Array, param2:int, param3:Boolean = false) : Object
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:Array = [];
|
||||
if(param1)
|
||||
{
|
||||
_loc5_ = int(param1.length);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc5_)
|
||||
{
|
||||
if(param1[_loc6_].enviroType == param2)
|
||||
{
|
||||
_loc4_.push(param1[_loc6_]);
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
if(param3)
|
||||
{
|
||||
return _loc4_.length;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
public static function setupNotEnoughGemsPopup(param1:DisplayObjectContainer, param2:int, param3:int = 0, param4:Function = null) : void
|
||||
{
|
||||
if(_notEnoughGemsPopup)
|
||||
{
|
||||
_showLoadingSpiral(false);
|
||||
_notEnoughGemsPopup.x = MainFrame.VIEW_WIDTH * 0.5;
|
||||
_notEnoughGemsPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
|
||||
if(param3 == Item.GEM_CURRENCY)
|
||||
{
|
||||
_notEnoughGemsPopup.currency.gotoAndStop("gems");
|
||||
_notEnoughGemsPopup.gemsTxt.text = gMainFrame.clientInfo.gemCount;
|
||||
}
|
||||
else if(param3 == Item.TICKET_CURRENCY)
|
||||
{
|
||||
_notEnoughGemsPopup.currency.gotoAndStop("tickets");
|
||||
_notEnoughGemsPopup.gemsTxt.text = gMainFrame.clientInfo.ticketCount;
|
||||
}
|
||||
else if(param3 == Item.ORB_CURRENCY)
|
||||
{
|
||||
_notEnoughGemsPopup.currency.gotoAndStop("orbs");
|
||||
_notEnoughGemsPopup.gemsTxt.text = gMainFrame.clientInfo.orbCount;
|
||||
}
|
||||
else if(param3 == Item.DIAMOND_CURRENCY)
|
||||
{
|
||||
_notEnoughGemsPopup.currency.gotoAndStop("diamonds");
|
||||
_notEnoughGemsPopup.gemsTxt.text = gMainFrame.clientInfo.diamondCount;
|
||||
}
|
||||
_notEnoughGemsPopup.costTxt.text = param2;
|
||||
_notEnoughGemsPopup.needTxt.text = param2 - int(_notEnoughGemsPopup.gemsTxt.text);
|
||||
_notEnoughGemsPopup.addEventListener(MouseEvent.MOUSE_DOWN,onPopupDown,false,0,true);
|
||||
_notEnoughGemsPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,onClose,false,0,true);
|
||||
_notEnoughGemsPopup.closeCallback = param4;
|
||||
param1.addChild(_notEnoughGemsPopup);
|
||||
_darken(_notEnoughGemsPopup);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loadingMediaHelper = new MediaHelper();
|
||||
_loadingMediaHelper.init(NOT_ENOUGH_GEMS_POPUP_ID,onMediaItemLoaded,{
|
||||
"guiLayer":param1,
|
||||
"itemCost":param2,
|
||||
"currencyType":param3,
|
||||
"callback":param4
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static function onMediaItemLoaded(param1:MovieClip) : void
|
||||
{
|
||||
if(param1.mediaHelper.id == NOT_ENOUGH_GEMS_POPUP_ID)
|
||||
{
|
||||
SBTracker.push();
|
||||
SBTracker.trackPageview("/game/play/popup/avatarSwitch/buyAnimal_notEnoughGems");
|
||||
_notEnoughGemsPopup = MovieClip(param1.getChildAt(0));
|
||||
setupNotEnoughGemsPopup(param1.passback.guiLayer,param1.passback.itemCost,param1.passback.currencyType,param1.passback.callback);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onPopupDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
|
||||
private static function onClose(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(param1.currentTarget.parent == _notEnoughGemsPopup)
|
||||
{
|
||||
SBTracker.pop();
|
||||
_undarken(_notEnoughGemsPopup);
|
||||
_notEnoughGemsPopup.parent.removeChild(_notEnoughGemsPopup);
|
||||
if(_notEnoughGemsPopup.closeCallback != null)
|
||||
{
|
||||
_notEnoughGemsPopup.closeCallback();
|
||||
_notEnoughGemsPopup.closeCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function canBuddy() : Boolean
|
||||
{
|
||||
return (gMainFrame.clientInfo.interactions & 1) == 1;
|
||||
}
|
||||
|
||||
public static function canTrade() : Boolean
|
||||
{
|
||||
return (gMainFrame.clientInfo.interactions >> 1 & 1) == 1;
|
||||
}
|
||||
|
||||
public static function canGift() : Boolean
|
||||
{
|
||||
return (gMainFrame.clientInfo.interactions >> 2 & 1) == 1;
|
||||
}
|
||||
|
||||
public static function canChat() : Boolean
|
||||
{
|
||||
return (gMainFrame.clientInfo.interactions >> 3 & 1) == 1;
|
||||
}
|
||||
|
||||
public static function canJAG() : Boolean
|
||||
{
|
||||
return (gMainFrame.clientInfo.interactions >> 4 & 1) == 1;
|
||||
}
|
||||
|
||||
public static function canMultiplayer() : Boolean
|
||||
{
|
||||
return (gMainFrame.clientInfo.interactions >> 5 & 1) == 1;
|
||||
}
|
||||
|
||||
public static function canPVP() : Boolean
|
||||
{
|
||||
return (gMainFrame.clientInfo.interactions >> 6 & 1) == 1;
|
||||
}
|
||||
|
||||
public static function canQuest() : Boolean
|
||||
{
|
||||
return (gMainFrame.clientInfo.interactions >> 7 & 1) == 1;
|
||||
}
|
||||
|
||||
public static function calculatePrintTime(param1:int, param2:int, param3:Boolean = false, param4:int = 0) : String
|
||||
{
|
||||
var _loc5_:String = null;
|
||||
if(param2 > 0 || param4 > 0)
|
||||
{
|
||||
if(param1 == 0)
|
||||
{
|
||||
param3 = true;
|
||||
}
|
||||
if(param4 > 0)
|
||||
{
|
||||
if(param4 == 1)
|
||||
{
|
||||
_loc5_ = param4 + " day ";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = param4 + " days ";
|
||||
}
|
||||
}
|
||||
if(param3)
|
||||
{
|
||||
if(param2 == 1)
|
||||
{
|
||||
_loc5_ = _loc5_ + param2 + " hour";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _loc5_ + param2 + " hours";
|
||||
}
|
||||
if(param1 == 1)
|
||||
{
|
||||
_loc5_ = _loc5_ + " and " + param1 + " minute";
|
||||
}
|
||||
else if(param1 != 0)
|
||||
{
|
||||
_loc5_ = _loc5_ + " and " + param1 + " minutes";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(param2 == 1)
|
||||
{
|
||||
_loc5_ = _loc5_ + param2 + " hr ";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _loc5_ + param2 + " hrs ";
|
||||
}
|
||||
if(param1 == 1)
|
||||
{
|
||||
_loc5_ = _loc5_ + param1 + " min";
|
||||
}
|
||||
else if(param1 != 0)
|
||||
{
|
||||
_loc5_ = _loc5_ + param1 + " mins";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(param1 == 1)
|
||||
{
|
||||
_loc5_ = param1 + " minute";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = param1 + " minutes";
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
public static function calculateTime(param1:int) : Object
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc2_:Number = 0;
|
||||
var _loc6_:Number = Math.ceil(param1 / 60);
|
||||
if(_loc6_ < 60)
|
||||
{
|
||||
_loc5_ = _loc6_;
|
||||
_loc3_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = _loc6_ / 60;
|
||||
if(_loc4_ >= 24)
|
||||
{
|
||||
_loc2_ = _loc4_ / 24;
|
||||
_loc3_ = (_loc2_ - Math.floor(_loc2_)) * 24;
|
||||
_loc5_ = (_loc3_ - Math.floor(_loc3_)) * 60;
|
||||
_loc3_ = Math.floor(_loc3_);
|
||||
_loc2_ = int(_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = Math.floor(_loc4_);
|
||||
_loc5_ = Math.ceil((_loc4_ - Math.floor(_loc4_)) * 60);
|
||||
}
|
||||
}
|
||||
return {
|
||||
"days":_loc2_,
|
||||
"hours":_loc3_,
|
||||
"mins":_loc5_
|
||||
};
|
||||
}
|
||||
|
||||
public static function convertNumberToString(param1:int) : String
|
||||
{
|
||||
if(param1 > 999)
|
||||
{
|
||||
return param1.toString().replace(/\d{1,3}(?=(\d{3})+(?!\d))/g,"$&,");
|
||||
}
|
||||
return param1.toString();
|
||||
}
|
||||
|
||||
public static function isMember(param1:int) : Boolean
|
||||
{
|
||||
return param1 >= PREMIUM_MEMBER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.Timer;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
public class XtReplyDemuxer
|
||||
{
|
||||
|
||||
private static var _delayList:Array;
|
||||
|
||||
private static var _delayTimer:Timer;
|
||||
|
||||
private static var _xtReplyCallbacks:Array;
|
||||
|
||||
private static var _xtReplyCommands:Array;
|
||||
|
||||
private static var MSG_DELAY_MS:int = 0;
|
||||
|
||||
public function XtReplyDemuxer()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
if(MSG_DELAY_MS > 0)
|
||||
{
|
||||
_delayList = [];
|
||||
_delayTimer = new Timer(10);
|
||||
_delayTimer.addEventListener(TimerEvent.TIMER,delayTimerHandler,false,0,true);
|
||||
_delayTimer.start();
|
||||
}
|
||||
_xtReplyCallbacks = [];
|
||||
_xtReplyCommands = [];
|
||||
gMainFrame.server.addEventListener(SFEvent.ON_XT_REPLY,xtReplyHandler,false,0,true);
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_delayList = null;
|
||||
if(_delayTimer)
|
||||
{
|
||||
if(_delayTimer.running)
|
||||
{
|
||||
_delayTimer.stop();
|
||||
}
|
||||
_delayTimer = null;
|
||||
}
|
||||
_xtReplyCallbacks = null;
|
||||
_xtReplyCommands = null;
|
||||
gMainFrame.server.removeEventListener(SFEvent.ON_XT_REPLY,xtReplyHandler);
|
||||
}
|
||||
|
||||
public static function addModule(param1:Function, param2:String) : void
|
||||
{
|
||||
_xtReplyCallbacks.push(param1);
|
||||
_xtReplyCommands.push(param2);
|
||||
}
|
||||
|
||||
public static function removeModule(param1:Function) : void
|
||||
{
|
||||
var _loc2_:int = _xtReplyCallbacks.indexOf(param1);
|
||||
if(_loc2_ >= 0)
|
||||
{
|
||||
_xtReplyCallbacks.splice(_loc2_,1);
|
||||
_xtReplyCommands.splice(_loc2_,1);
|
||||
return;
|
||||
}
|
||||
throw new Error("module not found! callback:" + param1);
|
||||
}
|
||||
|
||||
public static function xtReplyHandler(param1:SFEvent) : void
|
||||
{
|
||||
if(_xtReplyCallbacks[_xtReplyCommands.indexOf(param1.obj[0].charAt(0))] == undefined)
|
||||
{
|
||||
throw new Error("ERROR: undefined module command:" + param1.obj[0]);
|
||||
}
|
||||
var _loc2_:Function = _xtReplyCallbacks[_xtReplyCommands.indexOf(param1.obj[0].charAt(0))];
|
||||
if(MSG_DELAY_MS == 0)
|
||||
{
|
||||
_loc2_(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_delayList.push({
|
||||
"f":_loc2_,
|
||||
"e":param1,
|
||||
"ts":getTimer() + MSG_DELAY_MS
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static function delayTimerHandler(param1:TimerEvent) : void
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
var _loc2_:uint = uint(getTimer());
|
||||
var _loc4_:* = 0;
|
||||
while(_loc4_ < _delayList.length)
|
||||
{
|
||||
_loc3_ = _delayList[_loc4_];
|
||||
if(_loc3_.ts >= _loc2_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc3_.f(_loc3_.e);
|
||||
_delayList.splice(0,1);
|
||||
_loc4_--;
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
package achievement
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class Achievement
|
||||
{
|
||||
|
||||
public static var GEMS_EARNED:int = 1;
|
||||
|
||||
public static var GEMS_SPENT:int = 2;
|
||||
|
||||
public static var SHOP_DEN_ITEM:int = 3;
|
||||
|
||||
public static var SHOP_ACCESSORY:int = 4;
|
||||
|
||||
public static var MAIL_SEND:int = 38;
|
||||
|
||||
public static var MAIL_GIFT:int = 39;
|
||||
|
||||
public static var BUDDY_ADDED:int = 40;
|
||||
|
||||
public static var MEMBER_NEW:int = 66;
|
||||
|
||||
public static var BASE_MEDAL_ID:int = 289;
|
||||
|
||||
public static var BASE_RIBBON_ID:int = 290;
|
||||
|
||||
public static var BASE_TROPHY_ID:int = 291;
|
||||
|
||||
private var _invId:int;
|
||||
|
||||
private var _baseImageMediaId:int;
|
||||
|
||||
private var _iconMediaId:int;
|
||||
|
||||
private var _name:String;
|
||||
|
||||
private var _descr:String;
|
||||
|
||||
private var _mediaText:String;
|
||||
|
||||
private var _baseImage:Sprite;
|
||||
|
||||
private var _baseImageHelper:MediaHelper;
|
||||
|
||||
private var _icon:Sprite;
|
||||
|
||||
private var _iconHelper:MediaHelper;
|
||||
|
||||
private var _baseImageReceived:Boolean;
|
||||
|
||||
private var _iconReceived:Boolean;
|
||||
|
||||
private var _isMyAchievement:Boolean;
|
||||
|
||||
private var _scalePercent:Number = 1;
|
||||
|
||||
private var _xPos:Number = 0;
|
||||
|
||||
private var _yPos:Number = 0;
|
||||
|
||||
public function Achievement()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:int, param2:int, param3:int, param4:String, param5:String = "", param6:Boolean = false) : void
|
||||
{
|
||||
this._invId = param1;
|
||||
this._baseImageMediaId = param2;
|
||||
this._iconMediaId = param3;
|
||||
this._name = param4;
|
||||
this._mediaText = param5;
|
||||
this._isMyAchievement = param6;
|
||||
this._baseImage = new Sprite();
|
||||
this._baseImageHelper = new MediaHelper();
|
||||
this._baseImageHelper.init(this._baseImageMediaId,this.baseImageReceived);
|
||||
this._icon = new Sprite();
|
||||
this._iconHelper = new MediaHelper();
|
||||
this._iconHelper.init(this._iconMediaId,this.iconReceived);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(this._iconHelper)
|
||||
{
|
||||
this._iconHelper.destroy();
|
||||
}
|
||||
if(this._baseImageHelper)
|
||||
{
|
||||
this._baseImageHelper.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public function clone() : Achievement
|
||||
{
|
||||
var _loc1_:Achievement = null;
|
||||
_loc1_ = new Achievement();
|
||||
_loc1_.init(this._invId,this._baseImageMediaId,this._iconMediaId,this._name,this._mediaText,this._isMyAchievement);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function setScale(param1:Number) : void
|
||||
{
|
||||
this._scalePercent = param1;
|
||||
if(this._iconReceived && this._baseImageReceived)
|
||||
{
|
||||
this._baseImage.scaleX = this._scalePercent;
|
||||
this._baseImage.scaleY = this._scalePercent;
|
||||
}
|
||||
}
|
||||
|
||||
public function setPosition(param1:Number, param2:Number) : void
|
||||
{
|
||||
this._xPos = param1;
|
||||
this._yPos = param2;
|
||||
if(this._iconReceived && this._baseImageReceived)
|
||||
{
|
||||
this._baseImage.x = -this._baseImage.width * this._xPos;
|
||||
this._baseImage.y = -this._baseImage.height * this._yPos;
|
||||
}
|
||||
}
|
||||
|
||||
private function baseImageReceived(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
if(param1)
|
||||
{
|
||||
param1 = MovieClip(param1.getChildAt(0));
|
||||
this._baseImage.addChild(param1);
|
||||
if(this._iconReceived)
|
||||
{
|
||||
param1.itemBlock.addChild(this._icon);
|
||||
this.allImagesLoaded();
|
||||
}
|
||||
if(this._mediaText == "")
|
||||
{
|
||||
param1.num.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.num.txt.text = this._mediaText;
|
||||
_loc2_ = Number(param1.num.txt.textWidth);
|
||||
if(_loc2_ > 15)
|
||||
{
|
||||
if(_loc2_ > 25)
|
||||
{
|
||||
param1.num.gotoAndPlay(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.num.gotoAndPlay(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
this._baseImageHelper.destroy();
|
||||
this._baseImageHelper = null;
|
||||
this._baseImageReceived = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function iconReceived(param1:MovieClip) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
this._icon.addChild(param1);
|
||||
if(this._baseImageReceived)
|
||||
{
|
||||
MovieClip(this._baseImage.getChildAt(0)).itemBlock.addChild(this._icon);
|
||||
this.allImagesLoaded();
|
||||
}
|
||||
this._iconHelper.destroy();
|
||||
this._iconHelper = null;
|
||||
this._iconReceived = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function allImagesLoaded() : void
|
||||
{
|
||||
var _loc1_:Number = 0.9;
|
||||
if(this._isMyAchievement)
|
||||
{
|
||||
_loc1_ = 1;
|
||||
}
|
||||
this._baseImage.scaleX = _loc1_ * this._scalePercent;
|
||||
this._baseImage.scaleY = _loc1_ * this._scalePercent;
|
||||
this._baseImage.x = -this._baseImage.width * this._xPos;
|
||||
this._baseImage.y = -this._baseImage.height * this._yPos;
|
||||
}
|
||||
|
||||
public function get invId() : int
|
||||
{
|
||||
return this._invId;
|
||||
}
|
||||
|
||||
public function get baseImageMediaId() : int
|
||||
{
|
||||
return this._baseImageMediaId;
|
||||
}
|
||||
|
||||
public function get iconMediaId() : int
|
||||
{
|
||||
return this._iconMediaId;
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return this._name;
|
||||
}
|
||||
|
||||
public function get descr() : String
|
||||
{
|
||||
return this._descr;
|
||||
}
|
||||
|
||||
public function get mediaText() : String
|
||||
{
|
||||
return this._mediaText;
|
||||
}
|
||||
|
||||
public function get image() : Sprite
|
||||
{
|
||||
return this._baseImage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
package achievement
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.Timer;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class AchievementManager
|
||||
{
|
||||
|
||||
private static var _newAchievements:Array;
|
||||
|
||||
private static var _finishedCallbacks:Array;
|
||||
|
||||
private static var _popupMediaHelper:MediaHelper;
|
||||
|
||||
private static var _achievementPopup:MovieClip;
|
||||
|
||||
private static var _achievementImg:Sprite;
|
||||
|
||||
private static var _popupDisplayTimer:Timer;
|
||||
|
||||
private static var _popupDelayTimer:Timer;
|
||||
|
||||
private static var _state:int;
|
||||
|
||||
private static var _fpsLayer:DisplayObjectContainer;
|
||||
|
||||
private static const ACHIEVEMENT_POPUP_MEDIA_ID:int = 282;
|
||||
|
||||
private static const STATE_IDLE:int = 0;
|
||||
|
||||
private static const STATE_DISPLAYING:int = 1;
|
||||
|
||||
public function AchievementManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
_fpsLayer = param1;
|
||||
_popupMediaHelper = new MediaHelper();
|
||||
_popupMediaHelper.init(ACHIEVEMENT_POPUP_MEDIA_ID,popupHelperCallback);
|
||||
_finishedCallbacks = [];
|
||||
_newAchievements = [];
|
||||
_popupDisplayTimer = new Timer(3000);
|
||||
_popupDelayTimer = new Timer(500);
|
||||
_state = STATE_IDLE;
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_newAchievements.splice(0,_newAchievements.length);
|
||||
_newAchievements = null;
|
||||
_finishedCallbacks.splice(0,_finishedCallbacks.length);
|
||||
_finishedCallbacks = null;
|
||||
if(_popupDisplayTimer)
|
||||
{
|
||||
_popupDisplayTimer.stop();
|
||||
_popupDisplayTimer = null;
|
||||
}
|
||||
if(_popupDelayTimer)
|
||||
{
|
||||
_popupDelayTimer.stop();
|
||||
_popupDelayTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function hasAchievement() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function displayNewAchievements(param1:Function = null) : void
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
if(_finishedCallbacks.indexOf(param1) < 0 && _newAchievements.length > 0)
|
||||
{
|
||||
_finishedCallbacks.push(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1();
|
||||
}
|
||||
}
|
||||
if(_state == STATE_IDLE && _newAchievements.length > 0)
|
||||
{
|
||||
_state = STATE_DISPLAYING;
|
||||
displayNextAchievement();
|
||||
}
|
||||
}
|
||||
|
||||
private static function finishedDisplayingNewAchievements() : void
|
||||
{
|
||||
var _loc1_:int = int(_finishedCallbacks.length);
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < _loc1_)
|
||||
{
|
||||
_finishedCallbacks[_loc2_]();
|
||||
_loc2_++;
|
||||
}
|
||||
_finishedCallbacks.splice(0,_finishedCallbacks.length);
|
||||
}
|
||||
|
||||
private static function displayNextAchievement() : void
|
||||
{
|
||||
var _loc1_:Achievement = _newAchievements[0];
|
||||
_achievementImg = _loc1_.image;
|
||||
_loc1_.setScale(2);
|
||||
_loc1_.setPosition(0.5,0.5);
|
||||
_achievementPopup.achievementWindow.itemBlock.addChild(_achievementImg);
|
||||
_achievementPopup.achievementWindow.acmtNameTxt.text = _loc1_.name;
|
||||
_fpsLayer.addChild(_achievementPopup);
|
||||
_achievementPopup.gotoAndPlay(1);
|
||||
_achievementPopup.achievementWindow.gotoAndPlay(1);
|
||||
AJAudio.playAchievementSound();
|
||||
_popupDisplayTimer.start();
|
||||
_popupDisplayTimer.addEventListener("timer",onDisplayTimerFinished,false,0,true);
|
||||
}
|
||||
|
||||
private static function onDisplayTimerFinished(param1:TimerEvent) : void
|
||||
{
|
||||
_popupDisplayTimer.stop();
|
||||
_fpsLayer.removeChild(_achievementPopup);
|
||||
_achievementPopup.achievementWindow.itemBlock.removeChild(_achievementImg);
|
||||
_newAchievements.splice(0,1);
|
||||
if(_newAchievements.length > 0)
|
||||
{
|
||||
_popupDelayTimer.start();
|
||||
_popupDelayTimer.addEventListener("timer",onDelayTimerFinished,false,0,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_state = STATE_IDLE;
|
||||
finishedDisplayingNewAchievements();
|
||||
}
|
||||
}
|
||||
|
||||
private static function onDelayTimerFinished(param1:TimerEvent) : void
|
||||
{
|
||||
_popupDelayTimer.stop();
|
||||
displayNextAchievement();
|
||||
}
|
||||
|
||||
private static function popupHelperCallback(param1:MovieClip) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_achievementPopup = new MovieClip();
|
||||
_achievementPopup = param1;
|
||||
_achievementPopup.visible = true;
|
||||
_achievementPopup.addEventListener(MouseEvent.MOUSE_DOWN,onPopupDown,false,0,true);
|
||||
_popupMediaHelper.destroy();
|
||||
_popupMediaHelper = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onPopupDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
|
||||
public static function addAchievement(param1:Achievement) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_newAchievements.push(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
package achievement
|
||||
{
|
||||
import avatar.UserInfo;
|
||||
import com.sbi.client.SFEvent;
|
||||
|
||||
public class AchievementXtCommManager
|
||||
{
|
||||
|
||||
private static var _zaCallback:Function;
|
||||
|
||||
private static var _inMinigame:Function;
|
||||
|
||||
private static var _onUserVarsReceived:Function;
|
||||
|
||||
private static var _setGemBonusValues:Function;
|
||||
|
||||
private static var _bMyUserVarsReceived:Boolean;
|
||||
|
||||
private static var _zsCallbacks:Object;
|
||||
|
||||
public static const UV_JAMAA_JOURNAL_TIMESTAMP:int = 112;
|
||||
|
||||
public static const UV_JAMAA_JOURNAL_TIMESTAMP_STARTUP:int = 158;
|
||||
|
||||
public static const UV_BRADY_BARR_COUNT:int = 128;
|
||||
|
||||
public static const UV_TRADING:int = 129;
|
||||
|
||||
public static const UV_PET_COUNTER:int = 212;
|
||||
|
||||
public static const UV_DAILY_GEM_BONUS:int = 214;
|
||||
|
||||
public static const UV_AVT_VIEWABLE_FLAG:int = 287;
|
||||
|
||||
public static const UV_TIERNEY_THYS_COUNT:int = 297;
|
||||
|
||||
public static const UV_PET_INVENTORY_MAX:int = 338;
|
||||
|
||||
public static const UV_PET_VIEWABLE_FLAG:int = 342;
|
||||
|
||||
public static const UV_SETTINGS:int = 363;
|
||||
|
||||
public static const UV_PARTY_JB_ENTER:int = 366;
|
||||
|
||||
public static const UV_PARTY_JB_ENTER_BIT_ARRAY:Array = [27];
|
||||
|
||||
public static const ACHIEVEMENT_REQUEST_INTERVAL:int = 10000;
|
||||
|
||||
public function AchievementXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:Function, param2:Function, param3:Function) : void
|
||||
{
|
||||
_inMinigame = param1;
|
||||
_onUserVarsReceived = param2;
|
||||
_setGemBonusValues = param3;
|
||||
_zsCallbacks = new Object();
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_zsCallbacks = null;
|
||||
}
|
||||
|
||||
public static function requestAchievements(param1:String, param2:Function = null) : void
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc3_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(param1);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc4_ = _loc3_.getTimeOfLastAchievementRequest();
|
||||
_loc5_ = new Date().getTime();
|
||||
if(_loc5_ - _loc4_ > ACHIEVEMENT_REQUEST_INTERVAL)
|
||||
{
|
||||
_zaCallback = param2;
|
||||
_loc3_.setTimeOfLastAchievementRequest(_loc5_);
|
||||
if(_loc4_ == 0)
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("za",[param1,-1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("za",[param1,int((_loc5_ - _loc4_) / 1000)]);
|
||||
}
|
||||
}
|
||||
else if(param2 != null)
|
||||
{
|
||||
param2(_loc3_.achievements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestSetUserVar(param1:int, param2:int, param3:Function = null, param4:Boolean = true) : void
|
||||
{
|
||||
if(!gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
if(param1 <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(param3 != null)
|
||||
{
|
||||
_zsCallbacks[param1] = {
|
||||
"uv":param1,
|
||||
"c":param3
|
||||
};
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("zs",[param1,param2,param4 ? 1 : 0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestAllUserVars() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("zg",[]);
|
||||
}
|
||||
|
||||
public static function requestDeleteAllAchievementsAndUserVars() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Object = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "za":
|
||||
getAchievementsResponse(_loc2_);
|
||||
break;
|
||||
case "zs":
|
||||
setUserVarResponse(_loc2_);
|
||||
break;
|
||||
case "zg":
|
||||
getUserVarsResponse(_loc2_);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Did not expect ext cmd=" + _loc2_[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function setUserVarResponse(param1:Object) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc7_:Boolean = false;
|
||||
var _loc8_:Array = null;
|
||||
var _loc10_:int = 0;
|
||||
var _loc11_:Achievement = null;
|
||||
var _loc2_:* = 2;
|
||||
var _loc3_:int = 1;
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc4_ = int(param1[_loc2_++]);
|
||||
_loc10_ = int(param1[_loc2_++]);
|
||||
gMainFrame.userInfo.userVarCache.updateUserVar(_loc4_,_loc10_);
|
||||
if(_loc4_ == UV_DAILY_GEM_BONUS)
|
||||
{
|
||||
_setGemBonusValues(_loc10_);
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
var _loc6_:int = int(param1[_loc2_++]);
|
||||
if(_loc6_ > 0)
|
||||
{
|
||||
_loc8_ = [];
|
||||
if(!gMainFrame.userInfo.playerUserInfo.achievements)
|
||||
{
|
||||
_loc7_ = true;
|
||||
}
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc6_)
|
||||
{
|
||||
_loc11_ = new Achievement();
|
||||
_loc11_.init(int(param1[_loc2_++]),int(param1[_loc2_++]),int(param1[_loc2_++]),param1[_loc2_++],param1[_loc2_++],true);
|
||||
_loc8_.unshift(_loc11_);
|
||||
AchievementManager.addAchievement(_loc11_.clone());
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
if(_loc7_)
|
||||
{
|
||||
requestAchievements(gMainFrame.userInfo.playerUserInfo.userName);
|
||||
}
|
||||
else if(_loc8_)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc6_)
|
||||
{
|
||||
gMainFrame.userInfo.playerUserInfo.achievements.unshift(_loc8_[_loc5_]);
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
if(!_inMinigame())
|
||||
{
|
||||
AchievementManager.displayNewAchievements();
|
||||
}
|
||||
var _loc9_:Object = _zsCallbacks[_loc4_];
|
||||
if(_loc9_)
|
||||
{
|
||||
_loc9_.c(_loc4_,_loc10_);
|
||||
}
|
||||
}
|
||||
|
||||
private static function getUserVarsResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:* = 2;
|
||||
var _loc3_:int = int(param1[_loc2_++]);
|
||||
var _loc4_:Object = new Object();
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc4_[int(param1[_loc2_++])] = {
|
||||
"type":int(param1[_loc2_++]),
|
||||
"value":int(param1[_loc2_++])
|
||||
};
|
||||
_loc5_++;
|
||||
}
|
||||
gMainFrame.userInfo.userVarCache.playerUserVars = _loc4_;
|
||||
if(!_bMyUserVarsReceived)
|
||||
{
|
||||
_onUserVarsReceived();
|
||||
}
|
||||
}
|
||||
|
||||
private static function getAchievementsResponse(param1:Object) : void
|
||||
{
|
||||
var _loc6_:Array = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:Achievement = null;
|
||||
var _loc2_:* = 2;
|
||||
var _loc3_:String = param1[_loc2_++];
|
||||
var _loc4_:int = int(param1[_loc2_++]);
|
||||
var _loc5_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(_loc3_);
|
||||
if(_loc4_ > 0)
|
||||
{
|
||||
_loc6_ = new Array(_loc4_);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc4_)
|
||||
{
|
||||
_loc8_ = new Achievement();
|
||||
_loc8_.init(int(param1[_loc2_++]),int(param1[_loc2_++]),int(param1[_loc2_++]),param1[_loc2_++],param1[_loc2_++],_loc3_ == gMainFrame.userInfo.playerUserInfo.userName);
|
||||
_loc6_[_loc7_] = _loc8_;
|
||||
_loc7_++;
|
||||
}
|
||||
_loc6_.sortOn("invId",Array.NUMERIC | Array.DESCENDING);
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc5_.addAchievementsTolist(_loc6_);
|
||||
}
|
||||
}
|
||||
if(_zaCallback != null)
|
||||
{
|
||||
if(_loc3_ == gMainFrame.userInfo.myUserName)
|
||||
{
|
||||
_zaCallback(_loc5_ ? _loc5_.achievements : null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_zaCallback(_loc5_ ? _loc5_.achievements : null,_loc4_ == -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,395 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import item.Item;
|
||||
|
||||
public class AccessoryState
|
||||
{
|
||||
|
||||
private var _accShownItems:Array;
|
||||
|
||||
private var _accShownLayers:Array;
|
||||
|
||||
public var ownerAvatar:Avatar;
|
||||
|
||||
public function AccessoryState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:Avatar) : void
|
||||
{
|
||||
this._accShownItems = [];
|
||||
this._accShownLayers = [];
|
||||
this.ownerAvatar = param1;
|
||||
if(this.ownerAvatar.avName == null)
|
||||
{
|
||||
DebugUtility.debugTrace("break here");
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(this._accShownItems)
|
||||
{
|
||||
this._accShownItems = null;
|
||||
}
|
||||
if(this._accShownLayers)
|
||||
{
|
||||
this._accShownLayers = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function copyShownAccRef(param1:AccessoryState) : void
|
||||
{
|
||||
DebugUtility.debugTrace("AccState copyAcc - ownerAvatar:" + this.ownerAvatar + (this.ownerAvatar ? " name:" + this.ownerAvatar.avName : "") + " copyFrom avatar:" + param1.ownerAvatar + " name:" + param1.ownerAvatar.avName);
|
||||
this.accShownItems = param1.accShownItems;
|
||||
this.accShownLayers = param1.accShownLayers;
|
||||
}
|
||||
|
||||
public function cloneShownAcc(param1:AccessoryState) : void
|
||||
{
|
||||
this.accShownItems = param1.accShownItems;
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < this.accShownItems.length)
|
||||
{
|
||||
this.accShownItems[_loc2_] = this.accShownItems[_loc2_].clone();
|
||||
_loc2_++;
|
||||
}
|
||||
this.accShownLayers = param1.accShownLayers;
|
||||
}
|
||||
|
||||
public function matchShownItems(param1:AccessoryState, param2:Array, param3:Array) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc4_:int = int(param1.accShownItems.length);
|
||||
this.accShownLayers = param1.accShownLayers;
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc4_)
|
||||
{
|
||||
if(param1.accShownItems[_loc5_].type == Item.CLOTHING_TYPE)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < param2.length)
|
||||
{
|
||||
if(param1.accShownItems[_loc5_].invIdx == param2[_loc6_].invIdx)
|
||||
{
|
||||
this.accShownItems[_loc5_] = param2[_loc6_];
|
||||
break;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
else if(param1.accShownItems[_loc5_].type == Item.BODY_MOD_TYPE)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < param3.length)
|
||||
{
|
||||
if(param1.accShownItems[_loc5_].invIdx == param3[_loc7_].invIdx)
|
||||
{
|
||||
this.accShownItems[_loc5_] = param3[_loc7_];
|
||||
break;
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function get accShownItems() : Array
|
||||
{
|
||||
return this._accShownItems;
|
||||
}
|
||||
|
||||
public function set accShownItems(param1:Array) : void
|
||||
{
|
||||
this._accShownItems = param1.concat();
|
||||
}
|
||||
|
||||
public function get accShownLayers() : Array
|
||||
{
|
||||
return this._accShownLayers;
|
||||
}
|
||||
|
||||
public function set accShownLayers(param1:Array) : void
|
||||
{
|
||||
this._accShownLayers = param1.concat();
|
||||
}
|
||||
|
||||
public function showAccessory(param1:Item) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
if(param1)
|
||||
{
|
||||
_loc2_ = 0;
|
||||
_loc3_ = int(this._accShownItems.length);
|
||||
while(_loc2_ < _loc3_)
|
||||
{
|
||||
if(this._accShownItems[_loc2_].invIdx == param1.invIdx)
|
||||
{
|
||||
DebugUtility.debugTrace("accessory showId:" + this._accShownItems[_loc2_].invIdx + " is already visible!");
|
||||
break;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
if(_loc2_ == _loc3_)
|
||||
{
|
||||
param1.setInUse(this.ownerAvatar.dbAvId,true);
|
||||
this.adjustAvatarQuestValues(true,param1);
|
||||
this._accShownItems.push(param1);
|
||||
this._accShownLayers.push(-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("WARNING: showAccessory received a null item");
|
||||
}
|
||||
}
|
||||
|
||||
public function replaceAccessory(param1:Item, param2:Item) : void
|
||||
{
|
||||
if(param1.accId != param2.accId)
|
||||
{
|
||||
throw new Error("Tried to replace accessory with different accId! Layers may not match! oldId:" + param1.accId + " newId:" + param2.accId);
|
||||
}
|
||||
var _loc3_:int = int(this._accShownItems.length);
|
||||
var _loc4_:int = 0;
|
||||
while(_loc4_ < _loc3_)
|
||||
{
|
||||
if(this._accShownItems[_loc4_] == param1)
|
||||
{
|
||||
this._accShownItems[_loc4_] = param2;
|
||||
if(!param2.getInUse(this.ownerAvatar.dbAvId))
|
||||
{
|
||||
this._accShownItems.splice(_loc4_,1);
|
||||
this._accShownLayers.splice(_loc4_,1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function isAccessoryVisibleByItemId(param1:int) : Boolean
|
||||
{
|
||||
var _loc2_:int = int(this._accShownItems.length);
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
if(this._accShownItems[_loc3_].invIdx == param1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isAccessoryVisibleByAccId(param1:int) : Boolean
|
||||
{
|
||||
var _loc2_:int = int(this._accShownItems.length);
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
if(this._accShownItems[_loc3_].accId == param1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isAccessoryVisibleByLayer(param1:int) : Boolean
|
||||
{
|
||||
var _loc2_:int = int(this._accShownLayers.length);
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
if(this._accShownLayers[_loc3_] == param1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hideAccessory(param1:Item) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
if(param1)
|
||||
{
|
||||
_loc2_ = 0;
|
||||
_loc3_ = int(this._accShownItems.length);
|
||||
while(_loc2_ < _loc3_)
|
||||
{
|
||||
if(this._accShownItems[_loc2_].invIdx == param1.invIdx)
|
||||
{
|
||||
param1.setInUse(this.ownerAvatar.dbAvId,false);
|
||||
this.adjustAvatarQuestValues(false,param1);
|
||||
this._accShownItems.splice(_loc2_,1);
|
||||
this._accShownLayers.splice(_loc2_,1);
|
||||
break;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
if(_loc2_ == this._accShownItems.length)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hideAll() : void
|
||||
{
|
||||
while(this._accShownItems.length > 0)
|
||||
{
|
||||
this.hideAccessory(this._accShownItems[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAllItems() : void
|
||||
{
|
||||
this._accShownItems = [];
|
||||
this._accShownLayers = [];
|
||||
this.ownerAvatar.meleeAttack = [0,0];
|
||||
this.ownerAvatar.rangedAttack = [0,0];
|
||||
this.ownerAvatar.fierceAttack = [0,0];
|
||||
this.ownerAvatar.healingPower = [0,0];
|
||||
this.ownerAvatar.defense = [0,0];
|
||||
}
|
||||
|
||||
public function hideAllExceptBase() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = int(this._accShownItems.length);
|
||||
while(_loc1_ < _loc2_)
|
||||
{
|
||||
if(this._accShownLayers[_loc1_] != 1)
|
||||
{
|
||||
this.hideAccessory(this._accShownItems[_loc1_]);
|
||||
_loc2_--;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hideAllClothingArticles(param1:Array = null) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:* = int(this._accShownItems.length);
|
||||
while(_loc2_ < _loc3_)
|
||||
{
|
||||
_loc4_ = int(this._accShownItems[_loc2_].layerId);
|
||||
if(_loc4_ > 3)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
param1.push(this._accShownItems[_loc2_].invIdx);
|
||||
}
|
||||
this.hideAccessory(this._accShownItems[_loc2_]);
|
||||
_loc3_--;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function adjustAvatarQuestValues(param1:Boolean, param2:Item) : void
|
||||
{
|
||||
if(param2.attack < 0)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
this.ownerAvatar.healingPower[0] += param2.attack * -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.healingPower[0] -= param2.attack * -1;
|
||||
}
|
||||
}
|
||||
else if(param2.combatType == Item.COMBAT_TYPE_RANGED)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
this.ownerAvatar.rangedAttack[0] += param2.attack;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.rangedAttack[0] -= param2.attack;
|
||||
}
|
||||
}
|
||||
else if(param1)
|
||||
{
|
||||
this.ownerAvatar.meleeAttack[0] += param2.attack;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.meleeAttack[0] -= param2.attack;
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
this.ownerAvatar.fierceAttack[0] += param2.fierceAttack;
|
||||
this.ownerAvatar.defense[0] += param2.defense;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.fierceAttack[0] -= param2.fierceAttack;
|
||||
this.ownerAvatar.defense[0] -= param2.defense;
|
||||
}
|
||||
switch(param2.modifierType)
|
||||
{
|
||||
case Item.MODIFIER_TYPE_DEFENSE:
|
||||
if(param1)
|
||||
{
|
||||
this.ownerAvatar.defense[1] += param2.modifierValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.defense[1] -= param2.modifierValue;
|
||||
}
|
||||
break;
|
||||
case Item.MODIFIER_TYPE_MELEE:
|
||||
if(param1)
|
||||
{
|
||||
this.ownerAvatar.meleeAttack[1] += param2.modifierValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.meleeAttack[1] -= param2.modifierValue;
|
||||
}
|
||||
break;
|
||||
case Item.MODIFIER_TYPE_RANGED:
|
||||
if(param1)
|
||||
{
|
||||
this.ownerAvatar.rangedAttack[1] += param2.modifierValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.rangedAttack[1] -= param2.modifierValue;
|
||||
}
|
||||
break;
|
||||
case Item.MODIFIER_TYPE_RESTORE:
|
||||
if(param1)
|
||||
{
|
||||
this.ownerAvatar.healingPower[1] += param2.modifierValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.healingPower[1] -= param2.modifierValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.events.EventDispatcher;
|
||||
import item.Inventory;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
|
||||
public class Avatar extends EventDispatcher
|
||||
{
|
||||
|
||||
private var _avName:String;
|
||||
|
||||
private var _userName:String;
|
||||
|
||||
private var _sfsUserId:int;
|
||||
|
||||
private var _dbAvId:int;
|
||||
|
||||
private var _avTypeId:int;
|
||||
|
||||
private var _roomType:int;
|
||||
|
||||
private var _enviroTypeFlag:int;
|
||||
|
||||
private var _colors:Array;
|
||||
|
||||
private var _accState:AccessoryState;
|
||||
|
||||
public var inventoryClothing:Inventory;
|
||||
|
||||
public var inventoryBodyMod:Inventory;
|
||||
|
||||
public var inventoryDenFull:Inventory;
|
||||
|
||||
public var inventoryDenPartial:Inventory;
|
||||
|
||||
public var isShaman:Boolean;
|
||||
|
||||
public var shamanName:String;
|
||||
|
||||
public var shamanText:String;
|
||||
|
||||
public var rangedAttack:Array;
|
||||
|
||||
public var meleeAttack:Array;
|
||||
|
||||
public var fierceAttack:Array;
|
||||
|
||||
public var healingPower:Array;
|
||||
|
||||
public var defense:Array;
|
||||
|
||||
public function Avatar()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:int, param2:String, param3:int, param4:Array, param5:AccessoryState = null, param6:String = "", param7:int = -1, param8:int = 0, param9:Array = null, param10:Array = null, param11:Array = null, param12:Array = null, param13:Array = null) : void
|
||||
{
|
||||
this.avTypeId = param3;
|
||||
this._dbAvId = param1;
|
||||
this._roomType = param8;
|
||||
this._avName = param2;
|
||||
this.rangedAttack = param9 == null ? [0,0] : param9;
|
||||
this.meleeAttack = param10 == null ? [0,0] : param10;
|
||||
this.fierceAttack = param11 == null ? [0,0] : param11;
|
||||
this.healingPower = param12 == null ? [0,0] : param12;
|
||||
this.defense = param13 == null ? [0,0] : param13;
|
||||
if(param6 != "")
|
||||
{
|
||||
this.userName = param6;
|
||||
}
|
||||
this._sfsUserId = param7;
|
||||
this._accState = new AccessoryState();
|
||||
if(param5)
|
||||
{
|
||||
DebugUtility.debugTrace("Avatar init - copying accState");
|
||||
this._accState.copyShownAccRef(param5);
|
||||
DebugUtility.debugTrace("old ownerAvatar:" + (this._accState.ownerAvatar ? this._accState.ownerAvatar.avName : this._accState.ownerAvatar));
|
||||
this._accState.ownerAvatar = this;
|
||||
DebugUtility.debugTrace("new ownerAvatar:" + this._accState.ownerAvatar.avName);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._accState.init(this);
|
||||
}
|
||||
if(param4)
|
||||
{
|
||||
this.copyColors(param4);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._colors = null;
|
||||
}
|
||||
this.inventoryClothing = new Inventory();
|
||||
this.inventoryBodyMod = new Inventory();
|
||||
this.inventoryDenFull = new Inventory();
|
||||
this.inventoryDenPartial = new Inventory();
|
||||
this.inventoryClothing.init(this._accState);
|
||||
this.inventoryBodyMod.init(this._accState);
|
||||
this.inventoryDenFull.init(this._accState);
|
||||
this.inventoryDenPartial.init(this._accState);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(this._accState)
|
||||
{
|
||||
this._accState.destroy();
|
||||
this._accState = null;
|
||||
}
|
||||
if(this.inventoryClothing)
|
||||
{
|
||||
this.inventoryClothing.destroy();
|
||||
this.inventoryClothing = null;
|
||||
}
|
||||
if(this.inventoryBodyMod)
|
||||
{
|
||||
this.inventoryBodyMod.destroy();
|
||||
this.inventoryBodyMod = null;
|
||||
}
|
||||
if(this.inventoryDenFull)
|
||||
{
|
||||
this.inventoryDenFull.destroy();
|
||||
this.inventoryDenFull = null;
|
||||
}
|
||||
if(this.inventoryDenPartial)
|
||||
{
|
||||
this.inventoryDenPartial.destroy();
|
||||
this.inventoryDenPartial = null;
|
||||
}
|
||||
this._colors = null;
|
||||
}
|
||||
|
||||
public function get dbAvId() : int
|
||||
{
|
||||
return this._dbAvId;
|
||||
}
|
||||
|
||||
public function set dbAvId(param1:int) : void
|
||||
{
|
||||
this._dbAvId = param1;
|
||||
}
|
||||
|
||||
public function get avName() : String
|
||||
{
|
||||
return this._avName;
|
||||
}
|
||||
|
||||
public function set avName(param1:String) : void
|
||||
{
|
||||
this._avName = param1;
|
||||
}
|
||||
|
||||
public function get userName() : String
|
||||
{
|
||||
return this._userName;
|
||||
}
|
||||
|
||||
public function set userName(param1:String) : void
|
||||
{
|
||||
this._userName = param1;
|
||||
}
|
||||
|
||||
public function get sfsUserId() : int
|
||||
{
|
||||
return this._sfsUserId;
|
||||
}
|
||||
|
||||
public function set avTypeId(param1:int) : void
|
||||
{
|
||||
this._avTypeId = param1;
|
||||
this._enviroTypeFlag = gMainFrame.userInfo.getAvatarEnviroTypeFlagByAvType(this._avTypeId);
|
||||
}
|
||||
|
||||
public function get avTypeId() : int
|
||||
{
|
||||
return this._avTypeId;
|
||||
}
|
||||
|
||||
public function get enviroTypeFlag() : int
|
||||
{
|
||||
return this._enviroTypeFlag;
|
||||
}
|
||||
|
||||
public function set colors(param1:Array) : void
|
||||
{
|
||||
this.setColors(param1[0],param1[1],param1[2]);
|
||||
}
|
||||
|
||||
public function get colors() : Array
|
||||
{
|
||||
return this._colors;
|
||||
}
|
||||
|
||||
public function get accShownItems() : Array
|
||||
{
|
||||
return this._accState.accShownItems;
|
||||
}
|
||||
|
||||
public function copyShownAccRefsFromAvatar(param1:Avatar) : void
|
||||
{
|
||||
this._accState.copyShownAccRef(param1._accState);
|
||||
this.inventoryBodyMod.itemArray = param1.inventoryBodyMod.itemArray.concat();
|
||||
if(param1.inventoryClothing)
|
||||
{
|
||||
this.inventoryClothing.itemArray = param1.inventoryClothing.itemArray.concat();
|
||||
}
|
||||
}
|
||||
|
||||
public function cloneShownAccFromAvatar(param1:Avatar) : void
|
||||
{
|
||||
this._accState.cloneShownAcc(param1._accState);
|
||||
this.inventoryBodyMod.itemArray = param1.inventoryBodyMod.itemArray.concat();
|
||||
if(param1.inventoryClothing)
|
||||
{
|
||||
this.inventoryClothing.itemArray = param1.inventoryClothing.itemArray.concat();
|
||||
}
|
||||
}
|
||||
|
||||
public function matchShownAcc(param1:AccessoryState) : void
|
||||
{
|
||||
this._accState.matchShownItems(param1,this.inventoryClothing.itemArray,this.inventoryBodyMod.itemArray);
|
||||
}
|
||||
|
||||
public function setColors(param1:uint, param2:uint, param3:uint) : void
|
||||
{
|
||||
if(this._colors == null)
|
||||
{
|
||||
this._colors = new Array(3);
|
||||
}
|
||||
var _loc4_:uint = uint(gMainFrame.userInfo.getAvatarColorLayer1InfoByAvType(this._avTypeId));
|
||||
var _loc5_:int = param1 >> 24 & 0xFF;
|
||||
var _loc6_:int = param1 >> 16 & 0xFF;
|
||||
var _loc7_:int = _loc4_ >> 8 & 0xFF;
|
||||
var _loc8_:int = _loc4_ & 0xFF;
|
||||
var _loc9_:uint = uint(gMainFrame.userInfo.getAvatarColorLayer3InfoByAvType(this._avTypeId));
|
||||
var _loc10_:int = param3 >> 24 & 0xFF;
|
||||
var _loc11_:int = _loc9_ >> 16 & 0xFF;
|
||||
var _loc12_:int = _loc9_ >> 8 & 0xFF;
|
||||
var _loc13_:int = _loc9_ & 0xFF;
|
||||
this._colors[0] = uint(_loc5_ << 24 | _loc6_ << 16 | _loc7_ << 8 | _loc8_);
|
||||
this._colors[1] = param2;
|
||||
this._colors[2] = uint(_loc10_ << 24 | _loc11_ << 16 | _loc12_ << 8 | _loc13_);
|
||||
dispatchEvent(new AvatarEvent(AvatarEvent.AVATAR_CHANGED));
|
||||
}
|
||||
|
||||
public function copyColors(param1:Array) : void
|
||||
{
|
||||
this.colors = param1.concat();
|
||||
}
|
||||
|
||||
public function itemResponseIntegrate(param1:Array) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:Item = null;
|
||||
var _loc4_:int = 0;
|
||||
if(Boolean(this.inventoryBodyMod) && Boolean(this.inventoryClothing))
|
||||
{
|
||||
this.removeAllItems();
|
||||
_loc2_ = int(param1.length);
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc2_)
|
||||
{
|
||||
_loc3_ = param1[_loc4_];
|
||||
if(_loc3_.type == Item.BODY_MOD_TYPE)
|
||||
{
|
||||
if(ItemXtCommManager.canUseItem(_loc3_.defId,this._avTypeId))
|
||||
{
|
||||
this.inventoryBodyMod.addItem(_loc3_);
|
||||
if(_loc3_.getInUse(this._dbAvId))
|
||||
{
|
||||
this._accState.showAccessory(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_loc3_.type == Item.CLOTHING_TYPE)
|
||||
{
|
||||
if(this._enviroTypeFlag == 1 << Utility.ENVIRO_LAND || this._enviroTypeFlag == 1 << Utility.ENVIRO_OCEAN || _loc3_.enviroType == this._roomType)
|
||||
{
|
||||
this.inventoryClothing.addItem(_loc3_);
|
||||
if(_loc3_.getInUse(this._dbAvId))
|
||||
{
|
||||
this._accState.showAccessory(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: Bad item type: " + _loc3_.type);
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
dispatchEvent(new AvatarEvent(AvatarEvent.AVATAR_CHANGED));
|
||||
}
|
||||
}
|
||||
|
||||
public function accStateShowAccessory(param1:Item, param2:Function = null) : void
|
||||
{
|
||||
var _loc4_:Item = null;
|
||||
var _loc3_:Array = param1.type == Item.BODY_MOD_TYPE ? this.inventoryBodyMod.itemArray : this.inventoryClothing.itemArray;
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc3_.length)
|
||||
{
|
||||
_loc4_ = _loc3_[_loc5_];
|
||||
if(_loc4_.layerId == param1.layerId && _loc4_.getInUse(this._dbAvId))
|
||||
{
|
||||
if(_loc4_ != param1)
|
||||
{
|
||||
this.accStateHideAccessory(_loc4_,false);
|
||||
if(param2 != null)
|
||||
{
|
||||
param2(_loc4_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
this._accState.showAccessory(param1);
|
||||
dispatchEvent(new AvatarEvent(AvatarEvent.AVATAR_CHANGED));
|
||||
}
|
||||
|
||||
public function accStateHideAccessory(param1:Item, param2:Boolean = true) : void
|
||||
{
|
||||
this._accState.hideAccessory(param1);
|
||||
if(param2)
|
||||
{
|
||||
dispatchEvent(new AvatarEvent(AvatarEvent.AVATAR_CHANGED));
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAllItems() : void
|
||||
{
|
||||
this.inventoryBodyMod.itemArray = [];
|
||||
this.inventoryClothing.itemArray = [];
|
||||
this._accState.removeAllItems();
|
||||
}
|
||||
|
||||
public function get accState() : AccessoryState
|
||||
{
|
||||
return this._accState;
|
||||
}
|
||||
|
||||
public function clone(param1:Avatar) : void
|
||||
{
|
||||
this._avTypeId = param1.avTypeId;
|
||||
this._dbAvId = param1.dbAvId;
|
||||
this._avName = param1.avName;
|
||||
this.userName = param1.userName;
|
||||
this._sfsUserId = param1._sfsUserId;
|
||||
this._accState = new AccessoryState();
|
||||
this._accState.cloneShownAcc(param1.accState);
|
||||
this._accState.ownerAvatar = this;
|
||||
this.copyColors(param1.colors);
|
||||
this.inventoryClothing = new Inventory();
|
||||
this.inventoryClothing.clone(param1.inventoryClothing);
|
||||
this.inventoryBodyMod = new Inventory();
|
||||
this.inventoryBodyMod.clone(param1.inventoryBodyMod);
|
||||
this.inventoryDenFull = new Inventory();
|
||||
this.inventoryDenFull.clone(param1.inventoryDenFull);
|
||||
this.inventoryDenPartial = new Inventory();
|
||||
this.inventoryDenPartial.clone(param1.inventoryDenPartial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import item.Item;
|
||||
|
||||
public class AvatarEditorView extends AvatarView
|
||||
{
|
||||
|
||||
public function AvatarEditorView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function init(param1:Avatar, param2:Function = null) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
_avatar = new Avatar();
|
||||
_avatar.init(param1.dbAvId,"editorAvatar",param1.avTypeId,param1.colors,null,"",-1,0,param1.rangedAttack,param1.meleeAttack,param1.fierceAttack,param1.healingPower,param1.defense);
|
||||
if(param1.inventoryClothing.itemArray)
|
||||
{
|
||||
_avatar.inventoryClothing.itemArray = param1.inventoryClothing.itemArray.concat();
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _avatar.inventoryClothing.itemArray.length)
|
||||
{
|
||||
_avatar.inventoryClothing.itemArray[_loc3_].makeSmallIcon();
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
if(param1.inventoryBodyMod.itemArray)
|
||||
{
|
||||
_avatar.inventoryBodyMod.itemArray = param1.inventoryBodyMod.itemArray.concat();
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _avatar.inventoryBodyMod.itemArray.length)
|
||||
{
|
||||
_avatar.inventoryBodyMod.itemArray[_loc4_].makeSmallIcon();
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
_avatar.matchShownAcc(param1.accState);
|
||||
_avatar.addEventListener(AvatarEvent.AVATAR_CHANGED,avatarChanged,false,0,true);
|
||||
_layerAnim = LayerAnim.getNew();
|
||||
_layerAnim.avDefId = _avatar.avTypeId;
|
||||
_layerAnim.layers = AvatarUtility.layerArrayForItemsAndColors(param1.inventoryClothing.itemArray.concat(param1.inventoryBodyMod.itemArray.concat()),param1.colors,param1.dbAvId);
|
||||
this.addChild(_layerAnim.bitmap);
|
||||
}
|
||||
|
||||
override public function destroy(param1:Boolean = true) : void
|
||||
{
|
||||
if(param1 && Boolean(_avatar))
|
||||
{
|
||||
_avatar.removeEventListener(AvatarEvent.AVATAR_CHANGED,avatarChanged);
|
||||
_avatar.destroy();
|
||||
_avatar = null;
|
||||
}
|
||||
avTypeChangedCallback = null;
|
||||
LayerAnim.destroy(_layerAnim);
|
||||
_layerAnim = null;
|
||||
}
|
||||
|
||||
public function get colors() : Array
|
||||
{
|
||||
return _avatar.colors;
|
||||
}
|
||||
|
||||
public function set colors(param1:Array) : void
|
||||
{
|
||||
_avatar.colors = param1;
|
||||
}
|
||||
|
||||
public function get accState() : AccessoryState
|
||||
{
|
||||
return _avatar.accState;
|
||||
}
|
||||
|
||||
public function showAccessory(param1:Item, param2:Function = null) : void
|
||||
{
|
||||
_avatar.accStateShowAccessory(param1,param2);
|
||||
}
|
||||
|
||||
public function hideAccessory(param1:Item) : void
|
||||
{
|
||||
_avatar.accStateHideAccessory(param1);
|
||||
}
|
||||
|
||||
public function get viewAvatar() : Avatar
|
||||
{
|
||||
return _avatar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package avatar
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class AvatarEvent extends Event
|
||||
{
|
||||
|
||||
public static const AVATAR_CHANGED:String = "OnAvatarChanged";
|
||||
|
||||
public function AvatarEvent(param1:String)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new AvatarEvent(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
package avatar
|
||||
{
|
||||
public class AvatarInfo
|
||||
{
|
||||
|
||||
public var dbAvId:int;
|
||||
|
||||
public var userName:String;
|
||||
|
||||
public var avName:String;
|
||||
|
||||
public var type:int;
|
||||
|
||||
public var colors:Array;
|
||||
|
||||
public var currEnviroType:int;
|
||||
|
||||
public var landPetInvId:int;
|
||||
|
||||
public var oceanPetInvId:int;
|
||||
|
||||
public var questXp:int;
|
||||
|
||||
public var questLevel:int;
|
||||
|
||||
public var questXPPercentage:int;
|
||||
|
||||
public var questHealthPercentage:int;
|
||||
|
||||
public var isDead:Boolean;
|
||||
|
||||
public var healthBase:int;
|
||||
|
||||
public var attackBase:int;
|
||||
|
||||
public var attackMax:int;
|
||||
|
||||
public var defenseBase:int;
|
||||
|
||||
public var defenseMax:int;
|
||||
|
||||
public function AvatarInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:int = -1, param2:String = "", param3:String = "", param4:int = -1, param5:Array = null, param6:int = 0, param7:int = 0, param8:int = 0, param9:int = 0, param10:int = 0, param11:int = 0, param12:int = 0, param13:int = 0, param14:int = 0, param15:int = 0, param16:int = 0, param17:int = 100) : void
|
||||
{
|
||||
this.isDead = false;
|
||||
this.dbAvId = param1;
|
||||
this.avName = param2;
|
||||
this.userName = param3;
|
||||
this.type = param4;
|
||||
this.colors = param5 == null ? [286331153,286331153,286331153] : param5;
|
||||
this.currEnviroType = param6;
|
||||
this.landPetInvId = param7;
|
||||
this.oceanPetInvId = param8;
|
||||
this.questXp = param9;
|
||||
this.questLevel = param10;
|
||||
this.questXPPercentage = param11;
|
||||
this.questHealthPercentage = param17;
|
||||
this.attackBase = param13;
|
||||
this.attackMax = param14;
|
||||
this.defenseBase = param16;
|
||||
this.defenseMax = param15;
|
||||
this.healthBase = param12;
|
||||
}
|
||||
|
||||
public function getItems(param1:Boolean = false) : Array
|
||||
{
|
||||
var _loc2_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(_loc2_)
|
||||
{
|
||||
return _loc2_.getPartialItemList(this.type,param1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getFullItems(param1:Boolean = false) : Array
|
||||
{
|
||||
var _loc2_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(_loc2_)
|
||||
{
|
||||
return _loc2_.getFullItemList(param1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function set fullItemList(param1:Array) : void
|
||||
{
|
||||
var _loc2_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.fullItemList = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get denItems() : Array
|
||||
{
|
||||
var _loc1_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(_loc1_)
|
||||
{
|
||||
return _loc1_.denItemsFull;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get achievements() : Array
|
||||
{
|
||||
var _loc1_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(_loc1_)
|
||||
{
|
||||
return _loc1_.achievements;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function set denItems(param1:Array) : void
|
||||
{
|
||||
var _loc2_:UserInfo = null;
|
||||
if(param1)
|
||||
{
|
||||
_loc2_ = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.denItemsFull = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get accountType() : int
|
||||
{
|
||||
var _loc1_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(_loc1_)
|
||||
{
|
||||
return _loc1_.accountType;
|
||||
}
|
||||
return Utility.NON_MEMBER;
|
||||
}
|
||||
|
||||
public function get isMember() : Boolean
|
||||
{
|
||||
return Utility.isMember(this.accountType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,917 @@
|
||||
package avatar
|
||||
{
|
||||
import buddy.BuddyEvent;
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import createAccountGui.GuiAvatarCreationAssets;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.media.SoundTransform;
|
||||
import gui.BuddyCard;
|
||||
import gui.BuddyManager;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.GuiNameTypeScreen;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.MediaHelper;
|
||||
import pet.PetManager;
|
||||
import room.RoomManagerWorld;
|
||||
import room.RoomXtCommManager;
|
||||
|
||||
public class AvatarSwitch
|
||||
{
|
||||
|
||||
public static var avatars:Array;
|
||||
|
||||
public static var activeAvatarIdx:int;
|
||||
|
||||
public static var playerUserInfo:UserInfo;
|
||||
|
||||
public static var nameTypeScreen:GuiNameTypeScreen;
|
||||
|
||||
public static var creationAssets:GuiAvatarCreationAssets;
|
||||
|
||||
public static var playerUsername:String;
|
||||
|
||||
public static var playerSfsUserId:int;
|
||||
|
||||
public static var isSlotAvail:int;
|
||||
|
||||
public static var isAddingSlot:Boolean;
|
||||
|
||||
public static var availSlotFlags:int;
|
||||
|
||||
public static var isChoosing:Boolean;
|
||||
|
||||
private static var _addSlotCallback:Function;
|
||||
|
||||
private static var _switchCallback:Function;
|
||||
|
||||
private static var _addIdx:int;
|
||||
|
||||
private static var _switchIdx:int;
|
||||
|
||||
private static var _addAvatarCallback:Function;
|
||||
|
||||
private static var _addAvatar:Avatar;
|
||||
|
||||
private static var _addAvName:String;
|
||||
|
||||
private static var _removeCallback:Function;
|
||||
|
||||
private static var _removeIdx:int;
|
||||
|
||||
private static var _isChoosing:Boolean;
|
||||
|
||||
private static var _asTransformVec:Vector.<MediaHelper>;
|
||||
|
||||
private static var _secondChosenAvtIdx:int;
|
||||
|
||||
private static var _numOpenNonMemberSlots:int;
|
||||
|
||||
private static var _caIdx:int;
|
||||
|
||||
private static var _avatarName:String;
|
||||
|
||||
private static var _avatarNameIndexes:Array;
|
||||
|
||||
private static var _shopId:int;
|
||||
|
||||
private static var _itemInShopDefId:int;
|
||||
|
||||
public static const ASTRANSFORM_MEDIA_ID_TOP:int = 33;
|
||||
|
||||
public static const ASTRANSFORM_MEDIA_ID_BOTTOM:int = 34;
|
||||
|
||||
public static const ASTRANSFORM_OCEAN_MEDIA_ID_TOP:int = 1171;
|
||||
|
||||
public static const ASTRANSFORM_OCEAN_MEDIA_ID_BOTTOM:int = 1172;
|
||||
|
||||
public function AvatarSwitch()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_asTransformVec = new Vector.<MediaHelper>();
|
||||
_secondChosenAvtIdx = -1;
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_asTransformVec = null;
|
||||
}
|
||||
|
||||
public static function playerInfoSet() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(playerUserInfo == null)
|
||||
{
|
||||
playerUserInfo = gMainFrame.userInfo.playerUserInfo;
|
||||
playerUsername = playerUserInfo.userName;
|
||||
playerSfsUserId = gMainFrame.server.userId;
|
||||
avatars = [];
|
||||
updateAvatars();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < avatars.length)
|
||||
{
|
||||
if(Boolean(avatars[_loc1_]) && avatars[_loc1_].dbAvId == gMainFrame.userInfo.myDbAvId)
|
||||
{
|
||||
if(_loc1_ != 0)
|
||||
{
|
||||
avatars.unshift(avatars[_loc1_]);
|
||||
avatars.splice(_loc1_ + 1,1);
|
||||
activeAvatarIdx = _switchIdx = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
avatars[activeAvatarIdx] = AvatarManager.playerAvatar;
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateSlotPositions() : void
|
||||
{
|
||||
var _loc1_:Array = avatars.slice();
|
||||
var _loc2_:int = int(avatars[_switchIdx].dbAvId);
|
||||
var _loc3_:int = int(avatars[activeAvatarIdx].dbAvId);
|
||||
var _loc4_:int = 0;
|
||||
avatars = [];
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc1_.length)
|
||||
{
|
||||
if(_loc1_[_loc5_] != null)
|
||||
{
|
||||
avatars.push(_loc1_[_loc5_]);
|
||||
if(_loc2_ == _loc1_[_loc5_].dbAvId)
|
||||
{
|
||||
_switchIdx = _loc5_ - _loc4_;
|
||||
AvatarXtCommManager.avSlotInfo[_loc2_].slotId = _switchIdx;
|
||||
}
|
||||
if(_loc3_ == _loc1_[_loc5_].dbAvId)
|
||||
{
|
||||
activeAvatarIdx = _loc5_ - _loc4_;
|
||||
AvatarXtCommManager.avSlotInfo[_loc3_].slotId = activeAvatarIdx;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_++;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
|
||||
private static function updateAvatars() : void
|
||||
{
|
||||
var _loc1_:AvatarInfo = null;
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Avatar = null;
|
||||
var _loc5_:Avatar = null;
|
||||
for each(_loc1_ in playerUserInfo.avList)
|
||||
{
|
||||
if(_loc1_.dbAvId == playerUserInfo.currDbAvId)
|
||||
{
|
||||
_loc4_ = AvatarManager.playerAvatar;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = avatars[AvatarXtCommManager.avSlotInfo[_loc1_.dbAvId].slotId];
|
||||
if(!_loc4_)
|
||||
{
|
||||
_loc4_ = new Avatar();
|
||||
_loc4_ = AvatarUtility.generateNew(_loc1_.dbAvId,_loc4_,playerSfsUserId,AvatarManager.roomEnviroType);
|
||||
}
|
||||
}
|
||||
avatars[AvatarXtCommManager.avSlotInfo[_loc1_.dbAvId].slotId] = _loc4_;
|
||||
_loc4_ = null;
|
||||
}
|
||||
_loc2_ = int(avatars.length);
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
if(avatars[_loc3_] != null)
|
||||
{
|
||||
_loc5_ = avatars[_loc3_];
|
||||
if(playerUserInfo.currDbAvId == _loc5_.dbAvId)
|
||||
{
|
||||
activeAvatarIdx = _switchIdx = _loc3_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
public static function shouldChoose() : Boolean
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
while(_loc4_ < avatars.length)
|
||||
{
|
||||
if(avatars[_loc4_])
|
||||
{
|
||||
if(isMemberOnlyAvatar(_loc4_))
|
||||
{
|
||||
_loc3_++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(avatars[_loc4_].enviroTypeFlag == 2)
|
||||
{
|
||||
_loc2_++;
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
if(_loc1_ < 3 && _loc1_ > 0 && _loc2_ < 2 && _loc1_ != _loc2_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function isMemberOnlyAvatar(param1:int) : Boolean
|
||||
{
|
||||
return gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[param1].avTypeId);
|
||||
}
|
||||
|
||||
public static function get numTotalAvatars() : int
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < avatars.length)
|
||||
{
|
||||
if(avatars[_loc2_])
|
||||
{
|
||||
_loc1_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public static function getNumUsableLandAvatars(param1:Boolean, param2:Boolean) : int
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
while(_loc4_ < avatars.length)
|
||||
{
|
||||
if(Boolean(avatars[_loc4_]) && Utility.isLand(avatars[_loc4_].enviroTypeFlag))
|
||||
{
|
||||
if(param1 || param2)
|
||||
{
|
||||
_loc3_++;
|
||||
}
|
||||
else if((availSlotFlags & 1 << AvatarXtCommManager.avSlotInfo[avatars[_loc4_].dbAvId].avInvId) > 0)
|
||||
{
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public static function get numMemberAvatars() : int
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < avatars.length)
|
||||
{
|
||||
if(Boolean(avatars[_loc2_]) && Boolean(gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[_loc2_].avTypeId)))
|
||||
{
|
||||
_loc1_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public static function get numNonMemberAvatars() : int
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < avatars.length)
|
||||
{
|
||||
if(Boolean(avatars[_loc2_]) && !gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[_loc2_].avTypeId))
|
||||
{
|
||||
_loc1_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public static function get numNonMemberOceanAvatars() : int
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < avatars.length)
|
||||
{
|
||||
if(Boolean(avatars[_loc2_]) && Boolean(!gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[_loc2_].avTypeId)) && avatars[_loc2_].enviroTypeFlag == 2)
|
||||
{
|
||||
_loc1_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public static function getNumNonMemberAvailableAvatars() : int
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < avatars.length)
|
||||
{
|
||||
if(Boolean(avatars[_loc2_]) && Boolean(!gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[_loc2_].avTypeId)) && (availSlotFlags & 1 << AvatarXtCommManager.avSlotInfo[avatars[_loc2_].dbAvId].avInvId) > 0)
|
||||
{
|
||||
_loc1_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public static function get numAvailAvatars() : int
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < avatars.length)
|
||||
{
|
||||
if(Boolean(avatars[_loc2_]) && (availSlotFlags & 1 << AvatarXtCommManager.avSlotInfo[avatars[_loc2_].dbAvId].avInvId) > 0)
|
||||
{
|
||||
_loc1_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public static function isSwitching() : Boolean
|
||||
{
|
||||
return Boolean(activeAvatarIdx != _switchIdx);
|
||||
}
|
||||
|
||||
public static function isSlotAvailable(param1:int) : Boolean
|
||||
{
|
||||
return (availSlotFlags & 1 << AvatarXtCommManager.avSlotInfo[avatars[param1].dbAvId].avInvId) > 0;
|
||||
}
|
||||
|
||||
public static function get numOpenNonMemberSlots() : int
|
||||
{
|
||||
return _numOpenNonMemberSlots;
|
||||
}
|
||||
|
||||
public static function set numOpenNonMemberSlots(param1:int) : void
|
||||
{
|
||||
_numOpenNonMemberSlots = param1;
|
||||
}
|
||||
|
||||
public static function addSlot(param1:Function) : void
|
||||
{
|
||||
_addSlotCallback = param1;
|
||||
AvatarXtCommManager.requestAvatarBuy(showNewAvatarPopup);
|
||||
}
|
||||
|
||||
public static function showNewAvatarPopup(param1:Boolean) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
isAddingSlot = false;
|
||||
addNewWorldAvatar(_caIdx,_avatarName,_avatarNameIndexes);
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(_addSlotCallback != null)
|
||||
{
|
||||
_addSlotCallback(param1,true);
|
||||
}
|
||||
}
|
||||
|
||||
public static function addAvatar(param1:int, param2:Boolean = false, param3:Function = null, param4:Boolean = false, param5:Boolean = false, param6:int = -1, param7:Boolean = false, param8:int = 0, param9:int = -1, param10:int = -1, param11:int = -1) : void
|
||||
{
|
||||
_addIdx = param1;
|
||||
_addAvatarCallback = param3;
|
||||
_isChoosing = param4;
|
||||
_shopId = param10;
|
||||
_itemInShopDefId = param11;
|
||||
isAddingSlot = param2;
|
||||
creationAssets = AvatarUtility.creationAssets;
|
||||
if(creationAssets == null)
|
||||
{
|
||||
throw new Error("AvatarSwitch could not get a creationAssets reference!");
|
||||
}
|
||||
creationAssets.parent.setChildIndex(creationAssets,creationAssets.parent.numChildren - 1);
|
||||
var _loc12_:int = AvatarUtility.numNonMemberAvatars();
|
||||
AvatarUtility.reloadAvatarChooser(param5,_loc12_ >= 1 && _loc12_ - numNonMemberOceanAvatars > 0 ? false : param4,param6,param7,param8,param9);
|
||||
creationAssets.visible = true;
|
||||
}
|
||||
|
||||
public static function set addAvatarCallback(param1:Function) : void
|
||||
{
|
||||
_addAvatarCallback = param1;
|
||||
}
|
||||
|
||||
public static function addNewWorldAvatar(param1:int, param2:String, param3:Array, param4:Boolean = false) : void
|
||||
{
|
||||
if(isAddingSlot)
|
||||
{
|
||||
_caIdx = param1;
|
||||
_avatarName = param2;
|
||||
_avatarNameIndexes = param3;
|
||||
addSlot(_addAvatarCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
_addAvatar = AvatarUtility.creationAvatars[AvatarUtility.findAvatarIndexByType(param1)];
|
||||
_addAvName = param2;
|
||||
if(_addAvatar != null && param3[0] != null && param3[1] != null && param3[2] != null)
|
||||
{
|
||||
SBTracker.pop();
|
||||
if(_shopId != -1 && param4)
|
||||
{
|
||||
AvatarXtCommManager.requestAvatarShopBuy([_shopId,_itemInShopDefId,GenericListXtCommManager.getAvailListUniqueId(),param3[0],param3[1],param3[2],_addAvatar.avTypeId],addAvatarResponse);
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarXtCommManager.requestAvatarAdd([param3[0],param3[1],param3[2],_addAvatar.avTypeId],addAvatarResponse);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("Failed to request add avatar with addAvatar = " + _addAvatar + " AvatarNameIndexes[0] = " + param3[0] + " AvatarNameIndexes[1] = " + param3[1] + " AvatarNameIndexes[2] = " + param3[2] + " addAvatar.avTypeId = " + (_addAvatar != null ? _addAvatar.avTypeId : null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function addAvatarResponse(param1:int, param2:int, param3:int) : void
|
||||
{
|
||||
var _loc4_:Avatar = null;
|
||||
if(param1 == 1)
|
||||
{
|
||||
_loc4_ = new Avatar();
|
||||
_loc4_.init(param2,_addAvName,_addAvatar.avTypeId,null,null,playerUsername,playerSfsUserId);
|
||||
_loc4_.copyColors(_addAvatar.colors);
|
||||
_loc4_.cloneShownAccFromAvatar(_addAvatar);
|
||||
_loc4_.accState.hideAllClothingArticles();
|
||||
if(!_isChoosing)
|
||||
{
|
||||
if((availSlotFlags & 1 << param3) == 0)
|
||||
{
|
||||
availSlotFlags |= 1 << param3;
|
||||
}
|
||||
if(!Utility.isSameEnviroType(_loc4_.enviroTypeFlag,AvatarManager.roomEnviroType))
|
||||
{
|
||||
avatars.splice(_addIdx,1);
|
||||
avatars.unshift(_loc4_);
|
||||
AvatarXtCommManager.avSlotInfo[_loc4_.dbAvId] = {
|
||||
"slotId":0,
|
||||
"avInvId":param3
|
||||
};
|
||||
_addIdx = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarXtCommManager.avSlotInfo[_loc4_.dbAvId] = {
|
||||
"slotId":_addIdx,
|
||||
"avInvId":param3
|
||||
};
|
||||
avatars[_addIdx] = _loc4_;
|
||||
}
|
||||
switchAvatars(_addIdx);
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarXtCommManager.avSlotInfo[_loc4_.dbAvId] = {
|
||||
"slotId":_addIdx,
|
||||
"avInvId":param3
|
||||
};
|
||||
avatars[_addIdx] = _loc4_;
|
||||
}
|
||||
}
|
||||
if(param1 != 1 || _isChoosing)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(_addAvatarCallback != null)
|
||||
{
|
||||
_addAvatarCallback(param1);
|
||||
_addAvatarCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function switchAvatars(param1:int, param2:Function = null) : void
|
||||
{
|
||||
if(param1 < 0 || param1 >= avatars.length)
|
||||
{
|
||||
throw new Error("Invalid switchIdx:" + param1);
|
||||
}
|
||||
_switchCallback = param2;
|
||||
_switchIdx = param1;
|
||||
RoomXtCommManager.isSwitching = true;
|
||||
_isChoosing = false;
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
RoomManagerWorld.instance.forceStopMovement();
|
||||
AvatarXtCommManager.requestAvatarSwitch([avatars[param1].dbAvId]);
|
||||
}
|
||||
|
||||
public static function setAvatarSwitchCallback(param1:Function) : void
|
||||
{
|
||||
_switchCallback = param1;
|
||||
}
|
||||
|
||||
public static function avatarSwitchResponse(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:AvatarWorldView = null;
|
||||
var _loc6_:MediaHelper = null;
|
||||
var _loc7_:MediaHelper = null;
|
||||
var _loc8_:* = 0;
|
||||
var _loc9_:DisplayObject = null;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(!_isChoosing)
|
||||
{
|
||||
if(_addAvatarCallback != null)
|
||||
{
|
||||
_addAvatarCallback(true);
|
||||
_addAvatarCallback = null;
|
||||
}
|
||||
}
|
||||
var _loc2_:* = 2;
|
||||
var _loc3_:Boolean = Boolean(int(param1[int(_loc2_++)]));
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc4_ = int(param1[int(_loc2_++)]);
|
||||
_loc5_ = AvatarManager.avatarViewList[_loc4_];
|
||||
if(_loc5_ == null)
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: invalid avatar worldview savw:" + _loc5_ + " sfsUserId:" + _loc4_ + " data:" + param1);
|
||||
return;
|
||||
}
|
||||
_loc5_.setActivePet(0,0,0);
|
||||
if(_loc5_.getChildAt(0).hasOwnProperty("onbottom1"))
|
||||
{
|
||||
_loc8_ = int(_loc5_.numChildren - 1);
|
||||
while(_loc8_ > 0)
|
||||
{
|
||||
_loc9_ = _loc5_.getChildAt(_loc8_);
|
||||
if(_loc9_ is MovieClip && MovieClip(_loc9_).hasOwnProperty("isTransformTop"))
|
||||
{
|
||||
endTransformAnim(MovieClip(_loc9_));
|
||||
break;
|
||||
}
|
||||
_loc8_--;
|
||||
}
|
||||
endTransformAnim(_loc5_.getChildAt(0) as MovieClip);
|
||||
}
|
||||
if(_asTransformVec == null)
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: invalid AvatarSwitch state _asTransformTopMHVec:" + " data:" + param1);
|
||||
return;
|
||||
}
|
||||
_loc6_ = new MediaHelper();
|
||||
_loc6_.init(_loc5_.roomType == Utility.ENVIRO_LAND ? uint(ASTRANSFORM_MEDIA_ID_TOP) : uint(ASTRANSFORM_OCEAN_MEDIA_ID_TOP),asTransformMediaHelper,[_loc5_,param1]);
|
||||
_asTransformVec.push(_loc6_);
|
||||
_loc7_ = new MediaHelper();
|
||||
_loc7_.init(_loc5_.roomType == Utility.ENVIRO_LAND ? uint(ASTRANSFORM_MEDIA_ID_BOTTOM) : uint(ASTRANSFORM_OCEAN_MEDIA_ID_BOTTOM),asTransformMediaHelper,[_loc5_]);
|
||||
_asTransformVec.push(_loc7_);
|
||||
if(_loc4_ == playerSfsUserId)
|
||||
{
|
||||
GuiManager.setSwapBtnGray(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("switch error!!!");
|
||||
RoomXtCommManager.isSwitching = false;
|
||||
GuiManager.setSwapBtnGray(false);
|
||||
if(_switchIdx != activeAvatarIdx)
|
||||
{
|
||||
_switchIdx = activeAvatarIdx;
|
||||
}
|
||||
}
|
||||
if(_switchCallback != null)
|
||||
{
|
||||
_switchCallback(_loc3_,true);
|
||||
if(!_loc3_)
|
||||
{
|
||||
_switchCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function myAvatarListCallback(param1:int) : void
|
||||
{
|
||||
availSlotFlags = param1;
|
||||
}
|
||||
|
||||
public static function removeAvatar(param1:int, param2:Function) : void
|
||||
{
|
||||
if(param1 < 0 || param1 >= avatars.length)
|
||||
{
|
||||
throw new Error("Invalid removeIdx:" + param1);
|
||||
}
|
||||
if(avatars.length <= 1)
|
||||
{
|
||||
throw new Error("Tried to remove avatar when less than 2 were left!");
|
||||
}
|
||||
_removeCallback = param2;
|
||||
_removeIdx = param1;
|
||||
AvatarXtCommManager.requestAvatarKill([avatars[param1].dbAvId],avatarKillResponse);
|
||||
}
|
||||
|
||||
public static function avatarKillResponse(param1:Boolean, param2:int) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc5_:UserInfo = null;
|
||||
if(param1)
|
||||
{
|
||||
_loc4_ = isSlotAvailable(_removeIdx);
|
||||
_loc3_ = int(AvatarXtCommManager.avSlotInfo[avatars[_removeIdx].dbAvId].avInvId);
|
||||
_loc5_ = gMainFrame.userInfo.getUserInfoByUserName(avatars[_removeIdx].userName);
|
||||
_loc5_.allItemsInUseOff(avatars[_removeIdx].dbAvId);
|
||||
AvatarXtCommManager.avSlotInfo[avatars[_removeIdx].dbAvId].avInvId = null;
|
||||
avatars[_removeIdx] = null;
|
||||
}
|
||||
if(_removeCallback != null)
|
||||
{
|
||||
_removeCallback(param1,_removeIdx,_loc3_,param2,_loc4_);
|
||||
}
|
||||
_removeIdx = -1;
|
||||
}
|
||||
|
||||
public static function chooseTwo(param1:Array, param2:Function) : void
|
||||
{
|
||||
_switchIdx = avatars[param1[0]].enviroTypeFlag == 2 ? int(param1[1]) : int(param1[0]);
|
||||
_secondChosenAvtIdx = -1;
|
||||
var _loc3_:Array = [];
|
||||
_loc3_[0] = AvatarXtCommManager.avSlotInfo[avatars[param1[0]].dbAvId].avInvId;
|
||||
if(param1[1] != null && Boolean(AvatarSwitch.avatars[param1[1]]))
|
||||
{
|
||||
_loc3_[1] = AvatarXtCommManager.avSlotInfo[avatars[param1[1]].dbAvId].avInvId;
|
||||
_secondChosenAvtIdx = param1[1];
|
||||
}
|
||||
AvatarXtCommManager.requestAvatarOrdain(_loc3_,param2);
|
||||
}
|
||||
|
||||
private static function asTransformMediaHelper(param1:MovieClip) : void
|
||||
{
|
||||
if(!param1.hasOwnProperty("mediaHelper"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc2_:MediaHelper = MediaHelper(param1.mediaHelper);
|
||||
var _loc3_:int = _loc2_.id;
|
||||
if(_loc3_ != ASTRANSFORM_MEDIA_ID_TOP && _loc3_ != ASTRANSFORM_MEDIA_ID_BOTTOM && _loc3_ != ASTRANSFORM_OCEAN_MEDIA_ID_TOP && _loc3_ != ASTRANSFORM_OCEAN_MEDIA_ID_BOTTOM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
param1.addEventListener(Event.ENTER_FRAME,transformEnterFrameHandler);
|
||||
var _loc4_:AvatarView = AvatarView((param1.passback as Array)[0]);
|
||||
if(_loc3_ == ASTRANSFORM_MEDIA_ID_TOP || _loc3_ == ASTRANSFORM_OCEAN_MEDIA_ID_TOP)
|
||||
{
|
||||
param1.data = (param1.passback as Array)[1] as Array;
|
||||
DebugUtility.debugTrace("got top media for sfsUserId:" + int(param1.data[3]));
|
||||
param1.isTransformTop = true;
|
||||
_loc4_.addChild(param1);
|
||||
_asTransformVec.splice(_asTransformVec.indexOf(_loc2_),1);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.isTransformBottom = true;
|
||||
_loc4_.addChildAt(param1,0);
|
||||
_asTransformVec.splice(_asTransformVec.indexOf(_loc2_),1);
|
||||
}
|
||||
param1.gotoAndPlay(1);
|
||||
param1.mediaHelper.destroy();
|
||||
delete param1.mediaHelper;
|
||||
delete param1.passback;
|
||||
}
|
||||
|
||||
private static function transformEnterFrameHandler(param1:Event) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
var _loc4_:* = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:Boolean = false;
|
||||
var _loc7_:Avatar = null;
|
||||
var _loc8_:Avatar = null;
|
||||
var _loc9_:AvatarWorldView = null;
|
||||
var _loc10_:AvatarInfo = null;
|
||||
var _loc11_:Avatar = null;
|
||||
var _loc12_:int = 0;
|
||||
var _loc13_:Object = null;
|
||||
var _loc14_:AvatarInfo = null;
|
||||
var _loc15_:int = 0;
|
||||
var _loc16_:int = 0;
|
||||
var _loc17_:int = 0;
|
||||
var _loc18_:int = 0;
|
||||
var _loc19_:BuddyEvent = null;
|
||||
var _loc20_:AvatarWorldView = null;
|
||||
var _loc21_:AvatarWorldView = null;
|
||||
var _loc2_:MovieClip = MovieClip(param1.target);
|
||||
if(_loc2_.parent == null || AvatarView(_loc2_.parent).avatarData == null)
|
||||
{
|
||||
endTransformAnim(_loc2_);
|
||||
return;
|
||||
}
|
||||
if(_loc2_.currentFrameLabel != null)
|
||||
{
|
||||
DebugUtility.debugTrace("entered frame:" + _loc2_.currentFrameLabel + " on transform effect for sfsUserId:" + AvatarView(_loc2_.parent).userId);
|
||||
}
|
||||
if(_loc2_.currentFrameLabel == "hideAvatar")
|
||||
{
|
||||
AvatarView(_loc2_.parent).hideAvatar();
|
||||
if(_loc2_.hasOwnProperty("data"))
|
||||
{
|
||||
_loc3_ = _loc2_.data;
|
||||
_loc4_ = 3;
|
||||
_loc5_ = int(_loc3_[int(_loc4_++)]);
|
||||
_loc6_ = Boolean(_loc5_ == playerSfsUserId);
|
||||
_loc7_ = AvatarManager.getAvatarBySfsUserId(_loc5_);
|
||||
if(_loc6_)
|
||||
{
|
||||
_loc8_ = avatars[_switchIdx];
|
||||
_loc8_.dbAvId = _loc7_.dbAvId;
|
||||
_loc8_.avTypeId = _loc7_.avTypeId;
|
||||
_loc8_.copyColors(_loc7_.colors);
|
||||
_loc8_.avName = _loc7_.avName;
|
||||
_loc8_.cloneShownAccFromAvatar(_loc7_);
|
||||
AvatarManager.clearPlayerSplashColor();
|
||||
}
|
||||
_loc7_.removeAllItems();
|
||||
_loc7_.dbAvId = int(_loc3_[int(_loc4_++)]);
|
||||
_loc7_.avTypeId = int(_loc3_[int(_loc4_++)]);
|
||||
_loc7_.setColors(uint(_loc3_[int(_loc4_++)]),uint(_loc3_[int(_loc4_++)]),uint(_loc3_[int(_loc4_++)]));
|
||||
_loc7_.avName = _loc3_[int(_loc4_++)];
|
||||
if(_loc7_.userName == gMainFrame.userInfo.myUserName && gMainFrame.userInfo.getAvatarInfoByDbAvId(_loc7_.dbAvId) == null)
|
||||
{
|
||||
AvatarXtCommManager.requestADForAvatar(_loc7_.dbAvId,true,null,_loc7_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc10_ = new AvatarInfo();
|
||||
_loc10_.dbAvId = _loc7_.dbAvId;
|
||||
_loc10_.avName = _loc7_.avName;
|
||||
_loc10_.userName = _loc7_.userName;
|
||||
_loc10_.colors = _loc7_.colors.concat();
|
||||
_loc10_.type = _loc7_.avTypeId;
|
||||
}
|
||||
if(_loc6_)
|
||||
{
|
||||
gMainFrame.userInfo.myDbAvId = _loc7_.dbAvId;
|
||||
GuiManager.positionHudAvatar();
|
||||
_loc11_ = avatars[activeAvatarIdx];
|
||||
avatars.splice(activeAvatarIdx,1);
|
||||
avatars.unshift(avatars[_switchIdx - 1]);
|
||||
avatars.splice(_switchIdx,1);
|
||||
if(_secondChosenAvtIdx != -1)
|
||||
{
|
||||
avatars.unshift(avatars[_secondChosenAvtIdx - 1]);
|
||||
avatars.splice(_secondChosenAvtIdx,1);
|
||||
}
|
||||
avatars.unshift(_loc11_);
|
||||
activeAvatarIdx = 0;
|
||||
_switchIdx = 0;
|
||||
_secondChosenAvtIdx = -1;
|
||||
_loc12_ = int(_loc3_[int(_loc4_++)]);
|
||||
_loc13_ = PetManager.getMyPetByInvId(_loc12_);
|
||||
if(AvatarManager.playerAvatarWorldView)
|
||||
{
|
||||
_loc9_ = AvatarManager.playerAvatarWorldView;
|
||||
_loc9_.setActivePet(_loc13_ ? uint(_loc13_.lBits) : 0,_loc13_ ? uint(_loc13_.uBits) : 0,_loc13_ ? uint(_loc13_.eBits) : 0);
|
||||
}
|
||||
PetManager.myActivePetInvId = _loc12_;
|
||||
_loc14_ = gMainFrame.userInfo.getAvatarInfoByDbAvId(_loc7_.dbAvId);
|
||||
if(_loc14_)
|
||||
{
|
||||
_loc10_.questLevel = _loc14_.questLevel;
|
||||
_loc10_.questHealthPercentage = _loc14_.questHealthPercentage;
|
||||
_loc10_.healthBase = _loc14_.healthBase;
|
||||
_loc10_.attackBase = _loc14_.attackBase;
|
||||
_loc10_.attackMax = _loc14_.attackMax;
|
||||
_loc10_.defenseBase = _loc14_.defenseBase;
|
||||
_loc10_.defenseMax = _loc14_.defenseMax;
|
||||
_loc7_.itemResponseIntegrate(gMainFrame.userInfo.getUserInfoByUserName(_loc7_.userName).getPartialItemList(_loc7_.avTypeId,true));
|
||||
gMainFrame.userInfo.setAvatarInfoByDbAvId(_loc7_.dbAvId,_loc10_,true);
|
||||
_loc9_.updateNameBarLevelShape(_loc10_.questLevel);
|
||||
}
|
||||
updateAvatarSlotIds();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemXtCommManager.requestItemListForAvatar(null,_loc7_,false,false);
|
||||
if(Boolean(AvatarManager.buddyCardAvatarView) && _loc7_.userName == AvatarManager.buddyCardAvatarView.userName)
|
||||
{
|
||||
BuddyCard.updateCurrBuddyCardAvatar(_loc7_);
|
||||
}
|
||||
_loc15_ = int(_loc3_[int(_loc4_++)]);
|
||||
_loc16_ = int(_loc3_[int(_loc4_++)]);
|
||||
_loc17_ = int(_loc3_[int(_loc4_++)]);
|
||||
_loc18_ = int(_loc3_[_loc4_++]);
|
||||
_loc9_ = AvatarManager.getAvatarWorldViewBySfsUserId(_loc5_);
|
||||
if(_loc9_)
|
||||
{
|
||||
_loc9_.setActivePet(_loc15_,_loc16_,_loc17_);
|
||||
}
|
||||
_loc10_.questLevel = _loc18_;
|
||||
gMainFrame.userInfo.setAvatarInfoByDbAvId(_loc7_.dbAvId,_loc10_,true);
|
||||
_loc9_.updateNameBarLevelShape(_loc10_.questLevel);
|
||||
_loc19_ = new BuddyEvent(BuddyEvent.BUDDY_CHANGED);
|
||||
_loc19_.userName = _loc10_.userName;
|
||||
BuddyManager.eventDispatcher.dispatchEvent(_loc19_);
|
||||
}
|
||||
AvatarWorldView(_loc2_.parent).setPos(_loc2_.parent.x,_loc2_.parent.y,false);
|
||||
delete _loc2_.data;
|
||||
if(_switchCallback != null)
|
||||
{
|
||||
_switchCallback(true);
|
||||
_switchCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_loc2_.currentFrameLabel == "changeAvatar")
|
||||
{
|
||||
AvatarView(_loc2_.parent).showAvatar();
|
||||
}
|
||||
else if(_loc2_.currentFrameLabel == "tintOn")
|
||||
{
|
||||
_loc20_ = AvatarWorldView(_loc2_.parent);
|
||||
if(_loc20_.roomType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
_loc20_.setBlendColor(4290903190,7534606);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc20_.setBlendColor(4294967295,16777107);
|
||||
}
|
||||
}
|
||||
else if(_loc2_.currentFrameLabel == "tintOff")
|
||||
{
|
||||
_loc21_ = AvatarWorldView(_loc2_.parent);
|
||||
_loc21_.setBlendColor(0);
|
||||
_loc21_.setAlphaLevel(100);
|
||||
if(_loc21_.userId == playerSfsUserId)
|
||||
{
|
||||
AvatarManager.clearPlayerSplashColor();
|
||||
}
|
||||
}
|
||||
else if(_loc2_.currentFrame == _loc2_.totalFrames)
|
||||
{
|
||||
endTransformAnim(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private static function endTransformAnim(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:AvatarView = AvatarView(param1.parent);
|
||||
if(param1.parent != null && _loc2_.avatarData != null)
|
||||
{
|
||||
DebugUtility.debugTrace("ending one of two transitions for sfsUserId:" + _loc2_.userId);
|
||||
}
|
||||
param1.removeEventListener(Event.ENTER_FRAME,transformEnterFrameHandler);
|
||||
var _loc3_:SoundTransform = param1.soundTransform;
|
||||
_loc3_.volume = 0;
|
||||
param1.soundTransform = _loc3_;
|
||||
param1.gotoAndStop(1);
|
||||
RoomXtCommManager.isSwitching = false;
|
||||
GuiManager.setSwapBtnGray(false);
|
||||
if(param1.parent != null)
|
||||
{
|
||||
param1.parent.removeChild(param1);
|
||||
}
|
||||
}
|
||||
|
||||
private static function updateAvatarSlotIds() : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc1_:Object = AvatarXtCommManager.avSlotInfo;
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < avatars.length)
|
||||
{
|
||||
if(avatars[_loc3_])
|
||||
{
|
||||
_loc2_ = _loc1_[avatars[_loc3_].dbAvId];
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.slotId = _loc3_;
|
||||
}
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,955 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.popup.SBWizard;
|
||||
import createAccountGui.GuiAvatarCreationAssets;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Point;
|
||||
import gui.SharedAvatarAnimalConstants;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
|
||||
public class AvatarUtility
|
||||
{
|
||||
|
||||
public static var avatarTypes:Array;
|
||||
|
||||
public static var creationAvatars:Array;
|
||||
|
||||
public static var avatarDefInfo:Array;
|
||||
|
||||
public static var creationAssets:GuiAvatarCreationAssets;
|
||||
|
||||
public static var skippedIndexes:Array;
|
||||
|
||||
private static var _avtMgrGetAvtByDbAvId:Function;
|
||||
|
||||
private static var _numViewsLoaded:int;
|
||||
|
||||
private static var _numNonMemberAvatars:Function;
|
||||
|
||||
public static const AVT_AVAIL_HIDDEN:int = 0;
|
||||
|
||||
public static const AVT_AVAIL_ACTIVE:int = 1;
|
||||
|
||||
public static const AVT_AVAIL_ENDANGERED:int = 2;
|
||||
|
||||
public static const AVT_AVAIL_EXTINCT:int = 3;
|
||||
|
||||
public function AvatarUtility()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:MovieClip, param2:SBWizard, param3:Function, param4:INewAvatar = null, param5:DisplayObjectContainer = null, param6:Function = null, param7:Function = null, param8:Boolean = true) : void
|
||||
{
|
||||
var _loc9_:Function = null;
|
||||
_avtMgrGetAvtByDbAvId = param3;
|
||||
_numNonMemberAvatars = param6;
|
||||
creationAssets = new GuiAvatarCreationAssets(param8 ? MainFrame.avatarCreationWorld : MainFrame.avatarCreationLogin,param8);
|
||||
creationAssets.init(param8 ? MainFrame.avatarCreationWorld : MainFrame.avatarCreationLogin,param8);
|
||||
creationAssets.visible = false;
|
||||
param5.addChild(creationAssets);
|
||||
_loc9_ = param8 ? buildCreationAvatarViews : param7;
|
||||
GenericListXtCommManager.requestGenericList(GenericListXtCommManager.AVATAR_LIST_ID,_loc9_,null,param8);
|
||||
}
|
||||
|
||||
public static function reloadAvatarChooser(param1:Boolean, param2:Boolean, param3:int = -1, param4:Boolean = false, param5:int = 0, param6:int = -1) : void
|
||||
{
|
||||
if(creationAssets)
|
||||
{
|
||||
creationAssets.reloadChooser(param1,param2,param3,param4,param5,param6);
|
||||
}
|
||||
}
|
||||
|
||||
public static function destroyReloadedItems() : void
|
||||
{
|
||||
if(creationAssets)
|
||||
{
|
||||
creationAssets.destroyReloadedItems();
|
||||
}
|
||||
}
|
||||
|
||||
public static function buildCreationAvatarViews(param1:Array, param2:Boolean = false) : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc5_:Avatar = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:Item = null;
|
||||
var _loc9_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc12_:int = 0;
|
||||
var _loc13_:Object = null;
|
||||
var _loc14_:Object = null;
|
||||
var _loc15_:Object = null;
|
||||
avatarTypes = [];
|
||||
skippedIndexes = [];
|
||||
var _loc4_:int = int(param1.length);
|
||||
var _loc11_:int = 0;
|
||||
if(creationAvatars)
|
||||
{
|
||||
if(creationAvatars.length > 0)
|
||||
{
|
||||
_loc12_ = 0;
|
||||
while(_loc12_ < creationAvatars.length)
|
||||
{
|
||||
creationAvatars[_loc12_].destroy();
|
||||
_loc12_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
avatarDefInfo = new Array(_loc4_);
|
||||
creationAvatars = [];
|
||||
_loc10_ = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc10_ < _loc4_)
|
||||
{
|
||||
_loc13_ = gMainFrame.userInfo.getAvatarDefByAvType(param1[_loc10_]);
|
||||
if(_loc13_)
|
||||
{
|
||||
if(isAvatarActive(_loc13_.availability) && (!param2 || param2 && !_loc13_.isMemOnly && !isExtinct(_loc13_.availability) && Utility.isLand(_loc13_.enviroTypeFlag)))
|
||||
{
|
||||
_loc6_ = int(param1[_loc10_]);
|
||||
avatarTypes[_loc10_ - _loc11_] = _loc6_;
|
||||
avatarDefInfo[_loc10_ - _loc11_] = {
|
||||
"isMemberOnly":_loc13_.isMemOnly,
|
||||
"enviroFlag":_loc13_.enviroTypeFlag,
|
||||
"cost":_loc13_.cost,
|
||||
"availability":_loc13_.availability
|
||||
};
|
||||
_loc5_ = new Avatar();
|
||||
_loc5_.init(0,"",_loc6_,[_loc13_.colorLayer1,_loc13_.colorLayer2,_loc13_.colorLayer3]);
|
||||
_loc14_ = ItemXtCommManager.getItemDef(_loc13_.defEyes);
|
||||
_loc15_ = ItemXtCommManager.getItemDef(_loc13_.defPattern);
|
||||
_loc8_ = new Item();
|
||||
_loc8_.init(1,_loc3_++,0,-1,-1);
|
||||
_loc5_.inventoryBodyMod.addItem(_loc8_);
|
||||
_loc5_.accStateShowAccessory(_loc8_);
|
||||
_loc8_ = new Item();
|
||||
_loc8_.init(_loc14_.defId,_loc3_++,_loc14_.colors,-1,-1);
|
||||
_loc5_.inventoryBodyMod.addItem(_loc8_);
|
||||
_loc5_.accStateShowAccessory(_loc8_);
|
||||
if(_loc15_)
|
||||
{
|
||||
_loc8_ = new Item();
|
||||
_loc8_.init(_loc15_.defId,_loc3_++,_loc15_.colors,-1,-1);
|
||||
_loc5_.inventoryBodyMod.addItem(_loc8_);
|
||||
_loc5_.accStateShowAccessory(_loc8_);
|
||||
}
|
||||
creationAvatars.push(_loc5_);
|
||||
skippedIndexes[_loc10_] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
skippedIndexes[_loc10_] = true;
|
||||
_loc11_++;
|
||||
}
|
||||
}
|
||||
_loc10_++;
|
||||
}
|
||||
if(!param2)
|
||||
{
|
||||
creationAssets.creationWiz.chooseAnimalScreen.init();
|
||||
}
|
||||
}
|
||||
|
||||
public static function generateNew(param1:int, param2:Avatar = null, param3:int = -1, param4:int = 0, param5:Function = null) : Avatar
|
||||
{
|
||||
var _loc7_:AvatarInfo = null;
|
||||
var _loc6_:Avatar = null;
|
||||
if(param2 == null && _avtMgrGetAvtByDbAvId != null)
|
||||
{
|
||||
_loc6_ = _avtMgrGetAvtByDbAvId(param1);
|
||||
}
|
||||
if(!_loc6_)
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_loc6_ = param2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = new Avatar();
|
||||
}
|
||||
_loc7_ = gMainFrame.userInfo.getAvatarInfoByDbAvId(param1);
|
||||
if((Boolean(_loc7_)) && _loc7_.type != -1)
|
||||
{
|
||||
_loc6_.init(param1,_loc7_.avName,_loc7_.type,_loc7_.colors,null,_loc7_.userName,param3,param4);
|
||||
getAvatarItemData(_loc6_,param5,_loc7_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_.init(param1,"tempAvt",-1,[0,0,0],null,"tempUser",param3);
|
||||
AvatarXtCommManager.requestADForAvatar(param1,true,param5,_loc6_);
|
||||
}
|
||||
}
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
public static function getAvatarItemData(param1:Avatar, param2:Function = null, param3:AvatarInfo = null) : void
|
||||
{
|
||||
if(param1 == null || param1.dbAvId < 0)
|
||||
{
|
||||
throw new Error("Invalid avatar!");
|
||||
}
|
||||
if(param3 == null)
|
||||
{
|
||||
param3 = gMainFrame.userInfo.getAvatarInfoByDbAvId(param1.dbAvId);
|
||||
if(param3 == null)
|
||||
{
|
||||
throw new Error("Invalid avatar or avInfo!");
|
||||
}
|
||||
}
|
||||
var _loc4_:Array = param3.getItems(true);
|
||||
if((Boolean(_loc4_)) && _loc4_.length > 0)
|
||||
{
|
||||
param1.itemResponseIntegrate(_loc4_);
|
||||
}
|
||||
else if(param1.avTypeId > 0)
|
||||
{
|
||||
ItemXtCommManager.requestItemListForAvatar(null,param1,ItemXtCommManager.hasRequestedFullItemList);
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarXtCommManager.requestADForAvatar(param1.dbAvId,true,param2,param1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function layerArrayForItemsAndColors(param1:Array, param2:Array, param3:int) : Array
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc5_:uint = 0;
|
||||
var _loc7_:Item = null;
|
||||
var _loc6_:Array = [];
|
||||
for each(_loc7_ in param1)
|
||||
{
|
||||
if(_loc7_.getInUse(param3))
|
||||
{
|
||||
if(_loc7_.layerId == 1)
|
||||
{
|
||||
_loc5_ = uint(param2[0]);
|
||||
}
|
||||
else if(_loc7_.layerId == 2)
|
||||
{
|
||||
_loc5_ = uint(param2[1]);
|
||||
}
|
||||
else if(_loc7_.layerId == 3)
|
||||
{
|
||||
_loc5_ = uint(param2[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _loc7_.color;
|
||||
}
|
||||
_loc4_ = {
|
||||
"l":_loc7_.accId,
|
||||
"c":_loc5_
|
||||
};
|
||||
_loc6_.push(_loc4_);
|
||||
}
|
||||
}
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
public static function findAvDefIndexByType(param1:int) : int
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < avatarTypes.length)
|
||||
{
|
||||
if(Boolean(avatarTypes[_loc2_]) && avatarTypes[_loc2_] == param1)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function findAvatarIndexByType(param1:int) : int
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < creationAvatars.length)
|
||||
{
|
||||
if(Boolean(creationAvatars[_loc2_]) && creationAvatars[_loc2_].avTypeId == param1)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function findAvDefByType(param1:int) : Object
|
||||
{
|
||||
var _loc2_:int = findAvDefIndexByType(param1);
|
||||
if(_loc2_ != -1)
|
||||
{
|
||||
return avatarDefInfo[_loc2_];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function numNonMemberAvatars() : int
|
||||
{
|
||||
if(_numNonMemberAvatars != null)
|
||||
{
|
||||
return _numNonMemberAvatars();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static function nameTypeScreenMouseDownHandler(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
|
||||
public static function getAvatarHudPosition(param1:int) : Point
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
switch(param1)
|
||||
{
|
||||
case SharedAvatarAnimalConstants.AV_TIGER:
|
||||
_loc2_ = 228;
|
||||
_loc3_ = 220;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_WOLF:
|
||||
_loc2_ = 226;
|
||||
_loc3_ = 217;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KOALA:
|
||||
_loc2_ = 228;
|
||||
_loc3_ = 220;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PANDA:
|
||||
_loc2_ = 225;
|
||||
_loc3_ = 215;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_MONKEY:
|
||||
_loc2_ = 228;
|
||||
_loc3_ = 216;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_BUNNY:
|
||||
_loc2_ = 231;
|
||||
_loc3_ = 216;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RHINO:
|
||||
_loc2_ = 230;
|
||||
_loc3_ = 216;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_CROC:
|
||||
_loc2_ = 222;
|
||||
_loc3_ = 216;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ELEPHANT:
|
||||
_loc2_ = 230;
|
||||
_loc3_ = 216;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SEAL:
|
||||
_loc2_ = 222;
|
||||
_loc3_ = 213;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_DOLPHIN:
|
||||
_loc2_ = 216;
|
||||
_loc3_ = 250;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SHARK:
|
||||
_loc2_ = 222;
|
||||
_loc3_ = 245;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_LION:
|
||||
_loc2_ = 232;
|
||||
_loc3_ = 216;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_HORSE:
|
||||
_loc2_ = 232;
|
||||
_loc3_ = 220;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_TURTLE:
|
||||
_loc2_ = 225;
|
||||
_loc3_ = 237;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PENGUIN:
|
||||
_loc2_ = 223;
|
||||
_loc3_ = 217;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_OCTOPUS:
|
||||
_loc2_ = 221;
|
||||
_loc3_ = 249;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_GIRAFFE:
|
||||
_loc2_ = 220;
|
||||
_loc3_ = 215;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_FOX:
|
||||
_loc2_ = 216;
|
||||
_loc3_ = 218;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ARCTIC_WOLF:
|
||||
_loc2_ = 222;
|
||||
_loc3_ = 222;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SNOW_LEOPARD:
|
||||
_loc2_ = 220;
|
||||
_loc3_ = 223;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RACCOON:
|
||||
_loc2_ = 220;
|
||||
_loc3_ = 212;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KANGAROO:
|
||||
_loc2_ = 220;
|
||||
_loc3_ = 212;
|
||||
break;
|
||||
default:
|
||||
_loc2_ = 225;
|
||||
_loc3_ = 200;
|
||||
}
|
||||
return new Point(_loc2_,_loc3_);
|
||||
}
|
||||
|
||||
public static function getAvatarViewPosition(param1:int) : Point
|
||||
{
|
||||
var _loc2_:Point = new Point();
|
||||
switch(param1)
|
||||
{
|
||||
case SharedAvatarAnimalConstants.AV_TIGER:
|
||||
_loc2_.x = 137;
|
||||
_loc2_.y = 85;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_WOLF:
|
||||
_loc2_.x = 136;
|
||||
_loc2_.y = 85;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KOALA:
|
||||
_loc2_.x = 133;
|
||||
_loc2_.y = 85;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PANDA:
|
||||
_loc2_.x = 131;
|
||||
_loc2_.y = 90;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_MONKEY:
|
||||
_loc2_.x = 136;
|
||||
_loc2_.y = 95;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_BUNNY:
|
||||
_loc2_.x = 140;
|
||||
_loc2_.y = 85;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RHINO:
|
||||
_loc2_.x = 125;
|
||||
_loc2_.y = 95;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_CROC:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 130;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ELEPHANT:
|
||||
_loc2_.x = 134;
|
||||
_loc2_.y = 80;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SEAL:
|
||||
_loc2_.x = 131;
|
||||
_loc2_.y = 75;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_DOLPHIN:
|
||||
_loc2_.x = 125;
|
||||
_loc2_.y = 90;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SHARK:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 120;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_LION:
|
||||
_loc2_.x = 140;
|
||||
_loc2_.y = 100;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_HORSE:
|
||||
_loc2_.x = 130;
|
||||
_loc2_.y = 100;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_TURTLE:
|
||||
_loc2_.x = 125;
|
||||
_loc2_.y = 117;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PENGUIN:
|
||||
_loc2_.x = 129;
|
||||
_loc2_.y = 95;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_OCTOPUS:
|
||||
_loc2_.x = 128;
|
||||
_loc2_.y = 95;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_GIRAFFE:
|
||||
_loc2_.x = 124;
|
||||
_loc2_.y = 110;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_FOX:
|
||||
_loc2_.x = 123;
|
||||
_loc2_.y = 115;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ARCTIC_WOLF:
|
||||
_loc2_.x = 129;
|
||||
_loc2_.y = 115;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SNOW_LEOPARD:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 115;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RACCOON:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 115;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KANGAROO:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 110;
|
||||
break;
|
||||
default:
|
||||
_loc2_.x = 112;
|
||||
_loc2_.y = 140;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function getAvatarChatOffset(param1:int) : Point
|
||||
{
|
||||
var _loc2_:Point = new Point();
|
||||
switch(param1)
|
||||
{
|
||||
case SharedAvatarAnimalConstants.AV_TIGER:
|
||||
_loc2_.x = 10;
|
||||
_loc2_.y = -70;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_WOLF:
|
||||
_loc2_.x = 5;
|
||||
_loc2_.y = -80;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KOALA:
|
||||
_loc2_.x = -25;
|
||||
_loc2_.y = -75;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PANDA:
|
||||
_loc2_.x = -15;
|
||||
_loc2_.y = -85;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_MONKEY:
|
||||
_loc2_.x = -25;
|
||||
_loc2_.y = -75;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_BUNNY:
|
||||
_loc2_.x = -25;
|
||||
_loc2_.y = -75;
|
||||
break;
|
||||
case 10:
|
||||
_loc2_.x = 0;
|
||||
_loc2_.y = -115;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RHINO:
|
||||
_loc2_.x = -10;
|
||||
_loc2_.y = -95;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_CROC:
|
||||
_loc2_.x = -10;
|
||||
_loc2_.y = -90;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ELEPHANT:
|
||||
_loc2_.x = -10;
|
||||
_loc2_.y = -105;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SEAL:
|
||||
_loc2_.x = -15;
|
||||
_loc2_.y = -60;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_DOLPHIN:
|
||||
_loc2_.x = -10;
|
||||
_loc2_.y = -95;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SHARK:
|
||||
_loc2_.x = -15;
|
||||
_loc2_.y = -88;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_LION:
|
||||
_loc2_.x = -15;
|
||||
_loc2_.y = -90;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_HORSE:
|
||||
_loc2_.x = -20;
|
||||
_loc2_.y = -104;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_TURTLE:
|
||||
_loc2_.x = -10;
|
||||
_loc2_.y = -75;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PENGUIN:
|
||||
_loc2_.x = -16;
|
||||
_loc2_.y = -95;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_OCTOPUS:
|
||||
_loc2_.x = -25;
|
||||
_loc2_.y = -95;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_GIRAFFE:
|
||||
_loc2_.x = -17;
|
||||
_loc2_.y = -130;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_FOX:
|
||||
_loc2_.x = -17;
|
||||
_loc2_.y = -88;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ARCTIC_WOLF:
|
||||
_loc2_.x = -7;
|
||||
_loc2_.y = -113;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SNOW_LEOPARD:
|
||||
_loc2_.x = -7;
|
||||
_loc2_.y = -99;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RACCOON:
|
||||
_loc2_.x = -2;
|
||||
_loc2_.y = -58;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KANGAROO:
|
||||
_loc2_.x = -2;
|
||||
_loc2_.y = -95;
|
||||
break;
|
||||
default:
|
||||
_loc2_.x = -25;
|
||||
_loc2_.y = -75;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function getAnimalItemWindowOffset(param1:int) : Point
|
||||
{
|
||||
var _loc2_:Point = new Point();
|
||||
switch(param1)
|
||||
{
|
||||
case SharedAvatarAnimalConstants.AV_TIGER:
|
||||
_loc2_.x = 123;
|
||||
_loc2_.y = 34;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_WOLF:
|
||||
_loc2_.x = 134;
|
||||
_loc2_.y = 45;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KOALA:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 58;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PANDA:
|
||||
_loc2_.x = 124;
|
||||
_loc2_.y = 50;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_MONKEY:
|
||||
_loc2_.x = 133;
|
||||
_loc2_.y = 54;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_BUNNY:
|
||||
_loc2_.x = 138;
|
||||
_loc2_.y = 65;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RHINO:
|
||||
_loc2_.x = 120;
|
||||
_loc2_.y = 85;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_CROC:
|
||||
_loc2_.x = 133;
|
||||
_loc2_.y = 85;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ELEPHANT:
|
||||
_loc2_.x = 125;
|
||||
_loc2_.y = 52;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SEAL:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 38;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_DOLPHIN:
|
||||
_loc2_.x = 125;
|
||||
_loc2_.y = 75;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SHARK:
|
||||
_loc2_.x = 128;
|
||||
_loc2_.y = 80;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_LION:
|
||||
_loc2_.x = 135;
|
||||
_loc2_.y = 60;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_HORSE:
|
||||
_loc2_.x = 135;
|
||||
_loc2_.y = 75;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_TURTLE:
|
||||
_loc2_.x = 120;
|
||||
_loc2_.y = 67;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PENGUIN:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 62;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_OCTOPUS:
|
||||
_loc2_.x = 122;
|
||||
_loc2_.y = 62;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_GIRAFFE:
|
||||
_loc2_.x = 122;
|
||||
_loc2_.y = 78;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_FOX:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 72;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ARCTIC_WOLF:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 90;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SNOW_LEOPARD:
|
||||
_loc2_.x = 127;
|
||||
_loc2_.y = 90;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RACCOON:
|
||||
_loc2_.x = 114;
|
||||
_loc2_.y = 98;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KANGAROO:
|
||||
_loc2_.x = 128;
|
||||
_loc2_.y = 65;
|
||||
break;
|
||||
default:
|
||||
_loc2_.x = 120;
|
||||
_loc2_.y = 50;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function getTalkingHeadOffset(param1:int) : Point
|
||||
{
|
||||
var _loc2_:Point = new Point();
|
||||
var _loc3_:int = param1;
|
||||
switch(0)
|
||||
{
|
||||
}
|
||||
_loc2_.x = 112;
|
||||
_loc2_.y = 140;
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function getAvatarPhotoOffset(param1:int) : Point
|
||||
{
|
||||
var _loc2_:Point = new Point();
|
||||
switch(param1)
|
||||
{
|
||||
case SharedAvatarAnimalConstants.AV_TIGER:
|
||||
_loc2_.x = -150;
|
||||
_loc2_.y = -160;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_WOLF:
|
||||
_loc2_.x = -155;
|
||||
_loc2_.y = -190;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KOALA:
|
||||
_loc2_.x = -152;
|
||||
_loc2_.y = -140;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PANDA:
|
||||
_loc2_.x = -130;
|
||||
_loc2_.y = -158;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_MONKEY:
|
||||
_loc2_.x = -140;
|
||||
_loc2_.y = -175;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_BUNNY:
|
||||
_loc2_.x = -145;
|
||||
_loc2_.y = -192;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RHINO:
|
||||
_loc2_.x = -160;
|
||||
_loc2_.y = -155;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_CROC:
|
||||
_loc2_.x = -165;
|
||||
_loc2_.y = -125;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ELEPHANT:
|
||||
_loc2_.x = -162;
|
||||
_loc2_.y = -148;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SEAL:
|
||||
_loc2_.x = -107;
|
||||
_loc2_.y = -140;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_DOLPHIN:
|
||||
_loc2_.x = -160;
|
||||
_loc2_.y = -190;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SHARK:
|
||||
_loc2_.x = -160;
|
||||
_loc2_.y = -190;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_LION:
|
||||
_loc2_.x = -155;
|
||||
_loc2_.y = -150;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_HORSE:
|
||||
_loc2_.x = -130;
|
||||
_loc2_.y = -185;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_TURTLE:
|
||||
_loc2_.x = -160;
|
||||
_loc2_.y = -190;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PENGUIN:
|
||||
_loc2_.x = -162;
|
||||
_loc2_.y = -180;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_OCTOPUS:
|
||||
_loc2_.x = -160;
|
||||
_loc2_.y = -190;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_GIRAFFE:
|
||||
_loc2_.x = -140;
|
||||
_loc2_.y = -160;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_FOX:
|
||||
_loc2_.x = -165;
|
||||
_loc2_.y = -175;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ARCTIC_WOLF:
|
||||
_loc2_.x = -150;
|
||||
_loc2_.y = -165;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SNOW_LEOPARD:
|
||||
_loc2_.x = -145;
|
||||
_loc2_.y = -180;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RACCOON:
|
||||
_loc2_.x = -140;
|
||||
_loc2_.y = -165;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KANGAROO:
|
||||
_loc2_.x = -145;
|
||||
_loc2_.y = -160;
|
||||
break;
|
||||
default:
|
||||
_loc2_.x = -160;
|
||||
_loc2_.y = -190;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function getAvatarMinigameLobbyOffset(param1:int) : Point
|
||||
{
|
||||
var _loc2_:Point = new Point(0,0);
|
||||
switch(param1)
|
||||
{
|
||||
case SharedAvatarAnimalConstants.AV_TIGER:
|
||||
case SharedAvatarAnimalConstants.AV_WOLF:
|
||||
_loc2_.x = 160;
|
||||
_loc2_.y = 152;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KOALA:
|
||||
case SharedAvatarAnimalConstants.AV_PANDA:
|
||||
_loc2_.x = 158;
|
||||
_loc2_.y = 152;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_MONKEY:
|
||||
_loc2_.x = 157;
|
||||
_loc2_.y = 148;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_BUNNY:
|
||||
_loc2_.x = 162;
|
||||
_loc2_.y = 149;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RHINO:
|
||||
case SharedAvatarAnimalConstants.AV_ELEPHANT:
|
||||
case SharedAvatarAnimalConstants.AV_CROC:
|
||||
_loc2_.x = 160;
|
||||
_loc2_.y = 152;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_TURTLE:
|
||||
case SharedAvatarAnimalConstants.AV_SEAL:
|
||||
_loc2_.x = 153;
|
||||
_loc2_.y = 150;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_DOLPHIN:
|
||||
_loc2_.x = 148;
|
||||
_loc2_.y = 173;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SHARK:
|
||||
_loc2_.x = 153;
|
||||
_loc2_.y = 170;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_LION:
|
||||
case SharedAvatarAnimalConstants.AV_HORSE:
|
||||
_loc2_.x = 162;
|
||||
_loc2_.y = 152;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_PENGUIN:
|
||||
_loc2_.x = 155;
|
||||
_loc2_.y = 152;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_GIRAFFE:
|
||||
_loc2_.x = 155;
|
||||
_loc2_.y = 150;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_FOX:
|
||||
_loc2_.x = 153;
|
||||
_loc2_.y = 152;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_ARCTIC_WOLF:
|
||||
_loc2_.x = 155;
|
||||
_loc2_.y = 152;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_SNOW_LEOPARD:
|
||||
_loc2_.x = 155;
|
||||
_loc2_.y = 155;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_RACCOON:
|
||||
_loc2_.x = 152;
|
||||
_loc2_.y = 155;
|
||||
break;
|
||||
case SharedAvatarAnimalConstants.AV_KANGAROO:
|
||||
_loc2_.x = 152;
|
||||
_loc2_.y = 155;
|
||||
break;
|
||||
default:
|
||||
_loc2_.x = 160;
|
||||
_loc2_.y = 152;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function isAvatarActive(param1:int) : Boolean
|
||||
{
|
||||
if(param1 > AVT_AVAIL_HIDDEN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function isEndangered(param1:int) : Boolean
|
||||
{
|
||||
if(param1 == AVT_AVAIL_ENDANGERED)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function isExtinct(param1:int) : Boolean
|
||||
{
|
||||
if(param1 == AVT_AVAIL_EXTINCT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import flash.display.Sprite;
|
||||
import flash.filters.ColorMatrixFilter;
|
||||
import item.Item;
|
||||
|
||||
public class AvatarView extends Sprite
|
||||
{
|
||||
|
||||
protected var _layerAnim:LayerAnim;
|
||||
|
||||
protected var _avatar:Avatar;
|
||||
|
||||
public var avTypeChangedCallback:Function;
|
||||
|
||||
private var _isOffScreen:Boolean;
|
||||
|
||||
private var _holdAnimId:int;
|
||||
|
||||
private var _lastAnimToHappen:int;
|
||||
|
||||
public function AvatarView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function set lastAnimToHappen(param1:int) : void
|
||||
{
|
||||
this._lastAnimToHappen = param1;
|
||||
}
|
||||
|
||||
public function get lastAnimToHappen() : int
|
||||
{
|
||||
return this._lastAnimToHappen;
|
||||
}
|
||||
|
||||
public function set holdAnimId(param1:int) : void
|
||||
{
|
||||
this._holdAnimId = param1;
|
||||
}
|
||||
|
||||
public function init(param1:Avatar, param2:Function = null) : void
|
||||
{
|
||||
this._holdAnimId = 0;
|
||||
this._avatar = param1;
|
||||
this._avatar.addEventListener(AvatarEvent.AVATAR_CHANGED,this.avatarChanged,false,0,true);
|
||||
this.avTypeChangedCallback = param2;
|
||||
this._layerAnim = LayerAnim.getNew();
|
||||
this._layerAnim.avDefId = this._avatar.avTypeId;
|
||||
if(this._avatar.colors)
|
||||
{
|
||||
this._layerAnim.layers = this.setLayerHelper();
|
||||
}
|
||||
this.addChild(this._layerAnim.bitmap);
|
||||
}
|
||||
|
||||
public function destroy(param1:Boolean = false) : void
|
||||
{
|
||||
if(param1 && Boolean(this._avatar))
|
||||
{
|
||||
this._avatar.removeEventListener(AvatarEvent.AVATAR_CHANGED,this.avatarChanged);
|
||||
this._avatar.destroy();
|
||||
}
|
||||
this._avatar = null;
|
||||
this.avTypeChangedCallback = null;
|
||||
LayerAnim.destroy(this._layerAnim);
|
||||
this._layerAnim = null;
|
||||
}
|
||||
|
||||
public function resetAvatar(param1:Avatar) : void
|
||||
{
|
||||
if(Boolean(this._avatar) && this._avatar.hasEventListener(AvatarEvent.AVATAR_CHANGED))
|
||||
{
|
||||
this._avatar.removeEventListener(AvatarEvent.AVATAR_CHANGED,this.avatarChanged);
|
||||
}
|
||||
this._avatar = param1;
|
||||
this._avatar.addEventListener(AvatarEvent.AVATAR_CHANGED,this.avatarChanged,false,0,true);
|
||||
if(this._layerAnim)
|
||||
{
|
||||
this._layerAnim.avDefId = this._avatar.avTypeId;
|
||||
if(this._avatar.colors)
|
||||
{
|
||||
this._layerAnim.layers = this.setLayerHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid() : Boolean
|
||||
{
|
||||
return this._layerAnim != null;
|
||||
}
|
||||
|
||||
public function hideAvatar() : void
|
||||
{
|
||||
this._layerAnim.visible = false;
|
||||
}
|
||||
|
||||
public function showAvatar() : void
|
||||
{
|
||||
this._layerAnim.visible = true;
|
||||
}
|
||||
|
||||
public function set isOffScreen(param1:Boolean) : void
|
||||
{
|
||||
this._isOffScreen = param1;
|
||||
}
|
||||
|
||||
public function get isOffScreen() : Boolean
|
||||
{
|
||||
return this._isOffScreen;
|
||||
}
|
||||
|
||||
public function pauseAnim(param1:Boolean) : void
|
||||
{
|
||||
this._layerAnim.pause = param1;
|
||||
}
|
||||
|
||||
public function advanceFrame() : void
|
||||
{
|
||||
++this._layerAnim.frame;
|
||||
}
|
||||
|
||||
public function get frame() : int
|
||||
{
|
||||
return this._layerAnim.frame;
|
||||
}
|
||||
|
||||
public function set frame(param1:int) : void
|
||||
{
|
||||
this._layerAnim.frame = param1;
|
||||
}
|
||||
|
||||
public function get flip() : Boolean
|
||||
{
|
||||
return this._layerAnim.hFlip;
|
||||
}
|
||||
|
||||
protected function avatarChanged(param1:AvatarEvent) : void
|
||||
{
|
||||
if(this._layerAnim)
|
||||
{
|
||||
if(this._layerAnim.avDefId != this._avatar.avTypeId)
|
||||
{
|
||||
this._layerAnim.avDefId = this._avatar.avTypeId;
|
||||
if(this.avTypeChangedCallback != null)
|
||||
{
|
||||
this.avTypeChangedCallback(this);
|
||||
}
|
||||
}
|
||||
this._layerAnim.layers = this.setLayerHelper();
|
||||
}
|
||||
}
|
||||
|
||||
protected function setLayerHelper() : Array
|
||||
{
|
||||
var _loc2_:AvatarInfo = null;
|
||||
var _loc3_:Array = null;
|
||||
var _loc1_:Array = null;
|
||||
if(Boolean(this._avatar.inventoryBodyMod) && Boolean(this._avatar.inventoryBodyMod.itemArray) && this._avatar.inventoryBodyMod.itemArray.length >= 1)
|
||||
{
|
||||
_loc1_ = this._avatar.inventoryBodyMod.itemArray.concat(this._avatar.inventoryClothing.itemArray.concat());
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = gMainFrame.userInfo.getAvatarInfoByDbAvId(this._avatar.dbAvId);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc3_ = _loc2_.getItems(true);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc1_ = _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
return AvatarUtility.layerArrayForItemsAndColors(_loc1_,this._avatar.colors,this._avatar.dbAvId);
|
||||
}
|
||||
|
||||
public function playAnim(param1:int, param2:Boolean = false, param3:int = 0, param4:Function = null) : void
|
||||
{
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc6_:Array = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:Array = null;
|
||||
var _loc10_:Array = null;
|
||||
var _loc11_:Object = null;
|
||||
var _loc12_:Array = null;
|
||||
var _loc13_:uint = 0;
|
||||
var _loc14_:Item = null;
|
||||
if(this._holdAnimId == 0 || param1 == this._holdAnimId)
|
||||
{
|
||||
if(!this._isOffScreen)
|
||||
{
|
||||
_loc5_ = false;
|
||||
_loc6_ = this._avatar.accShownItems;
|
||||
if(!this._layerAnim.layers)
|
||||
{
|
||||
_loc5_ = true;
|
||||
}
|
||||
else if(this._layerAnim.layers.length != _loc6_.length)
|
||||
{
|
||||
_loc5_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_ = int(_loc6_.length);
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc7_)
|
||||
{
|
||||
if(this._layerAnim.layers.indexOf(_loc6_[_loc8_].accId) == -1)
|
||||
{
|
||||
_loc5_ = true;
|
||||
break;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc9_ = [];
|
||||
_loc10_ = _loc6_;
|
||||
_loc12_ = this._avatar.colors;
|
||||
for each(_loc14_ in _loc10_)
|
||||
{
|
||||
if(_loc14_.getInUse(this._avatar.dbAvId))
|
||||
{
|
||||
if(_loc14_.layerId == 1)
|
||||
{
|
||||
_loc13_ = uint(_loc12_[0]);
|
||||
}
|
||||
else if(_loc14_.layerId == 2)
|
||||
{
|
||||
_loc13_ = uint(_loc12_[1]);
|
||||
}
|
||||
else if(_loc14_.layerId == 3)
|
||||
{
|
||||
_loc13_ = uint(_loc12_[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = _loc14_.color;
|
||||
}
|
||||
_loc11_ = {
|
||||
"l":_loc14_.accId,
|
||||
"c":_loc13_
|
||||
};
|
||||
_loc9_.push(_loc11_);
|
||||
}
|
||||
}
|
||||
this._layerAnim.layers = _loc9_;
|
||||
}
|
||||
this._layerAnim.hFlip = param2;
|
||||
this._layerAnim.playAnim(param1,param3,param4);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._lastAnimToHappen = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function reloadItemsFromCache() : void
|
||||
{
|
||||
var _loc1_:Array = gMainFrame.userInfo.getAvatarInfoByDbAvId(this._avatar.dbAvId).getItems(true);
|
||||
this._avatar.itemResponseIntegrate(_loc1_);
|
||||
}
|
||||
|
||||
public function preloadAnims(param1:Array, param2:Function = null) : void
|
||||
{
|
||||
this._layerAnim.preload(param1,param2);
|
||||
}
|
||||
|
||||
public function blackOut() : void
|
||||
{
|
||||
var _loc1_:Array = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0];
|
||||
this._layerAnim.bitmap.filters = [new ColorMatrixFilter(_loc1_)];
|
||||
}
|
||||
|
||||
public function get avatarData() : Avatar
|
||||
{
|
||||
return this._avatar;
|
||||
}
|
||||
|
||||
public function get userName() : String
|
||||
{
|
||||
if(this._avatar != null)
|
||||
{
|
||||
return this._avatar.userName;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function get userId() : int
|
||||
{
|
||||
if(this._avatar == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return this._avatar.sfsUserId;
|
||||
}
|
||||
|
||||
public function get avTypeId() : int
|
||||
{
|
||||
return this._avatar.avTypeId;
|
||||
}
|
||||
|
||||
public function get dbAvId() : int
|
||||
{
|
||||
return this._avatar.dbAvId;
|
||||
}
|
||||
|
||||
public function get inventoryBodyModItems() : Array
|
||||
{
|
||||
return this._avatar.inventoryBodyMod.itemArray;
|
||||
}
|
||||
|
||||
public function get inventoryClothingItems() : Array
|
||||
{
|
||||
return this._avatar.inventoryClothing.itemArray;
|
||||
}
|
||||
|
||||
public function setAvtColors(param1:Array) : void
|
||||
{
|
||||
this._avatar.colors = param1;
|
||||
}
|
||||
|
||||
public function get avName() : String
|
||||
{
|
||||
return this._avatar.avName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
package avatar
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Loader;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Shape;
|
||||
import flash.display.Sprite;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class AvatarViewExt_Splash
|
||||
{
|
||||
|
||||
private static const SHADOW_X_OFFSET:int = -100;
|
||||
|
||||
private static const SHADOW_Y_OFFSET:int = -20;
|
||||
|
||||
private static const Shadow:Class = AvatarViewExt_Splash_Shadow;
|
||||
|
||||
private static const WaterSplashSWF:Class = AvatarViewExt_Splash_WaterSplashSWF;
|
||||
|
||||
private const _constSplash:ByteArray = new WaterSplashSWF();
|
||||
|
||||
private var _mask:Shape;
|
||||
|
||||
private var _shadow:Bitmap;
|
||||
|
||||
private var _splash:Loader;
|
||||
|
||||
private var _parent:Sprite;
|
||||
|
||||
private var _maskLayer:DisplayObject;
|
||||
|
||||
private var _bLastSplashVolume:Boolean;
|
||||
|
||||
private var _bSplashInProgress:Boolean;
|
||||
|
||||
private var _lastSplashLiquid:String;
|
||||
|
||||
public function AvatarViewExt_Splash(param1:Sprite, param2:DisplayObject)
|
||||
{
|
||||
super();
|
||||
this._parent = param1;
|
||||
this._bSplashInProgress = false;
|
||||
this._bLastSplashVolume = false;
|
||||
this.createShadow();
|
||||
this.createMask(param2);
|
||||
this._parent.addChild(param2);
|
||||
this.createSplash();
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(this._shadow)
|
||||
{
|
||||
this._parent.removeChild(this._shadow);
|
||||
this._shadow = null;
|
||||
}
|
||||
if(this._splash)
|
||||
{
|
||||
this._parent.removeChild(this._splash);
|
||||
this._splash.unloadAndStop();
|
||||
this._splash = null;
|
||||
}
|
||||
if(this._mask)
|
||||
{
|
||||
this._parent.removeChild(this._mask);
|
||||
this._mask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function showShadow(param1:Boolean = true) : void
|
||||
{
|
||||
this._shadow.visible = param1;
|
||||
}
|
||||
|
||||
private function createShadow() : void
|
||||
{
|
||||
this._shadow = new Shadow();
|
||||
this._shadow.x = SHADOW_X_OFFSET;
|
||||
this._shadow.y = SHADOW_Y_OFFSET;
|
||||
this._parent.addChild(this._shadow);
|
||||
}
|
||||
|
||||
private function createMask(param1:DisplayObject) : void
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
this._maskLayer = param1;
|
||||
this._mask = new Shape();
|
||||
this._parent.addChild(this._mask);
|
||||
this._mask.graphics.lineStyle();
|
||||
this._mask.graphics.beginFill(16777215,1);
|
||||
_loc2_ = -150;
|
||||
_loc3_ = -275;
|
||||
this._mask.graphics.moveTo(_loc2_,_loc3_);
|
||||
this._mask.graphics.lineTo(_loc2_ + 245,_loc3_);
|
||||
this._mask.graphics.lineTo(_loc2_ + 245,_loc3_ + 235);
|
||||
this._mask.graphics.curveTo(_loc2_ + 122.5,_loc3_ + 260,_loc2_,_loc3_ + 235);
|
||||
this._mask.graphics.lineTo(_loc2_,_loc3_);
|
||||
this._mask.graphics.endFill();
|
||||
this._maskLayer.mask = null;
|
||||
this._mask.visible = false;
|
||||
}
|
||||
|
||||
private function createSplash() : void
|
||||
{
|
||||
this._splash = new Loader();
|
||||
this._splash.loadBytes(this._constSplash);
|
||||
this._splash.x = -18;
|
||||
this._splash.y = -28;
|
||||
this._parent.addChild(this._splash);
|
||||
this._splash.visible = false;
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Boolean, param2:Boolean, param3:String) : void
|
||||
{
|
||||
var _loc4_:MovieClip = MovieClip(this._splash.content);
|
||||
if(_loc4_)
|
||||
{
|
||||
if(param3 == "ice" || param3 == "fire" || param3 == "ghost")
|
||||
{
|
||||
param1 = false;
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
_loc4_.setState(param2 ? 1 : 2);
|
||||
}
|
||||
else if(_loc4_.currentFrame == 1 && this._splash.visible == true)
|
||||
{
|
||||
this._splash.visible = false;
|
||||
}
|
||||
if(param1 != this._bLastSplashVolume || param3 != this._lastSplashLiquid)
|
||||
{
|
||||
_loc4_.setLiquid(param3);
|
||||
this._bLastSplashVolume = param1;
|
||||
this._lastSplashLiquid = param3;
|
||||
this.showMask(param1);
|
||||
if(param1)
|
||||
{
|
||||
if(this._splash.visible == false)
|
||||
{
|
||||
this._splash.visible = true;
|
||||
}
|
||||
_loc4_.setState(param2 ? 1 : 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_.setState(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function showMask(param1:Boolean = true) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
this._maskLayer.mask = this._mask;
|
||||
this.showShadow(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._maskLayer.mask = null;
|
||||
this.showShadow(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package avatar
|
||||
{
|
||||
import mx.core.BitmapAsset;
|
||||
|
||||
[Embed(source="/_assets/8_avatar.AvatarViewExt_Splash_Shadow.png")]
|
||||
public class AvatarViewExt_Splash_Shadow extends BitmapAsset
|
||||
{
|
||||
|
||||
public function AvatarViewExt_Splash_Shadow()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package avatar
|
||||
{
|
||||
import mx.core.ByteArrayAsset;
|
||||
|
||||
[Embed(source="/_assets/10_avatar.AvatarViewExt_Splash_WaterSplashSWF.bin", mimeType="application/octet-stream")]
|
||||
public class AvatarViewExt_Splash_WaterSplashSWF extends ByteArrayAsset
|
||||
{
|
||||
|
||||
public function AvatarViewExt_Splash_WaterSplashSWF()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,780 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.client.SFClient;
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.loader.FileServerEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.Dictionary;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.DefPacksDefHelper;
|
||||
|
||||
public class AvatarXtCommManager
|
||||
{
|
||||
|
||||
public static var avSlotInfo:Object;
|
||||
|
||||
private static var _adAvatarQueue:Array;
|
||||
|
||||
private static var _agQueue:Dictionary;
|
||||
|
||||
private static var _agsQueue:Dictionary;
|
||||
|
||||
private static var _avatarCreateResponse:Function;
|
||||
|
||||
private static var _avatarUpdateResponse:Function;
|
||||
|
||||
private static var _avatarPaintResponse:Function;
|
||||
|
||||
private static var _avatarRemoveResponse:Function;
|
||||
|
||||
private static var _avatarListResponse:Function;
|
||||
|
||||
private static var _getAvatarByUsername:Function;
|
||||
|
||||
private static var _buddyCardUpdateDropDownHandler:Function;
|
||||
|
||||
private static var _avatarInfoCallback:Function;
|
||||
|
||||
private static var _abCallback:Function;
|
||||
|
||||
private static var _asCallback:Function;
|
||||
|
||||
private static var _aaCallback:Function;
|
||||
|
||||
private static var _alCallback:Function;
|
||||
|
||||
private static var _handleCreateAvatarData:Function;
|
||||
|
||||
private static var _akCallback:Function;
|
||||
|
||||
private static var _aoCallback:Function;
|
||||
|
||||
private static var _photoTakeCallback:Function;
|
||||
|
||||
private static var _avatarsInRoom:Object;
|
||||
|
||||
private static var _gameAvatarAdCallback:Function;
|
||||
|
||||
public function AvatarXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:Function = null, param2:Function = null, param3:Function = null, param4:Function = null, param5:Function = null, param6:Object = null, param7:Function = null, param8:Function = null, param9:Function = null) : void
|
||||
{
|
||||
_avatarCreateResponse = param1;
|
||||
_avatarUpdateResponse = param2;
|
||||
_avatarPaintResponse = param3;
|
||||
_avatarRemoveResponse = param4;
|
||||
_avatarListResponse = param5;
|
||||
_getAvatarByUsername = param7;
|
||||
_asCallback = param8;
|
||||
_buddyCardUpdateDropDownHandler = param9;
|
||||
_adAvatarQueue = [];
|
||||
avSlotInfo = new Object();
|
||||
_agQueue = new Dictionary(false);
|
||||
_agsQueue = new Dictionary(false);
|
||||
_avatarsInRoom = param6;
|
||||
XtReplyDemuxer.addModule(handleXtReply,"a");
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_adAvatarQueue = null;
|
||||
XtReplyDemuxer.removeModule(handleXtReply);
|
||||
}
|
||||
|
||||
public static function requestAvatarMake(param1:Function) : void
|
||||
{
|
||||
_handleCreateAvatarData = param1;
|
||||
gMainFrame.server.setXtObject_Str("am",[],gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function requestAvatarInfo(param1:Function) : void
|
||||
{
|
||||
var _loc2_:DefPacksDefHelper = null;
|
||||
_avatarInfoCallback = param1;
|
||||
if(gMainFrame.userInfo.avtDefsCached)
|
||||
{
|
||||
if(_avatarInfoCallback != null)
|
||||
{
|
||||
_avatarInfoCallback();
|
||||
_avatarInfoCallback = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = new DefPacksDefHelper();
|
||||
_loc2_.init(DefPacksDefHelper.DEF_AVATAR,avatarInfoResponse,null,FileServerEvent.AMF3_TYPE);
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_AVATAR] = _loc2_;
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestADForAvatar(param1:int, param2:Boolean = true, param3:Function = null, param4:Avatar = null) : void
|
||||
{
|
||||
_adAvatarQueue.push({
|
||||
"a":param4,
|
||||
"c":(param2 ? null : param3)
|
||||
});
|
||||
var _loc5_:Boolean = ItemXtCommManager.hasRequestedFullItemList;
|
||||
var _loc6_:AvatarInfo = gMainFrame.userInfo.getAvatarInfoByDbAvId(param1);
|
||||
if((Boolean(_loc6_)) && _loc6_.type != -1)
|
||||
{
|
||||
avatarDataResponseIntegrate([_loc6_.dbAvId,_loc6_.avName,_loc6_.userName,_loc6_.type,_loc6_.colors[0],_loc6_.colors[1],_loc6_.colors[2]]);
|
||||
if(param2)
|
||||
{
|
||||
if(param4 == null)
|
||||
{
|
||||
throw new Error("requestAvatarData got requestItemList=true but getAvDataAvatar=null!");
|
||||
}
|
||||
ItemXtCommManager.requestItemListForAvatar(param3,param4,_loc5_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
ItemXtCommManager.insertIntoILAvatarQueue(param1,param3,param4);
|
||||
}
|
||||
sendAvatarDataRequest([param1,param2 ? (_loc5_ ? "2" : "1") : "0"]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestAvatarList(param1:Array, param2:Function = null) : void
|
||||
{
|
||||
_alCallback = param2;
|
||||
gMainFrame.server.setXtObject_Str("al",param1,gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function requestAvatarBuy(param1:Function) : void
|
||||
{
|
||||
_abCallback = param1;
|
||||
gMainFrame.server.setXtObject_Str("ab",[]);
|
||||
}
|
||||
|
||||
public static function requestAvatarSwitch(param1:Array) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("as",param1);
|
||||
}
|
||||
|
||||
public static function requestAvatarAdd(param1:Array, param2:Function) : void
|
||||
{
|
||||
_aaCallback = param2;
|
||||
gMainFrame.server.setXtObject_Str("aa",param1,gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function requestAvatarShopBuy(param1:Array, param2:Function) : void
|
||||
{
|
||||
_aaCallback = param2;
|
||||
gMainFrame.server.setXtObject_Str("asb",param1,gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function requestAvatarKill(param1:Array, param2:Function) : void
|
||||
{
|
||||
_akCallback = param2;
|
||||
gMainFrame.server.setXtObject_Str("ak",param1);
|
||||
}
|
||||
|
||||
public static function requestAvatarOrdain(param1:Array, param2:Function) : void
|
||||
{
|
||||
_aoCallback = param2;
|
||||
gMainFrame.server.setXtObject_Str("ao",param1);
|
||||
}
|
||||
|
||||
public static function requestAvatarGet(param1:String, param2:Function, param3:Boolean = false) : void
|
||||
{
|
||||
_agQueue[param1.toLowerCase()] = param2;
|
||||
gMainFrame.server.setXtObject_Str("ag",[param1,param3 ? "1" : "0"]);
|
||||
}
|
||||
|
||||
public static function requestAvatarGetBySfsId(param1:int, param2:Function) : void
|
||||
{
|
||||
_agsQueue[param1] = param2;
|
||||
gMainFrame.server.setXtObject_Str("ags",[param1,"0"]);
|
||||
}
|
||||
|
||||
public static function requestColorChange(param1:Array, param2:int, param3:Function = null) : void
|
||||
{
|
||||
if(param3 != null)
|
||||
{
|
||||
_avatarPaintResponse = param3;
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("ap",[param1[0],param1[1],param1[2],param2],gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function setGameAvatarAdCallback(param1:Function) : void
|
||||
{
|
||||
_gameAvatarAdCallback = param1;
|
||||
}
|
||||
|
||||
public static function sendAvatarFiveMinutesUpdate(param1:Array) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("af",param1);
|
||||
}
|
||||
|
||||
public static function sendAvatarPhotoTakeCheck(param1:Function) : void
|
||||
{
|
||||
_photoTakeCallback = param1;
|
||||
gMainFrame.server.setXtObject_Str("apc",[]);
|
||||
}
|
||||
|
||||
public static function sendAvatarPhotoTake(param1:Function) : void
|
||||
{
|
||||
_photoTakeCallback = param1;
|
||||
gMainFrame.server.setXtObject_Str("apb",[]);
|
||||
}
|
||||
|
||||
private static function sendAvatarDataRequest(param1:Array) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("ad",param1,gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
if(!param1.status)
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: AvatarXtCommManager handleXtReply was called with bad evt.status:" + param1.status);
|
||||
return;
|
||||
}
|
||||
var _loc2_:Array = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "au":
|
||||
if(_avatarUpdateResponse != null)
|
||||
{
|
||||
_avatarUpdateResponse(_loc2_);
|
||||
}
|
||||
break;
|
||||
case "ad":
|
||||
avatarDataResponse(_loc2_);
|
||||
break;
|
||||
case "ac":
|
||||
if(_avatarCreateResponse != null)
|
||||
{
|
||||
_avatarCreateResponse(_loc2_);
|
||||
}
|
||||
break;
|
||||
case "ap":
|
||||
if(_avatarPaintResponse != null)
|
||||
{
|
||||
_avatarPaintResponse(_loc2_);
|
||||
}
|
||||
break;
|
||||
case "ag":
|
||||
avatarGetResponse(_loc2_);
|
||||
break;
|
||||
case "ar":
|
||||
if(_avatarRemoveResponse != null)
|
||||
{
|
||||
_avatarRemoveResponse(_loc2_);
|
||||
}
|
||||
break;
|
||||
case "al":
|
||||
avatarListResponse(_loc2_);
|
||||
break;
|
||||
case "ab":
|
||||
avatarBuyResponse(_loc2_);
|
||||
break;
|
||||
case "as":
|
||||
avatarSwitchResponse(_loc2_);
|
||||
break;
|
||||
case "aa":
|
||||
avatarAddResponse(_loc2_);
|
||||
break;
|
||||
case "ak":
|
||||
avatarKillResponse(_loc2_);
|
||||
break;
|
||||
case "am":
|
||||
_handleCreateAvatarData(_loc2_);
|
||||
break;
|
||||
case "ao":
|
||||
avatarOrdainResponse(_loc2_);
|
||||
break;
|
||||
case "apb":
|
||||
case "apc":
|
||||
if(_photoTakeCallback != null)
|
||||
{
|
||||
_photoTakeCallback(_loc2_);
|
||||
_photoTakeCallback = null;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("AvatarXtCommManager illegal data:" + _loc2_[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarInfoResponse(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc6_:Object = null;
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_AVATAR] = null;
|
||||
var _loc2_:Object = param1.def;
|
||||
var _loc4_:Object = new Object();
|
||||
var _loc5_:Array = [];
|
||||
for each(_loc6_ in _loc2_)
|
||||
{
|
||||
_loc5_[int(_loc6_.id)] = new Point(_loc6_.x,_loc6_.y);
|
||||
_loc4_[int(_loc6_.id)] = {
|
||||
"colorLayer1":uint(_loc6_.colorLayer1),
|
||||
"colorLayer2":uint(_loc6_.colorLayer2),
|
||||
"colorLayer3":uint(_loc6_.colorLayer3),
|
||||
"defPattern":int(_loc6_.basePatternId),
|
||||
"defEyes":int(_loc6_.baseEyesId),
|
||||
"isMemOnly":Boolean(_loc6_.membersOnly == "1"),
|
||||
"enviroTypeFlag":int(_loc6_.enviroTypeFlags),
|
||||
"cost":int(_loc6_.cost),
|
||||
"titleStrRef":int(_loc6_.titleStrRef),
|
||||
"availability":int(_loc6_.availability),
|
||||
"attackItemRefId":int(_loc6_.attackItemRefId),
|
||||
"iconMediaId":int(_loc6_.iconMediaRefId)
|
||||
};
|
||||
}
|
||||
if(!gMainFrame.userInfo.avtDefsCached)
|
||||
{
|
||||
gMainFrame.setAvatarOffsets(_loc5_);
|
||||
gMainFrame.userInfo.setAvatarDefs(_loc4_);
|
||||
}
|
||||
var _loc7_:DefPacksDefHelper = new DefPacksDefHelper();
|
||||
_loc7_.init(DefPacksDefHelper.DEF_LAYER,liDefPacksResponse,null,FileServerEvent.AMF3_TYPE);
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_LAYER] = _loc7_;
|
||||
}
|
||||
|
||||
private static function liDefPacksResponse(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_LAYER] = null;
|
||||
var _loc2_:Object = param1.def;
|
||||
var _loc3_:Object = {};
|
||||
for each(_loc4_ in _loc2_)
|
||||
{
|
||||
_loc3_[int(_loc4_.id)] = int(_loc4_.layerId);
|
||||
}
|
||||
gMainFrame.layerInfo = _loc3_;
|
||||
if(_avatarInfoCallback != null)
|
||||
{
|
||||
_avatarInfoCallback();
|
||||
_avatarInfoCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarDataResponse(param1:Array) : void
|
||||
{
|
||||
var _loc13_:Boolean = false;
|
||||
var _loc19_:int = 0;
|
||||
var _loc20_:int = 0;
|
||||
var _loc21_:int = 0;
|
||||
var _loc22_:int = 0;
|
||||
var _loc23_:int = 0;
|
||||
var _loc25_:AvatarInfo = null;
|
||||
var _loc26_:AvatarInfo = null;
|
||||
var _loc27_:UserInfo = null;
|
||||
var _loc28_:Array = null;
|
||||
var _loc2_:* = 2;
|
||||
var _loc3_:int = int(param1[_loc2_++]);
|
||||
var _loc4_:String = param1[_loc2_++];
|
||||
var _loc5_:int = int(param1[_loc2_++]);
|
||||
var _loc6_:uint = uint(param1[_loc2_++]);
|
||||
var _loc7_:uint = uint(param1[_loc2_++]);
|
||||
var _loc8_:uint = uint(param1[_loc2_++]);
|
||||
var _loc9_:String = param1[_loc2_++];
|
||||
var _loc10_:int = int(param1[_loc2_++]);
|
||||
var _loc11_:int = int(param1[_loc2_++]);
|
||||
var _loc12_:int = int(param1[_loc2_++]);
|
||||
var _loc14_:int = -1;
|
||||
var _loc15_:int = 0;
|
||||
var _loc16_:int = 0;
|
||||
var _loc17_:int = 0;
|
||||
var _loc18_:int = 0;
|
||||
if(_loc4_ == gMainFrame.userInfo.myUserName)
|
||||
{
|
||||
_loc13_ = true;
|
||||
_loc14_ = int(param1[_loc2_++]);
|
||||
_loc15_ = int(param1[_loc2_++]);
|
||||
_loc16_ = int(param1[_loc2_++]);
|
||||
_loc19_ = int(param1[_loc2_++]);
|
||||
_loc20_ = int(param1[_loc2_++]);
|
||||
_loc21_ = int(param1[_loc2_++]);
|
||||
_loc22_ = int(param1[_loc2_++]);
|
||||
_loc23_ = int(param1[_loc2_++]);
|
||||
}
|
||||
var _loc24_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(_loc4_);
|
||||
if(_loc24_)
|
||||
{
|
||||
for each(_loc26_ in _loc24_.avList)
|
||||
{
|
||||
if(_loc26_.dbAvId == _loc3_)
|
||||
{
|
||||
_loc25_ = _loc26_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_loc24_.nameBarData = _loc10_;
|
||||
}
|
||||
if(_loc25_)
|
||||
{
|
||||
_loc25_.avName = _loc9_;
|
||||
_loc25_.userName = _loc4_;
|
||||
_loc25_.type = _loc5_;
|
||||
_loc25_.colors = [_loc6_,_loc7_,_loc8_];
|
||||
_loc25_.currEnviroType = _loc11_;
|
||||
_loc25_.questLevel = _loc12_;
|
||||
if(_loc13_)
|
||||
{
|
||||
if(_loc14_ >= 0)
|
||||
{
|
||||
avSlotInfo[_loc25_.dbAvId].avInvId = _loc14_;
|
||||
}
|
||||
_loc25_.landPetInvId = _loc15_;
|
||||
_loc25_.oceanPetInvId = _loc16_;
|
||||
_loc25_.questXp = _loc17_;
|
||||
_loc25_.healthBase = _loc23_;
|
||||
_loc25_.attackBase = _loc19_;
|
||||
_loc25_.attackMax = _loc20_;
|
||||
_loc25_.defenseBase = _loc21_;
|
||||
_loc25_.defenseMax = _loc22_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc25_ = new AvatarInfo();
|
||||
_loc25_.init(_loc3_,_loc9_,_loc4_,_loc5_,[_loc6_,_loc7_,_loc8_]);
|
||||
_loc25_.questLevel = _loc12_;
|
||||
if(_loc13_)
|
||||
{
|
||||
if(_loc14_ >= 0)
|
||||
{
|
||||
avSlotInfo[_loc25_.dbAvId] = {
|
||||
"slotId":-1,
|
||||
"avInvId":_loc14_
|
||||
};
|
||||
}
|
||||
_loc25_.landPetInvId = _loc15_;
|
||||
_loc25_.oceanPetInvId = _loc16_;
|
||||
_loc25_.questXp = _loc17_;
|
||||
_loc25_.healthBase = _loc23_;
|
||||
_loc25_.attackBase = _loc19_;
|
||||
_loc25_.attackMax = _loc20_;
|
||||
_loc25_.defenseBase = _loc21_;
|
||||
_loc25_.defenseMax = _loc22_;
|
||||
}
|
||||
if(_loc24_)
|
||||
{
|
||||
_loc24_.addAvatarToList(_loc25_);
|
||||
_loc24_.nameBarData = _loc10_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc27_ = new UserInfo();
|
||||
_loc28_ = new Array();
|
||||
_loc28_[_loc25_.dbAvId] = _loc25_;
|
||||
_loc27_.init(_loc4_,_loc28_,_loc25_.dbAvId);
|
||||
_loc27_.nameBarData = _loc10_;
|
||||
gMainFrame.userInfo.setUserInfoByUserName(_loc4_,_loc27_);
|
||||
}
|
||||
}
|
||||
avatarDataResponseIntegrate([_loc3_,_loc9_,_loc4_,_loc5_,_loc6_,_loc7_,_loc8_]);
|
||||
}
|
||||
|
||||
private static function avatarDataResponseIntegrate(param1:Array) : void
|
||||
{
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:String = null;
|
||||
var _loc7_:Avatar = null;
|
||||
var _loc8_:* = 0;
|
||||
var _loc2_:Avatar = null;
|
||||
var _loc3_:Function = null;
|
||||
if(Boolean(_adAvatarQueue) && _adAvatarQueue.length > 0)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _adAvatarQueue.length)
|
||||
{
|
||||
if(_adAvatarQueue[_loc5_].a.dbAvId == param1[0])
|
||||
{
|
||||
_loc2_ = _adAvatarQueue[_loc5_].a;
|
||||
_loc3_ = _adAvatarQueue[_loc5_].c;
|
||||
_adAvatarQueue.splice(_loc5_,1);
|
||||
break;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
else if(_avatarsInRoom)
|
||||
{
|
||||
_loc6_ = param1[2];
|
||||
if(_getAvatarByUsername != null)
|
||||
{
|
||||
_loc7_ = _getAvatarByUsername(_loc6_);
|
||||
}
|
||||
if(_loc7_)
|
||||
{
|
||||
_loc2_ = _loc7_;
|
||||
_loc4_ = true;
|
||||
}
|
||||
}
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
_loc2_.dbAvId = int(param1[_loc8_++]);
|
||||
_loc2_.avName = param1[_loc8_++];
|
||||
_loc2_.userName = param1[_loc8_++];
|
||||
_loc2_.avTypeId = int(param1[_loc8_++]);
|
||||
_loc2_.setColors(uint(param1[_loc8_++]),uint(param1[_loc8_++]),uint(param1[_loc8_++]));
|
||||
if(!_loc4_)
|
||||
{
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc3_();
|
||||
_loc3_ = null;
|
||||
}
|
||||
if(_gameAvatarAdCallback != null)
|
||||
{
|
||||
_gameAvatarAdCallback(_loc2_);
|
||||
}
|
||||
}
|
||||
_buddyCardUpdateDropDownHandler(_loc2_.userName);
|
||||
}
|
||||
else if(_loc3_ != null)
|
||||
{
|
||||
DebugUtility.debugTrace("calling loadDataAvatarResult even though dataAvatar was null...");
|
||||
_loc3_();
|
||||
_loc3_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarGetResponse(param1:Array) : void
|
||||
{
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:Boolean = false;
|
||||
var _loc9_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc11_:int = 0;
|
||||
var _loc12_:Array = null;
|
||||
var _loc13_:String = null;
|
||||
var _loc14_:int = 0;
|
||||
var _loc15_:int = 0;
|
||||
var _loc16_:int = 0;
|
||||
var _loc17_:int = 0;
|
||||
var _loc18_:int = 0;
|
||||
var _loc19_:int = 0;
|
||||
var _loc20_:Array = null;
|
||||
var _loc21_:* = 0;
|
||||
var _loc22_:UserInfo = null;
|
||||
var _loc23_:AvatarInfo = null;
|
||||
var _loc24_:Item = null;
|
||||
var _loc25_:Array = null;
|
||||
var _loc2_:* = 2;
|
||||
var _loc3_:String = param1[_loc2_++];
|
||||
var _loc4_:int = int(param1[_loc2_++]);
|
||||
var _loc5_:int = _loc4_ == 0 ? SFClient.STATUS_OFFLINE_ACTIVE : (_loc4_ == 1 ? SFClient.STATUS_ONLINE : (_loc4_ == 2 ? SFClient.STATUS_OFFLINE_ARCHIVED : SFClient.STATUS_OFFLINE_UNKNOWN));
|
||||
if(_loc4_ <= 1)
|
||||
{
|
||||
_loc7_ = int(param1[_loc2_++]);
|
||||
_loc8_ = param1[_loc2_++] == "1";
|
||||
_loc9_ = int(param1[_loc2_++]);
|
||||
_loc10_ = int(param1[_loc2_++]);
|
||||
_loc11_ = int(param1[_loc2_++]);
|
||||
_loc12_ = new Array(3);
|
||||
_loc12_[0] = uint(param1[_loc2_++]);
|
||||
_loc12_[1] = uint(param1[_loc2_++]);
|
||||
_loc12_[2] = uint(param1[_loc2_++]);
|
||||
_loc13_ = param1[_loc2_++];
|
||||
_loc14_ = int(param1[_loc2_++]);
|
||||
_loc15_ = int(param1[_loc2_++]);
|
||||
_loc16_ = int(param1[_loc2_++]);
|
||||
_loc17_ = int(param1[_loc2_++]);
|
||||
_loc18_ = int(param1[_loc2_++]);
|
||||
_loc19_ = _loc15_ > 0 ? 3 : 2;
|
||||
_loc20_ = new Array(_loc17_ + _loc19_);
|
||||
_loc21_ = 0;
|
||||
var _loc26_:Number;
|
||||
_loc20_[_loc26_ = _loc21_++] = ItemXtCommManager.getBodyModFromDefId(1,_loc11_,true);
|
||||
var _loc27_:Number;
|
||||
_loc20_[_loc27_ = _loc21_++] = ItemXtCommManager.getBodyModFromDefId(_loc14_,_loc11_,true);
|
||||
if(_loc15_ > 0)
|
||||
{
|
||||
var _loc28_:Number;
|
||||
_loc20_[_loc28_ = _loc21_++] = ItemXtCommManager.getBodyModFromDefId(_loc15_,_loc11_,true);
|
||||
}
|
||||
while(_loc21_ < _loc17_ + _loc19_)
|
||||
{
|
||||
_loc24_ = new Item();
|
||||
_loc24_.init(int(param1[_loc2_++]),_loc21_,uint(param1[_loc2_++]));
|
||||
_loc24_.setInUse(_loc9_,true);
|
||||
_loc20_[_loc21_] = _loc24_;
|
||||
_loc21_++;
|
||||
}
|
||||
_loc22_ = gMainFrame.userInfo.getUserInfoByUserName(_loc3_);
|
||||
_loc23_ = new AvatarInfo();
|
||||
_loc23_.init(_loc9_,_loc13_,_loc3_,_loc11_,_loc12_,0,0,0,0,_loc16_);
|
||||
if(!_loc22_)
|
||||
{
|
||||
_loc25_ = new Array(1);
|
||||
_loc25_[_loc9_] = _loc23_;
|
||||
_loc22_ = new UserInfo();
|
||||
_loc22_.init(_loc3_,_loc25_,_loc9_,_loc7_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc22_.currDbAvId = _loc9_;
|
||||
_loc22_.accountType = _loc7_;
|
||||
_loc22_.addAvatarToList(_loc23_);
|
||||
}
|
||||
_loc22_.nameBarData = _loc10_;
|
||||
_loc22_.isGuide = _loc8_;
|
||||
gMainFrame.userInfo.setUserInfoByUserName(_loc3_,_loc22_);
|
||||
}
|
||||
var _loc6_:String = _loc3_.toLowerCase();
|
||||
if(_agQueue[_loc6_])
|
||||
{
|
||||
_agQueue[_loc6_](_loc3_,_loc4_ < 3,_loc5_);
|
||||
delete _agQueue[_loc6_];
|
||||
}
|
||||
if(_agsQueue[_loc18_])
|
||||
{
|
||||
_agsQueue[_loc18_](_loc3_,_loc4_ < 3,_loc5_,_loc18_);
|
||||
delete _agsQueue[_loc18_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarListResponse(param1:Array) : void
|
||||
{
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc7_:String = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:Array = null;
|
||||
var _loc10_:int = 0;
|
||||
var _loc11_:UserInfo = null;
|
||||
var _loc12_:int = 0;
|
||||
var _loc13_:UserInfo = null;
|
||||
var _loc14_:int = 0;
|
||||
var _loc15_:int = 0;
|
||||
var _loc16_:String = null;
|
||||
var _loc17_:AvatarInfo = null;
|
||||
var _loc2_:* = 2;
|
||||
var _loc3_:int = int(param1[_loc2_++]);
|
||||
var _loc4_:int = -1;
|
||||
var _loc6_:int = 0;
|
||||
while(_loc6_ < _loc3_)
|
||||
{
|
||||
_loc7_ = param1[_loc2_++];
|
||||
if(_loc7_ == gMainFrame.server.userName)
|
||||
{
|
||||
_loc5_ = true;
|
||||
_loc4_ = int(param1[_loc2_++]);
|
||||
}
|
||||
_loc8_ = int(param1[_loc2_++]);
|
||||
_loc9_ = [];
|
||||
_loc11_ = gMainFrame.userInfo.getUserInfoByUserName(_loc7_);
|
||||
_loc12_ = 0;
|
||||
while(_loc12_ < _loc8_)
|
||||
{
|
||||
_loc14_ = int(param1[_loc2_++]);
|
||||
if(_loc12_ == 0)
|
||||
{
|
||||
_loc10_ = _loc14_;
|
||||
}
|
||||
_loc15_ = int(param1[_loc2_++]);
|
||||
_loc16_ = param1[_loc2_++];
|
||||
if(_loc11_)
|
||||
{
|
||||
_loc17_ = _loc11_.getAvatarInfoByDbAvId(_loc14_);
|
||||
if(!_loc17_)
|
||||
{
|
||||
_loc17_ = new AvatarInfo();
|
||||
_loc17_.init(_loc14_,_loc16_,_loc7_);
|
||||
if(_loc5_)
|
||||
{
|
||||
avSlotInfo[_loc14_] = {
|
||||
"slotId":_loc12_,
|
||||
"avInvId":_loc15_
|
||||
};
|
||||
}
|
||||
}
|
||||
_loc9_[_loc14_] = _loc17_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc17_ = new AvatarInfo();
|
||||
_loc17_.init(_loc14_,_loc16_,_loc7_);
|
||||
if(_loc5_)
|
||||
{
|
||||
avSlotInfo[_loc14_] = {
|
||||
"slotId":_loc12_,
|
||||
"avInvId":_loc15_
|
||||
};
|
||||
}
|
||||
_loc9_[_loc14_] = _loc17_;
|
||||
}
|
||||
_loc12_++;
|
||||
}
|
||||
_loc13_ = new UserInfo();
|
||||
_loc13_.init(_loc7_,_loc9_,_loc10_);
|
||||
gMainFrame.userInfo.setUserInfoByUserName(_loc7_,_loc13_);
|
||||
_loc6_++;
|
||||
}
|
||||
if(_loc7_ != gMainFrame.server.userName)
|
||||
{
|
||||
if(_avatarListResponse != null)
|
||||
{
|
||||
_avatarListResponse();
|
||||
}
|
||||
}
|
||||
if(_alCallback != null)
|
||||
{
|
||||
if(_loc4_ >= 0)
|
||||
{
|
||||
_alCallback(_loc4_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_alCallback(_loc3_ == -1);
|
||||
}
|
||||
_alCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarBuyResponse(param1:Array) : void
|
||||
{
|
||||
if(_abCallback != null)
|
||||
{
|
||||
_abCallback(Boolean(int(param1[2])));
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarSwitchResponse(param1:Array) : void
|
||||
{
|
||||
if(_asCallback != null)
|
||||
{
|
||||
_asCallback(param1);
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarAddResponse(param1:Array) : void
|
||||
{
|
||||
if(_aaCallback != null)
|
||||
{
|
||||
_aaCallback(int(param1[2]),int(param1[3]),int(param1[4]));
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarKillResponse(param1:Array) : void
|
||||
{
|
||||
if(_akCallback != null)
|
||||
{
|
||||
_akCallback(Boolean(int(param1[2])),int(param1[3]));
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarOrdainResponse(param1:Array) : void
|
||||
{
|
||||
if(_aoCallback != null)
|
||||
{
|
||||
_aoCallback(Boolean(int(param1[2])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package avatar
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public interface INewAvatar
|
||||
{
|
||||
|
||||
function screenInitCallback(param1:MovieClip) : void;
|
||||
|
||||
function get playSound() : Boolean;
|
||||
|
||||
function newAvatarData(param1:int, param2:String, param3:Array, param4:Function, param5:Boolean = false) : void;
|
||||
|
||||
function hideConnectingMsg() : void;
|
||||
|
||||
function logInForCreateAvatarData() : void;
|
||||
|
||||
function nameTypeScreenDone() : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,608 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.filters.GlowFilter;
|
||||
import flash.geom.Point;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFieldAutoSize;
|
||||
import flash.text.TextFormat;
|
||||
import flash.utils.getDefinitionByName;
|
||||
import gskinner.motion.GTween;
|
||||
import gskinner.motion.easing.Linear;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.MediaHelper;
|
||||
import quest.QuestManager;
|
||||
|
||||
public class NPCView extends Sprite
|
||||
{
|
||||
|
||||
public static const NPC_STATE_LOADING:int = -2;
|
||||
|
||||
public static const NPC_STATE_LOADED:int = -1;
|
||||
|
||||
public static const NPC_STATE_IDLE:int = 0;
|
||||
|
||||
public static const NPC_STATE_MOVE:int = 1;
|
||||
|
||||
public static const NPC_STATE_ATTACK:int = 2;
|
||||
|
||||
public static const NPC_STATE_RECOIL:int = 3;
|
||||
|
||||
public static const NPC_STATE_DEATH:int = 4;
|
||||
|
||||
public static const NPC_STATE_TREASURE_APPEAR:int = 5;
|
||||
|
||||
public static const NPC_STATE_TREASURE_OPEN:int = 6;
|
||||
|
||||
public static const NPC_STATE_TREASURE_DISAPPEAR:int = 7;
|
||||
|
||||
public static const NPC_STATE_DANCE:int = 8;
|
||||
|
||||
private var _npcDef:Object;
|
||||
|
||||
private var _npcMC:MovieClip;
|
||||
|
||||
private var _npcAvatarView:AvatarWorldView;
|
||||
|
||||
private var _playerId:int;
|
||||
|
||||
private var _namebar:NameBar;
|
||||
|
||||
private var _mediaHelperObj:MediaHelper;
|
||||
|
||||
private var _onLoadingCompleteCallback:Function;
|
||||
|
||||
private var _npcState:int;
|
||||
|
||||
private var _npcAngle:int;
|
||||
|
||||
private var _npcEyeAngle:int;
|
||||
|
||||
private var _npcEyeAngleUpdateDelay:int;
|
||||
|
||||
private var _healthBar:MovieClip;
|
||||
|
||||
private var _hitText:TextField;
|
||||
|
||||
private var _hitTextTween:GTween;
|
||||
|
||||
public function NPCView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get npcState() : int
|
||||
{
|
||||
return this._npcState;
|
||||
}
|
||||
|
||||
public function get npcStateComplete() : Boolean
|
||||
{
|
||||
switch(this._npcState)
|
||||
{
|
||||
case NPC_STATE_LOADING:
|
||||
return false;
|
||||
case NPC_STATE_LOADED:
|
||||
return true;
|
||||
case NPC_STATE_TREASURE_APPEAR:
|
||||
case NPC_STATE_TREASURE_OPEN:
|
||||
case NPC_STATE_TREASURE_DISAPPEAR:
|
||||
return this._npcMC == null || Boolean(this._npcMC.finished);
|
||||
default:
|
||||
throw new Error("NPVView: npcStateComplete: Unsupported state");
|
||||
}
|
||||
}
|
||||
|
||||
public function get readyToLaunchAttack() : Boolean
|
||||
{
|
||||
if(this._npcState == NPC_STATE_ATTACK)
|
||||
{
|
||||
if(this._npcMC != null && this._npcMC.attacking == true)
|
||||
{
|
||||
this._npcMC.attacking = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get readyToAttack() : Boolean
|
||||
{
|
||||
if(this._npcState != NPC_STATE_ATTACK && this._npcState != NPC_STATE_DEATH)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get isDead() : Boolean
|
||||
{
|
||||
return this._npcState == NPC_STATE_DEATH && (this._npcMC == null || this._npcMC.animActive == false);
|
||||
}
|
||||
|
||||
public function get isDying() : Boolean
|
||||
{
|
||||
return this._npcState == NPC_STATE_DEATH;
|
||||
}
|
||||
|
||||
public function setNpcState(param1:int, param2:Number = 0) : void
|
||||
{
|
||||
if(this._npcMC)
|
||||
{
|
||||
if(this._npcState != NPC_STATE_DEATH)
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case NPC_STATE_TREASURE_APPEAR:
|
||||
if(this._npcMC)
|
||||
{
|
||||
this._npcMC.appear();
|
||||
this._npcState = param1;
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_TREASURE_OPEN:
|
||||
if(this._npcMC)
|
||||
{
|
||||
this._npcMC.openChest();
|
||||
this._npcState = param1;
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_TREASURE_DISAPPEAR:
|
||||
if(this._npcMC)
|
||||
{
|
||||
this._npcMC.disappear();
|
||||
this._npcState = param1;
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_DEATH:
|
||||
this._npcState = param1;
|
||||
this._npcMC.noHealth();
|
||||
break;
|
||||
case NPC_STATE_IDLE:
|
||||
if(this._npcMC.animActive == false)
|
||||
{
|
||||
this._npcState = param1;
|
||||
this._npcMC.idle(270);
|
||||
if(this._npcEyeAngle != 270)
|
||||
{
|
||||
--this._npcEyeAngleUpdateDelay;
|
||||
if(this._npcEyeAngleUpdateDelay <= 0)
|
||||
{
|
||||
this._npcEyeAngleUpdateDelay = Math.random() * 8 + 2;
|
||||
this._npcEyeAngle = 270;
|
||||
if(this._npcMC["setEye"] != null)
|
||||
{
|
||||
this._npcMC.setEye(270);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this._npcMC.hasOwnProperty("getSortHeight"))
|
||||
{
|
||||
this._npcMC.parent.parent.name = this._npcMC.getSortHeight();
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_MOVE:
|
||||
this._npcAngle = param2;
|
||||
if(this._npcMC.animActive == false)
|
||||
{
|
||||
this._npcState = param1;
|
||||
this._npcMC.moveCycle(this._npcAngle);
|
||||
if(this._npcEyeAngle != this._npcAngle)
|
||||
{
|
||||
--this._npcEyeAngleUpdateDelay;
|
||||
if(this._npcEyeAngleUpdateDelay <= 0)
|
||||
{
|
||||
this._npcEyeAngleUpdateDelay = Math.random() * 8 + 2;
|
||||
this._npcEyeAngle = this._npcAngle;
|
||||
if(this._npcMC["setEye"] != null)
|
||||
{
|
||||
this._npcMC.setEye(this._npcAngle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_ATTACK:
|
||||
this._npcState = param1;
|
||||
this._npcAngle = param2;
|
||||
this._npcMC.attack(this._npcAngle);
|
||||
if(this._npcEyeAngle != this._npcAngle)
|
||||
{
|
||||
--this._npcEyeAngleUpdateDelay;
|
||||
if(this._npcEyeAngleUpdateDelay <= 0)
|
||||
{
|
||||
this._npcEyeAngleUpdateDelay = Math.random() * 8 + 2;
|
||||
this._npcEyeAngle = this._npcAngle;
|
||||
if(this._npcMC["setEye"] != null)
|
||||
{
|
||||
this._npcMC.setEye(this._npcAngle);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_RECOIL:
|
||||
if(this._npcState != NPC_STATE_RECOIL)
|
||||
{
|
||||
if(this._npcState == NPC_STATE_IDLE || this._npcState == NPC_STATE_MOVE)
|
||||
{
|
||||
this._npcState = param1;
|
||||
}
|
||||
this._npcMC.recoil(this._npcAngle);
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_DANCE:
|
||||
this._npcState = param1;
|
||||
this.playAnimationState(LayerAnim.AN_DANCE,false,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get collisionRadius() : Number
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
return this._npcMC.getCollisionRadius();
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
||||
public function get collisionRadiusMoving() : Number
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionRadius" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionRadius(1);
|
||||
}
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
||||
public function get collisionPoint() : Point
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionPoint" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionPoint(1);
|
||||
}
|
||||
}
|
||||
return new Point(0,0);
|
||||
}
|
||||
|
||||
public function get collisionZapPoint() : Point
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionPoint" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionPoint(2);
|
||||
}
|
||||
}
|
||||
return new Point(0,0);
|
||||
}
|
||||
|
||||
public function get collisionRadiusAttack() : Number
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionRadius" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionRadius(0);
|
||||
}
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
||||
public function get collisionPointAttack() : Point
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionPoint" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionPoint(0);
|
||||
}
|
||||
}
|
||||
return new Point(0,0);
|
||||
}
|
||||
|
||||
public function get avatar() : Avatar
|
||||
{
|
||||
if(this._npcAvatarView != null)
|
||||
{
|
||||
return this._npcAvatarView.avatarData;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get talkingHeadMediaId() : int
|
||||
{
|
||||
if(this._npcDef != null)
|
||||
{
|
||||
return this._npcDef.headMediaRefId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function reset() : void
|
||||
{
|
||||
this._npcState = NPC_STATE_LOADING;
|
||||
}
|
||||
|
||||
public function init(param1:int, param2:int, param3:int = -1, param4:Boolean = false, param5:Function = null) : void
|
||||
{
|
||||
var _loc6_:Avatar = null;
|
||||
var _loc7_:Array = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:Item = null;
|
||||
var _loc10_:* = 0;
|
||||
var _loc11_:Array = null;
|
||||
var _loc12_:Array = null;
|
||||
this._npcState = NPC_STATE_LOADING;
|
||||
this._npcAngle = 0;
|
||||
this._npcDef = QuestManager.getNPCDef(param1);
|
||||
this._playerId = param2;
|
||||
this._onLoadingCompleteCallback = param5;
|
||||
this._hitText = new TextField();
|
||||
this._hitText.selectable = false;
|
||||
this._hitText.multiline = false;
|
||||
this._hitText.autoSize = TextFieldAutoSize.CENTER;
|
||||
this._hitText.visible = false;
|
||||
this._hitText.embedFonts = true;
|
||||
this._hitText.defaultTextFormat = new TextFormat("Tiki-Island",36,4286945);
|
||||
this._hitText.filters = [new GlowFilter(0,1,3,3,10,2)];
|
||||
switch(this._npcDef.type)
|
||||
{
|
||||
case 0:
|
||||
this._mediaHelperObj = new MediaHelper();
|
||||
this._mediaHelperObj.init(this._npcDef.mediaRefId,this.onMediaLoaded);
|
||||
break;
|
||||
case 1:
|
||||
_loc6_ = new Avatar();
|
||||
_loc6_.avName = "";
|
||||
_loc6_.userName = "";
|
||||
this._npcAvatarView = new AvatarWorldView();
|
||||
this._npcAvatarView.initWorldView(_loc6_,QuestManager._layerManager.room_chat,Utility.NON_MEMBER,true);
|
||||
_loc6_.init(-1,_loc6_.avName,this._npcDef.avatarRefId,[this._npcDef.baseColor,this._npcDef.patternColor,this._npcDef.eyesColor]);
|
||||
_loc6_.itemResponseIntegrate(ItemXtCommManager.generateBodyModList(this._npcDef.avatarRefId,this._npcDef.patternItemRefId,this._npcDef.eyesItemRefId,false));
|
||||
if(param3 > 0)
|
||||
{
|
||||
LocalizationXtCommManager.sendTranslateStringRequest(param3,LocalizationXtCommManager.LANG_ENG,this.onNameBarLocReceived,param3);
|
||||
}
|
||||
_loc7_ = new Array();
|
||||
_loc10_ = 100;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < this._npcAvatarView.avatarData.inventoryBodyMod.itemArray.length)
|
||||
{
|
||||
_loc7_.push(this._npcAvatarView.avatarData.inventoryBodyMod.itemArray[_loc8_]);
|
||||
_loc8_++;
|
||||
}
|
||||
if(this._npcDef.backItemRefId != 0)
|
||||
{
|
||||
_loc9_ = new Item();
|
||||
_loc11_ = ItemXtCommManager.getItemDef(this._npcDef.backItemRefId).colors;
|
||||
_loc9_.init(this._npcDef.backItemRefId,_loc10_++,_loc11_[Math.min(this._npcDef.backColor,_loc11_.length - 1)],-1,-1);
|
||||
_loc7_.push(_loc9_);
|
||||
}
|
||||
if(this._npcDef.headItemRefId != 0)
|
||||
{
|
||||
_loc9_ = new Item();
|
||||
_loc11_ = ItemXtCommManager.getItemDef(this._npcDef.headItemRefId).colors;
|
||||
_loc9_.init(this._npcDef.headItemRefId,_loc10_++,_loc11_[Math.min(this._npcDef.headColor,_loc11_.length - 1)],-1,-1);
|
||||
_loc7_.push(_loc9_);
|
||||
}
|
||||
if(this._npcDef.legItemRefId != 0)
|
||||
{
|
||||
_loc9_ = new Item();
|
||||
_loc11_ = ItemXtCommManager.getItemDef(this._npcDef.legItemRefId).colors;
|
||||
_loc9_.init(this._npcDef.legItemRefId,_loc10_++,_loc11_[Math.min(this._npcDef.legColor,_loc11_.length - 1)],-1,-1);
|
||||
_loc7_.push(_loc9_);
|
||||
}
|
||||
if(this._npcDef.neckItemRefId != 0)
|
||||
{
|
||||
_loc9_ = new Item();
|
||||
_loc11_ = ItemXtCommManager.getItemDef(this._npcDef.neckItemRefId).colors;
|
||||
_loc9_.init(this._npcDef.neckItemRefId,_loc10_++,_loc11_[Math.min(this._npcDef.neckColor,_loc11_.length - 1)],-1,-1);
|
||||
_loc7_.push(_loc9_);
|
||||
}
|
||||
if(this._npcDef.tailItemRefId != 0)
|
||||
{
|
||||
_loc9_ = new Item();
|
||||
_loc11_ = ItemXtCommManager.getItemDef(this._npcDef.tailItemRefId).colors;
|
||||
_loc9_.init(this._npcDef.tailItemRefId,_loc10_++,_loc11_[Math.min(this._npcDef.tailColor,_loc11_.length - 1)],-1,-1);
|
||||
_loc7_.push(_loc9_);
|
||||
}
|
||||
this._npcAvatarView.avatarData.itemResponseIntegrate(_loc7_);
|
||||
_loc12_ = new Array(3);
|
||||
_loc12_[0] = LayerAnim.AN_IDLE_SE;
|
||||
_loc12_[1] = LayerAnim.AN_DANCE;
|
||||
_loc12_[2] = LayerAnim.AN_SLEEP;
|
||||
this._npcAvatarView.preloadAnims(_loc12_,this.redrawCallback);
|
||||
}
|
||||
if(param4)
|
||||
{
|
||||
this._healthBar = new (getDefinitionByName("NPCHealth") as Class)();
|
||||
this._healthBar.x = -this._healthBar.width * 0.5;
|
||||
this._healthBar.y = 18;
|
||||
this._healthBar.hpBar.width = this._healthBar.hpEnemyBarContainer.width;
|
||||
addChild(this._healthBar);
|
||||
}
|
||||
}
|
||||
|
||||
private function onNameBarLocReceived(param1:int, param2:String, param3:Object) : void
|
||||
{
|
||||
if(this._npcAvatarView != null && this._npcAvatarView.avatarData != null)
|
||||
{
|
||||
this._npcAvatarView.avatarData.avName = param2;
|
||||
this._npcAvatarView.avatarData.userName = param2;
|
||||
if(this._npcAvatarView.nameBar != null)
|
||||
{
|
||||
this._npcAvatarView.nameBar.setAvName(param2);
|
||||
this._npcAvatarView.nameBar.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(this._mediaHelperObj)
|
||||
{
|
||||
this._mediaHelperObj.destroy();
|
||||
this._mediaHelperObj = null;
|
||||
}
|
||||
if(Boolean(this._npcMC) && this._npcMC.parent != null)
|
||||
{
|
||||
this._npcMC.parent.removeChild(this._npcMC);
|
||||
}
|
||||
if(this._namebar)
|
||||
{
|
||||
this._namebar.destroy();
|
||||
this._namebar = null;
|
||||
}
|
||||
if(this._healthBar)
|
||||
{
|
||||
this._healthBar = null;
|
||||
}
|
||||
if(this._npcAvatarView)
|
||||
{
|
||||
if(this._npcAvatarView.parent != null)
|
||||
{
|
||||
this._npcAvatarView.parent.removeChild(this._npcAvatarView);
|
||||
}
|
||||
this._npcAvatarView.destroy(true);
|
||||
}
|
||||
this._hitTextTween = null;
|
||||
}
|
||||
|
||||
public function updateHealthBar(param1:int, param2:int, param3:Boolean) : void
|
||||
{
|
||||
if(this._healthBar)
|
||||
{
|
||||
if(param1 == 0)
|
||||
{
|
||||
this._healthBar.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._healthBar.hpBar.width = this._healthBar.hpEnemyBarContainer.width * (param1 / 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function playHitText(param1:String) : void
|
||||
{
|
||||
var attachmentPoint:Point = null;
|
||||
var hitString:String = param1;
|
||||
this._hitText.visible = true;
|
||||
this._hitText.alpha = 2;
|
||||
this._hitText.text = hitString;
|
||||
try
|
||||
{
|
||||
attachmentPoint = this._npcMC.getAttachmentPoint();
|
||||
this._hitText.x = attachmentPoint.x + this.x - this._hitText.textWidth * 0.5;
|
||||
this._hitText.y = attachmentPoint.y + this.y;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
_hitText.x = this.x - _hitText.textWidth * 0.5;
|
||||
_hitText.y = this.y - _hitText.textHeight;
|
||||
}
|
||||
if(parent != null)
|
||||
{
|
||||
this._hitText.x += parent.x;
|
||||
this._hitText.y += parent.y;
|
||||
}
|
||||
if(this._hitTextTween)
|
||||
{
|
||||
this._hitTextTween.resetValues({
|
||||
"y":this._hitText.y - 90,
|
||||
"alpha":0
|
||||
});
|
||||
this._hitTextTween.beginning();
|
||||
this._hitTextTween.paused = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._hitTextTween = new GTween(this._hitText,1,{
|
||||
"y":this._hitText.y - 90,
|
||||
"alpha":0
|
||||
},{"ease":Linear.easeNone});
|
||||
}
|
||||
}
|
||||
|
||||
public function playAnimationState(param1:int, param2:Boolean, param3:int, param4:Function) : void
|
||||
{
|
||||
if(this._npcAvatarView)
|
||||
{
|
||||
this._npcAvatarView.playAnim(param1,param2,param3,param4);
|
||||
}
|
||||
}
|
||||
|
||||
public function get npcMC() : MovieClip
|
||||
{
|
||||
return this._npcMC;
|
||||
}
|
||||
|
||||
public function get defId() : int
|
||||
{
|
||||
return this._npcDef.defId;
|
||||
}
|
||||
|
||||
public function get npcDef() : Object
|
||||
{
|
||||
return this._npcDef;
|
||||
}
|
||||
|
||||
private function onMediaLoaded(param1:MovieClip) : void
|
||||
{
|
||||
this._npcMC = param1;
|
||||
this._mediaHelperObj.destroy();
|
||||
this._mediaHelperObj = null;
|
||||
addChild(this._npcMC);
|
||||
this.loadingComplete();
|
||||
}
|
||||
|
||||
private function redrawCallback(param1:LayerAnim) : void
|
||||
{
|
||||
if(Boolean(param1) && Boolean(this._npcAvatarView))
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_IDLE_SE,false,LayerAnim.PLAY_LOOP,null);
|
||||
addChild(this._npcAvatarView);
|
||||
this.loadingComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private function loadingComplete() : void
|
||||
{
|
||||
this._npcState = NPC_STATE_LOADED;
|
||||
QuestManager._layerManager.room_chat.addChild(this._hitText);
|
||||
if(this._onLoadingCompleteCallback != null)
|
||||
{
|
||||
this._onLoadingCompleteCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public function setSwfState(param1:String) : Number
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
return this._npcMC.setStateByScript(param1);
|
||||
}
|
||||
if(this._npcAvatarView != null)
|
||||
{
|
||||
if(param1 == "dance")
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_DANCE,false,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,730 @@
|
||||
package avatar
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class NameBar extends MovieClip
|
||||
{
|
||||
|
||||
private static var _getNamebarIconsFunc:Function;
|
||||
|
||||
public static var NON_BUDDY:String = "nonBuddy";
|
||||
|
||||
public static var BUDDY:String = "buddy";
|
||||
|
||||
public static var GUIDE:String = "guide";
|
||||
|
||||
private static var BADGE_ID_VIP_CAMERA:int = 31;
|
||||
|
||||
private static const LEVEL_SHAPES:Array = new Array(1851,1858,1853,1857);
|
||||
|
||||
private var _iconIdsArray:Array;
|
||||
|
||||
private const MAX_COLORS:int = 10;
|
||||
|
||||
private var _isBlocked:Boolean;
|
||||
|
||||
private var _nubType:String;
|
||||
|
||||
private var _left:MovieClip;
|
||||
|
||||
private var _mid:MovieClip;
|
||||
|
||||
private var _right:MovieClip;
|
||||
|
||||
private var _avName:MovieClip;
|
||||
|
||||
private var _meter:MovieClip;
|
||||
|
||||
private var _shape:MovieClip;
|
||||
|
||||
private var _iconsMediaHelperArray:Array;
|
||||
|
||||
private var _iconImages:Array;
|
||||
|
||||
private var _nubDataArray:Array;
|
||||
|
||||
private var _nameBarDataToBeLoaded:int;
|
||||
|
||||
private var _currframeName:String;
|
||||
|
||||
private var _packedNameBarData:int;
|
||||
|
||||
private var _badgeId:int;
|
||||
|
||||
private var _levelShapeHelper:MediaHelper;
|
||||
|
||||
private var _shapesMediaHelperArray:Array;
|
||||
|
||||
private var _currShapeMouse:MovieClip;
|
||||
|
||||
private var _currShapeUp:MovieClip;
|
||||
|
||||
private var _isMember:Boolean;
|
||||
|
||||
public function NameBar(param1:String = "nonBuddy", param2:Boolean = false)
|
||||
{
|
||||
super();
|
||||
if(this["e"].currentFrameLabel)
|
||||
{
|
||||
this._left = this["e"][String(this["e"].currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._left = this["e"];
|
||||
}
|
||||
if(this["n"].currentFrameLabel)
|
||||
{
|
||||
this._mid = this["n"][String(this["n"].currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._mid = this["n"];
|
||||
}
|
||||
if(this["meter"] != null)
|
||||
{
|
||||
if(this["meter"].currentFrameLabel)
|
||||
{
|
||||
this._meter = this["meter"][String(this["meter"].currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._meter = this["meter"];
|
||||
}
|
||||
}
|
||||
if(this["shape"] != null)
|
||||
{
|
||||
if(this["shape"].currentFrameLabel)
|
||||
{
|
||||
this._shape = this["shape"][String(this["shape"].currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._shape = this["shape"];
|
||||
}
|
||||
}
|
||||
this._right = this["selnub"];
|
||||
this._avName = this["c"];
|
||||
if(!(Boolean(this._left) && Boolean(this._mid) && Boolean(this._right) && Boolean(this._avName) && this._avName.txt))
|
||||
{
|
||||
throw new Error("NameBar is missing parts or parts are named improperly!");
|
||||
}
|
||||
this._currframeName = "black";
|
||||
this.isBlocked = param2;
|
||||
this.nubType = param1;
|
||||
this._iconsMediaHelperArray = [];
|
||||
this._shapesMediaHelperArray = [];
|
||||
this._iconImages = [];
|
||||
this._nubDataArray = [];
|
||||
if(_getNamebarIconsFunc != null)
|
||||
{
|
||||
this._iconIdsArray = _getNamebarIconsFunc();
|
||||
}
|
||||
if(!this._iconIdsArray)
|
||||
{
|
||||
this._iconIdsArray = [];
|
||||
}
|
||||
this._nameBarDataToBeLoaded = -1;
|
||||
this.cacheAsBitmap = true;
|
||||
addEventListener(MouseEvent.ROLL_OVER,this.onOverHandler,false,0,true);
|
||||
addEventListener(MouseEvent.ROLL_OUT,this.onOutHandler,false,0,true);
|
||||
}
|
||||
|
||||
public static function set getNamebarIconsFunc(param1:Function) : void
|
||||
{
|
||||
_getNamebarIconsFunc = param1;
|
||||
}
|
||||
|
||||
public static function isVIPBadge(param1:int) : Boolean
|
||||
{
|
||||
var _loc2_:int = param1 >> 8 & 0xFF;
|
||||
return _loc2_ + 1 == BADGE_ID_VIP_CAMERA;
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this.removeListeners();
|
||||
}
|
||||
|
||||
public function set isBlocked(param1:Boolean) : void
|
||||
{
|
||||
this._isBlocked = param1;
|
||||
if(this._nubType != GUIDE)
|
||||
{
|
||||
this._right.blocked.visible = this._isBlocked;
|
||||
}
|
||||
}
|
||||
|
||||
public function setColorAndBadge(param1:int) : void
|
||||
{
|
||||
this._packedNameBarData = param1;
|
||||
var _loc2_:int = param1 & 0xFF;
|
||||
var _loc3_:int = param1 >> 8 & 0xFF;
|
||||
this._badgeId = _loc3_ + 1;
|
||||
if(this["e"].currentFrameLabel)
|
||||
{
|
||||
this.setColor(_loc2_);
|
||||
this.setBadgeIcon(_loc3_);
|
||||
if(Boolean(this._currShapeMouse) && this._currShapeMouse.level != null)
|
||||
{
|
||||
this.setCurrShape();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setNubType(param1:String, param2:Boolean = true) : void
|
||||
{
|
||||
this.nubType = param1;
|
||||
this.resize(param2);
|
||||
}
|
||||
|
||||
public function setAvName(param1:String, param2:Boolean = true) : void
|
||||
{
|
||||
this._avName.txt.text = param1;
|
||||
this.resize(param2);
|
||||
}
|
||||
|
||||
public function showHealthBar(param1:Boolean, param2:int = -1, param3:Boolean = false, param4:int = 0) : void
|
||||
{
|
||||
if(this._meter)
|
||||
{
|
||||
this["meter"].visible = param1;
|
||||
this._isMember = param3;
|
||||
if(param2 != -1 && param2 > 0)
|
||||
{
|
||||
this.setShape(param2);
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
this.setMeter(param4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setQuestLevel(param1:int, param2:Boolean, param3:Boolean) : void
|
||||
{
|
||||
this._isMember = param2;
|
||||
if(param3)
|
||||
{
|
||||
this.setShape(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateMeter(param1:int) : void
|
||||
{
|
||||
this.setMeter(param1);
|
||||
}
|
||||
|
||||
public function getMeterValue() : int
|
||||
{
|
||||
if(this["meter"])
|
||||
{
|
||||
return this["meter"].hpBar.width;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function removeListeners() : void
|
||||
{
|
||||
removeEventListener(MouseEvent.ROLL_OVER,this.onOverHandler);
|
||||
removeEventListener(MouseEvent.ROLL_OUT,this.onOutHandler);
|
||||
}
|
||||
|
||||
public function get nubData() : Array
|
||||
{
|
||||
return this._nubDataArray;
|
||||
}
|
||||
|
||||
public function set nubData(param1:Array) : void
|
||||
{
|
||||
this._nubDataArray = param1;
|
||||
}
|
||||
|
||||
public function get iconIds() : Array
|
||||
{
|
||||
return this._iconIdsArray;
|
||||
}
|
||||
|
||||
public function set iconIds(param1:Array) : void
|
||||
{
|
||||
this._iconIdsArray = param1;
|
||||
}
|
||||
|
||||
public function get packedNameBarData() : int
|
||||
{
|
||||
return this._packedNameBarData;
|
||||
}
|
||||
|
||||
public function get xpShapeIcons() : Object
|
||||
{
|
||||
return {
|
||||
"mouseIcon":this._currShapeMouse,
|
||||
"upIcon":this._currShapeUp
|
||||
};
|
||||
}
|
||||
|
||||
public function set xpShapeIcons(param1:Object) : void
|
||||
{
|
||||
this._currShapeMouse = param1.mouseIcon;
|
||||
this._currShapeUp = param1.upIcon;
|
||||
if(Boolean(this._currShapeMouse) && this._currShapeMouse.level != null)
|
||||
{
|
||||
this.setShape(this._currShapeMouse.level);
|
||||
}
|
||||
}
|
||||
|
||||
public function get currentLevel() : int
|
||||
{
|
||||
if(Boolean(this._currShapeMouse) && this._currShapeMouse.level != null)
|
||||
{
|
||||
return this._currShapeMouse.level;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function setColor(param1:int) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(param1 == 0)
|
||||
{
|
||||
_loc2_ = 4;
|
||||
}
|
||||
else if(param1 > 3 && param1 <= this.MAX_COLORS)
|
||||
{
|
||||
_loc2_ = param1 + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = Math.min(4,param1);
|
||||
}
|
||||
this._currframeName = this["e"].currentLabels[_loc2_ - 1].name;
|
||||
this["e"].gotoAndStop(this._currframeName);
|
||||
this._left = this["e"][this._currframeName];
|
||||
this["n"].gotoAndStop(this._currframeName);
|
||||
this._mid = this["n"][this._currframeName];
|
||||
if(this._meter)
|
||||
{
|
||||
this["meter"].gotoAndStop(this._currframeName);
|
||||
this._meter = this["meter"][this._currframeName];
|
||||
}
|
||||
if(this._shape)
|
||||
{
|
||||
this["shape"].gotoAndStop(this._currframeName);
|
||||
this._shape = this["shape"][this._currframeName];
|
||||
}
|
||||
if(this["selnub"].nub.currentFrameLabel)
|
||||
{
|
||||
this["selnub"].nub.gotoAndStop(this._currframeName);
|
||||
this._right = this["selnub"];
|
||||
}
|
||||
if(this._avName.currentFrameLabel)
|
||||
{
|
||||
this._avName.gotoAndStop(this._currframeName);
|
||||
}
|
||||
this._left.mouse.gotoAndStop(1);
|
||||
this._mid.mouse.gotoAndStop(1);
|
||||
if(this._shape)
|
||||
{
|
||||
this._shape.mouse.gotoAndStop(1);
|
||||
}
|
||||
if(this._right.nub.currentFrameLabel)
|
||||
{
|
||||
this._right.nub[this._currframeName].mouse.gotoAndStop(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.nub.mouse.gotoAndStop(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function setBadgeIcon(param1:int) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(this._iconIdsArray.length > 0)
|
||||
{
|
||||
if(this["selnub"].currentFrameLabel == "buddy")
|
||||
{
|
||||
while(this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
while(this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
_loc2_ = int(this._iconIdsArray[param1]);
|
||||
param1 *= 2;
|
||||
if(param1 % 2 != 0)
|
||||
{
|
||||
param1++;
|
||||
}
|
||||
if(Boolean(this._iconImages[param1]) && Boolean(this._iconImages[param1 + 1]))
|
||||
{
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.mouse.icon.addChild(this._iconImages[param1]);
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.up.icon.addChild(this._iconImages[param1 + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._nubDataArray[param1] = this._right.nub[String(this._right.nub.currentFrameLabel)].mouse;
|
||||
this.loadIcon(_loc2_,param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._nameBarDataToBeLoaded = this._packedNameBarData;
|
||||
}
|
||||
}
|
||||
|
||||
private function set nubType(param1:String) : void
|
||||
{
|
||||
if(param1 == "")
|
||||
{
|
||||
this._right.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.visible = true;
|
||||
this._nubType = param1;
|
||||
this._right.gotoAndStop(this._nubType);
|
||||
if(this._right.nub.currentFrameLabel)
|
||||
{
|
||||
this._right.nub.gotoAndStop(this._currframeName);
|
||||
this._right.nub[this._currframeName].mouse.gotoAndStop(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.nub.mouse.gotoAndStop(1);
|
||||
}
|
||||
if(this._isBlocked && this._nubType != GUIDE)
|
||||
{
|
||||
this._right.blocked.gotoAndStop(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function resize(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:MovieClip = null;
|
||||
var _loc4_:MovieClip = null;
|
||||
var _loc5_:MovieClip = null;
|
||||
var _loc6_:MovieClip = null;
|
||||
if(param1)
|
||||
{
|
||||
_loc3_ = this._mid.parent != this ? MovieClip(this._mid.parent) : this._mid;
|
||||
_loc4_ = this._left.parent != this ? MovieClip(this._left.parent) : this._left;
|
||||
_loc5_ = Boolean(this._shape) && this._shape.parent != this ? MovieClip(this._shape.parent) : this._shape;
|
||||
_loc6_ = Boolean(this._meter) && this._meter.parent != this ? MovieClip(this._meter.parent) : this._meter;
|
||||
if(this._nubType == NON_BUDDY && !this._isBlocked)
|
||||
{
|
||||
_loc2_ = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = 20;
|
||||
}
|
||||
this._avName.txt.width = 300;
|
||||
if(this._avName.txt.textWidth + _loc2_ < 60)
|
||||
{
|
||||
_loc3_.width = 60 + 0.5 * this._right.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_.width = Math.ceil(this._avName.txt.textWidth + _loc2_);
|
||||
}
|
||||
_loc3_.x = _loc3_.width * 0.5 * -1;
|
||||
this._avName.txt.width = _loc3_.width - _loc2_ + 5;
|
||||
_loc4_.x = _loc3_.x - _loc4_.width;
|
||||
this._avName.x = _loc3_.x + 2;
|
||||
this._right.x = _loc3_.x + _loc3_.width - 1;
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc5_.x = _loc4_.x - _loc5_.width * 0.5;
|
||||
}
|
||||
if(_loc6_)
|
||||
{
|
||||
_loc6_.width = this._avName.txt.width + 18;
|
||||
_loc6_.x = this._avName.x - 7;
|
||||
}
|
||||
}
|
||||
this._left.mouse.gotoAndStop(1);
|
||||
this._mid.mouse.gotoAndStop(1);
|
||||
if(this._shape)
|
||||
{
|
||||
this._shape.mouse.gotoAndStop(1);
|
||||
}
|
||||
if(this._right.nub.currentFrameLabel)
|
||||
{
|
||||
this._right.nub[this._currframeName].mouse.gotoAndStop(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.nub.mouse.gotoAndStop(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function loadIcon(param1:int, param2:int) : void
|
||||
{
|
||||
var _loc3_:MediaHelper = new MediaHelper();
|
||||
_loc3_.init(param1,this.onIconsLoaded,param2);
|
||||
this._iconsMediaHelperArray[param2] = _loc3_;
|
||||
_loc3_ = new MediaHelper();
|
||||
_loc3_.init(param1,this.onIconsLoaded,param2 + 1);
|
||||
this._iconsMediaHelperArray[param2 + 1] = _loc3_;
|
||||
}
|
||||
|
||||
private function onIconsLoaded(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc3_:int = 0;
|
||||
if(param1)
|
||||
{
|
||||
param1.cacheAsBitmap = true;
|
||||
_loc3_ = int(param1.passback);
|
||||
this._iconImages[_loc3_] = param1;
|
||||
if(param1.passback % 2 == 0)
|
||||
{
|
||||
_loc2_ = this._nubDataArray[_loc3_].mouse.icon;
|
||||
while(_loc2_.numChildren > 0)
|
||||
{
|
||||
_loc2_.removeChildAt(0);
|
||||
}
|
||||
_loc2_.addChild(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = this._nubDataArray[_loc3_ - 1].up.icon;
|
||||
while(_loc2_.numChildren > 0)
|
||||
{
|
||||
_loc2_.removeChildAt(0);
|
||||
}
|
||||
_loc2_.addChild(param1);
|
||||
}
|
||||
if(this._iconsMediaHelperArray[_loc3_])
|
||||
{
|
||||
this._iconsMediaHelperArray[_loc3_].destroy();
|
||||
this._iconsMediaHelperArray[_loc3_] = null;
|
||||
delete this._iconsMediaHelperArray[_loc3_];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setCurrShape() : void
|
||||
{
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.up.icon.addChild(this._currShapeUp);
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.mouse.icon.addChild(this._currShapeMouse);
|
||||
}
|
||||
|
||||
private function setShape(param1:int) : void
|
||||
{
|
||||
if(param1 > 0)
|
||||
{
|
||||
if(this._currShapeMouse == null || this._currShapeMouse.level != param1 && Math.floor(this._currShapeMouse.level / 5) != Math.floor(param1 / 5))
|
||||
{
|
||||
this._levelShapeHelper = new MediaHelper();
|
||||
this._levelShapeHelper.init(LEVEL_SHAPES[Math.floor(param1 / 5)],this.onLevelShapeLoaded,-1);
|
||||
this._shapesMediaHelperArray.push(this._levelShapeHelper);
|
||||
this._levelShapeHelper = new MediaHelper();
|
||||
this._levelShapeHelper.init(LEVEL_SHAPES[Math.floor(param1 / 5)],this.onLevelShapeLoaded,param1);
|
||||
this._shapesMediaHelperArray.push(this._levelShapeHelper);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.up.icon.addChild(this._currShapeUp);
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.mouse.icon.addChild(this._currShapeMouse);
|
||||
this._currShapeMouse.text.text = param1;
|
||||
this._currShapeUp.text.text = param1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onLevelShapeLoaded(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
if(param1)
|
||||
{
|
||||
_loc2_ = MovieClip(param1.getChildAt(0));
|
||||
if(param1.passback == -1)
|
||||
{
|
||||
this._currShapeUp = _loc2_;
|
||||
if(this._isMember)
|
||||
{
|
||||
this._currShapeUp.gotoAndStop("member");
|
||||
}
|
||||
if(this._currShapeMouse)
|
||||
{
|
||||
this._currShapeUp.text.text = this._currShapeMouse.level;
|
||||
}
|
||||
this._shapesMediaHelperArray[0].destroy();
|
||||
this._shapesMediaHelperArray.splice(0,1);
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.up.icon.addChild(this._currShapeUp);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._currShapeMouse = _loc2_;
|
||||
if(this._isMember)
|
||||
{
|
||||
this._currShapeMouse.gotoAndStop("member");
|
||||
}
|
||||
this._currShapeMouse.level = this._currShapeMouse.text.text = param1.passback;
|
||||
if(this._currShapeUp)
|
||||
{
|
||||
this._currShapeUp.text.text = this._currShapeMouse.level;
|
||||
}
|
||||
this._shapesMediaHelperArray[this._shapesMediaHelperArray.length - 1].destroy();
|
||||
this._shapesMediaHelperArray.pop();
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.mouse.icon.addChild(this._currShapeMouse);
|
||||
}
|
||||
this._shape.mouse.gotoAndStop(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function setMeter(param1:int) : void
|
||||
{
|
||||
if(this["meter"])
|
||||
{
|
||||
this["meter"].hpBar.width = this["meter"].hpBarContainer.width * (param1 / 100);
|
||||
}
|
||||
}
|
||||
|
||||
private function onOverHandler(param1:MouseEvent) : void
|
||||
{
|
||||
this._left.mouse.gotoAndPlay(1);
|
||||
this._mid.mouse.gotoAndPlay(1);
|
||||
if(this._shape)
|
||||
{
|
||||
this._shape.mouse.gotoAndPlay(1);
|
||||
}
|
||||
if(this._right.nub.currentFrameLabel)
|
||||
{
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.gotoAndPlay(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.nub.mouse.gotoAndPlay(1);
|
||||
}
|
||||
if(this._isBlocked && this._nubType != GUIDE)
|
||||
{
|
||||
this._right.blocked.mouse.gotoAndPlay(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function onOutHandler(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
if(this._right.nub[String(this._right.nub.currentFrameLabel)])
|
||||
{
|
||||
_loc2_ = this._right.nub[String(this._right.nub.currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = this._right.nub;
|
||||
}
|
||||
if(this._left.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(this._left.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._left.mouse.stop();
|
||||
}
|
||||
if(this._mid.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(this._mid.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._mid.mouse.stop();
|
||||
}
|
||||
if(this._shape)
|
||||
{
|
||||
if(this._shape.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(this._shape.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._shape.mouse.stop();
|
||||
}
|
||||
}
|
||||
if(_loc2_.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(_loc2_.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.mouse.stop();
|
||||
}
|
||||
if(this._isBlocked && this._nubType != GUIDE)
|
||||
{
|
||||
if(this._right.blocked.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(this._right.blocked.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.blocked.mouse.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function playBackwards(param1:MovieClip) : void
|
||||
{
|
||||
param1.addEventListener(Event.ENTER_FRAME,this.pbFrameHandler,false,0,true);
|
||||
}
|
||||
|
||||
private function pbFrameHandler(param1:Event) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
if(param1.target as MovieClip)
|
||||
{
|
||||
_loc2_ = MovieClip(param1.target);
|
||||
if(_loc2_.currentFrame == 1)
|
||||
{
|
||||
_loc2_.removeEventListener(Event.ENTER_FRAME,this.pbFrameHandler);
|
||||
return;
|
||||
}
|
||||
_loc2_.prevFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import flash.display.MovieClip;
|
||||
import gui.DarkenManager;
|
||||
|
||||
public class NewWorldAvatar implements INewAvatar
|
||||
{
|
||||
|
||||
public function NewWorldAvatar()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function screenInitCallback(param1:MovieClip) : void
|
||||
{
|
||||
param1.visible = false;
|
||||
}
|
||||
|
||||
public function get playSound() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function newAvatarData(param1:int, param2:String, param3:Array, param4:Function, param5:Boolean = false) : void
|
||||
{
|
||||
SBTracker.trackPageview("/game/play/popup/avatarSwitch/buyAnimal");
|
||||
var _loc6_:Boolean = Boolean(param2 && param2 != "" && RegExp(/a-zA-Z0-9 /)["exec"](param2) == null);
|
||||
if(_loc6_)
|
||||
{
|
||||
AvatarSwitch.addNewWorldAvatar(param1,param2,param3,param5);
|
||||
}
|
||||
if(param4 != null && !AvatarSwitch.isAddingSlot)
|
||||
{
|
||||
param4(_loc6_);
|
||||
}
|
||||
if(_loc6_)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function hideConnectingMsg() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function nameTypeScreenDone() : void
|
||||
{
|
||||
AvatarUtility.creationAssets.visible = false;
|
||||
AvatarUtility.creationAssets.destroyReloadedItems();
|
||||
}
|
||||
|
||||
public function logInForCreateAvatarData() : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,700 @@
|
||||
package avatar
|
||||
{
|
||||
import com.adobe.utils.StringUtil;
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.loader.FileServerEvent;
|
||||
import com.sbi.popup.*;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.text.TextFormat;
|
||||
import game.MinigameManager;
|
||||
import gui.ActionManager;
|
||||
import gui.ChatHistory;
|
||||
import gui.EmoticonManager;
|
||||
import gui.EmoticonUtility;
|
||||
import gui.GuiManager;
|
||||
import gui.SafeChatManager;
|
||||
import loader.DefPacksDefHelper;
|
||||
import loader.JCDefHelper;
|
||||
import room.RoomManagerWorld;
|
||||
|
||||
public class UserCommXtCommManager
|
||||
{
|
||||
|
||||
public static var RAW_STR:String;
|
||||
|
||||
private static var _mainHud:MovieClip;
|
||||
|
||||
private static var _chatHist:ChatHistory;
|
||||
|
||||
private static var _emoteMgr:EmoticonManager;
|
||||
|
||||
private static var _actionMgr:ActionManager;
|
||||
|
||||
private static var _roomMgr:RoomManagerWorld;
|
||||
|
||||
private static var _spellingCorrections:Object;
|
||||
|
||||
private static var _emoteDefs:Object;
|
||||
|
||||
private static var _specialWords:Object;
|
||||
|
||||
private static var _replacedWords:Object;
|
||||
|
||||
public static const CHAT_TYPE_TYPED:int = 0;
|
||||
|
||||
public static const CHAT_TYPE_SAFE:int = 1;
|
||||
|
||||
public static const CHAT_TYPE_EMOTE:int = 2;
|
||||
|
||||
public static const CHAT_TYPE_ACTION:int = 3;
|
||||
|
||||
public static const CHAT_TYPE_ATTACHMENT:int = 4;
|
||||
|
||||
public static const CHAT_TYPE_PERM_EMOTE:int = 5;
|
||||
|
||||
public static const CHAT_TYPE_SLIDE:int = 6;
|
||||
|
||||
public static const CHAT_TYPE_PET_ACTION:int = 7;
|
||||
|
||||
public static const CHAT_TYPE_BLEND_COLOR:int = 8;
|
||||
|
||||
public static const CHAT_TYPE_LIMITED:int = 9;
|
||||
|
||||
public static const CHAT_TYPE_ALPHA_LEVEL:int = 10;
|
||||
|
||||
private static var _playerSfsUserId:int = -1;
|
||||
|
||||
public function UserCommXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
DebugUtility.debugTrace("UserCommXtCommManager init - initializing");
|
||||
_mainHud = GuiManager.mainHud;
|
||||
_chatHist = GuiManager.chatHist;
|
||||
_emoteMgr = GuiManager.emoteMgr;
|
||||
_actionMgr = GuiManager.actionMgr;
|
||||
_roomMgr = RoomManagerWorld.instance;
|
||||
_playerSfsUserId = AvatarManager.playerSfsUserId;
|
||||
RAW_STR = gMainFrame.server.rawProtocolSeparator;
|
||||
var _loc1_:DefPacksDefHelper = new DefPacksDefHelper();
|
||||
_loc1_.init(DefPacksDefHelper.DEF_EMOTICON,onEmoticonDefsLoaded,null,FileServerEvent.AMF3_TYPE);
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_EMOTICON] = _loc1_;
|
||||
_loc1_ = new DefPacksDefHelper();
|
||||
_loc1_.init(DefPacksDefHelper.AUTO_CORRECT_TEXT_FILE,onAutoCorrectListLoaded,null,FileServerEvent.PLAIN_TEXT_TYPE);
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.AUTO_CORRECT_TEXT_FILE] = _loc1_;
|
||||
_specialWords = {};
|
||||
_specialWords["cockroach"] = "roach";
|
||||
}
|
||||
|
||||
private static function onAutoCorrectListLoaded(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.AUTO_CORRECT_TEXT_FILE] = null;
|
||||
var _loc2_:String = param1.def.toString().toLowerCase() as String;
|
||||
_spellingCorrections = {};
|
||||
var _loc3_:Array = _loc2_.split("\r\n");
|
||||
var _loc4_:int = 0;
|
||||
while(_loc4_ < _loc3_.length)
|
||||
{
|
||||
_loc3_[_loc4_] = _loc3_[_loc4_].split(",");
|
||||
if(!(_loc3_[_loc4_][0] == null || _loc3_[_loc4_][0].length == 0 || _loc3_[_loc4_][1] == null || _loc3_[_loc4_][1].length == 0))
|
||||
{
|
||||
_spellingCorrections[StringUtil.trim(_loc3_[_loc4_][0])] = StringUtil.trim(_loc3_[_loc4_][1]);
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onEmoticonDefsLoaded(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_EMOTICON] = null;
|
||||
var _loc2_:Object = param1.def;
|
||||
var _loc3_:Object = new Object();
|
||||
for each(_loc4_ in _loc2_)
|
||||
{
|
||||
_loc3_[_loc4_.id] = int(_loc4_.mediaRef);
|
||||
}
|
||||
_emoteDefs = _loc3_;
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function set playerSfsUserId(param1:int) : void
|
||||
{
|
||||
_playerSfsUserId = param1;
|
||||
}
|
||||
|
||||
public static function getEmoticonMediaId(param1:int) : int
|
||||
{
|
||||
if(!_emoteDefs[param1])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return _emoteDefs[param1];
|
||||
}
|
||||
|
||||
public static function getEmoticonDefId(param1:int) : int
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
for(_loc2_ in _emoteDefs)
|
||||
{
|
||||
if(_emoteDefs[_loc2_] == param1)
|
||||
{
|
||||
return int(_loc2_);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function addChatMessage(param1:String) : void
|
||||
{
|
||||
_chatHist.addMessage(gMainFrame.userInfo.playerAvatarInfo.avName,param1);
|
||||
}
|
||||
|
||||
public static function sendAvatarSafeChat(param1:String, param2:String, param3:Boolean = true) : void
|
||||
{
|
||||
if(gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AvatarManager.addAvatarMessage(param1,_playerSfsUserId,0);
|
||||
addChatMessage(param1);
|
||||
gMainFrame.server.sendMessage(param2 + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_SAFE);
|
||||
if(_chatHist.enableFreeChatValue)
|
||||
{
|
||||
_chatHist.resetTreeSearch();
|
||||
_chatHist.chatMsgText.text = "";
|
||||
gMainFrame.stage.focus = _chatHist.chatMsgText;
|
||||
}
|
||||
if(param3)
|
||||
{
|
||||
GuiManager.safeChatBtnDownHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendAvatarEmote(param1:Sprite) : void
|
||||
{
|
||||
if(gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AvatarManager.setAvatarEmote(param1);
|
||||
if(!EmoticonUtility.getEmoteString(param1))
|
||||
{
|
||||
throw new Error("setAvatarEmote: sent invalid emote sprite?!");
|
||||
}
|
||||
addChatMessage(EmoticonUtility.getEmoteString(param1));
|
||||
gMainFrame.server.sendMessage(EmoticonUtility.idForEmote(param1) + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_EMOTE);
|
||||
if(_chatHist.enableFreeChatValue)
|
||||
{
|
||||
_chatHist.chatMsgText.text = "";
|
||||
gMainFrame.stage.focus = _chatHist.chatMsgText;
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendAvatarAction(param1:Sprite) : void
|
||||
{
|
||||
if(gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AvatarManager.setAvatarAction(param1);
|
||||
if(!_actionMgr.getActionString(param1))
|
||||
{
|
||||
throw new Error("setAvatarAction: sent invalid action sprite?!");
|
||||
}
|
||||
addChatMessage(_actionMgr.getActionString(param1));
|
||||
var _loc2_:AvatarWorldView = AvatarManager.avatarViewList[AvatarManager.playerSfsUserId];
|
||||
var _loc3_:int = _loc2_.lastIdleAnim;
|
||||
gMainFrame.server.sendMessage(_actionMgr.getActionString(param1) + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_ACTION + RAW_STR + _loc3_);
|
||||
if(_chatHist.enableFreeChatValue)
|
||||
{
|
||||
_chatHist.chatMsgText.text = "";
|
||||
gMainFrame.stage.focus = _chatHist.chatMsgText;
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendAvatarAttachmentEmot(param1:int, param2:String = null) : void
|
||||
{
|
||||
if(gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = "";
|
||||
}
|
||||
gMainFrame.server.sendMessage(param1 + "," + param2 + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_ATTACHMENT);
|
||||
}
|
||||
|
||||
public static function sendAvatarBlendColor(param1:uint) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage(int(param1) + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_BLEND_COLOR);
|
||||
}
|
||||
|
||||
public static function sendAvatarAlphaLevel(param1:uint) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage(int(param1) + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_ALPHA_LEVEL);
|
||||
}
|
||||
|
||||
public static function sendChatMessage(param1:int, param2:String, param3:Boolean) : void
|
||||
{
|
||||
if(Boolean(gMainFrame.clientInfo.invisMode) || !Utility.canChat())
|
||||
{
|
||||
return;
|
||||
}
|
||||
param2 = fixMispellings(param2);
|
||||
param2 = adjustCamelCase(param2);
|
||||
AvatarManager.addAvatarMessage(param2,param1,0);
|
||||
param2 = adjustSpecialWords(param2);
|
||||
var _loc4_:int = gMainFrame.userInfo.sgChatType == ChatHistory.SG_CHAT_TYPE_FREE ? CHAT_TYPE_TYPED : CHAT_TYPE_LIMITED;
|
||||
gMainFrame.server.sendMessage(param2 + RAW_STR + int(param3) + RAW_STR + _loc4_);
|
||||
if(_chatHist.enableFreeChatValue)
|
||||
{
|
||||
_chatHist.chatMsgText.text = "";
|
||||
gMainFrame.stage.focus = _chatHist.chatMsgText;
|
||||
}
|
||||
}
|
||||
|
||||
private static function adjustSpecialWords(param1:String) : String
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc7_:String = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:String = null;
|
||||
var _loc10_:String = null;
|
||||
var _loc11_:String = null;
|
||||
_replacedWords = {};
|
||||
var _loc2_:Array = param1.split(" ");
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
while(_loc6_ < _loc2_.length)
|
||||
{
|
||||
_loc3_ = _loc2_[_loc6_];
|
||||
_loc4_ = _loc3_.toLowerCase();
|
||||
for(_loc7_ in _specialWords)
|
||||
{
|
||||
_loc8_ = _loc4_.indexOf(_loc7_);
|
||||
if(_loc8_ >= 0)
|
||||
{
|
||||
_loc9_ = _loc3_.substr(0,_loc8_);
|
||||
_loc10_ = _loc3_.substr(_loc8_,_loc7_.length);
|
||||
_loc11_ = _loc3_.substr(_loc8_ + _loc7_.length);
|
||||
_loc5_ = getCaseType(_loc10_);
|
||||
_loc10_ = setCaseType(_specialWords[_loc7_],_loc5_);
|
||||
_loc2_[_loc6_] = _loc9_ + _loc10_ + _loc11_;
|
||||
_replacedWords[_loc2_[_loc6_]] = _loc3_;
|
||||
}
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
return _loc2_.join(" ");
|
||||
}
|
||||
|
||||
private static function getCaseType(param1:String) : int
|
||||
{
|
||||
if(param1.toLowerCase() == param1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var _loc2_:String = param1.charAt(0);
|
||||
var _loc3_:int = int(param1.match(/[A-Z]/g).length);
|
||||
if(_loc3_ == param1.length)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
private static function setCaseType(param1:String, param2:int) : String
|
||||
{
|
||||
if(param2 == 0)
|
||||
{
|
||||
return param1.toLowerCase();
|
||||
}
|
||||
if(param2 == 1)
|
||||
{
|
||||
return param1.toUpperCase();
|
||||
}
|
||||
param1 = param1.toLowerCase();
|
||||
var _loc3_:String = param1.charAt(0).toUpperCase();
|
||||
return _loc3_ + param1.substr(1);
|
||||
}
|
||||
|
||||
private static function reverseSpecialWords(param1:String) : String
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
if(_replacedWords == null)
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
var _loc3_:Array = param1.split(" ");
|
||||
var _loc4_:int = 0;
|
||||
while(_loc4_ < _loc3_.length)
|
||||
{
|
||||
_loc2_ = _loc3_[_loc4_].toLowerCase();
|
||||
if(!(_replacedWords[_loc2_] == null || _loc2_ == "constructor"))
|
||||
{
|
||||
_loc3_[_loc4_] = _replacedWords[_loc2_];
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
_replacedWords = null;
|
||||
return _loc3_.join(" ");
|
||||
}
|
||||
|
||||
private static function adjustCamelCase(param1:String) : String
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:String = null;
|
||||
var _loc5_:String = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc2_:Array = param1.split(" ");
|
||||
var _loc7_:int = 0;
|
||||
while(_loc7_ < _loc2_.length)
|
||||
{
|
||||
_loc4_ = _loc2_[_loc7_];
|
||||
_loc5_ = _loc4_.match(/[a-zA-Z]/g).join("");
|
||||
_loc6_ = _loc5_.charAt(0);
|
||||
_loc3_ = int(_loc5_.match(/[A-Z]/g).length);
|
||||
if(_loc3_ > 0 && _loc3_ != _loc5_.length)
|
||||
{
|
||||
if(_loc6_.match(/[A-z]/g).length == 1)
|
||||
{
|
||||
_loc8_ = getIndexOfFirstLetter(_loc4_,_loc5_);
|
||||
_loc2_[_loc7_] = _loc4_.substr(0,_loc8_) + _loc6_ + _loc4_.toLowerCase().substr(_loc8_ + 1,_loc4_.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_[_loc7_] = _loc4_.toLowerCase();
|
||||
}
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
return _loc2_.join(" ");
|
||||
}
|
||||
|
||||
public static function getFirstLetter(param1:String) : String
|
||||
{
|
||||
var _loc2_:String = param1.match(/[a-zA-Z]/g).join("");
|
||||
if(_loc2_.length > 0)
|
||||
{
|
||||
return _loc2_.charAt(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getIndexOfFirstLetter(param1:String, param2:String) : int
|
||||
{
|
||||
if(param2 == "")
|
||||
{
|
||||
param2 = param1.match(/[a-zA-Z]/g).join();
|
||||
}
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
if(param1.charAt(_loc3_) == param2.charAt(0))
|
||||
{
|
||||
return _loc3_;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function fixMispellings(param1:String) : String
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
if(!_spellingCorrections)
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
var _loc2_:Array = param1.split(" ");
|
||||
var _loc4_:int = 0;
|
||||
while(_loc4_ < _loc2_.length)
|
||||
{
|
||||
_loc3_ = _loc2_[_loc4_].toLowerCase();
|
||||
_loc3_ = stripPunctuation(_loc3_);
|
||||
if(_spellingCorrections[_loc3_] != null)
|
||||
{
|
||||
_loc3_ = _spellingCorrections[_loc3_];
|
||||
_loc2_[_loc4_] = _loc3_;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return _loc2_.join(" ");
|
||||
}
|
||||
|
||||
public static function stripPunctuation(param1:String) : String
|
||||
{
|
||||
return param1.replace(/[^A-Za-z0-9 ]+/g,"");
|
||||
}
|
||||
|
||||
public static function sendAvatarSlide(param1:String) : void
|
||||
{
|
||||
if(gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
gMainFrame.server.sendMessage(param1 + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_SLIDE);
|
||||
}
|
||||
|
||||
public static function sendPermEmote(param1:int, param2:Boolean) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage(param1 + RAW_STR + int(param2) + RAW_STR + CHAT_TYPE_PERM_EMOTE);
|
||||
}
|
||||
|
||||
public static function sendPetAction(param1:int, param2:int = 0) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage(param1 + "," + param2 + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_PET_ACTION);
|
||||
}
|
||||
|
||||
public static function onSendMessage(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc4_:Sprite = null;
|
||||
var _loc5_:String = null;
|
||||
if(_playerSfsUserId == -1)
|
||||
{
|
||||
DebugUtility.debugTrace("WARNING - UserCommXtCommManager.init was never called or the playerAvatarId is bad");
|
||||
_playerSfsUserId = AvatarManager.playerSfsUserId;
|
||||
}
|
||||
var _loc2_:String = _mainHud.chatBar.text01_chat.text;
|
||||
_loc2_ = _loc2_.split("\r").join("");
|
||||
_loc2_ = _loc2_.split(RAW_STR).join("");
|
||||
_loc2_ = StringUtil.trim(_loc2_);
|
||||
if(_loc2_.length <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc3_:Object = EmoticonUtility.matchEmoteString(_loc2_);
|
||||
if(_loc3_.status)
|
||||
{
|
||||
if(_loc3_.sprite)
|
||||
{
|
||||
sendAvatarEmote(_loc3_.sprite);
|
||||
AvatarManager.setAvatarEmote(_loc3_.sprite,-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = _actionMgr.matchActionString(_loc2_);
|
||||
if(_loc4_)
|
||||
{
|
||||
sendAvatarAction(_loc4_);
|
||||
AvatarManager.setAvatarAction(_loc4_,-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = SafeChatManager.safeChatCodeForString(_loc2_);
|
||||
if(_loc5_)
|
||||
{
|
||||
sendAvatarSafeChat(_loc2_,_loc5_,false);
|
||||
AvatarManager.addAvatarMessage(_loc2_,_playerSfsUserId,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendChatMessage(_playerSfsUserId,_loc2_,MinigameManager.inMinigame());
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
_chatHist.chatMsgText.text = "";
|
||||
gMainFrame.stage.focus = _chatHist.chatMsgText;
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Array = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "uc":
|
||||
userCommChatResponse(_loc2_);
|
||||
break;
|
||||
case "ua":
|
||||
userCommAdminMessageResponse(_loc2_);
|
||||
break;
|
||||
default:
|
||||
throw new Error("UserCommXtCommManager illegal data:" + _loc2_[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function userCommChatResponse(param1:Array) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:Array = null;
|
||||
var _loc8_:String = null;
|
||||
var _loc9_:Boolean = false;
|
||||
var _loc10_:String = null;
|
||||
var _loc11_:Sprite = null;
|
||||
var _loc12_:Sprite = null;
|
||||
var _loc13_:Array = null;
|
||||
var _loc14_:int = 0;
|
||||
var _loc15_:Avatar = null;
|
||||
var _loc2_:int = int(param1[2]);
|
||||
var _loc3_:Boolean = Boolean(int(param1[4]));
|
||||
var _loc4_:int = int(param1[5]);
|
||||
var _loc5_:Boolean = true;
|
||||
if(_loc5_)
|
||||
{
|
||||
if(_loc4_ == CHAT_TYPE_PERM_EMOTE)
|
||||
{
|
||||
_loc6_ = int(param1[3]);
|
||||
if(_loc6_ >= 0)
|
||||
{
|
||||
AvatarManager.setAvatarEmote(null,_loc2_,_loc6_);
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarManager.setChatBalloonReadyForClear(_loc2_);
|
||||
}
|
||||
}
|
||||
else if(_loc4_ == CHAT_TYPE_SLIDE)
|
||||
{
|
||||
if(_loc2_ != gMainFrame.server.userId)
|
||||
{
|
||||
_roomMgr.attachAvatarToSlide(AvatarManager.avatarViewList[_loc2_],param1[3]);
|
||||
}
|
||||
}
|
||||
else if(_loc4_ == CHAT_TYPE_PET_ACTION)
|
||||
{
|
||||
_loc7_ = param1[3].split(",");
|
||||
AvatarManager.setPetAction(_loc2_,_loc7_[0],_loc7_[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = param1[3];
|
||||
_loc9_ = false;
|
||||
if(_loc4_ == CHAT_TYPE_SAFE)
|
||||
{
|
||||
_loc10_ = SafeChatManager.safeChatStringForCode(_loc8_);
|
||||
if(_loc10_)
|
||||
{
|
||||
_loc8_ = _loc10_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc9_ = true;
|
||||
}
|
||||
}
|
||||
if(!_loc9_)
|
||||
{
|
||||
switch(_loc4_)
|
||||
{
|
||||
case CHAT_TYPE_TYPED:
|
||||
case CHAT_TYPE_LIMITED:
|
||||
case CHAT_TYPE_SAFE:
|
||||
_loc8_ = adjustCamelCase(_loc8_);
|
||||
if(_loc2_ == gMainFrame.server.userId)
|
||||
{
|
||||
_loc8_ = reverseSpecialWords(_loc8_);
|
||||
}
|
||||
AvatarManager.addAvatarMessage(_loc8_,_loc2_,int(param1[6]));
|
||||
break;
|
||||
case CHAT_TYPE_EMOTE:
|
||||
_loc11_ = EmoticonUtility.emoteForId(int(_loc8_));
|
||||
if(_loc11_)
|
||||
{
|
||||
AvatarManager.setAvatarEmote(_loc11_,_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc9_ = true;
|
||||
}
|
||||
_loc8_ = EmoticonUtility.stringForId(int(_loc8_));
|
||||
break;
|
||||
case CHAT_TYPE_ACTION:
|
||||
_loc12_ = _actionMgr.matchActionString(_loc8_);
|
||||
if(_loc12_)
|
||||
{
|
||||
AvatarManager.setAvatarAction(_loc12_,_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc9_ = true;
|
||||
}
|
||||
break;
|
||||
case CHAT_TYPE_ATTACHMENT:
|
||||
_loc13_ = _loc8_.split(",");
|
||||
_loc14_ = int(_loc13_[0]);
|
||||
AvatarManager._setAvatarAttachmentEmot(_loc14_,_loc13_[1],_loc2_);
|
||||
break;
|
||||
case CHAT_TYPE_BLEND_COLOR:
|
||||
AvatarManager._setAvatarBlendColor(_loc2_,uint(param1[3]));
|
||||
return;
|
||||
case CHAT_TYPE_ALPHA_LEVEL:
|
||||
AvatarManager._setAvatarAlphaLevel(_loc2_,uint(param1[3]));
|
||||
return;
|
||||
default:
|
||||
_loc9_ = true;
|
||||
}
|
||||
}
|
||||
if(_loc9_)
|
||||
{
|
||||
DebugUtility.debugTrace("WARNING - got bad chat! msg:" + _loc8_ + " chatType:" + _loc4_ + " from userId:" + _loc2_);
|
||||
return;
|
||||
}
|
||||
if(_loc4_ != CHAT_TYPE_ATTACHMENT)
|
||||
{
|
||||
if(gMainFrame.clientInfo.extCallsActive)
|
||||
{
|
||||
_loc15_ = AvatarManager.getAvatarBySfsUserId(_loc2_);
|
||||
DebugUtility.debugTrace("mrc:sending cm command - chattyUserId:" + _loc2_ + " chattyAv:" + _loc15_);
|
||||
ExternalInterface.call("mrc",["cm",_loc15_.userName,_loc8_,int(param1[6])]);
|
||||
DebugUtility.debugTrace("mrc:cm command sent - chattyUserName:" + _loc15_.userName + " msg:" + _loc8_);
|
||||
}
|
||||
if(_loc2_ != gMainFrame.server.userId || _loc2_ == gMainFrame.server.userId && (_loc4_ == CHAT_TYPE_TYPED || _loc4_ == CHAT_TYPE_LIMITED))
|
||||
{
|
||||
_chatHist.addMessageById(_loc2_,_loc8_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function userCommAdminMessageResponse(param1:Array) : void
|
||||
{
|
||||
var _loc3_:JCDefHelper = null;
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc2_:String = param1[1];
|
||||
if(_loc2_ == "__ABSU_CBS__")
|
||||
{
|
||||
_loc3_ = new JCDefHelper();
|
||||
_loc3_.deleteIndexFileFromCache();
|
||||
_loc3_.destroy();
|
||||
_loc3_ = null;
|
||||
GuiManager.refreshJammerCentral();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = param1[2] == null || int(param1[2]) == 1;
|
||||
if(!_loc4_)
|
||||
{
|
||||
gMainFrame.clientInfo.lastBroadcastMessage = _loc2_;
|
||||
GuiManager.updateSettingsMessage();
|
||||
}
|
||||
new SBAJOkPopup(GuiManager.guiLayer,_loc2_);
|
||||
_chatHist.addPrivateMessage("Animal Jam HQ",gMainFrame.server.userName,_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private static function getSpecialFormat() : TextFormat
|
||||
{
|
||||
var _loc1_:TextFormat = new TextFormat();
|
||||
_loc1_.color = 12845056;
|
||||
_loc1_.bold = true;
|
||||
return _loc1_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
package avatar
|
||||
{
|
||||
public class UserInfo
|
||||
{
|
||||
|
||||
public var userName:String;
|
||||
|
||||
public var currDbAvId:int;
|
||||
|
||||
public var avList:Object;
|
||||
|
||||
public var denItemsFull:Array;
|
||||
|
||||
public var denItemsPartial:Array;
|
||||
|
||||
public var accountType:int;
|
||||
|
||||
public var nameBarData:int;
|
||||
|
||||
public var isGuide:Boolean;
|
||||
|
||||
private var _allItems:Array;
|
||||
|
||||
private var _achievements:Array;
|
||||
|
||||
private var _timeStampSinceLastRequest:Number;
|
||||
|
||||
public function UserInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:String, param2:Array = null, param3:int = -1, param4:int = 1) : void
|
||||
{
|
||||
this.userName = param1;
|
||||
this._timeStampSinceLastRequest = 0;
|
||||
this._allItems = [];
|
||||
if(param2)
|
||||
{
|
||||
this.avList = param2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.avList = {};
|
||||
}
|
||||
if(param3 > 0)
|
||||
{
|
||||
this.currDbAvId = param3;
|
||||
}
|
||||
this.accountType = param4;
|
||||
}
|
||||
|
||||
public function addAvatarToList(param1:AvatarInfo) : void
|
||||
{
|
||||
this.avList[param1.dbAvId] = param1;
|
||||
}
|
||||
|
||||
public function getAvatarInfoByDbAvId(param1:int) : AvatarInfo
|
||||
{
|
||||
if(param1 == -1)
|
||||
{
|
||||
return this.avList[this.currDbAvId];
|
||||
}
|
||||
if(this.avList[param1])
|
||||
{
|
||||
return this.avList[param1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addAchievementsTolist(param1:Array) : void
|
||||
{
|
||||
if(!this._achievements)
|
||||
{
|
||||
this._achievements = [];
|
||||
}
|
||||
var _loc2_:* = int(this._achievements.length);
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
var _loc4_:Number;
|
||||
this._achievements[_loc4_ = _loc2_++] = param1[_loc3_];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function set fullItemList(param1:Array) : void
|
||||
{
|
||||
this._allItems = param1;
|
||||
}
|
||||
|
||||
public function get fullItemList() : Array
|
||||
{
|
||||
return this._allItems;
|
||||
}
|
||||
|
||||
public function getFullItemList(param1:Boolean) : Array
|
||||
{
|
||||
var _loc2_:Array = [];
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < this._allItems.length)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_loc2_.push(this._allItems[_loc3_]);
|
||||
}
|
||||
else if(this._allItems[_loc3_].invIdx >= 0)
|
||||
{
|
||||
_loc2_.push(this._allItems[_loc3_]);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function getPartialItemList(param1:int, param2:Boolean) : Array
|
||||
{
|
||||
var _loc3_:Array = [];
|
||||
var _loc4_:int = 0;
|
||||
while(_loc4_ < this._allItems.length)
|
||||
{
|
||||
if(this._allItems[_loc4_].invIdx < 0 && param2 || Utility.isSameEnviroType(gMainFrame.userInfo.getAvatarEnviroTypeFlagByAvType(param1),this._allItems[_loc4_].enviroType))
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_loc3_.push(this._allItems[_loc4_]);
|
||||
}
|
||||
else if(this._allItems[_loc4_].invIdx >= 0)
|
||||
{
|
||||
_loc3_.push(this._allItems[_loc4_]);
|
||||
}
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function allItemsInUseOff(param1:int) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < this._allItems.length)
|
||||
{
|
||||
this._allItems[_loc2_].setInUse(param1,false);
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function get achievements() : Array
|
||||
{
|
||||
return this._achievements;
|
||||
}
|
||||
|
||||
public function get isMember() : Boolean
|
||||
{
|
||||
return Utility.isMember(this.accountType);
|
||||
}
|
||||
|
||||
public function resetAchievements() : void
|
||||
{
|
||||
this._achievements = [];
|
||||
}
|
||||
|
||||
public function getTimeOfLastAchievementRequest() : Number
|
||||
{
|
||||
return this._timeStampSinceLastRequest;
|
||||
}
|
||||
|
||||
public function setTimeOfLastAchievementRequest(param1:Number) : void
|
||||
{
|
||||
this._timeStampSinceLastRequest = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class UserInfoCache
|
||||
{
|
||||
|
||||
public var myUserName:String;
|
||||
|
||||
public var myBuddyCount:int;
|
||||
|
||||
public var isMember:Boolean;
|
||||
|
||||
public var isModerator:Boolean;
|
||||
|
||||
public var isGuide:Boolean;
|
||||
|
||||
public var isSilenced:Boolean;
|
||||
|
||||
public var isMyDenPrivate:Boolean;
|
||||
|
||||
public var sgChatType:int;
|
||||
|
||||
public var firstFiveMinutes:int;
|
||||
|
||||
public var pendingFlags:Number;
|
||||
|
||||
public var activeDenRoomInvId:int;
|
||||
|
||||
public var numLogins:int;
|
||||
|
||||
public var worldMapRoomName:String;
|
||||
|
||||
public var avtDefsCached:Boolean;
|
||||
|
||||
private var _userInfo:Object;
|
||||
|
||||
private var _dbAvIdToUserName:Dictionary;
|
||||
|
||||
private var _myDbAvId:int;
|
||||
|
||||
private var _myUserVarCache:UserVarCache;
|
||||
|
||||
private var _avatarDefs:Object;
|
||||
|
||||
private var _denRoomDefs:Object;
|
||||
|
||||
private var _genericListDefsInfo:Object;
|
||||
|
||||
private var _myTradeList:Array;
|
||||
|
||||
private var _myPetsInDen:Array;
|
||||
|
||||
public function UserInfoCache()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init() : void
|
||||
{
|
||||
this._userInfo = {};
|
||||
this._myDbAvId = -1;
|
||||
this.myUserName = "";
|
||||
this.avtDefsCached = false;
|
||||
this._myUserVarCache = new UserVarCache();
|
||||
this._myUserVarCache.init();
|
||||
this._dbAvIdToUserName = new Dictionary(true);
|
||||
this._avatarDefs = new Object();
|
||||
this._genericListDefsInfo = new Object();
|
||||
this._myTradeList = [];
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this._userInfo = null;
|
||||
this._avatarDefs = null;
|
||||
this._denRoomDefs = null;
|
||||
this._genericListDefsInfo = null;
|
||||
this._myTradeList = null;
|
||||
}
|
||||
|
||||
public function getUserInfoByUserName(param1:String) : UserInfo
|
||||
{
|
||||
return this._userInfo[param1];
|
||||
}
|
||||
|
||||
public function setUserInfoByUserName(param1:String, param2:UserInfo) : void
|
||||
{
|
||||
var _loc3_:UserInfo = null;
|
||||
var _loc4_:AvatarInfo = null;
|
||||
var _loc5_:String = null;
|
||||
var _loc6_:UserInfo = null;
|
||||
var _loc7_:AvatarInfo = null;
|
||||
if(Boolean(param1) && param1 != "")
|
||||
{
|
||||
_loc3_ = this._userInfo[param1] = param2;
|
||||
for each(_loc4_ in _loc3_.avList)
|
||||
{
|
||||
_loc5_ = this._dbAvIdToUserName[_loc4_.dbAvId];
|
||||
if((Boolean(_loc5_)) && _loc5_ != param1)
|
||||
{
|
||||
_loc6_ = this._userInfo[_loc5_];
|
||||
if(_loc6_)
|
||||
{
|
||||
for each(_loc7_ in _loc6_.avList)
|
||||
{
|
||||
delete this._dbAvIdToUserName[_loc7_.dbAvId];
|
||||
}
|
||||
delete this._userInfo[_loc5_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for each(_loc4_ in _loc3_.avList)
|
||||
{
|
||||
this._dbAvIdToUserName[_loc4_.dbAvId] = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAvatarInfoByDbAvId(param1:int) : AvatarInfo
|
||||
{
|
||||
var _loc2_:UserInfo = null;
|
||||
var _loc3_:AvatarInfo = null;
|
||||
loop0:
|
||||
for each(_loc2_ in this._userInfo)
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:* = _loc2_.avList;
|
||||
do
|
||||
{
|
||||
for each(_loc3_ in _loc7_)
|
||||
{
|
||||
}
|
||||
continue loop0;
|
||||
}
|
||||
while(_loc3_.dbAvId != param1);
|
||||
return _loc3_;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function changeUserName(param1:String, param2:String) : void
|
||||
{
|
||||
var _loc3_:UserInfo = null;
|
||||
var _loc4_:AvatarInfo = null;
|
||||
if(this._userInfo.hasOwnProperty(param1))
|
||||
{
|
||||
_loc3_ = this._userInfo[param1];
|
||||
this._userInfo[param2] = _loc3_;
|
||||
this._userInfo[param2].userName = param2;
|
||||
for each(_loc4_ in _loc3_.avList)
|
||||
{
|
||||
_loc4_.userName = param2;
|
||||
this._dbAvIdToUserName[_loc4_.dbAvId] = param2;
|
||||
}
|
||||
delete this._userInfo[param1];
|
||||
}
|
||||
}
|
||||
|
||||
public function getAvatarInfoByUserName(param1:String) : AvatarInfo
|
||||
{
|
||||
if(this._userInfo.hasOwnProperty(param1))
|
||||
{
|
||||
return this._userInfo[param1].avList[this._userInfo[param1].currDbAvId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAvatarInfoByUserNameThenDbAvId(param1:String, param2:int) : AvatarInfo
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
if(this._userInfo.hasOwnProperty(param1))
|
||||
{
|
||||
_loc3_ = this._userInfo[param1];
|
||||
return this._userInfo[param1].avList[param2];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get myDbAvId() : int
|
||||
{
|
||||
return this._myDbAvId;
|
||||
}
|
||||
|
||||
public function setCurrAvDbId(param1:String, param2:int) : void
|
||||
{
|
||||
if(this._userInfo.hasOwnProperty(param1))
|
||||
{
|
||||
this._userInfo[param1].currDbAvId = param2;
|
||||
}
|
||||
}
|
||||
|
||||
public function set myDbAvId(param1:int) : void
|
||||
{
|
||||
this._myDbAvId = param1;
|
||||
if(this._userInfo.hasOwnProperty(this.myUserName) && Boolean(this._userInfo[this.myUserName]))
|
||||
{
|
||||
UserInfo(this._userInfo[this.myUserName]).currDbAvId = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function setAvatarInfoByDbAvId(param1:int, param2:AvatarInfo, param3:Boolean = false) : void
|
||||
{
|
||||
var _loc4_:String = param2.userName;
|
||||
if(!this._userInfo.hasOwnProperty(_loc4_))
|
||||
{
|
||||
throw new Error("Invalid setAvatarInfo! Needs userName!");
|
||||
}
|
||||
this._userInfo[_loc4_].avList[param1] = param2;
|
||||
if(param3)
|
||||
{
|
||||
this._userInfo[_loc4_].currDbAvId = param1;
|
||||
this._dbAvIdToUserName[param1] = _loc4_;
|
||||
}
|
||||
}
|
||||
|
||||
public function setAccountTypeByUserName(param1:String, param2:int) : void
|
||||
{
|
||||
if(this._userInfo.hasOwnProperty(param1))
|
||||
{
|
||||
this._userInfo[param1].accountType = param2;
|
||||
}
|
||||
}
|
||||
|
||||
public function set playerAvatarInfo(param1:AvatarInfo) : void
|
||||
{
|
||||
this._myDbAvId = param1.dbAvId;
|
||||
this.myUserName = param1.userName;
|
||||
var _loc2_:UserInfo = UserInfo(this._userInfo[this.myUserName]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.avList[this._myDbAvId] = param1;
|
||||
_loc2_.currDbAvId = this._myDbAvId;
|
||||
}
|
||||
}
|
||||
|
||||
public function get playerAvatarInfo() : AvatarInfo
|
||||
{
|
||||
try
|
||||
{
|
||||
return this._userInfo[this.myUserName].avList[this._myDbAvId];
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
DebugUtility.debugTrace("Error trying to get playerAvatarInfo! msg:" + e.message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get playerUserInfo() : UserInfo
|
||||
{
|
||||
return this.getUserInfoByUserName(this.myUserName);
|
||||
}
|
||||
|
||||
public function get userVarCache() : UserVarCache
|
||||
{
|
||||
return this._myUserVarCache;
|
||||
}
|
||||
|
||||
public function setAvatarDefs(param1:Object) : void
|
||||
{
|
||||
this._avatarDefs = param1;
|
||||
this.avtDefsCached = true;
|
||||
}
|
||||
|
||||
public function getAvatarColorLayer1InfoByAvType(param1:uint) : uint
|
||||
{
|
||||
if(this._avatarDefs[param1])
|
||||
{
|
||||
return this._avatarDefs[param1].colorLayer1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarColorLayer2InfoByAvType(param1:uint) : uint
|
||||
{
|
||||
if(this._avatarDefs[param1])
|
||||
{
|
||||
return this._avatarDefs[param1].colorLayer2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarColorLayer3InfoByAvType(param1:uint) : uint
|
||||
{
|
||||
if(this._avatarDefs[param1])
|
||||
{
|
||||
return this._avatarDefs[param1].colorLayer3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarDefPatternInfoByAvType(param1:int) : uint
|
||||
{
|
||||
if(this._avatarDefs[param1])
|
||||
{
|
||||
return this._avatarDefs[param1].defPattern;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarDefEyesInfoByAvType(param1:int) : uint
|
||||
{
|
||||
if(this._avatarDefs[param1])
|
||||
{
|
||||
return this._avatarDefs[param1].defEyes;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarMemberInfoByAvType(param1:int) : Boolean
|
||||
{
|
||||
if(this._avatarDefs[param1])
|
||||
{
|
||||
return this._avatarDefs[param1].isMemOnly;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getAvatarEnviroTypeFlagByAvType(param1:int) : int
|
||||
{
|
||||
if(this._avatarDefs[param1])
|
||||
{
|
||||
return this._avatarDefs[param1].enviroTypeFlag;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarDefByAvType(param1:int) : Object
|
||||
{
|
||||
return this._avatarDefs[param1];
|
||||
}
|
||||
|
||||
public function set denRoomDefs(param1:Object) : void
|
||||
{
|
||||
this._denRoomDefs = param1;
|
||||
}
|
||||
|
||||
public function get denRoomDefs() : Object
|
||||
{
|
||||
return this._denRoomDefs;
|
||||
}
|
||||
|
||||
public function getDenRoomDefByDefId(param1:int) : Object
|
||||
{
|
||||
return this._denRoomDefs[param1];
|
||||
}
|
||||
|
||||
public function set genericListDefs(param1:Object) : void
|
||||
{
|
||||
this._genericListDefsInfo = param1;
|
||||
}
|
||||
|
||||
public function getGenericListDefByDefId(param1:int) : Object
|
||||
{
|
||||
return this._genericListDefsInfo[param1];
|
||||
}
|
||||
|
||||
public function getMyTradeList() : Array
|
||||
{
|
||||
return this._myTradeList;
|
||||
}
|
||||
|
||||
public function set myTradeList(param1:Array) : void
|
||||
{
|
||||
this._myTradeList = param1;
|
||||
}
|
||||
|
||||
public function removeFromMyTradeList(param1:int) : void
|
||||
{
|
||||
this._myTradeList.splice(param1,1);
|
||||
}
|
||||
|
||||
public function set myPetsInDen(param1:Array) : void
|
||||
{
|
||||
this._myPetsInDen = param1;
|
||||
}
|
||||
|
||||
public function get myPetsInDen() : Array
|
||||
{
|
||||
return this._myPetsInDen;
|
||||
}
|
||||
|
||||
public function isPendingFlagSet(param1:int) : Boolean
|
||||
{
|
||||
return (this.pendingFlags & 1 << param1) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package avatar
|
||||
{
|
||||
public class UserVarCache
|
||||
{
|
||||
|
||||
private var _cache:Object;
|
||||
|
||||
public function UserVarCache()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init() : void
|
||||
{
|
||||
this._cache = new Object();
|
||||
}
|
||||
|
||||
public function set playerUserVars(param1:Object) : void
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
this._cache = new Object();
|
||||
for(_loc2_ in param1)
|
||||
{
|
||||
this._cache[_loc2_] = {
|
||||
"value":param1[_loc2_].value,
|
||||
"type":param1[_loc2_].type
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public function get playerUserVars() : Object
|
||||
{
|
||||
return this._cache;
|
||||
}
|
||||
|
||||
public function getUserVarValueById(param1:int) : int
|
||||
{
|
||||
if(Boolean(this._cache) && Boolean(this._cache[param1]))
|
||||
{
|
||||
return this._cache[param1].value;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function getUserVarTypeById(param1:int) : int
|
||||
{
|
||||
if(Boolean(this._cache) && Boolean(this._cache[param1]))
|
||||
{
|
||||
return this._cache[param1].type;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function isBitSet(param1:int, param2:int) : Boolean
|
||||
{
|
||||
if(Boolean(this._cache) && Boolean(this._cache[param1]))
|
||||
{
|
||||
return Boolean(this._cache[param1].value & 1 << param2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function updateUserVar(param1:int, param2:int, param3:int = -1) : void
|
||||
{
|
||||
if(!this._cache)
|
||||
{
|
||||
this._cache = new Object();
|
||||
}
|
||||
if(this._cache[param1])
|
||||
{
|
||||
this._cache[param1].value = param2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._cache[param1] = {
|
||||
"value":param2,
|
||||
"type":param3
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package buddy
|
||||
{
|
||||
import com.sbi.client.SFClient;
|
||||
|
||||
public class Buddy
|
||||
{
|
||||
|
||||
private var _userName:String;
|
||||
|
||||
private var _onlineStatus:int;
|
||||
|
||||
private var _numDaysSinceLastLogin:int;
|
||||
|
||||
public function Buddy()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:String, param2:int, param3:int = 0) : void
|
||||
{
|
||||
this._userName = param1;
|
||||
this._onlineStatus = param2;
|
||||
this._numDaysSinceLastLogin = param3;
|
||||
}
|
||||
|
||||
public function get userName() : String
|
||||
{
|
||||
return this._userName;
|
||||
}
|
||||
|
||||
public function get onlineStatus() : int
|
||||
{
|
||||
return this._onlineStatus;
|
||||
}
|
||||
|
||||
public function get isOnline() : Boolean
|
||||
{
|
||||
return this._onlineStatus == SFClient.STATUS_ONLINE;
|
||||
}
|
||||
|
||||
public function get numDaysSinceLastLogin() : int
|
||||
{
|
||||
return this._numDaysSinceLastLogin;
|
||||
}
|
||||
|
||||
public function set userName(param1:String) : void
|
||||
{
|
||||
this._userName = param1;
|
||||
}
|
||||
|
||||
public function set onlineStatus(param1:int) : void
|
||||
{
|
||||
this._onlineStatus = param1;
|
||||
}
|
||||
|
||||
public function set numDaysSinceLastLogin(param1:int) : void
|
||||
{
|
||||
this._numDaysSinceLastLogin = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package buddy
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class BuddyEvent extends Event
|
||||
{
|
||||
|
||||
public static const BUDDY_LIST:String = "OnBuddyList";
|
||||
|
||||
public static const BUDDY_CHANGED:String = "OnBuddyChanged";
|
||||
|
||||
public var userName:String;
|
||||
|
||||
public function BuddyEvent(param1:String)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new BuddyEvent(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package buddy
|
||||
{
|
||||
import flash.utils.Timer;
|
||||
|
||||
public class BuddyTimer extends Timer
|
||||
{
|
||||
|
||||
public var userName:String;
|
||||
|
||||
public function BuddyTimer(param1:Number, param2:int = 0)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
package buddy
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
import gui.BuddyCard;
|
||||
import gui.BuddyManager;
|
||||
|
||||
public class BuddyXtCommManager
|
||||
{
|
||||
|
||||
private static var _searchCallback:Function;
|
||||
|
||||
private static var _requestCallback:Function;
|
||||
|
||||
public function BuddyXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function sendBuddyListRequest(param1:Function = null) : void
|
||||
{
|
||||
_requestCallback = param1;
|
||||
gMainFrame.server.setXtObject_Str("bl",[]);
|
||||
}
|
||||
|
||||
public static function sendBuddyAddRequest(param1:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("ba",[param1]);
|
||||
}
|
||||
|
||||
public static function sendBuddyConfirmRequest(param1:String, param2:Boolean) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("bc",[param1,param2 ? "1" : "0"]);
|
||||
}
|
||||
|
||||
public static function sendBuddyDeleteRequest(param1:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("bd",[param1]);
|
||||
}
|
||||
|
||||
public static function sendBuddyRoomRequest(param1:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("br",[param1],true,false,false);
|
||||
}
|
||||
|
||||
public static function sendBuddyBlockRequest(param1:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("bb",[param1]);
|
||||
}
|
||||
|
||||
public static function sendBuddyUnblockRequest(param1:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("bu",[param1]);
|
||||
}
|
||||
|
||||
public static function sendBuddyBlockInfoRequest(param1:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("bi",[param1]);
|
||||
}
|
||||
|
||||
public static function sendSearchRequest(param1:String, param2:Function) : void
|
||||
{
|
||||
_searchCallback = param2;
|
||||
userSearchResponse([false,-1]);
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Array = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "bl":
|
||||
buddyListblockedListResponse(_loc2_);
|
||||
break;
|
||||
case "ba":
|
||||
buddyAddRequestResponse(int(_loc2_[2]),_loc2_[3]);
|
||||
break;
|
||||
case "bs":
|
||||
buddyStatusResponse(_loc2_);
|
||||
break;
|
||||
case "bd":
|
||||
buddyDeleteResponse(_loc2_[2]);
|
||||
break;
|
||||
case "br":
|
||||
buddyRoomResponse(_loc2_);
|
||||
break;
|
||||
case "bb":
|
||||
buddyBlockResponse(_loc2_);
|
||||
break;
|
||||
case "bu":
|
||||
buddyUnblockResponse(_loc2_);
|
||||
break;
|
||||
case "bi":
|
||||
buddyIsBlockingMeResponse(_loc2_);
|
||||
break;
|
||||
default:
|
||||
throw new Error("BuddyXtCommManager illegal data:" + _loc2_[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function buddyListblockedListResponse(param1:Object) : void
|
||||
{
|
||||
if(param1[2] == "0")
|
||||
{
|
||||
BuddyManager.buddyListResponseHandler(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuddyManager.blockedListResponseHandler(param1);
|
||||
}
|
||||
if(_requestCallback != null)
|
||||
{
|
||||
_requestCallback();
|
||||
_requestCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function buddyAddRequestResponse(param1:int, param2:String) : void
|
||||
{
|
||||
BuddyManager.buddyAddRequestResponseHandler(param1,param2);
|
||||
}
|
||||
|
||||
private static function buddyStatusResponse(param1:Object) : void
|
||||
{
|
||||
if(param1[2] == "1")
|
||||
{
|
||||
BuddyManager.buddyStatusResponseHandler(param1[3],param1[4] == "1",int(param1[5]),int(param1[6]),null,param1[7],int(param1[8]));
|
||||
}
|
||||
else
|
||||
{
|
||||
BuddyManager.buddyStatusResponseHandler(param1[3],param1[4] == "1",int(param1[5]),int(param1[6]),param1[7]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function buddyDeleteResponse(param1:String) : void
|
||||
{
|
||||
BuddyManager.buddyDeleteResponseHandler(param1);
|
||||
}
|
||||
|
||||
private static function buddyRoomResponse(param1:Object) : void
|
||||
{
|
||||
BuddyCard.buddyRoomResponseHandler(param1[2],param1[3],param1[4] == "1",int(param1[5]));
|
||||
}
|
||||
|
||||
private static function buddyBlockResponse(param1:Object) : void
|
||||
{
|
||||
BuddyManager.buddyBlockResponseHandler(param1[2],param1[3] == "1");
|
||||
}
|
||||
|
||||
private static function buddyUnblockResponse(param1:Object) : void
|
||||
{
|
||||
BuddyManager.buddyUnblockResponseHandler(param1[2],param1[3] == "1");
|
||||
}
|
||||
|
||||
private static function userSearchResponse(param1:Object) : void
|
||||
{
|
||||
_searchCallback(param1[0],param1[1]);
|
||||
}
|
||||
|
||||
private static function buddyIsBlockingMeResponse(param1:Object) : void
|
||||
{
|
||||
BuddyCard.buddyBlockInfoResponseHandler(param1[2],param1[3] == "1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.adobe.crypto
|
||||
{
|
||||
import com.adobe.utils.IntUtil;
|
||||
|
||||
public class MD5
|
||||
{
|
||||
|
||||
public function MD5()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function hash(param1:String) : String
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc2_:int = 1732584193;
|
||||
var _loc3_:int = -271733879;
|
||||
var _loc4_:int = -1732584194;
|
||||
var _loc5_:int = 271733878;
|
||||
var _loc10_:Array = createBlocks(param1);
|
||||
var _loc11_:int = int(_loc10_.length);
|
||||
var _loc12_:int = 0;
|
||||
while(_loc12_ < _loc11_)
|
||||
{
|
||||
_loc6_ = _loc2_;
|
||||
_loc7_ = _loc3_;
|
||||
_loc8_ = _loc4_;
|
||||
_loc9_ = _loc5_;
|
||||
_loc2_ = ff(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 0],7,-680876936);
|
||||
_loc5_ = ff(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 1],12,-389564586);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 2],17,606105819);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 3],22,-1044525330);
|
||||
_loc2_ = ff(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 4],7,-176418897);
|
||||
_loc5_ = ff(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 5],12,1200080426);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 6],17,-1473231341);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 7],22,-45705983);
|
||||
_loc2_ = ff(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 8],7,1770035416);
|
||||
_loc5_ = ff(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 9],12,-1958414417);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 10],17,-42063);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 11],22,-1990404162);
|
||||
_loc2_ = ff(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 12],7,1804603682);
|
||||
_loc5_ = ff(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 13],12,-40341101);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 14],17,-1502002290);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 15],22,1236535329);
|
||||
_loc2_ = gg(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 1],5,-165796510);
|
||||
_loc5_ = gg(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 6],9,-1069501632);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 11],14,643717713);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 0],20,-373897302);
|
||||
_loc2_ = gg(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 5],5,-701558691);
|
||||
_loc5_ = gg(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 10],9,38016083);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 15],14,-660478335);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 4],20,-405537848);
|
||||
_loc2_ = gg(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 9],5,568446438);
|
||||
_loc5_ = gg(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 14],9,-1019803690);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 3],14,-187363961);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 8],20,1163531501);
|
||||
_loc2_ = gg(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 13],5,-1444681467);
|
||||
_loc5_ = gg(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 2],9,-51403784);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 7],14,1735328473);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 12],20,-1926607734);
|
||||
_loc2_ = hh(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 5],4,-378558);
|
||||
_loc5_ = hh(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 8],11,-2022574463);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 11],16,1839030562);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 14],23,-35309556);
|
||||
_loc2_ = hh(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 1],4,-1530992060);
|
||||
_loc5_ = hh(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 4],11,1272893353);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 7],16,-155497632);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 10],23,-1094730640);
|
||||
_loc2_ = hh(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 13],4,681279174);
|
||||
_loc5_ = hh(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 0],11,-358537222);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 3],16,-722521979);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 6],23,76029189);
|
||||
_loc2_ = hh(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 9],4,-640364487);
|
||||
_loc5_ = hh(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 12],11,-421815835);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 15],16,530742520);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 2],23,-995338651);
|
||||
_loc2_ = ii(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 0],6,-198630844);
|
||||
_loc5_ = ii(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 7],10,1126891415);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 14],15,-1416354905);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 5],21,-57434055);
|
||||
_loc2_ = ii(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 12],6,1700485571);
|
||||
_loc5_ = ii(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 3],10,-1894986606);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 10],15,-1051523);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 1],21,-2054922799);
|
||||
_loc2_ = ii(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 8],6,1873313359);
|
||||
_loc5_ = ii(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 15],10,-30611744);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 6],15,-1560198380);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 13],21,1309151649);
|
||||
_loc2_ = ii(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 4],6,-145523070);
|
||||
_loc5_ = ii(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 11],10,-1120210379);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 2],15,718787259);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 9],21,-343485551);
|
||||
_loc2_ += _loc6_;
|
||||
_loc3_ += _loc7_;
|
||||
_loc4_ += _loc8_;
|
||||
_loc5_ += _loc9_;
|
||||
_loc12_ += 16;
|
||||
}
|
||||
return IntUtil.toHex(_loc2_) + IntUtil.toHex(_loc3_) + IntUtil.toHex(_loc4_) + IntUtil.toHex(_loc5_);
|
||||
}
|
||||
|
||||
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 _loc2_:Array = new Array();
|
||||
var _loc3_:int = param1.length * 8;
|
||||
var _loc4_:int = 255;
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc2_[_loc5_ >> 5] |= (param1.charCodeAt(_loc5_ / 8) & _loc4_) << _loc5_ % 32;
|
||||
_loc5_ += 8;
|
||||
}
|
||||
_loc2_[_loc3_ >> 5] |= 128 << _loc3_ % 32;
|
||||
_loc2_[(_loc3_ + 64 >>> 9 << 4) + 14] = _loc3_;
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSON
|
||||
{
|
||||
|
||||
public function JSON()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function encode(param1:Object) : String
|
||||
{
|
||||
var _loc2_:JSONEncoder = new JSONEncoder(param1);
|
||||
return _loc2_.getString();
|
||||
}
|
||||
|
||||
public static function decode(param1:String) : *
|
||||
{
|
||||
var _loc2_:JSONDecoder = new JSONDecoder(param1);
|
||||
return _loc2_.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONDecoder
|
||||
{
|
||||
|
||||
private var value:*;
|
||||
|
||||
private var tokenizer:JSONTokenizer;
|
||||
|
||||
private var token:JSONToken;
|
||||
|
||||
public function JSONDecoder(param1:String)
|
||||
{
|
||||
super();
|
||||
this.tokenizer = new JSONTokenizer(param1);
|
||||
this.nextToken();
|
||||
this.value = this.parseValue();
|
||||
}
|
||||
|
||||
public function getValue() : *
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
private function nextToken() : JSONToken
|
||||
{
|
||||
return this.token = this.tokenizer.getNextToken();
|
||||
}
|
||||
|
||||
private function parseArray() : Array
|
||||
{
|
||||
var _loc1_:Array = new Array();
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.RIGHT_BRACKET)
|
||||
{
|
||||
return _loc1_;
|
||||
}
|
||||
while(true)
|
||||
{
|
||||
_loc1_.push(this.parseValue());
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.RIGHT_BRACKET)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(this.token.type == JSONTokenType.COMMA)
|
||||
{
|
||||
this.nextToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tokenizer.parseError("Expecting ] or , but found " + this.token.value);
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function parseObject() : Object
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc1_:Object = new Object();
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.RIGHT_BRACE)
|
||||
{
|
||||
return _loc1_;
|
||||
}
|
||||
while(true)
|
||||
{
|
||||
if(this.token.type == JSONTokenType.STRING)
|
||||
{
|
||||
_loc2_ = String(this.token.value);
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.COLON)
|
||||
{
|
||||
this.nextToken();
|
||||
_loc1_[_loc2_] = this.parseValue();
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.RIGHT_BRACE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(this.token.type == JSONTokenType.COMMA)
|
||||
{
|
||||
this.nextToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tokenizer.parseError("Expecting } or , but found " + this.token.value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tokenizer.parseError("Expecting : but found " + this.token.value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tokenizer.parseError("Expecting string but found " + this.token.value);
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function parseValue() : Object
|
||||
{
|
||||
switch(this.token.type)
|
||||
{
|
||||
case JSONTokenType.LEFT_BRACE:
|
||||
return this.parseObject();
|
||||
case JSONTokenType.LEFT_BRACKET:
|
||||
return this.parseArray();
|
||||
case JSONTokenType.STRING:
|
||||
case JSONTokenType.NUMBER:
|
||||
case JSONTokenType.TRUE:
|
||||
case JSONTokenType.FALSE:
|
||||
case JSONTokenType.NULL:
|
||||
return this.token.value;
|
||||
default:
|
||||
this.tokenizer.parseError("Unexpected " + this.token.value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
import flash.utils.describeType;
|
||||
|
||||
public class JSONEncoder
|
||||
{
|
||||
|
||||
private var jsonString:String;
|
||||
|
||||
public function JSONEncoder(param1:*)
|
||||
{
|
||||
super();
|
||||
this.jsonString = this.convertToString(param1);
|
||||
}
|
||||
|
||||
public function getString() : String
|
||||
{
|
||||
return this.jsonString;
|
||||
}
|
||||
|
||||
private function convertToString(param1:*) : String
|
||||
{
|
||||
if(param1 is String)
|
||||
{
|
||||
return this.escapeString(param1 as String);
|
||||
}
|
||||
if(param1 is Number)
|
||||
{
|
||||
return isFinite(param1 as Number) ? param1.toString() : "null";
|
||||
}
|
||||
if(param1 is Boolean)
|
||||
{
|
||||
return param1 ? "true" : "false";
|
||||
}
|
||||
if(param1 is Array)
|
||||
{
|
||||
return this.arrayToString(param1 as Array);
|
||||
}
|
||||
if(param1 is Object && param1 != null)
|
||||
{
|
||||
return this.objectToString(param1);
|
||||
}
|
||||
return "null";
|
||||
}
|
||||
|
||||
private function escapeString(param1:String) : String
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc7_:String = null;
|
||||
var _loc2_:String = "";
|
||||
var _loc4_:Number = param1.length;
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc4_)
|
||||
{
|
||||
_loc3_ = param1.charAt(_loc5_);
|
||||
switch(_loc3_)
|
||||
{
|
||||
case "\"":
|
||||
_loc2_ += "\\\"";
|
||||
break;
|
||||
case "\\":
|
||||
_loc2_ += "\\\\";
|
||||
break;
|
||||
case "\b":
|
||||
_loc2_ += "\\b";
|
||||
break;
|
||||
case "\f":
|
||||
_loc2_ += "\\f";
|
||||
break;
|
||||
case "\n":
|
||||
_loc2_ += "\\n";
|
||||
break;
|
||||
case "\r":
|
||||
_loc2_ += "\\r";
|
||||
break;
|
||||
case "\t":
|
||||
_loc2_ += "\\t";
|
||||
break;
|
||||
default:
|
||||
if(_loc3_ < " ")
|
||||
{
|
||||
_loc6_ = _loc3_.charCodeAt(0).toString(16);
|
||||
_loc7_ = _loc6_.length == 2 ? "00" : "000";
|
||||
_loc2_ += "\\u" + _loc7_ + _loc6_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ += _loc3_;
|
||||
}
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return "\"" + _loc2_ + "\"";
|
||||
}
|
||||
|
||||
private function arrayToString(param1:Array) : String
|
||||
{
|
||||
var _loc2_:String = "";
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
if(_loc2_.length > 0)
|
||||
{
|
||||
_loc2_ += ",";
|
||||
}
|
||||
_loc2_ += this.convertToString(param1[_loc3_]);
|
||||
_loc3_++;
|
||||
}
|
||||
return "[" + _loc2_ + "]";
|
||||
}
|
||||
|
||||
private function objectToString(param1:Object) : String
|
||||
{
|
||||
var value:Object = null;
|
||||
var key:String = null;
|
||||
var v:XML = null;
|
||||
var o:Object = param1;
|
||||
var s:String = "";
|
||||
var classInfo:XML = describeType(o);
|
||||
if(classInfo.@name.toString() == "Object")
|
||||
{
|
||||
for(key in o)
|
||||
{
|
||||
value = o[key];
|
||||
if(!(value is Function))
|
||||
{
|
||||
if(s.length > 0)
|
||||
{
|
||||
s += ",";
|
||||
}
|
||||
s += this.escapeString(key) + ":" + this.convertToString(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for each(v in classInfo..*.(name() == "variable" || name() == "accessor"))
|
||||
{
|
||||
if(s.length > 0)
|
||||
{
|
||||
s += ",";
|
||||
}
|
||||
s += this.escapeString(v.@name.toString()) + ":" + this.convertToString(o[v.@name]);
|
||||
}
|
||||
}
|
||||
return "{" + s + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONParseError extends Error
|
||||
{
|
||||
|
||||
private var _location:int;
|
||||
|
||||
private var _text:String;
|
||||
|
||||
public function JSONParseError(param1:String = "", param2:int = 0, param3:String = "")
|
||||
{
|
||||
super(param1);
|
||||
this._location = param2;
|
||||
this._text = param3;
|
||||
}
|
||||
|
||||
public function get location() : int
|
||||
{
|
||||
return this._location;
|
||||
}
|
||||
|
||||
public function get text() : String
|
||||
{
|
||||
return this._text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONToken
|
||||
{
|
||||
|
||||
private var _type:int;
|
||||
|
||||
private var _value:Object;
|
||||
|
||||
public function JSONToken(param1:int = -1, param2:Object = null)
|
||||
{
|
||||
super();
|
||||
this._type = param1;
|
||||
this._value = param2;
|
||||
}
|
||||
|
||||
public function get type() : int
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public function set type(param1:int) : void
|
||||
{
|
||||
this._type = param1;
|
||||
}
|
||||
|
||||
public function get value() : Object
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
public function set value(param1:Object) : void
|
||||
{
|
||||
this._value = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONTokenType
|
||||
{
|
||||
|
||||
public static const UNKNOWN:int = -1;
|
||||
|
||||
public static const COMMA:int = 0;
|
||||
|
||||
public static const LEFT_BRACE:int = 1;
|
||||
|
||||
public static const RIGHT_BRACE:int = 2;
|
||||
|
||||
public static const LEFT_BRACKET:int = 3;
|
||||
|
||||
public static const RIGHT_BRACKET:int = 4;
|
||||
|
||||
public static const COLON:int = 6;
|
||||
|
||||
public static const TRUE:int = 7;
|
||||
|
||||
public static const FALSE:int = 8;
|
||||
|
||||
public static const NULL:int = 9;
|
||||
|
||||
public static const STRING:int = 10;
|
||||
|
||||
public static const NUMBER:int = 11;
|
||||
|
||||
public function JSONTokenType()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONTokenizer
|
||||
{
|
||||
|
||||
private var obj:Object;
|
||||
|
||||
private var jsonString:String;
|
||||
|
||||
private var loc:int;
|
||||
|
||||
private var ch:String;
|
||||
|
||||
public function JSONTokenizer(param1:String)
|
||||
{
|
||||
super();
|
||||
this.jsonString = param1;
|
||||
this.loc = 0;
|
||||
this.nextChar();
|
||||
}
|
||||
|
||||
public function getNextToken() : JSONToken
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc1_:JSONToken = new JSONToken();
|
||||
this.skipIgnored();
|
||||
switch(this.ch)
|
||||
{
|
||||
case "{":
|
||||
_loc1_.type = JSONTokenType.LEFT_BRACE;
|
||||
_loc1_.value = "{";
|
||||
this.nextChar();
|
||||
break;
|
||||
case "}":
|
||||
_loc1_.type = JSONTokenType.RIGHT_BRACE;
|
||||
_loc1_.value = "}";
|
||||
this.nextChar();
|
||||
break;
|
||||
case "[":
|
||||
_loc1_.type = JSONTokenType.LEFT_BRACKET;
|
||||
_loc1_.value = "[";
|
||||
this.nextChar();
|
||||
break;
|
||||
case "]":
|
||||
_loc1_.type = JSONTokenType.RIGHT_BRACKET;
|
||||
_loc1_.value = "]";
|
||||
this.nextChar();
|
||||
break;
|
||||
case ",":
|
||||
_loc1_.type = JSONTokenType.COMMA;
|
||||
_loc1_.value = ",";
|
||||
this.nextChar();
|
||||
break;
|
||||
case ":":
|
||||
_loc1_.type = JSONTokenType.COLON;
|
||||
_loc1_.value = ":";
|
||||
this.nextChar();
|
||||
break;
|
||||
case "t":
|
||||
_loc2_ = "t" + this.nextChar() + this.nextChar() + this.nextChar();
|
||||
if(_loc2_ == "true")
|
||||
{
|
||||
_loc1_.type = JSONTokenType.TRUE;
|
||||
_loc1_.value = true;
|
||||
this.nextChar();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.parseError("Expecting \'true\' but found " + _loc2_);
|
||||
}
|
||||
break;
|
||||
case "f":
|
||||
_loc3_ = "f" + this.nextChar() + this.nextChar() + this.nextChar() + this.nextChar();
|
||||
if(_loc3_ == "false")
|
||||
{
|
||||
_loc1_.type = JSONTokenType.FALSE;
|
||||
_loc1_.value = false;
|
||||
this.nextChar();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.parseError("Expecting \'false\' but found " + _loc3_);
|
||||
}
|
||||
break;
|
||||
case "n":
|
||||
_loc4_ = "n" + this.nextChar() + this.nextChar() + this.nextChar();
|
||||
if(_loc4_ == "null")
|
||||
{
|
||||
_loc1_.type = JSONTokenType.NULL;
|
||||
_loc1_.value = null;
|
||||
this.nextChar();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.parseError("Expecting \'null\' but found " + _loc4_);
|
||||
}
|
||||
break;
|
||||
case "\"":
|
||||
_loc1_ = this.readString();
|
||||
break;
|
||||
default:
|
||||
if(this.isDigit(this.ch) || this.ch == "-")
|
||||
{
|
||||
_loc1_ = this.readNumber();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.ch == "")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
this.parseError("Unexpected " + this.ch + " encountered");
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function readString() : JSONToken
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc1_:JSONToken = new JSONToken();
|
||||
_loc1_.type = JSONTokenType.STRING;
|
||||
var _loc2_:String = "";
|
||||
this.nextChar();
|
||||
while(this.ch != "\"" && this.ch != "")
|
||||
{
|
||||
if(this.ch == "\\")
|
||||
{
|
||||
this.nextChar();
|
||||
switch(this.ch)
|
||||
{
|
||||
case "\"":
|
||||
_loc2_ += "\"";
|
||||
break;
|
||||
case "/":
|
||||
_loc2_ += "/";
|
||||
break;
|
||||
case "\\":
|
||||
_loc2_ += "\\";
|
||||
break;
|
||||
case "b":
|
||||
_loc2_ += "\b";
|
||||
break;
|
||||
case "f":
|
||||
_loc2_ += "\f";
|
||||
break;
|
||||
case "n":
|
||||
_loc2_ += "\n";
|
||||
break;
|
||||
case "r":
|
||||
_loc2_ += "\r";
|
||||
break;
|
||||
case "t":
|
||||
_loc2_ += "\t";
|
||||
break;
|
||||
case "u":
|
||||
_loc3_ = "";
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 4)
|
||||
{
|
||||
if(!this.isHexDigit(this.nextChar()))
|
||||
{
|
||||
this.parseError(" Excepted a hex digit, but found: " + this.ch);
|
||||
}
|
||||
_loc3_ += this.ch;
|
||||
_loc4_++;
|
||||
}
|
||||
_loc2_ += String.fromCharCode(parseInt(_loc3_,16));
|
||||
break;
|
||||
default:
|
||||
_loc2_ += "\\" + this.ch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
}
|
||||
this.nextChar();
|
||||
}
|
||||
if(this.ch == "")
|
||||
{
|
||||
this.parseError("Unterminated string literal");
|
||||
}
|
||||
this.nextChar();
|
||||
_loc1_.value = _loc2_;
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function readNumber() : JSONToken
|
||||
{
|
||||
var _loc1_:JSONToken = new JSONToken();
|
||||
_loc1_.type = JSONTokenType.NUMBER;
|
||||
var _loc2_:String = "";
|
||||
if(this.ch == "-")
|
||||
{
|
||||
_loc2_ += "-";
|
||||
this.nextChar();
|
||||
}
|
||||
if(!this.isDigit(this.ch))
|
||||
{
|
||||
this.parseError("Expecting a digit");
|
||||
}
|
||||
if(this.ch == "0")
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
if(this.isDigit(this.ch))
|
||||
{
|
||||
this.parseError("A digit cannot immediately follow 0");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this.isDigit(this.ch))
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
}
|
||||
}
|
||||
if(this.ch == ".")
|
||||
{
|
||||
_loc2_ += ".";
|
||||
this.nextChar();
|
||||
if(!this.isDigit(this.ch))
|
||||
{
|
||||
this.parseError("Expecting a digit");
|
||||
}
|
||||
while(this.isDigit(this.ch))
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
}
|
||||
}
|
||||
if(this.ch == "e" || this.ch == "E")
|
||||
{
|
||||
_loc2_ += "e";
|
||||
this.nextChar();
|
||||
if(this.ch == "+" || this.ch == "-")
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
}
|
||||
if(!this.isDigit(this.ch))
|
||||
{
|
||||
this.parseError("Scientific notation number needs exponent value");
|
||||
}
|
||||
while(this.isDigit(this.ch))
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
}
|
||||
}
|
||||
var _loc3_:Number = Number(_loc2_);
|
||||
if(isFinite(_loc3_) && !isNaN(_loc3_))
|
||||
{
|
||||
_loc1_.value = _loc3_;
|
||||
return _loc1_;
|
||||
}
|
||||
this.parseError("Number " + _loc3_ + " is not valid!");
|
||||
return null;
|
||||
}
|
||||
|
||||
private function nextChar() : String
|
||||
{
|
||||
return this.ch = this.jsonString.charAt(this.loc++);
|
||||
}
|
||||
|
||||
private function skipIgnored() : void
|
||||
{
|
||||
this.skipWhite();
|
||||
this.skipComments();
|
||||
this.skipWhite();
|
||||
}
|
||||
|
||||
private function skipComments() : void
|
||||
{
|
||||
if(this.ch == "/")
|
||||
{
|
||||
this.nextChar();
|
||||
switch(this.ch)
|
||||
{
|
||||
case "/":
|
||||
do
|
||||
{
|
||||
this.nextChar();
|
||||
}
|
||||
while(this.ch != "\n" && this.ch != "");
|
||||
this.nextChar();
|
||||
break;
|
||||
case "*":
|
||||
this.nextChar();
|
||||
while(true)
|
||||
{
|
||||
if(this.ch == "*")
|
||||
{
|
||||
this.nextChar();
|
||||
if(this.ch == "/")
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.nextChar();
|
||||
}
|
||||
if(this.ch == "")
|
||||
{
|
||||
this.parseError("Multi-line comment not closed");
|
||||
}
|
||||
}
|
||||
this.nextChar();
|
||||
break;
|
||||
default:
|
||||
this.parseError("Unexpected " + this.ch + " encountered (expecting \'/\' or \'*\' )");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function skipWhite() : void
|
||||
{
|
||||
while(this.isWhiteSpace(this.ch))
|
||||
{
|
||||
this.nextChar();
|
||||
}
|
||||
}
|
||||
|
||||
private function isWhiteSpace(param1:String) : Boolean
|
||||
{
|
||||
return param1 == " " || param1 == "\t" || param1 == "\n";
|
||||
}
|
||||
|
||||
private function isDigit(param1:String) : Boolean
|
||||
{
|
||||
return param1 >= "0" && param1 <= "9";
|
||||
}
|
||||
|
||||
private function isHexDigit(param1:String) : Boolean
|
||||
{
|
||||
var _loc2_:String = param1.toUpperCase();
|
||||
return this.isDigit(param1) || _loc2_ >= "A" && _loc2_ <= "F";
|
||||
}
|
||||
|
||||
public function parseError(param1:String) : void
|
||||
{
|
||||
throw new JSONParseError(param1,this.loc,this.jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 _loc4_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:String = "";
|
||||
if(param2)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 4)
|
||||
{
|
||||
_loc3_ += hexChars.charAt(param1 >> (3 - _loc4_) * 8 + 4 & 0x0F) + hexChars.charAt(param1 >> (3 - _loc4_) * 8 & 0x0F);
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 4)
|
||||
{
|
||||
_loc3_ += hexChars.charAt(param1 >> _loc5_ * 8 + 4 & 0x0F) + hexChars.charAt(param1 >> _loc5_ * 8 & 0x0F);
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
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 _loc2_:Number = param1.length;
|
||||
var _loc3_:Number = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
if(param1.charCodeAt(_loc3_) > 32)
|
||||
{
|
||||
return param1.substring(_loc3_);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function rtrim(param1:String) : String
|
||||
{
|
||||
var _loc2_:Number = param1.length;
|
||||
var _loc3_:Number = _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 _loc9_:Number = NaN;
|
||||
var _loc4_:String = new String();
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc6_:Number = param1.length;
|
||||
var _loc7_:Number = param2.length;
|
||||
var _loc8_:Number = 0;
|
||||
for(; _loc8_ < _loc6_; _loc8_++)
|
||||
{
|
||||
if(param1.charAt(_loc8_) == param2.charAt(0))
|
||||
{
|
||||
_loc5_ = true;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc7_)
|
||||
{
|
||||
if(param1.charAt(_loc8_ + _loc9_) != param2.charAt(_loc9_))
|
||||
{
|
||||
_loc5_ = false;
|
||||
break;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc4_ += param3;
|
||||
_loc8_ += _loc7_ - 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
_loc4_ += param1.charAt(_loc8_);
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
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)
|
||||
{
|
||||
this.setGraph(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function setGraph(param1:Graph) : void
|
||||
{
|
||||
this.graph = param1;
|
||||
this.updateGraph();
|
||||
}
|
||||
|
||||
private function updateGraph() : void
|
||||
{
|
||||
var _loc1_:int = this.graph.size();
|
||||
this.g = new Vector.<Number>(_loc1_,true);
|
||||
this.h = new Vector.<Number>(_loc1_,true);
|
||||
this.f = new Vector.<Number>(_loc1_,true);
|
||||
this.parent = new Vector.<int>(_loc1_,true);
|
||||
}
|
||||
|
||||
public function solve(param1:int, param2:int) : Vector.<int>
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc11_:int = 0;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc13_:Boolean = false;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc3_:Vector.<int> = new Vector.<int>();
|
||||
this.goalReached = false;
|
||||
this.open = new Vector.<int>();
|
||||
this.closed = new Vector.<int>();
|
||||
this.closedDict = new Dictionary(true);
|
||||
this.open.push(param1);
|
||||
this.g[param1] = 0;
|
||||
this.h[param1] = this.graph.distance(param1,param2);
|
||||
this.f[param1] = this.h[param1];
|
||||
this.parent[param1] = -1;
|
||||
this.graph.setStartGridPos(param1);
|
||||
while(this.open.length > 0)
|
||||
{
|
||||
_loc7_ = Number.POSITIVE_INFINITY;
|
||||
_loc8_ = -1;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < this.open.length)
|
||||
{
|
||||
_loc11_ = this.open[_loc9_];
|
||||
if(this.f[_loc11_] < _loc7_)
|
||||
{
|
||||
_loc7_ = this.f[_loc11_];
|
||||
_loc8_ = _loc11_;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
if(_loc8_ == param2)
|
||||
{
|
||||
this.goalReached = true;
|
||||
return this.createPath(param2,param1);
|
||||
}
|
||||
this.open.splice(this.open.indexOf(_loc8_),1);
|
||||
this.closed.push(_loc8_);
|
||||
this.closedDict[_loc8_] = 1;
|
||||
for each(_loc10_ in this.graph.getNeighbors(_loc8_,_loc3_))
|
||||
{
|
||||
if(this.closedDict[_loc10_] != 1)
|
||||
{
|
||||
_loc12_ = this.g[_loc8_] + this.graph.distance(_loc8_,_loc10_);
|
||||
_loc13_ = false;
|
||||
if(this.open.indexOf(_loc10_) == -1)
|
||||
{
|
||||
this.open.push(_loc10_);
|
||||
_loc13_ = true;
|
||||
}
|
||||
else if(_loc12_ < this.g[_loc10_])
|
||||
{
|
||||
_loc13_ = true;
|
||||
}
|
||||
if(_loc13_)
|
||||
{
|
||||
this.parent[_loc10_] = _loc8_;
|
||||
this.g[_loc10_] = _loc12_;
|
||||
this.h[_loc10_] = this.graph.distance(_loc10_,param2);
|
||||
this.f[_loc10_] = this.g[_loc10_] + this.h[_loc10_];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var _loc4_:Number = Number.POSITIVE_INFINITY;
|
||||
var _loc5_:int = -1;
|
||||
for each(_loc6_ in this.closed)
|
||||
{
|
||||
_loc14_ = this.h[_loc6_];
|
||||
if(_loc14_ < _loc4_)
|
||||
{
|
||||
_loc4_ = _loc14_;
|
||||
_loc5_ = _loc6_;
|
||||
}
|
||||
}
|
||||
return this.createPath(_loc5_,param1);
|
||||
}
|
||||
|
||||
public function hasReachedGoal() : Boolean
|
||||
{
|
||||
return this.goalReached;
|
||||
}
|
||||
|
||||
private function createPath(param1:int, param2:int) : Vector.<int>
|
||||
{
|
||||
var _loc3_:Vector.<int> = new Vector.<int>();
|
||||
while(this.parent[param1] != -1)
|
||||
{
|
||||
_loc3_.push(param1);
|
||||
param1 = this.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,180 @@
|
||||
package com.carlcalderon.arthropod
|
||||
{
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.Stage;
|
||||
import flash.events.StatusEvent;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.net.LocalConnection;
|
||||
import flash.system.System;
|
||||
|
||||
public class Debug
|
||||
{
|
||||
|
||||
public static const NAME:String = "Debug";
|
||||
|
||||
public static const VERSION:String = "0.74";
|
||||
|
||||
public static var password:String = "CDC309AF";
|
||||
|
||||
public static var RED:uint = 13369344;
|
||||
|
||||
public static var GREEN:uint = 52224;
|
||||
|
||||
public static var BLUE:uint = 6710988;
|
||||
|
||||
public static var PINK:uint = 13369548;
|
||||
|
||||
public static var YELLOW:uint = 13421568;
|
||||
|
||||
public static var LIGHT_BLUE:uint = 52428;
|
||||
|
||||
public static var ignoreStatus:Boolean = true;
|
||||
|
||||
public static var secure:Boolean = false;
|
||||
|
||||
public static var secureDomain:String = "*";
|
||||
|
||||
public static var allowLog:Boolean = true;
|
||||
|
||||
private static const DOMAIN:String = "com.carlcalderon.Arthropod";
|
||||
|
||||
private static const CHECK:String = ".161E714B6C1A76DE7B9865F88B32FCCE8FABA7B5.1";
|
||||
|
||||
private static const TYPE:String = "app";
|
||||
|
||||
private static const CONNECTION:String = "arthropod";
|
||||
|
||||
private static const LOG_OPERATION:String = "debug";
|
||||
|
||||
private static const ERROR_OPERATION:String = "debugError";
|
||||
|
||||
private static const WARNING_OPERATION:String = "debugWarning";
|
||||
|
||||
private static const ARRAY_OPERATION:String = "debugArray";
|
||||
|
||||
private static const BITMAP_OPERATION:String = "debugBitmapData";
|
||||
|
||||
private static const OBJECT_OPERATION:String = "debugObject";
|
||||
|
||||
private static const MEMORY_OPERATION:String = "debugMemory";
|
||||
|
||||
private static const CLEAR_OPERATION:String = "debugClear";
|
||||
|
||||
private static var lc:LocalConnection = new LocalConnection();
|
||||
|
||||
private static var hasEventListeners:Boolean = false;
|
||||
|
||||
public function Debug()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function log(param1:*, param2:uint = 16711422) : Boolean
|
||||
{
|
||||
return send(LOG_OPERATION,String(param1),param2);
|
||||
}
|
||||
|
||||
public static function error(param1:*) : Boolean
|
||||
{
|
||||
return send(ERROR_OPERATION,String(param1),13369344);
|
||||
}
|
||||
|
||||
public static function warning(param1:*) : Boolean
|
||||
{
|
||||
return send(WARNING_OPERATION,String(param1),13421568);
|
||||
}
|
||||
|
||||
public static function clear() : Boolean
|
||||
{
|
||||
return send(CLEAR_OPERATION,0,0);
|
||||
}
|
||||
|
||||
public static function array(param1:Array) : Boolean
|
||||
{
|
||||
return send(ARRAY_OPERATION,param1,null);
|
||||
}
|
||||
|
||||
public static function bitmap(param1:*, param2:String = null) : Boolean
|
||||
{
|
||||
var _loc3_:BitmapData = new BitmapData(100,100,true,16777215);
|
||||
var _loc4_:Matrix = new Matrix();
|
||||
var _loc5_:Number = 100 / (param1.width >= param1.height ? param1.width : param1.height);
|
||||
_loc4_.scale(_loc5_,_loc5_);
|
||||
_loc3_.draw(param1,_loc4_,null,null,null,true);
|
||||
var _loc6_:Rectangle = new Rectangle(0,0,Math.floor(param1.width * _loc5_),Math.floor(param1.height * _loc5_));
|
||||
return send(BITMAP_OPERATION,_loc3_.getPixels(_loc6_),{
|
||||
"bounds":_loc6_,
|
||||
"lbl":param2
|
||||
});
|
||||
}
|
||||
|
||||
public static function snapshot(param1:Stage, param2:String = null) : Boolean
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
return bitmap(param1,param2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function object(param1:*) : Boolean
|
||||
{
|
||||
return send(OBJECT_OPERATION,param1,null);
|
||||
}
|
||||
|
||||
public static function memory() : Boolean
|
||||
{
|
||||
return send(MEMORY_OPERATION,System.totalMemory,null);
|
||||
}
|
||||
|
||||
private static function send(param1:String, param2:*, param3:*) : Boolean
|
||||
{
|
||||
var operation:String = param1;
|
||||
var value:* = param2;
|
||||
var prop:* = param3;
|
||||
if(!secure)
|
||||
{
|
||||
lc.allowInsecureDomain("*");
|
||||
}
|
||||
else
|
||||
{
|
||||
lc.allowDomain(secureDomain);
|
||||
}
|
||||
if(!hasEventListeners)
|
||||
{
|
||||
if(ignoreStatus)
|
||||
{
|
||||
lc.addEventListener(StatusEvent.STATUS,ignore);
|
||||
}
|
||||
else
|
||||
{
|
||||
lc.addEventListener(StatusEvent.STATUS,status);
|
||||
}
|
||||
hasEventListeners = true;
|
||||
}
|
||||
if(!allowLog)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
lc.send(TYPE + "#" + DOMAIN + CHECK + ":" + CONNECTION,operation,password,value,prop);
|
||||
return true;
|
||||
}
|
||||
catch(e:*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static function status(param1:StatusEvent) : void
|
||||
{
|
||||
}
|
||||
|
||||
private static function ignore(param1:StatusEvent) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
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 _loc5_:ICipher = null;
|
||||
var _loc4_:Array = param1.split("-");
|
||||
switch(_loc4_[0])
|
||||
{
|
||||
case "simple":
|
||||
_loc4_.shift();
|
||||
param1 = _loc4_.join("-");
|
||||
_loc5_ = getCipher(param1,param2,param3);
|
||||
if(_loc5_ is IVMode)
|
||||
{
|
||||
return new SimpleIVMode(_loc5_ as IVMode);
|
||||
}
|
||||
return _loc5_;
|
||||
break;
|
||||
case "aes":
|
||||
case "aes128":
|
||||
case "aes192":
|
||||
case "aes256":
|
||||
_loc4_.shift();
|
||||
if(param2.length * 8 == _loc4_[0])
|
||||
{
|
||||
_loc4_.shift();
|
||||
}
|
||||
return getMode(_loc4_[0],new AESKey(param2),param3);
|
||||
case "bf":
|
||||
case "blowfish":
|
||||
_loc4_.shift();
|
||||
return getMode(_loc4_[0],new BlowFishKey(param2),param3);
|
||||
case "des":
|
||||
_loc4_.shift();
|
||||
if(_loc4_[0] != "ede" && _loc4_[0] != "ede3")
|
||||
{
|
||||
return getMode(_loc4_[0],new DESKey(param2),param3);
|
||||
}
|
||||
if(_loc4_.length == 1)
|
||||
{
|
||||
_loc4_.push("ecb");
|
||||
}
|
||||
break;
|
||||
case "3des":
|
||||
case "des3":
|
||||
break;
|
||||
case "xtea":
|
||||
_loc4_.shift();
|
||||
return getMode(_loc4_[0],new XTeaKey(param2),param3);
|
||||
case "rc4":
|
||||
_loc4_.shift();
|
||||
return new ARC4(param2);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
_loc4_.shift();
|
||||
return getMode(_loc4_[0],new TripleDESKey(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":
|
||||
return 16;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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":
|
||||
return new SHA1();
|
||||
case "sha224":
|
||||
return new SHA224();
|
||||
case "sha256":
|
||||
return new SHA256();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
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,78 @@
|
||||
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(this.bits != 0)
|
||||
{
|
||||
return this.bits / 8;
|
||||
}
|
||||
return this.hash.getHashSize();
|
||||
}
|
||||
|
||||
public function compute(param1:ByteArray, param2:ByteArray) : ByteArray
|
||||
{
|
||||
var _loc3_:ByteArray = null;
|
||||
if(param1.length > this.hash.getInputSize())
|
||||
{
|
||||
_loc3_ = this.hash.hash(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = new ByteArray();
|
||||
_loc3_.writeBytes(param1);
|
||||
}
|
||||
while(_loc3_.length < this.hash.getInputSize())
|
||||
{
|
||||
_loc3_[_loc3_.length] = 0;
|
||||
}
|
||||
var _loc4_:ByteArray = new ByteArray();
|
||||
var _loc5_:ByteArray = new ByteArray();
|
||||
var _loc6_:uint = 0;
|
||||
while(_loc6_ < _loc3_.length)
|
||||
{
|
||||
_loc4_[_loc6_] = _loc3_[_loc6_] ^ 0x36;
|
||||
_loc5_[_loc6_] = _loc3_[_loc6_] ^ 0x5C;
|
||||
_loc6_++;
|
||||
}
|
||||
_loc4_.position = _loc3_.length;
|
||||
_loc4_.writeBytes(param2);
|
||||
var _loc7_:ByteArray = this.hash.hash(_loc4_);
|
||||
_loc5_.position = _loc3_.length;
|
||||
_loc5_.writeBytes(_loc7_);
|
||||
var _loc8_:ByteArray = this.hash.hash(_loc5_);
|
||||
if(this.bits > 0 && this.bits < 8 * _loc8_.length)
|
||||
{
|
||||
_loc8_.length = this.bits / 8;
|
||||
}
|
||||
return _loc8_;
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
this.hash = null;
|
||||
this.bits = 0;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "hmac-" + (this.bits > 0 ? this.bits + "-" : "") + this.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,92 @@
|
||||
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 HASH_SIZE;
|
||||
}
|
||||
|
||||
public function hash(param1:ByteArray) : ByteArray
|
||||
{
|
||||
var _loc8_:uint = 0;
|
||||
var _loc9_:uint = 0;
|
||||
var _loc10_:uint = 0;
|
||||
var _loc2_:uint = param1.length;
|
||||
var _loc3_:uint = uint(uint(16 - param1.length % 16) || 16);
|
||||
do
|
||||
{
|
||||
param1[param1.length] = _loc3_;
|
||||
}
|
||||
while(param1.length % 16 != 0);
|
||||
var _loc4_:uint = param1.length;
|
||||
var _loc5_:ByteArray = new ByteArray();
|
||||
var _loc6_:uint = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc4_)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 16)
|
||||
{
|
||||
_loc6_ = uint(_loc5_[_loc8_] = _loc5_[_loc8_] ^ S[param1[_loc3_ + _loc8_] ^ _loc6_]);
|
||||
_loc8_++;
|
||||
}
|
||||
_loc3_ += 16;
|
||||
}
|
||||
param1.position = param1.length;
|
||||
param1.writeBytes(_loc5_);
|
||||
_loc4_ += 16;
|
||||
var _loc7_:ByteArray = new ByteArray();
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc4_)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 16)
|
||||
{
|
||||
_loc7_[32 + _loc8_] = (_loc7_[16 + _loc8_] = param1[_loc3_ + _loc8_]) ^ _loc7_[_loc8_];
|
||||
_loc8_++;
|
||||
}
|
||||
_loc9_ = 0;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 18)
|
||||
{
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < 48)
|
||||
{
|
||||
_loc7_[_loc10_] = _loc9_ = uint(_loc7_[_loc10_] ^ S[_loc9_]);
|
||||
_loc10_++;
|
||||
}
|
||||
_loc9_ = uint(_loc9_ + _loc8_ & 0xFF);
|
||||
_loc8_++;
|
||||
}
|
||||
_loc3_ += 16;
|
||||
}
|
||||
_loc7_.length = 16;
|
||||
param1.length = _loc2_;
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "md2";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.hurlant.crypto.hash
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.Endian;
|
||||
|
||||
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 HASH_SIZE;
|
||||
}
|
||||
|
||||
public function hash(param1:ByteArray) : ByteArray
|
||||
{
|
||||
var _loc2_:uint = param1.length * 8;
|
||||
var _loc3_:String = param1.endian;
|
||||
while(param1.length % 4 != 0)
|
||||
{
|
||||
param1[param1.length] = 0;
|
||||
}
|
||||
param1.position = 0;
|
||||
var _loc4_:Array = [];
|
||||
param1.endian = Endian.LITTLE_ENDIAN;
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < param1.length)
|
||||
{
|
||||
_loc4_.push(param1.readUnsignedInt());
|
||||
_loc5_ += 4;
|
||||
}
|
||||
var _loc6_:Array = this.core_md5(_loc4_,_loc2_);
|
||||
var _loc7_:ByteArray = new ByteArray();
|
||||
_loc7_.endian = Endian.LITTLE_ENDIAN;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 4)
|
||||
{
|
||||
_loc7_.writeUnsignedInt(_loc6_[_loc5_]);
|
||||
_loc5_++;
|
||||
}
|
||||
param1.length = _loc2_ / 8;
|
||||
param1.endian = _loc3_;
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
private function core_md5(param1:Array, param2:uint) : Array
|
||||
{
|
||||
var _loc8_:uint = 0;
|
||||
var _loc9_:uint = 0;
|
||||
var _loc10_:uint = 0;
|
||||
var _loc11_:uint = 0;
|
||||
param1[param2 >> 5] |= 128 << param2 % 32;
|
||||
param1[(param2 + 64 >>> 9 << 4) + 14] = param2;
|
||||
var _loc3_:uint = 1732584193;
|
||||
var _loc4_:uint = 4023233417;
|
||||
var _loc5_:uint = 2562383102;
|
||||
var _loc6_:uint = 271733878;
|
||||
var _loc7_:uint = 0;
|
||||
while(_loc7_ < param1.length)
|
||||
{
|
||||
param1[_loc7_] = param1[_loc7_] || 0;
|
||||
param1[_loc7_ + 1] = param1[_loc7_ + 1] || 0;
|
||||
param1[_loc7_ + 2] = param1[_loc7_ + 2] || 0;
|
||||
param1[_loc7_ + 3] = param1[_loc7_ + 3] || 0;
|
||||
param1[_loc7_ + 4] = param1[_loc7_ + 4] || 0;
|
||||
param1[_loc7_ + 5] = param1[_loc7_ + 5] || 0;
|
||||
param1[_loc7_ + 6] = param1[_loc7_ + 6] || 0;
|
||||
param1[_loc7_ + 7] = param1[_loc7_ + 7] || 0;
|
||||
param1[_loc7_ + 8] = param1[_loc7_ + 8] || 0;
|
||||
param1[_loc7_ + 9] = param1[_loc7_ + 9] || 0;
|
||||
param1[_loc7_ + 10] = param1[_loc7_ + 10] || 0;
|
||||
param1[_loc7_ + 11] = param1[_loc7_ + 11] || 0;
|
||||
param1[_loc7_ + 12] = param1[_loc7_ + 12] || 0;
|
||||
param1[_loc7_ + 13] = param1[_loc7_ + 13] || 0;
|
||||
param1[_loc7_ + 14] = param1[_loc7_ + 14] || 0;
|
||||
param1[_loc7_ + 15] = param1[_loc7_ + 15] || 0;
|
||||
_loc8_ = _loc3_;
|
||||
_loc9_ = _loc4_;
|
||||
_loc10_ = _loc5_;
|
||||
_loc11_ = _loc6_;
|
||||
_loc3_ = this.ff(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 0],7,3614090360);
|
||||
_loc6_ = this.ff(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 1],12,3905402710);
|
||||
_loc5_ = this.ff(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 2],17,606105819);
|
||||
_loc4_ = this.ff(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 3],22,3250441966);
|
||||
_loc3_ = this.ff(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 4],7,4118548399);
|
||||
_loc6_ = this.ff(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 5],12,1200080426);
|
||||
_loc5_ = this.ff(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 6],17,2821735955);
|
||||
_loc4_ = this.ff(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 7],22,4249261313);
|
||||
_loc3_ = this.ff(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 8],7,1770035416);
|
||||
_loc6_ = this.ff(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 9],12,2336552879);
|
||||
_loc5_ = this.ff(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 10],17,4294925233);
|
||||
_loc4_ = this.ff(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 11],22,2304563134);
|
||||
_loc3_ = this.ff(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 12],7,1804603682);
|
||||
_loc6_ = this.ff(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 13],12,4254626195);
|
||||
_loc5_ = this.ff(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 14],17,2792965006);
|
||||
_loc4_ = this.ff(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 15],22,1236535329);
|
||||
_loc3_ = this.gg(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 1],5,4129170786);
|
||||
_loc6_ = this.gg(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 6],9,3225465664);
|
||||
_loc5_ = this.gg(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 11],14,643717713);
|
||||
_loc4_ = this.gg(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 0],20,3921069994);
|
||||
_loc3_ = this.gg(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 5],5,3593408605);
|
||||
_loc6_ = this.gg(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 10],9,38016083);
|
||||
_loc5_ = this.gg(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 15],14,3634488961);
|
||||
_loc4_ = this.gg(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 4],20,3889429448);
|
||||
_loc3_ = this.gg(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 9],5,568446438);
|
||||
_loc6_ = this.gg(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 14],9,3275163606);
|
||||
_loc5_ = this.gg(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 3],14,4107603335);
|
||||
_loc4_ = this.gg(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 8],20,1163531501);
|
||||
_loc3_ = this.gg(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 13],5,2850285829);
|
||||
_loc6_ = this.gg(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 2],9,4243563512);
|
||||
_loc5_ = this.gg(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 7],14,1735328473);
|
||||
_loc4_ = this.gg(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 12],20,2368359562);
|
||||
_loc3_ = this.hh(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 5],4,4294588738);
|
||||
_loc6_ = this.hh(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 8],11,2272392833);
|
||||
_loc5_ = this.hh(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 11],16,1839030562);
|
||||
_loc4_ = this.hh(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 14],23,4259657740);
|
||||
_loc3_ = this.hh(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 1],4,2763975236);
|
||||
_loc6_ = this.hh(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 4],11,1272893353);
|
||||
_loc5_ = this.hh(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 7],16,4139469664);
|
||||
_loc4_ = this.hh(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 10],23,3200236656);
|
||||
_loc3_ = this.hh(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 13],4,681279174);
|
||||
_loc6_ = this.hh(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 0],11,3936430074);
|
||||
_loc5_ = this.hh(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 3],16,3572445317);
|
||||
_loc4_ = this.hh(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 6],23,76029189);
|
||||
_loc3_ = this.hh(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 9],4,3654602809);
|
||||
_loc6_ = this.hh(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 12],11,3873151461);
|
||||
_loc5_ = this.hh(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 15],16,530742520);
|
||||
_loc4_ = this.hh(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 2],23,3299628645);
|
||||
_loc3_ = this.ii(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 0],6,4096336452);
|
||||
_loc6_ = this.ii(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 7],10,1126891415);
|
||||
_loc5_ = this.ii(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 14],15,2878612391);
|
||||
_loc4_ = this.ii(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 5],21,4237533241);
|
||||
_loc3_ = this.ii(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 12],6,1700485571);
|
||||
_loc6_ = this.ii(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 3],10,2399980690);
|
||||
_loc5_ = this.ii(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 10],15,4293915773);
|
||||
_loc4_ = this.ii(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 1],21,2240044497);
|
||||
_loc3_ = this.ii(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 8],6,1873313359);
|
||||
_loc6_ = this.ii(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 15],10,4264355552);
|
||||
_loc5_ = this.ii(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 6],15,2734768916);
|
||||
_loc4_ = this.ii(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 13],21,1309151649);
|
||||
_loc3_ = this.ii(_loc3_,_loc4_,_loc5_,_loc6_,param1[_loc7_ + 4],6,4149444226);
|
||||
_loc6_ = this.ii(_loc6_,_loc3_,_loc4_,_loc5_,param1[_loc7_ + 11],10,3174756917);
|
||||
_loc5_ = this.ii(_loc5_,_loc6_,_loc3_,_loc4_,param1[_loc7_ + 2],15,718787259);
|
||||
_loc4_ = this.ii(_loc4_,_loc5_,_loc6_,_loc3_,param1[_loc7_ + 9],21,3951481745);
|
||||
_loc3_ += _loc8_;
|
||||
_loc4_ += _loc9_;
|
||||
_loc5_ += _loc10_;
|
||||
_loc6_ += _loc11_;
|
||||
_loc7_ += 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 this.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 this.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 this.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 this.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 this.cmn(param3 ^ (param2 | ~param4),param1,param2,param5,param6,param7);
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "md5";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
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 HASH_SIZE;
|
||||
}
|
||||
|
||||
override protected function core(param1:Array, param2:uint) : Array
|
||||
{
|
||||
var _loc10_:uint = 0;
|
||||
var _loc11_:uint = 0;
|
||||
var _loc12_:uint = 0;
|
||||
var _loc13_:uint = 0;
|
||||
var _loc14_:uint = 0;
|
||||
var _loc15_:uint = 0;
|
||||
var _loc16_:uint = 0;
|
||||
param1[param2 >> 5] |= 128 << 24 - param2 % 32;
|
||||
param1[(param2 + 64 >> 9 << 4) + 15] = param2;
|
||||
var _loc3_:Array = [];
|
||||
var _loc4_:uint = 1732584193;
|
||||
var _loc5_:uint = 4023233417;
|
||||
var _loc6_:uint = 2562383102;
|
||||
var _loc7_:uint = 271733878;
|
||||
var _loc8_:uint = 3285377520;
|
||||
var _loc9_:uint = 0;
|
||||
while(_loc9_ < param1.length)
|
||||
{
|
||||
_loc10_ = _loc4_;
|
||||
_loc11_ = _loc5_;
|
||||
_loc12_ = _loc6_;
|
||||
_loc13_ = _loc7_;
|
||||
_loc14_ = _loc8_;
|
||||
_loc15_ = 0;
|
||||
while(_loc15_ < 80)
|
||||
{
|
||||
if(_loc15_ < 16)
|
||||
{
|
||||
_loc3_[_loc15_] = param1[_loc9_ + _loc15_] || 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_[_loc15_] = this.rol(_loc3_[_loc15_ - 3] ^ _loc3_[_loc15_ - 8] ^ _loc3_[_loc15_ - 14] ^ _loc3_[_loc15_ - 16],1);
|
||||
}
|
||||
_loc16_ = this.rol(_loc4_,5) + this.ft(_loc15_,_loc5_,_loc6_,_loc7_) + _loc8_ + _loc3_[_loc15_] + this.kt(_loc15_);
|
||||
_loc8_ = _loc7_;
|
||||
_loc7_ = _loc6_;
|
||||
_loc6_ = this.rol(_loc5_,30);
|
||||
_loc5_ = _loc4_;
|
||||
_loc4_ = _loc16_;
|
||||
_loc15_++;
|
||||
}
|
||||
_loc4_ += _loc10_;
|
||||
_loc5_ += _loc11_;
|
||||
_loc6_ += _loc12_;
|
||||
_loc7_ += _loc13_;
|
||||
_loc8_ += _loc14_;
|
||||
_loc9_ += 16;
|
||||
}
|
||||
return [_loc4_,_loc5_,_loc6_,_loc7_,_loc8_];
|
||||
}
|
||||
|
||||
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 ? uint(2400959708) : uint(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,106 @@
|
||||
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 _loc13_:uint = 0;
|
||||
var _loc14_:uint = 0;
|
||||
var _loc15_:uint = 0;
|
||||
var _loc16_:uint = 0;
|
||||
var _loc17_:uint = 0;
|
||||
var _loc18_:uint = 0;
|
||||
var _loc19_:uint = 0;
|
||||
var _loc20_:uint = 0;
|
||||
var _loc21_:uint = 0;
|
||||
var _loc22_:uint = 0;
|
||||
var _loc23_:uint = 0;
|
||||
var _loc24_:uint = 0;
|
||||
var _loc25_:uint = 0;
|
||||
param1[param2 >> 5] |= 128 << 24 - param2 % 32;
|
||||
param1[(param2 + 64 >> 9 << 4) + 15] = param2;
|
||||
var _loc3_:Array = [];
|
||||
var _loc4_:uint = uint(this._h[0]);
|
||||
var _loc5_:uint = uint(this._h[1]);
|
||||
var _loc6_:uint = uint(this._h[2]);
|
||||
var _loc7_:uint = uint(this._h[3]);
|
||||
var _loc8_:uint = uint(this._h[4]);
|
||||
var _loc9_:uint = uint(this._h[5]);
|
||||
var _loc10_:uint = uint(this._h[6]);
|
||||
var _loc11_:uint = uint(this._h[7]);
|
||||
var _loc12_:uint = 0;
|
||||
while(_loc12_ < param1.length)
|
||||
{
|
||||
_loc13_ = _loc4_;
|
||||
_loc14_ = _loc5_;
|
||||
_loc15_ = _loc6_;
|
||||
_loc16_ = _loc7_;
|
||||
_loc17_ = _loc8_;
|
||||
_loc18_ = _loc9_;
|
||||
_loc19_ = _loc10_;
|
||||
_loc20_ = _loc11_;
|
||||
_loc21_ = 0;
|
||||
while(_loc21_ < 64)
|
||||
{
|
||||
if(_loc21_ < 16)
|
||||
{
|
||||
_loc3_[_loc21_] = param1[_loc12_ + _loc21_] || 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc24_ = uint(this.rrol(_loc3_[_loc21_ - 15],7) ^ this.rrol(_loc3_[_loc21_ - 15],18) ^ _loc3_[_loc21_ - 15] >>> 3);
|
||||
_loc25_ = uint(this.rrol(_loc3_[_loc21_ - 2],17) ^ this.rrol(_loc3_[_loc21_ - 2],19) ^ _loc3_[_loc21_ - 2] >>> 10);
|
||||
_loc3_[_loc21_] = _loc3_[_loc21_ - 16] + _loc24_ + _loc3_[_loc21_ - 7] + _loc25_;
|
||||
}
|
||||
_loc22_ = (this.rrol(_loc4_,2) ^ this.rrol(_loc4_,13) ^ this.rrol(_loc4_,22)) + (_loc4_ & _loc5_ ^ _loc4_ & _loc6_ ^ _loc5_ & _loc6_);
|
||||
_loc23_ = _loc11_ + (this.rrol(_loc8_,6) ^ this.rrol(_loc8_,11) ^ this.rrol(_loc8_,25)) + (_loc8_ & _loc9_ ^ _loc10_ & ~_loc8_) + k[_loc21_] + _loc3_[_loc21_];
|
||||
_loc11_ = _loc10_;
|
||||
_loc10_ = _loc9_;
|
||||
_loc9_ = _loc8_;
|
||||
_loc8_ = _loc7_ + _loc23_;
|
||||
_loc7_ = _loc6_;
|
||||
_loc6_ = _loc5_;
|
||||
_loc5_ = _loc4_;
|
||||
_loc4_ = _loc23_ + _loc22_;
|
||||
_loc21_++;
|
||||
}
|
||||
_loc4_ += _loc13_;
|
||||
_loc5_ += _loc14_;
|
||||
_loc6_ += _loc15_;
|
||||
_loc7_ += _loc16_;
|
||||
_loc8_ += _loc17_;
|
||||
_loc9_ += _loc18_;
|
||||
_loc10_ += _loc19_;
|
||||
_loc11_ += _loc20_;
|
||||
_loc12_ += 16;
|
||||
}
|
||||
return [_loc4_,_loc5_,_loc6_,_loc7_,_loc8_,_loc9_,_loc10_,_loc11_];
|
||||
}
|
||||
|
||||
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;
|
||||
import flash.utils.Endian;
|
||||
|
||||
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 _loc2_:uint = param1.length;
|
||||
var _loc3_:String = param1.endian;
|
||||
param1.endian = Endian.BIG_ENDIAN;
|
||||
var _loc4_:uint = _loc2_ * 8;
|
||||
while(param1.length % 4 != 0)
|
||||
{
|
||||
param1[param1.length] = 0;
|
||||
}
|
||||
param1.position = 0;
|
||||
var _loc5_:Array = [];
|
||||
var _loc6_:uint = 0;
|
||||
while(_loc6_ < param1.length)
|
||||
{
|
||||
_loc5_.push(param1.readUnsignedInt());
|
||||
_loc6_ += 4;
|
||||
}
|
||||
var _loc7_:Array = this.core(_loc5_,_loc4_);
|
||||
var _loc8_:ByteArray = new ByteArray();
|
||||
var _loc9_:uint = this.getHashSize() / 4;
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc9_)
|
||||
{
|
||||
_loc8_.writeUnsignedInt(_loc7_[_loc6_]);
|
||||
_loc6_++;
|
||||
}
|
||||
param1.length = _loc2_;
|
||||
param1.endian = _loc3_;
|
||||
return _loc8_;
|
||||
}
|
||||
|
||||
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();
|
||||
this.S = new ByteArray();
|
||||
if(param1)
|
||||
{
|
||||
this.init(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPoolSize() : uint
|
||||
{
|
||||
return this.psize;
|
||||
}
|
||||
|
||||
public function init(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < 256)
|
||||
{
|
||||
this.S[_loc2_] = _loc2_;
|
||||
_loc2_++;
|
||||
}
|
||||
_loc3_ = 0;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < 256)
|
||||
{
|
||||
_loc3_ = _loc3_ + this.S[_loc2_] + param1[_loc2_ % param1.length] & 0xFF;
|
||||
_loc4_ = int(this.S[_loc2_]);
|
||||
this.S[_loc2_] = this.S[_loc3_];
|
||||
this.S[_loc3_] = _loc4_;
|
||||
_loc2_++;
|
||||
}
|
||||
this.i = 0;
|
||||
this.j = 0;
|
||||
}
|
||||
|
||||
public function next() : uint
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
this.i = this.i + 1 & 0xFF;
|
||||
this.j = this.j + this.S[this.i] & 0xFF;
|
||||
_loc1_ = int(this.S[this.i]);
|
||||
this.S[this.i] = this.S[this.j];
|
||||
this.S[this.j] = _loc1_;
|
||||
return this.S[_loc1_ + this.S[this.i] & 0xFF];
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:uint = 0;
|
||||
while(_loc2_ < param1.length)
|
||||
{
|
||||
var _temp_2:* = param1;
|
||||
var _loc3_:uint = _loc2_++;
|
||||
_temp_2[_loc3_] ^= this.next();
|
||||
}
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
this.encrypt(param1);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
if(this.S != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.S.length)
|
||||
{
|
||||
this.S[_loc1_] = Math.random() * 256;
|
||||
_loc1_++;
|
||||
}
|
||||
this.S.length = 0;
|
||||
this.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,137 @@
|
||||
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_:uint = 0;
|
||||
super();
|
||||
if(param1 == null)
|
||||
{
|
||||
param1 = ARC4;
|
||||
}
|
||||
this.state = new param1() as IPRNG;
|
||||
this.psize = this.state.getPoolSize();
|
||||
this.pool = new ByteArray();
|
||||
this.pptr = 0;
|
||||
while(this.pptr < this.psize)
|
||||
{
|
||||
_loc2_ = 65536 * Math.random();
|
||||
this.pool[this.pptr++] = _loc2_ >>> 8;
|
||||
var _loc4_:Number;
|
||||
this.pool[_loc4_ = this.pptr++] = _loc2_ & 0xFF;
|
||||
}
|
||||
this.pptr = 0;
|
||||
this.seed();
|
||||
}
|
||||
|
||||
public function seed(param1:int = 0) : void
|
||||
{
|
||||
if(param1 == 0)
|
||||
{
|
||||
param1 = new Date().getTime();
|
||||
}
|
||||
var _temp_3:* = this.pool;
|
||||
var _loc2_:Number = this.pptr++;
|
||||
_temp_3[_loc2_] ^= param1 & 0xFF;
|
||||
var _temp_6:* = this.pool;
|
||||
var _loc3_:Number = this.pptr++;
|
||||
_temp_6[_loc3_] ^= param1 >> 8 & 0xFF;
|
||||
var _loc4_:Number;
|
||||
this.pool[_loc4_ = this.pptr++] = this.pool[_loc4_] ^ param1 >> 16 & 0xFF;
|
||||
var _loc5_:Number;
|
||||
this.pool[_loc5_ = this.pptr++] = this.pool[_loc5_] ^ param1 >> 24 & 0xFF;
|
||||
this.pptr %= this.psize;
|
||||
this.seeded = true;
|
||||
}
|
||||
|
||||
public function autoSeed() : void
|
||||
{
|
||||
var _loc3_:Font = null;
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
_loc1_.writeUnsignedInt(System.totalMemory);
|
||||
_loc1_.writeUTF(Capabilities.serverString);
|
||||
_loc1_.writeUnsignedInt(getTimer());
|
||||
_loc1_.writeUnsignedInt(new Date().getTime());
|
||||
var _loc2_:Array = Font.enumerateFonts(true);
|
||||
for each(_loc3_ in _loc2_)
|
||||
{
|
||||
_loc1_.writeUTF(_loc3_.fontName);
|
||||
_loc1_.writeUTF(_loc3_.fontStyle);
|
||||
_loc1_.writeUTF(_loc3_.fontType);
|
||||
}
|
||||
_loc1_.position = 0;
|
||||
while(_loc1_.bytesAvailable >= 4)
|
||||
{
|
||||
this.seed(_loc1_.readUnsignedInt());
|
||||
}
|
||||
}
|
||||
|
||||
public function nextBytes(param1:ByteArray, param2:int) : void
|
||||
{
|
||||
while(param2--)
|
||||
{
|
||||
param1.writeByte(this.nextByte());
|
||||
}
|
||||
}
|
||||
|
||||
public function nextByte() : int
|
||||
{
|
||||
if(!this.ready)
|
||||
{
|
||||
if(!this.seeded)
|
||||
{
|
||||
this.autoSeed();
|
||||
}
|
||||
this.state.init(this.pool);
|
||||
this.pool.length = 0;
|
||||
this.pptr = 0;
|
||||
this.ready = true;
|
||||
}
|
||||
return this.state.next();
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
while(_loc1_ < this.pool.length)
|
||||
{
|
||||
this.pool[_loc1_] = Math.random() * 256;
|
||||
_loc1_++;
|
||||
}
|
||||
this.pool.length = 0;
|
||||
this.pool = null;
|
||||
this.state.dispose();
|
||||
this.state = null;
|
||||
this.psize = 0;
|
||||
this.pptr = 0;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "random-" + this.state.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,318 @@
|
||||
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;
|
||||
this.canEncrypt = this.n != null && this.e != 0;
|
||||
this.canDecrypt = this.canEncrypt && this.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 _loc7_:BigInteger = null;
|
||||
var _loc8_:BigInteger = null;
|
||||
var _loc9_:BigInteger = null;
|
||||
var _loc10_:BigInteger = null;
|
||||
var _loc3_:Random = new Random();
|
||||
var _loc4_:uint = uint(param1 >> 1);
|
||||
var _loc5_:RSAKey = new RSAKey(null,0,null);
|
||||
_loc5_.e = parseInt(param2,16);
|
||||
var _loc6_:BigInteger = new BigInteger(param2,16);
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
_loc5_.p = bigRandom(param1 - _loc4_,_loc3_);
|
||||
}
|
||||
while(!(_loc5_.p.subtract(BigInteger.ONE).gcd(_loc6_).compareTo(BigInteger.ONE) == 0 && _loc5_.p.isProbablePrime(10)));
|
||||
do
|
||||
{
|
||||
_loc5_.q = bigRandom(_loc4_,_loc3_);
|
||||
}
|
||||
while(!(_loc5_.q.subtract(BigInteger.ONE).gcd(_loc6_).compareTo(BigInteger.ONE) == 0 && _loc5_.q.isProbablePrime(10)));
|
||||
if(_loc5_.p.compareTo(_loc5_.q) <= 0)
|
||||
{
|
||||
_loc10_ = _loc5_.p;
|
||||
_loc5_.p = _loc5_.q;
|
||||
_loc5_.q = _loc10_;
|
||||
}
|
||||
_loc7_ = _loc5_.p.subtract(BigInteger.ONE);
|
||||
_loc8_ = _loc5_.q.subtract(BigInteger.ONE);
|
||||
}
|
||||
while(_loc9_ = _loc7_.multiply(_loc8_), _loc9_.gcd(_loc6_).compareTo(BigInteger.ONE) != 0);
|
||||
_loc5_.n = _loc5_.p.multiply(_loc5_.q);
|
||||
_loc5_.d = _loc6_.modInverse(_loc9_);
|
||||
_loc5_.dmp1 = _loc5_.d.mod(_loc7_);
|
||||
_loc5_.dmq1 = _loc5_.d.mod(_loc8_);
|
||||
_loc5_.coeff = _loc5_.q.modInverse(_loc5_.p);
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
protected static function bigRandom(param1:int, param2:Random) : BigInteger
|
||||
{
|
||||
if(param1 < 2)
|
||||
{
|
||||
return BigInteger.nbv(1);
|
||||
}
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
param2.nextBytes(_loc3_,param1 >> 3);
|
||||
_loc3_.position = 0;
|
||||
var _loc4_:BigInteger = new BigInteger(_loc3_);
|
||||
_loc4_.primify(param1,1);
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return (this.n.bitLength() + 7) / 8;
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
this.e = 0;
|
||||
this.n.dispose();
|
||||
this.n = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray, param2:ByteArray, param3:uint, param4:Function = null) : void
|
||||
{
|
||||
this._encrypt(this.doPublic,param1,param2,param3,param4,2);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:ByteArray, param3:uint, param4:Function = null) : void
|
||||
{
|
||||
this._decrypt(this.doPrivate2,param1,param2,param3,param4,2);
|
||||
}
|
||||
|
||||
public function sign(param1:ByteArray, param2:ByteArray, param3:uint, param4:Function = null) : void
|
||||
{
|
||||
this._encrypt(this.doPrivate2,param1,param2,param3,param4,1);
|
||||
}
|
||||
|
||||
public function verify(param1:ByteArray, param2:ByteArray, param3:uint, param4:Function = null) : void
|
||||
{
|
||||
this._decrypt(this.doPublic,param1,param2,param3,param4,1);
|
||||
}
|
||||
|
||||
private function _encrypt(param1:Function, param2:ByteArray, param3:ByteArray, param4:uint, param5:Function, param6:int) : void
|
||||
{
|
||||
var _loc9_:BigInteger = null;
|
||||
var _loc10_:BigInteger = null;
|
||||
if(param5 == null)
|
||||
{
|
||||
param5 = this.pkcs1pad;
|
||||
}
|
||||
if(param2.position >= param2.length)
|
||||
{
|
||||
param2.position = 0;
|
||||
}
|
||||
var _loc7_:uint = this.getBlockSize();
|
||||
var _loc8_:int = param2.position + param4;
|
||||
while(param2.position < _loc8_)
|
||||
{
|
||||
_loc9_ = new BigInteger(param5(param2,_loc8_,_loc7_,param6),_loc7_);
|
||||
_loc10_ = param1(_loc9_);
|
||||
_loc10_.toArray(param3);
|
||||
}
|
||||
}
|
||||
|
||||
private function _decrypt(param1:Function, param2:ByteArray, param3:ByteArray, param4:uint, param5:Function, param6:int) : void
|
||||
{
|
||||
var _loc9_:BigInteger = null;
|
||||
var _loc10_:BigInteger = null;
|
||||
var _loc11_:ByteArray = null;
|
||||
if(param5 == null)
|
||||
{
|
||||
param5 = this.pkcs1unpad;
|
||||
}
|
||||
if(param2.position >= param2.length)
|
||||
{
|
||||
param2.position = 0;
|
||||
}
|
||||
var _loc7_:uint = this.getBlockSize();
|
||||
var _loc8_:int = param2.position + param4;
|
||||
while(param2.position < _loc8_)
|
||||
{
|
||||
_loc9_ = new BigInteger(param2,param4);
|
||||
_loc10_ = param1(_loc9_);
|
||||
_loc11_ = param5(_loc10_,_loc7_);
|
||||
param3.writeBytes(_loc11_);
|
||||
}
|
||||
}
|
||||
|
||||
private function pkcs1pad(param1:ByteArray, param2:int, param3:uint, param4:uint = 2) : ByteArray
|
||||
{
|
||||
var _loc9_:int = 0;
|
||||
var _loc5_:ByteArray = new ByteArray();
|
||||
var _loc6_:int = int(param1.position);
|
||||
param2 = Math.min(param2,param1.length,_loc6_ + param3 - 11);
|
||||
param1.position = param2;
|
||||
var _loc7_:* = int(param2 - 1);
|
||||
while(_loc7_ >= _loc6_ && param3 > 11)
|
||||
{
|
||||
var _loc10_:uint;
|
||||
_loc5_[_loc10_ = --param3] = param1[_loc7_--];
|
||||
}
|
||||
_loc5_[_loc10_ = --param3] = 0;
|
||||
var _loc8_:Random = new Random();
|
||||
while(param3 > 2)
|
||||
{
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ == 0)
|
||||
{
|
||||
_loc9_ = param4 == 2 ? _loc8_.nextByte() : 255;
|
||||
}
|
||||
var _loc11_:uint;
|
||||
_loc5_[_loc11_ = --param3] = _loc9_;
|
||||
}
|
||||
_loc5_[_loc11_ = --param3] = param4;
|
||||
var _loc12_:uint;
|
||||
_loc5_[_loc12_ = --param3] = 0;
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function pkcs1unpad(param1:BigInteger, param2:uint, param3:uint = 2) : ByteArray
|
||||
{
|
||||
var _loc4_:ByteArray = param1.toByteArray();
|
||||
var _loc5_:ByteArray = new ByteArray();
|
||||
var _loc6_:int = 0;
|
||||
while(_loc6_ < _loc4_.length && _loc4_[_loc6_] == 0)
|
||||
{
|
||||
_loc6_++;
|
||||
}
|
||||
if(_loc4_.length - _loc6_ != param2 - 1 || _loc4_[_loc6_] > 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_loc6_++;
|
||||
while(_loc4_[_loc6_] != 0)
|
||||
{
|
||||
if(++_loc6_ >= _loc4_.length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
while(++_loc6_ < _loc4_.length)
|
||||
{
|
||||
_loc5_.writeByte(_loc4_[_loc6_]);
|
||||
}
|
||||
_loc5_.position = 0;
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
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=" + this.n.toString(16) + "\n" + "E=" + this.e.toString(16) + "\n";
|
||||
if(this.canDecrypt)
|
||||
{
|
||||
_loc1_ += "D=" + this.d.toString(16) + "\n";
|
||||
if(this.p != null && this.q != null)
|
||||
{
|
||||
_loc1_ += "P=" + this.p.toString(16) + "\n";
|
||||
_loc1_ += "Q=" + this.q.toString(16) + "\n";
|
||||
_loc1_ += "DMP1=" + this.dmp1.toString(16) + "\n";
|
||||
_loc1_ += "DMQ1=" + this.dmq1.toString(16) + "\n";
|
||||
_loc1_ += "IQMP=" + this.coeff.toString(16) + "\n";
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
protected function doPublic(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1.modPowInt(this.e,this.n);
|
||||
}
|
||||
|
||||
protected function doPrivate2(param1:BigInteger) : BigInteger
|
||||
{
|
||||
if(this.p == null && this.q == null)
|
||||
{
|
||||
return param1.modPow(this.d,this.n);
|
||||
}
|
||||
var _loc2_:BigInteger = param1.mod(this.p).modPow(this.dmp1,this.p);
|
||||
var _loc3_:BigInteger = param1.mod(this.q).modPow(this.dmq1,this.q);
|
||||
while(_loc2_.compareTo(_loc3_) < 0)
|
||||
{
|
||||
_loc2_ = _loc2_.add(this.p);
|
||||
}
|
||||
return _loc2_.subtract(_loc3_).multiply(this.coeff).mod(this.p).multiply(this.q).add(_loc3_);
|
||||
}
|
||||
|
||||
protected function doPrivate(param1:BigInteger) : BigInteger
|
||||
{
|
||||
if(this.p == null || this.q == null)
|
||||
{
|
||||
return param1.modPow(this.d,this.n);
|
||||
}
|
||||
var _loc2_:BigInteger = param1.mod(this.p).modPow(this.dmp1,this.p);
|
||||
var _loc3_:BigInteger = param1.mod(this.q).modPow(this.dmq1,this.q);
|
||||
while(_loc2_.compareTo(_loc3_) < 0)
|
||||
{
|
||||
_loc2_ = _loc2_.add(this.p);
|
||||
}
|
||||
return _loc2_.subtract(_loc3_).multiply(this.coeff).mod(this.p).multiply(this.q).add(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
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;
|
||||
}
|
||||
|
||||
private static var Rcon:ByteArray = new ByteArray();
|
||||
|
||||
i = 0;
|
||||
while(i < _Rcon.length)
|
||||
{
|
||||
Rcon[i] = _Rcon[i];
|
||||
++i;
|
||||
}
|
||||
|
||||
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();
|
||||
this.tmp = new ByteArray();
|
||||
this.state = new ByteArray();
|
||||
this.keyLength = param1.length;
|
||||
this.key = new ByteArray();
|
||||
this.key.writeBytes(param1);
|
||||
this.expandKey();
|
||||
}
|
||||
|
||||
private function expandKey() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
var _loc2_:uint = 0;
|
||||
var _loc3_:uint = 0;
|
||||
var _loc4_:uint = 0;
|
||||
var _loc5_:uint = 0;
|
||||
var _loc6_:uint = 0;
|
||||
var _loc7_:uint = this.key.length / 4;
|
||||
this.Nr = _loc7_ + 6;
|
||||
_loc6_ = _loc7_;
|
||||
while(_loc6_ < Nb * (this.Nr + 1))
|
||||
{
|
||||
_loc1_ = uint(this.key[4 * _loc6_ - 4]);
|
||||
_loc2_ = uint(this.key[4 * _loc6_ - 3]);
|
||||
_loc3_ = uint(this.key[4 * _loc6_ - 2]);
|
||||
_loc4_ = uint(this.key[4 * _loc6_ - 1]);
|
||||
if(!(_loc6_ % _loc7_))
|
||||
{
|
||||
_loc5_ = _loc4_;
|
||||
_loc4_ = uint(Sbox[_loc1_]);
|
||||
_loc1_ = uint(Sbox[_loc2_] ^ Rcon[_loc6_ / _loc7_]);
|
||||
_loc2_ = uint(Sbox[_loc3_]);
|
||||
_loc3_ = uint(Sbox[_loc5_]);
|
||||
}
|
||||
else if(_loc7_ > 6 && _loc6_ % _loc7_ == 4)
|
||||
{
|
||||
_loc1_ = uint(Sbox[_loc1_]);
|
||||
_loc2_ = uint(Sbox[_loc2_]);
|
||||
_loc3_ = uint(Sbox[_loc3_]);
|
||||
_loc4_ = uint(Sbox[_loc4_]);
|
||||
}
|
||||
this.key[4 * _loc6_ + 0] = this.key[4 * _loc6_ - 4 * _loc7_ + 0] ^ _loc1_;
|
||||
this.key[4 * _loc6_ + 1] = this.key[4 * _loc6_ - 4 * _loc7_ + 1] ^ _loc2_;
|
||||
this.key[4 * _loc6_ + 2] = this.key[4 * _loc6_ - 4 * _loc7_ + 2] ^ _loc3_;
|
||||
this.key[4 * _loc6_ + 3] = this.key[4 * _loc6_ - 4 * _loc7_ + 3] ^ _loc4_;
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
var _loc3_:uint = 0;
|
||||
this.state.position = 0;
|
||||
this.state.writeBytes(param1,param2,Nb * 4);
|
||||
this.addRoundKey(this.key,0);
|
||||
_loc3_ = 1;
|
||||
while(_loc3_ < this.Nr + 1)
|
||||
{
|
||||
if(_loc3_ < this.Nr)
|
||||
{
|
||||
this.mixSubColumns();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.shiftRows();
|
||||
}
|
||||
this.addRoundKey(this.key,_loc3_ * Nb * 4);
|
||||
_loc3_++;
|
||||
}
|
||||
param1.position = param2;
|
||||
param1.writeBytes(this.state);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
var _loc3_:uint = 0;
|
||||
this.state.position = 0;
|
||||
this.state.writeBytes(param1,param2,Nb * 4);
|
||||
this.addRoundKey(this.key,this.Nr * Nb * 4);
|
||||
this.invShiftRows();
|
||||
_loc3_ = this.Nr;
|
||||
while(_loc3_--)
|
||||
{
|
||||
this.addRoundKey(this.key,_loc3_ * Nb * 4);
|
||||
if(_loc3_)
|
||||
{
|
||||
this.invMixSubColumns();
|
||||
}
|
||||
}
|
||||
param1.position = param2;
|
||||
param1.writeBytes(this.state);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
var _loc2_:Random = new Random();
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.key.length)
|
||||
{
|
||||
this.key[_loc1_] = _loc2_.nextByte();
|
||||
_loc1_++;
|
||||
}
|
||||
this.Nr = _loc2_.nextByte();
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.state.length)
|
||||
{
|
||||
this.state[_loc1_] = _loc2_.nextByte();
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.tmp.length)
|
||||
{
|
||||
this.tmp[_loc1_] = _loc2_.nextByte();
|
||||
_loc1_++;
|
||||
}
|
||||
this.key.length = 0;
|
||||
this.keyLength = 0;
|
||||
this.state.length = 0;
|
||||
this.tmp.length = 0;
|
||||
this.key = null;
|
||||
this.state = null;
|
||||
this.tmp = null;
|
||||
this.Nr = 0;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
protected function shiftRows() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
this.state[0] = Sbox[this.state[0]];
|
||||
this.state[4] = Sbox[this.state[4]];
|
||||
this.state[8] = Sbox[this.state[8]];
|
||||
this.state[12] = Sbox[this.state[12]];
|
||||
_loc1_ = uint(Sbox[this.state[1]]);
|
||||
this.state[1] = Sbox[this.state[5]];
|
||||
this.state[5] = Sbox[this.state[9]];
|
||||
this.state[9] = Sbox[this.state[13]];
|
||||
this.state[13] = _loc1_;
|
||||
_loc1_ = uint(Sbox[this.state[2]]);
|
||||
this.state[2] = Sbox[this.state[10]];
|
||||
this.state[10] = _loc1_;
|
||||
_loc1_ = uint(Sbox[this.state[6]]);
|
||||
this.state[6] = Sbox[this.state[14]];
|
||||
this.state[14] = _loc1_;
|
||||
_loc1_ = uint(Sbox[this.state[15]]);
|
||||
this.state[15] = Sbox[this.state[11]];
|
||||
this.state[11] = Sbox[this.state[7]];
|
||||
this.state[7] = Sbox[this.state[3]];
|
||||
this.state[3] = _loc1_;
|
||||
}
|
||||
|
||||
protected function invShiftRows() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
this.state[0] = InvSbox[this.state[0]];
|
||||
this.state[4] = InvSbox[this.state[4]];
|
||||
this.state[8] = InvSbox[this.state[8]];
|
||||
this.state[12] = InvSbox[this.state[12]];
|
||||
_loc1_ = uint(InvSbox[this.state[13]]);
|
||||
this.state[13] = InvSbox[this.state[9]];
|
||||
this.state[9] = InvSbox[this.state[5]];
|
||||
this.state[5] = InvSbox[this.state[1]];
|
||||
this.state[1] = _loc1_;
|
||||
_loc1_ = uint(InvSbox[this.state[2]]);
|
||||
this.state[2] = InvSbox[this.state[10]];
|
||||
this.state[10] = _loc1_;
|
||||
_loc1_ = uint(InvSbox[this.state[6]]);
|
||||
this.state[6] = InvSbox[this.state[14]];
|
||||
this.state[14] = _loc1_;
|
||||
_loc1_ = uint(InvSbox[this.state[3]]);
|
||||
this.state[3] = InvSbox[this.state[7]];
|
||||
this.state[7] = InvSbox[this.state[11]];
|
||||
this.state[11] = InvSbox[this.state[15]];
|
||||
this.state[15] = _loc1_;
|
||||
}
|
||||
|
||||
protected function mixSubColumns() : void
|
||||
{
|
||||
this.tmp.length = 0;
|
||||
this.tmp[0] = Xtime2Sbox[this.state[0]] ^ Xtime3Sbox[this.state[5]] ^ Sbox[this.state[10]] ^ Sbox[this.state[15]];
|
||||
this.tmp[1] = Sbox[this.state[0]] ^ Xtime2Sbox[this.state[5]] ^ Xtime3Sbox[this.state[10]] ^ Sbox[this.state[15]];
|
||||
this.tmp[2] = Sbox[this.state[0]] ^ Sbox[this.state[5]] ^ Xtime2Sbox[this.state[10]] ^ Xtime3Sbox[this.state[15]];
|
||||
this.tmp[3] = Xtime3Sbox[this.state[0]] ^ Sbox[this.state[5]] ^ Sbox[this.state[10]] ^ Xtime2Sbox[this.state[15]];
|
||||
this.tmp[4] = Xtime2Sbox[this.state[4]] ^ Xtime3Sbox[this.state[9]] ^ Sbox[this.state[14]] ^ Sbox[this.state[3]];
|
||||
this.tmp[5] = Sbox[this.state[4]] ^ Xtime2Sbox[this.state[9]] ^ Xtime3Sbox[this.state[14]] ^ Sbox[this.state[3]];
|
||||
this.tmp[6] = Sbox[this.state[4]] ^ Sbox[this.state[9]] ^ Xtime2Sbox[this.state[14]] ^ Xtime3Sbox[this.state[3]];
|
||||
this.tmp[7] = Xtime3Sbox[this.state[4]] ^ Sbox[this.state[9]] ^ Sbox[this.state[14]] ^ Xtime2Sbox[this.state[3]];
|
||||
this.tmp[8] = Xtime2Sbox[this.state[8]] ^ Xtime3Sbox[this.state[13]] ^ Sbox[this.state[2]] ^ Sbox[this.state[7]];
|
||||
this.tmp[9] = Sbox[this.state[8]] ^ Xtime2Sbox[this.state[13]] ^ Xtime3Sbox[this.state[2]] ^ Sbox[this.state[7]];
|
||||
this.tmp[10] = Sbox[this.state[8]] ^ Sbox[this.state[13]] ^ Xtime2Sbox[this.state[2]] ^ Xtime3Sbox[this.state[7]];
|
||||
this.tmp[11] = Xtime3Sbox[this.state[8]] ^ Sbox[this.state[13]] ^ Sbox[this.state[2]] ^ Xtime2Sbox[this.state[7]];
|
||||
this.tmp[12] = Xtime2Sbox[this.state[12]] ^ Xtime3Sbox[this.state[1]] ^ Sbox[this.state[6]] ^ Sbox[this.state[11]];
|
||||
this.tmp[13] = Sbox[this.state[12]] ^ Xtime2Sbox[this.state[1]] ^ Xtime3Sbox[this.state[6]] ^ Sbox[this.state[11]];
|
||||
this.tmp[14] = Sbox[this.state[12]] ^ Sbox[this.state[1]] ^ Xtime2Sbox[this.state[6]] ^ Xtime3Sbox[this.state[11]];
|
||||
this.tmp[15] = Xtime3Sbox[this.state[12]] ^ Sbox[this.state[1]] ^ Sbox[this.state[6]] ^ Xtime2Sbox[this.state[11]];
|
||||
this.state.position = 0;
|
||||
this.state.writeBytes(this.tmp,0,Nb * 4);
|
||||
}
|
||||
|
||||
protected function invMixSubColumns() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
this.tmp.length = 0;
|
||||
this.tmp[0] = XtimeE[this.state[0]] ^ XtimeB[this.state[1]] ^ XtimeD[this.state[2]] ^ Xtime9[this.state[3]];
|
||||
this.tmp[5] = Xtime9[this.state[0]] ^ XtimeE[this.state[1]] ^ XtimeB[this.state[2]] ^ XtimeD[this.state[3]];
|
||||
this.tmp[10] = XtimeD[this.state[0]] ^ Xtime9[this.state[1]] ^ XtimeE[this.state[2]] ^ XtimeB[this.state[3]];
|
||||
this.tmp[15] = XtimeB[this.state[0]] ^ XtimeD[this.state[1]] ^ Xtime9[this.state[2]] ^ XtimeE[this.state[3]];
|
||||
this.tmp[4] = XtimeE[this.state[4]] ^ XtimeB[this.state[5]] ^ XtimeD[this.state[6]] ^ Xtime9[this.state[7]];
|
||||
this.tmp[9] = Xtime9[this.state[4]] ^ XtimeE[this.state[5]] ^ XtimeB[this.state[6]] ^ XtimeD[this.state[7]];
|
||||
this.tmp[14] = XtimeD[this.state[4]] ^ Xtime9[this.state[5]] ^ XtimeE[this.state[6]] ^ XtimeB[this.state[7]];
|
||||
this.tmp[3] = XtimeB[this.state[4]] ^ XtimeD[this.state[5]] ^ Xtime9[this.state[6]] ^ XtimeE[this.state[7]];
|
||||
this.tmp[8] = XtimeE[this.state[8]] ^ XtimeB[this.state[9]] ^ XtimeD[this.state[10]] ^ Xtime9[this.state[11]];
|
||||
this.tmp[13] = Xtime9[this.state[8]] ^ XtimeE[this.state[9]] ^ XtimeB[this.state[10]] ^ XtimeD[this.state[11]];
|
||||
this.tmp[2] = XtimeD[this.state[8]] ^ Xtime9[this.state[9]] ^ XtimeE[this.state[10]] ^ XtimeB[this.state[11]];
|
||||
this.tmp[7] = XtimeB[this.state[8]] ^ XtimeD[this.state[9]] ^ Xtime9[this.state[10]] ^ XtimeE[this.state[11]];
|
||||
this.tmp[12] = XtimeE[this.state[12]] ^ XtimeB[this.state[13]] ^ XtimeD[this.state[14]] ^ Xtime9[this.state[15]];
|
||||
this.tmp[1] = Xtime9[this.state[12]] ^ XtimeE[this.state[13]] ^ XtimeB[this.state[14]] ^ XtimeD[this.state[15]];
|
||||
this.tmp[6] = XtimeD[this.state[12]] ^ Xtime9[this.state[13]] ^ XtimeE[this.state[14]] ^ XtimeB[this.state[15]];
|
||||
this.tmp[11] = XtimeB[this.state[12]] ^ XtimeD[this.state[13]] ^ Xtime9[this.state[14]] ^ XtimeE[this.state[15]];
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 4 * Nb)
|
||||
{
|
||||
this.state[_loc1_] = InvSbox[this.tmp[_loc1_]];
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
protected function addRoundKey(param1:ByteArray, param2:uint) : void
|
||||
{
|
||||
var _loc3_:uint = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 16)
|
||||
{
|
||||
this.state[_loc3_] ^= param1[_loc3_ + param2];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "aes" + 8 * this.keyLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
package com.hurlant.crypto.symmetric
|
||||
{
|
||||
import com.hurlant.util.Memory;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class BlowFishKey implements ISymmetricKey
|
||||
{
|
||||
|
||||
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 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 = ROUNDS + 2;
|
||||
|
||||
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;
|
||||
this.setKey(param1);
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return BLOCK_SIZE;
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
this.decryptBlock(param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.S0.length)
|
||||
{
|
||||
this.S0[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.S1.length)
|
||||
{
|
||||
this.S1[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.S2.length)
|
||||
{
|
||||
this.S2[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.S3.length)
|
||||
{
|
||||
this.S3[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.P.length)
|
||||
{
|
||||
this.P[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
this.S0 = null;
|
||||
this.S1 = null;
|
||||
this.S2 = null;
|
||||
this.S3 = null;
|
||||
this.P = null;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.key.length)
|
||||
{
|
||||
this.key[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
this.key.length = 0;
|
||||
this.key = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
this.encryptBlock(param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
private function F(param1:uint) : uint
|
||||
{
|
||||
return (this.S0[param1 >>> 24] + this.S1[param1 >>> 16 & 0xFF] ^ this.S2[param1 >>> 8 & 0xFF]) + this.S3[param1 & 0xFF];
|
||||
}
|
||||
|
||||
private function processTable(param1:uint, param2:uint, param3:Array) : void
|
||||
{
|
||||
var _loc6_:uint = 0;
|
||||
var _loc4_:uint = param3.length;
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < _loc4_)
|
||||
{
|
||||
param1 ^= this.P[0];
|
||||
_loc6_ = 1;
|
||||
while(_loc6_ < ROUNDS)
|
||||
{
|
||||
param2 ^= this.F(param1) ^ this.P[_loc6_];
|
||||
param1 ^= this.F(param2) ^ this.P[_loc6_ + 1];
|
||||
_loc6_ += 2;
|
||||
}
|
||||
param2 ^= this.P[ROUNDS + 1];
|
||||
param3[_loc5_] = param2;
|
||||
param3[_loc5_ + 1] = param1;
|
||||
param2 = param1;
|
||||
param1 = uint(param3[_loc5_]);
|
||||
_loc5_ += 2;
|
||||
}
|
||||
}
|
||||
|
||||
private function setKey(param1:ByteArray) : void
|
||||
{
|
||||
var _loc5_:uint = 0;
|
||||
var _loc6_:uint = 0;
|
||||
this.S0 = KS0.concat();
|
||||
this.S1 = KS1.concat();
|
||||
this.S2 = KS2.concat();
|
||||
this.S3 = KS3.concat();
|
||||
this.P = KP.concat();
|
||||
var _loc2_:uint = param1.length;
|
||||
var _loc3_:uint = 0;
|
||||
var _loc4_:uint = 0;
|
||||
while(_loc4_ < P_SZ)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < 4)
|
||||
{
|
||||
_loc5_ = uint(_loc5_ << 8 | param1[_loc3_++] & 0xFF);
|
||||
if(_loc3_ >= _loc2_)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
this.P[_loc4_] ^= _loc5_;
|
||||
_loc4_++;
|
||||
}
|
||||
this.processTable(0,0,this.P);
|
||||
this.processTable(this.P[P_SZ - 2],this.P[P_SZ - 1],this.S0);
|
||||
this.processTable(this.S0[SBOX_SK - 2],this.S0[SBOX_SK - 1],this.S1);
|
||||
this.processTable(this.S1[SBOX_SK - 2],this.S1[SBOX_SK - 1],this.S2);
|
||||
this.processTable(this.S2[SBOX_SK - 2],this.S2[SBOX_SK - 1],this.S3);
|
||||
}
|
||||
|
||||
private function encryptBlock(param1:ByteArray, param2:uint, param3:ByteArray, param4:uint) : void
|
||||
{
|
||||
var _loc5_:uint = this.BytesTo32bits(param1,param2);
|
||||
var _loc6_:uint = this.BytesTo32bits(param1,param2 + 4);
|
||||
_loc5_ ^= this.P[0];
|
||||
var _loc7_:uint = 1;
|
||||
while(_loc7_ < ROUNDS)
|
||||
{
|
||||
_loc6_ ^= this.F(_loc5_) ^ this.P[_loc7_];
|
||||
_loc5_ ^= this.F(_loc6_) ^ this.P[_loc7_ + 1];
|
||||
_loc7_ += 2;
|
||||
}
|
||||
_loc6_ ^= this.P[ROUNDS + 1];
|
||||
this.Bits32ToBytes(_loc6_,param3,param4);
|
||||
this.Bits32ToBytes(_loc5_,param3,param4 + 4);
|
||||
}
|
||||
|
||||
private function decryptBlock(param1:ByteArray, param2:uint, param3:ByteArray, param4:uint) : void
|
||||
{
|
||||
var _loc5_:uint = this.BytesTo32bits(param1,param2);
|
||||
var _loc6_:uint = this.BytesTo32bits(param1,param2 + 4);
|
||||
_loc5_ ^= this.P[ROUNDS + 1];
|
||||
var _loc7_:uint = ROUNDS;
|
||||
while(_loc7_ > 0)
|
||||
{
|
||||
_loc6_ ^= this.F(_loc5_) ^ this.P[_loc7_];
|
||||
_loc5_ ^= this.F(_loc6_) ^ this.P[_loc7_ - 1];
|
||||
_loc7_ -= 2;
|
||||
}
|
||||
_loc6_ ^= this.P[0];
|
||||
this.Bits32ToBytes(_loc6_,param3,param4);
|
||||
this.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,64 @@
|
||||
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 _loc4_:uint = 0;
|
||||
padding.pad(param1);
|
||||
var _loc2_:ByteArray = getIV4e();
|
||||
var _loc3_:uint = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < blockSize)
|
||||
{
|
||||
param1[_loc3_ + _loc4_] ^= _loc2_[_loc4_];
|
||||
_loc4_++;
|
||||
}
|
||||
key.encrypt(param1,_loc3_);
|
||||
_loc2_.position = 0;
|
||||
_loc2_.writeBytes(param1,_loc3_,blockSize);
|
||||
_loc3_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc5_:uint = 0;
|
||||
var _loc2_:ByteArray = getIV4d();
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
var _loc4_:uint = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
_loc3_.position = 0;
|
||||
_loc3_.writeBytes(param1,_loc4_,blockSize);
|
||||
key.decrypt(param1,_loc4_);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < blockSize)
|
||||
{
|
||||
param1[_loc4_ + _loc5_] ^= _loc2_[_loc5_];
|
||||
_loc5_++;
|
||||
}
|
||||
_loc2_.position = 0;
|
||||
_loc2_.writeBytes(_loc3_,0,blockSize);
|
||||
_loc4_ += blockSize;
|
||||
}
|
||||
padding.unpad(param1);
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-cbc";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
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 _loc5_:uint = 0;
|
||||
var _loc2_:ByteArray = getIV4e();
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
var _loc4_:uint = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
_loc3_.position = 0;
|
||||
_loc3_.writeBytes(_loc2_);
|
||||
key.encrypt(_loc2_);
|
||||
param1[_loc4_] ^= _loc2_[0];
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < blockSize - 1)
|
||||
{
|
||||
_loc2_[_loc5_] = _loc3_[_loc5_ + 1];
|
||||
_loc5_++;
|
||||
}
|
||||
_loc2_[blockSize - 1] = param1[_loc4_];
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc5_:uint = 0;
|
||||
var _loc6_:uint = 0;
|
||||
var _loc2_:ByteArray = getIV4d();
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
var _loc4_:uint = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
_loc5_ = uint(param1[_loc4_]);
|
||||
_loc3_.position = 0;
|
||||
_loc3_.writeBytes(_loc2_);
|
||||
key.encrypt(_loc2_);
|
||||
param1[_loc4_] ^= _loc2_[0];
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < blockSize - 1)
|
||||
{
|
||||
_loc2_[_loc6_] = _loc3_[_loc6_ + 1];
|
||||
_loc6_++;
|
||||
}
|
||||
_loc2_[blockSize - 1] = _loc5_;
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-cfb8";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
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 _loc5_:uint = 0;
|
||||
var _loc6_:uint = 0;
|
||||
var _loc2_:uint = param1.length;
|
||||
var _loc3_:ByteArray = getIV4e();
|
||||
var _loc4_:uint = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
key.encrypt(_loc3_);
|
||||
_loc5_ = _loc4_ + blockSize < _loc2_ ? blockSize : uint(_loc2_ - _loc4_);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc5_)
|
||||
{
|
||||
param1[_loc4_ + _loc6_] ^= _loc3_[_loc6_];
|
||||
_loc6_++;
|
||||
}
|
||||
_loc3_.position = 0;
|
||||
_loc3_.writeBytes(param1,_loc4_,_loc5_);
|
||||
_loc4_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc6_:uint = 0;
|
||||
var _loc7_:uint = 0;
|
||||
var _loc2_:uint = param1.length;
|
||||
var _loc3_:ByteArray = getIV4d();
|
||||
var _loc4_:ByteArray = new ByteArray();
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < param1.length)
|
||||
{
|
||||
key.encrypt(_loc3_);
|
||||
_loc6_ = _loc5_ + blockSize < _loc2_ ? blockSize : uint(_loc2_ - _loc5_);
|
||||
_loc4_.position = 0;
|
||||
_loc4_.writeBytes(param1,_loc5_,_loc6_);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc6_)
|
||||
{
|
||||
param1[_loc5_ + _loc7_] ^= _loc3_[_loc7_];
|
||||
_loc7_++;
|
||||
}
|
||||
_loc3_.position = 0;
|
||||
_loc3_.writeBytes(_loc4_);
|
||||
_loc5_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-cfb";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
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();
|
||||
this.core(param1,_loc2_);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:ByteArray = getIV4d();
|
||||
this.core(param1,_loc2_);
|
||||
padding.unpad(param1);
|
||||
}
|
||||
|
||||
private function core(param1:ByteArray, param2:ByteArray) : void
|
||||
{
|
||||
var _loc6_:uint = 0;
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
var _loc4_:ByteArray = new ByteArray();
|
||||
_loc3_.writeBytes(param2);
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < param1.length)
|
||||
{
|
||||
_loc4_.position = 0;
|
||||
_loc4_.writeBytes(_loc3_);
|
||||
key.encrypt(_loc4_);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < blockSize)
|
||||
{
|
||||
param1[_loc5_ + _loc6_] ^= _loc4_[_loc6_];
|
||||
_loc6_++;
|
||||
}
|
||||
_loc6_ = blockSize - 1;
|
||||
while(_loc6_ >= 0)
|
||||
{
|
||||
++_loc3_[_loc6_];
|
||||
if(_loc3_[_loc6_] != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc6_--;
|
||||
}
|
||||
_loc5_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-ctr";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
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 = this.generateWorkingKey(true,param1,0);
|
||||
this.decKey = this.generateWorkingKey(false,param1,0);
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
this.desFunc(this.decKey,param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.encKey.length)
|
||||
{
|
||||
this.encKey[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.decKey.length)
|
||||
{
|
||||
this.decKey[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
this.encKey = null;
|
||||
this.decKey = null;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.key.length)
|
||||
{
|
||||
this.key[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
this.key.length = 0;
|
||||
this.key = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
this.desFunc(this.encKey,param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
protected function generateWorkingKey(param1:Boolean, param2:ByteArray, param3:uint) : Array
|
||||
{
|
||||
var _loc7_:uint = 0;
|
||||
var _loc10_:uint = 0;
|
||||
var _loc11_:uint = 0;
|
||||
var _loc12_:uint = 0;
|
||||
var _loc13_:uint = 0;
|
||||
var _loc4_:Array = [];
|
||||
var _loc5_:ByteArray = new ByteArray();
|
||||
var _loc6_:ByteArray = new ByteArray();
|
||||
var _loc8_:uint = 0;
|
||||
while(_loc8_ < 56)
|
||||
{
|
||||
_loc7_ = uint(pc1[_loc8_]);
|
||||
_loc5_[_loc8_] = (param2[param3 + (_loc7_ >>> 3)] & bytebit[_loc7_ & 7]) != 0;
|
||||
_loc8_++;
|
||||
}
|
||||
var _loc9_:uint = 0;
|
||||
while(_loc9_ < 16)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_loc10_ = uint(_loc9_ << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc10_ = uint(15 - _loc9_ << 1);
|
||||
}
|
||||
_loc11_ = _loc10_ + 1;
|
||||
_loc4_[_loc10_] = _loc4_[_loc11_] = 0;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 28)
|
||||
{
|
||||
_loc7_ = _loc8_ + totrot[_loc9_];
|
||||
if(_loc7_ < 28)
|
||||
{
|
||||
_loc6_[_loc8_] = _loc5_[_loc7_];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_[_loc8_] = _loc5_[_loc7_ - 28];
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
_loc8_ = 28;
|
||||
while(_loc8_ < 56)
|
||||
{
|
||||
_loc7_ = _loc8_ + totrot[_loc9_];
|
||||
if(_loc7_ < 56)
|
||||
{
|
||||
_loc6_[_loc8_] = _loc5_[_loc7_];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_[_loc8_] = _loc5_[_loc7_ - 28];
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 24)
|
||||
{
|
||||
if(_loc6_[pc2[_loc8_]])
|
||||
{
|
||||
_loc4_[_loc10_] |= bigbyte[_loc8_];
|
||||
}
|
||||
if(_loc6_[pc2[_loc8_ + 24]])
|
||||
{
|
||||
_loc4_[_loc11_] |= bigbyte[_loc8_];
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ != 32)
|
||||
{
|
||||
_loc12_ = uint(_loc4_[_loc9_]);
|
||||
_loc13_ = uint(_loc4_[_loc9_ + 1]);
|
||||
_loc4_[_loc9_] = (_loc12_ & 0xFC0000) << 6 | (_loc12_ & 0x0FC0) << 10 | (_loc13_ & 0xFC0000) >>> 10 | (_loc13_ & 0x0FC0) >>> 6;
|
||||
_loc4_[_loc9_ + 1] = (_loc12_ & 0x03F000) << 12 | (_loc12_ & 0x3F) << 16 | (_loc13_ & 0x03F000) >>> 4 | _loc13_ & 0x3F;
|
||||
_loc9_ += 2;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
protected function desFunc(param1:Array, param2:ByteArray, param3:uint, param4:ByteArray, param5:uint) : void
|
||||
{
|
||||
var _loc6_:uint = 0;
|
||||
var _loc7_:uint = 0;
|
||||
var _loc8_:uint = 0;
|
||||
var _loc10_:uint = 0;
|
||||
_loc8_ = uint((param2[param3 + 0] & 0xFF) << 24);
|
||||
_loc8_ = uint(_loc8_ | (param2[param3 + 1] & 0xFF) << 16);
|
||||
_loc8_ = uint(_loc8_ | (param2[param3 + 2] & 0xFF) << 8);
|
||||
_loc8_ = uint(_loc8_ | param2[param3 + 3] & 0xFF);
|
||||
_loc7_ = uint((param2[param3 + 4] & 0xFF) << 24);
|
||||
_loc7_ = uint(_loc7_ | (param2[param3 + 5] & 0xFF) << 16);
|
||||
_loc7_ = uint(_loc7_ | (param2[param3 + 6] & 0xFF) << 8);
|
||||
_loc7_ = uint(_loc7_ | param2[param3 + 7] & 0xFF);
|
||||
_loc6_ = uint((_loc8_ >>> 4 ^ _loc7_) & 0x0F0F0F0F);
|
||||
_loc7_ ^= _loc6_;
|
||||
_loc8_ ^= _loc6_ << 4;
|
||||
_loc6_ = uint((_loc8_ >>> 16 ^ _loc7_) & 0xFFFF);
|
||||
_loc7_ ^= _loc6_;
|
||||
_loc8_ ^= _loc6_ << 16;
|
||||
_loc6_ = uint((_loc7_ >>> 2 ^ _loc8_) & 0x33333333);
|
||||
_loc8_ ^= _loc6_;
|
||||
_loc7_ ^= _loc6_ << 2;
|
||||
_loc6_ = uint((_loc7_ >>> 8 ^ _loc8_) & 0xFF00FF);
|
||||
_loc8_ ^= _loc6_;
|
||||
_loc7_ ^= _loc6_ << 8;
|
||||
_loc7_ = uint((_loc7_ << 1 | _loc7_ >>> 31 & 1) & 0xFFFFFFFF);
|
||||
_loc6_ = uint((_loc8_ ^ _loc7_) & 0xAAAAAAAA);
|
||||
_loc8_ ^= _loc6_;
|
||||
_loc7_ ^= _loc6_;
|
||||
_loc8_ = uint((_loc8_ << 1 | _loc8_ >>> 31 & 1) & 0xFFFFFFFF);
|
||||
var _loc9_:uint = 0;
|
||||
while(_loc9_ < 8)
|
||||
{
|
||||
_loc6_ = uint(_loc7_ << 28 | _loc7_ >>> 4);
|
||||
_loc6_ = uint(_loc6_ ^ param1[_loc9_ * 4 + 0]);
|
||||
_loc10_ = uint(SP7[_loc6_ & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP5[_loc6_ >>> 8 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP3[_loc6_ >>> 16 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP1[_loc6_ >>> 24 & 0x3F]);
|
||||
_loc6_ = uint(_loc7_ ^ param1[_loc9_ * 4 + 1]);
|
||||
_loc10_ |= SP8[_loc6_ & 0x3F];
|
||||
_loc10_ = uint(_loc10_ | SP6[_loc6_ >>> 8 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP4[_loc6_ >>> 16 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP2[_loc6_ >>> 24 & 0x3F]);
|
||||
_loc8_ ^= _loc10_;
|
||||
_loc6_ = uint(_loc8_ << 28 | _loc8_ >>> 4);
|
||||
_loc6_ = uint(_loc6_ ^ param1[_loc9_ * 4 + 2]);
|
||||
_loc10_ = uint(SP7[_loc6_ & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP5[_loc6_ >>> 8 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP3[_loc6_ >>> 16 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP1[_loc6_ >>> 24 & 0x3F]);
|
||||
_loc6_ = uint(_loc8_ ^ param1[_loc9_ * 4 + 3]);
|
||||
_loc10_ |= SP8[_loc6_ & 0x3F];
|
||||
_loc10_ = uint(_loc10_ | SP6[_loc6_ >>> 8 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP4[_loc6_ >>> 16 & 0x3F]);
|
||||
_loc10_ = uint(_loc10_ | SP2[_loc6_ >>> 24 & 0x3F]);
|
||||
_loc7_ ^= _loc10_;
|
||||
_loc9_++;
|
||||
}
|
||||
_loc7_ = uint(_loc7_ << 31 | _loc7_ >>> 1);
|
||||
_loc6_ = uint((_loc8_ ^ _loc7_) & 0xAAAAAAAA);
|
||||
_loc8_ ^= _loc6_;
|
||||
_loc7_ ^= _loc6_;
|
||||
_loc8_ = uint(_loc8_ << 31 | _loc8_ >>> 1);
|
||||
_loc6_ = uint((_loc8_ >>> 8 ^ _loc7_) & 0xFF00FF);
|
||||
_loc7_ ^= _loc6_;
|
||||
_loc8_ ^= _loc6_ << 8;
|
||||
_loc6_ = uint((_loc8_ >>> 2 ^ _loc7_) & 0x33333333);
|
||||
_loc7_ ^= _loc6_;
|
||||
_loc8_ ^= _loc6_ << 2;
|
||||
_loc6_ = uint((_loc7_ >>> 16 ^ _loc8_) & 0xFFFF);
|
||||
_loc8_ ^= _loc6_;
|
||||
_loc7_ ^= _loc6_ << 16;
|
||||
_loc6_ = uint((_loc7_ >>> 4 ^ _loc8_) & 0x0F0F0F0F);
|
||||
_loc8_ ^= _loc6_;
|
||||
_loc7_ ^= _loc6_ << 4;
|
||||
param4[param5 + 0] = _loc7_ >>> 24 & 0xFF;
|
||||
param4[param5 + 1] = _loc7_ >>> 16 & 0xFF;
|
||||
param4[param5 + 2] = _loc7_ >>> 8 & 0xFF;
|
||||
param4[param5 + 3] = _loc7_ & 0xFF;
|
||||
param4[param5 + 4] = _loc8_ >>> 24 & 0xFF;
|
||||
param4[param5 + 5] = _loc8_ >>> 16 & 0xFF;
|
||||
param4[param5 + 6] = _loc8_ >>> 8 & 0xFF;
|
||||
param4[param5 + 7] = _loc8_ & 0xFF;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "des";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
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 this.key.getBlockSize();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
this.padding.pad(param1);
|
||||
param1.position = 0;
|
||||
var _loc2_:uint = this.key.getBlockSize();
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
var _loc4_:ByteArray = new ByteArray();
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < param1.length)
|
||||
{
|
||||
_loc3_.length = 0;
|
||||
param1.readBytes(_loc3_,0,_loc2_);
|
||||
this.key.encrypt(_loc3_);
|
||||
_loc4_.writeBytes(_loc3_);
|
||||
_loc5_ += _loc2_;
|
||||
}
|
||||
param1.length = 0;
|
||||
param1.writeBytes(_loc4_);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
param1.position = 0;
|
||||
var _loc2_:uint = this.key.getBlockSize();
|
||||
if(param1.length % _loc2_ != 0)
|
||||
{
|
||||
throw new Error("ECB mode cipher length must be a multiple of blocksize " + _loc2_);
|
||||
}
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
var _loc4_:ByteArray = new ByteArray();
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < param1.length)
|
||||
{
|
||||
_loc3_.length = 0;
|
||||
param1.readBytes(_loc3_,0,_loc2_);
|
||||
this.key.decrypt(_loc3_);
|
||||
_loc4_.writeBytes(_loc3_);
|
||||
_loc5_ += _loc2_;
|
||||
}
|
||||
this.padding.unpad(_loc4_);
|
||||
param1.length = 0;
|
||||
param1.writeBytes(_loc4_);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
this.key.dispose();
|
||||
this.key = null;
|
||||
this.padding = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return this.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;
|
||||
this.blockSize = param1.getBlockSize();
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = new PKCS5(this.blockSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
param2.setBlockSize(this.blockSize);
|
||||
}
|
||||
this.padding = param2;
|
||||
this.prng = new Random();
|
||||
this.iv = null;
|
||||
this.lastIV = new ByteArray();
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return this.key.getBlockSize();
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:uint = 0;
|
||||
if(this.iv != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.iv.length)
|
||||
{
|
||||
this.iv[_loc1_] = this.prng.nextByte();
|
||||
_loc1_++;
|
||||
}
|
||||
this.iv.length = 0;
|
||||
this.iv = null;
|
||||
}
|
||||
if(this.lastIV != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.iv.length)
|
||||
{
|
||||
this.lastIV[_loc1_] = this.prng.nextByte();
|
||||
_loc1_++;
|
||||
}
|
||||
this.lastIV.length = 0;
|
||||
this.lastIV = null;
|
||||
}
|
||||
this.key.dispose();
|
||||
this.key = null;
|
||||
this.padding = null;
|
||||
this.prng.dispose();
|
||||
this.prng = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function set IV(param1:ByteArray) : void
|
||||
{
|
||||
this.iv = param1;
|
||||
this.lastIV.length = 0;
|
||||
this.lastIV.writeBytes(this.iv);
|
||||
}
|
||||
|
||||
public function get IV() : ByteArray
|
||||
{
|
||||
return this.lastIV;
|
||||
}
|
||||
|
||||
protected function getIV4e() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(this.iv)
|
||||
{
|
||||
_loc1_.writeBytes(this.iv);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.prng.nextBytes(_loc1_,this.blockSize);
|
||||
}
|
||||
this.lastIV.length = 0;
|
||||
this.lastIV.writeBytes(_loc1_);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
protected function getIV4d() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(this.iv)
|
||||
{
|
||||
_loc1_.writeBytes(this.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,56 @@
|
||||
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();
|
||||
this.core(param1,_loc2_);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray) : void
|
||||
{
|
||||
var _loc2_:ByteArray = getIV4d();
|
||||
this.core(param1,_loc2_);
|
||||
}
|
||||
|
||||
private function core(param1:ByteArray, param2:ByteArray) : void
|
||||
{
|
||||
var _loc6_:uint = 0;
|
||||
var _loc7_:uint = 0;
|
||||
var _loc3_:uint = param1.length;
|
||||
var _loc4_:ByteArray = new ByteArray();
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < param1.length)
|
||||
{
|
||||
key.encrypt(param2);
|
||||
_loc4_.position = 0;
|
||||
_loc4_.writeBytes(param2);
|
||||
_loc6_ = _loc5_ + blockSize < _loc3_ ? blockSize : uint(_loc3_ - _loc5_);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc6_)
|
||||
{
|
||||
param1[_loc5_ + _loc7_] ^= param2[_loc7_];
|
||||
_loc7_++;
|
||||
}
|
||||
param2.position = 0;
|
||||
param2.writeBytes(_loc4_);
|
||||
_loc5_ += blockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return key.toString() + "-ofb";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
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 _loc2_:uint = this.blockSize - param1.length % this.blockSize;
|
||||
var _loc3_:uint = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
param1[param1.length] = _loc2_;
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function unpad(param1:ByteArray) : void
|
||||
{
|
||||
var _loc4_:uint = 0;
|
||||
var _loc2_:uint = param1.length % this.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]);
|
||||
var _loc3_:uint = _loc2_;
|
||||
while(_loc3_ > 0)
|
||||
{
|
||||
_loc4_ = uint(param1[param1.length - 1]);
|
||||
--param1.length;
|
||||
if(_loc2_ != _loc4_)
|
||||
{
|
||||
throw new Error("PKCS#5:unpad: Invalid padding value. expected [" + _loc2_ + "], found [" + _loc4_ + "]");
|
||||
}
|
||||
_loc3_--;
|
||||
}
|
||||
}
|
||||
|
||||
public function setBlockSize(param1:uint) : void
|
||||
{
|
||||
this.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;
|
||||
this.cipher = param1 as ICipher;
|
||||
}
|
||||
|
||||
public function getBlockSize() : uint
|
||||
{
|
||||
return this.mode.getBlockSize();
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
this.mode.dispose();
|
||||
this.mode = null;
|
||||
this.cipher = null;
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
public function encrypt(param1:ByteArray) : void
|
||||
{
|
||||
this.cipher.encrypt(param1);
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc2_.writeBytes(this.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,this.getBlockSize());
|
||||
this.mode.IV = _loc2_;
|
||||
_loc2_ = new ByteArray();
|
||||
_loc2_.writeBytes(param1,this.getBlockSize());
|
||||
this.cipher.decrypt(_loc2_);
|
||||
param1.length = 0;
|
||||
param1.writeBytes(_loc2_);
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "simple-" + this.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);
|
||||
this.encKey2 = generateWorkingKey(false,param1,8);
|
||||
this.decKey2 = generateWorkingKey(true,param1,8);
|
||||
if(param1.length > 16)
|
||||
{
|
||||
this.encKey3 = generateWorkingKey(true,param1,16);
|
||||
this.decKey3 = generateWorkingKey(false,param1,16);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.encKey3 = encKey;
|
||||
this.decKey3 = decKey;
|
||||
}
|
||||
}
|
||||
|
||||
override public function dispose() : void
|
||||
{
|
||||
super.dispose();
|
||||
var _loc1_:uint = 0;
|
||||
if(this.encKey2 != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.encKey2.length)
|
||||
{
|
||||
this.encKey2[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
this.encKey2 = null;
|
||||
}
|
||||
if(this.encKey3 != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.encKey3.length)
|
||||
{
|
||||
this.encKey3[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
this.encKey3 = null;
|
||||
}
|
||||
if(this.decKey2 != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.decKey2.length)
|
||||
{
|
||||
this.decKey2[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
this.decKey2 = null;
|
||||
}
|
||||
if(this.decKey3 != null)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < this.decKey3.length)
|
||||
{
|
||||
this.decKey3[_loc1_] = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
this.decKey3 = null;
|
||||
}
|
||||
Memory.gc();
|
||||
}
|
||||
|
||||
override public function encrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
desFunc(encKey,param1,param2,param1,param2);
|
||||
desFunc(this.encKey2,param1,param2,param1,param2);
|
||||
desFunc(this.encKey3,param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
override public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
desFunc(this.decKey3,param1,param2,param1,param2);
|
||||
desFunc(this.decKey2,param1,param2,param1,param2);
|
||||
desFunc(decKey,param1,param2,param1,param2);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "3des";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
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;
|
||||
this.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 _loc5_:uint = 0;
|
||||
param1.position = param2;
|
||||
var _loc3_:uint = param1.readUnsignedInt();
|
||||
var _loc4_:uint = param1.readUnsignedInt();
|
||||
var _loc6_:uint = 0;
|
||||
var _loc7_:uint = 2654435769;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < this.NUM_ROUNDS)
|
||||
{
|
||||
_loc3_ += (_loc4_ << 4 ^ _loc4_ >> 5) + _loc4_ ^ _loc6_ + this.k[_loc6_ & 3];
|
||||
_loc6_ += _loc7_;
|
||||
_loc4_ += (_loc3_ << 4 ^ _loc3_ >> 5) + _loc3_ ^ _loc6_ + this.k[_loc6_ >> 11 & 3];
|
||||
_loc5_++;
|
||||
}
|
||||
param1.position -= 8;
|
||||
param1.writeUnsignedInt(_loc3_);
|
||||
param1.writeUnsignedInt(_loc4_);
|
||||
}
|
||||
|
||||
public function decrypt(param1:ByteArray, param2:uint = 0) : void
|
||||
{
|
||||
var _loc5_:uint = 0;
|
||||
param1.position = param2;
|
||||
var _loc3_:uint = param1.readUnsignedInt();
|
||||
var _loc4_:uint = param1.readUnsignedInt();
|
||||
var _loc6_:uint = 2654435769;
|
||||
var _loc7_:uint = _loc6_ * this.NUM_ROUNDS;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < this.NUM_ROUNDS)
|
||||
{
|
||||
_loc4_ -= (_loc3_ << 4 ^ _loc3_ >> 5) + _loc3_ ^ _loc7_ + this.k[_loc7_ >> 11 & 3];
|
||||
_loc7_ -= _loc6_;
|
||||
_loc3_ -= (_loc4_ << 4 ^ _loc4_ >> 5) + _loc4_ ^ _loc7_ + this.k[_loc7_ & 3];
|
||||
_loc5_++;
|
||||
}
|
||||
param1.position -= 8;
|
||||
param1.writeUnsignedInt(_loc3_);
|
||||
param1.writeUnsignedInt(_loc4_);
|
||||
}
|
||||
|
||||
public function dispose() : void
|
||||
{
|
||||
var _loc1_:Random = new Random();
|
||||
var _loc2_:uint = 0;
|
||||
while(_loc2_ < this.k.length)
|
||||
{
|
||||
this.k[_loc2_] = _loc1_.nextByte();
|
||||
delete this.k[_loc2_];
|
||||
_loc2_++;
|
||||
}
|
||||
this.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();
|
||||
this.r2 = new BigInteger();
|
||||
this.q3 = new BigInteger();
|
||||
BigInteger.ONE.dlShiftTo(2 * param1.t,this.r2);
|
||||
this.mu = this.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);
|
||||
this.reduce(param3);
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
this.reduce(param2);
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
var _loc2_:BigInteger = null;
|
||||
if(param1.s < 0 || param1.t > 2 * this.m.t)
|
||||
{
|
||||
return param1.mod(this.m);
|
||||
}
|
||||
if(param1.compareTo(this.m) < 0)
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
_loc2_ = new BigInteger();
|
||||
param1.copyTo(_loc2_);
|
||||
this.reduce(_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
var _loc2_:BigInteger = param1 as BigInteger;
|
||||
_loc2_.drShiftTo(this.m.t - 1,this.r2);
|
||||
if(_loc2_.t > this.m.t + 1)
|
||||
{
|
||||
_loc2_.t = this.m.t + 1;
|
||||
_loc2_.clamp();
|
||||
}
|
||||
this.mu.multiplyUpperTo(this.r2,this.m.t + 1,this.q3);
|
||||
this.m.multiplyLowerTo(this.q3,this.m.t + 1,this.r2);
|
||||
while(_loc2_.compareTo(this.r2) < 0)
|
||||
{
|
||||
_loc2_.dAddOffset(1,this.m.t + 1);
|
||||
}
|
||||
_loc2_.subTo(this.r2,_loc2_);
|
||||
while(_loc2_.compareTo(this.m) >= 0)
|
||||
{
|
||||
_loc2_.subTo(this.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(this.m) >= 0)
|
||||
{
|
||||
return param1.mod(this.m);
|
||||
}
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
param1.divRemTo(this.m,null,param1);
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
this.reduce(param3);
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
this.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,95 @@
|
||||
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;
|
||||
this.mp = param1.invDigit();
|
||||
this.mpl = this.mp & 0x7FFF;
|
||||
this.mph = this.mp >> 15;
|
||||
this.um = (1 << BigInteger.DB - 15) - 1;
|
||||
this.mt2 = 2 * param1.t;
|
||||
}
|
||||
|
||||
public function convert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
var _loc2_:BigInteger = new BigInteger();
|
||||
param1.abs().dlShiftTo(this.m.t,_loc2_);
|
||||
_loc2_.divRemTo(this.m,null,_loc2_);
|
||||
if(param1.s < 0 && _loc2_.compareTo(BigInteger.ZERO) > 0)
|
||||
{
|
||||
this.m.subTo(_loc2_,_loc2_);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function revert(param1:BigInteger) : BigInteger
|
||||
{
|
||||
var _loc2_:BigInteger = new BigInteger();
|
||||
param1.copyTo(_loc2_);
|
||||
this.reduce(_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function reduce(param1:BigInteger) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
while(param1.t <= this.mt2)
|
||||
{
|
||||
var _loc5_:Number;
|
||||
param1.a[_loc5_ = param1.t++] = 0;
|
||||
}
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < this.m.t)
|
||||
{
|
||||
_loc3_ = param1.a[_loc2_] & 0x7FFF;
|
||||
_loc4_ = _loc3_ * this.mpl + ((_loc3_ * this.mph + (param1.a[_loc2_] >> 15) * this.mpl & this.um) << 15) & BigInteger.DM;
|
||||
_loc3_ = _loc2_ + this.m.t;
|
||||
param1.a[_loc3_] += this.m.am(0,_loc4_,param1,_loc2_,0,this.m.t);
|
||||
while(param1.a[_loc3_] >= BigInteger.DV)
|
||||
{
|
||||
param1.a[_loc3_] -= BigInteger.DV;
|
||||
++param1.a[++_loc3_];
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
param1.clamp();
|
||||
param1.drShiftTo(this.m.t,param1);
|
||||
if(param1.compareTo(this.m) >= 0)
|
||||
{
|
||||
param1.subTo(this.m,param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function sqrTo(param1:BigInteger, param2:BigInteger) : void
|
||||
{
|
||||
param1.squareTo(param2);
|
||||
this.reduce(param2);
|
||||
}
|
||||
|
||||
public function mulTo(param1:BigInteger, param2:BigInteger, param3:BigInteger) : void
|
||||
{
|
||||
param1.multiplyTo(param2,param3);
|
||||
this.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,105 @@
|
||||
package com.hurlant.util
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class Base64
|
||||
{
|
||||
|
||||
private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
|
||||
public static const version:String = "1.0.0";
|
||||
|
||||
public function Base64()
|
||||
{
|
||||
super();
|
||||
throw new Error("Base64 class is static container only");
|
||||
}
|
||||
|
||||
public static function encode(param1:String) : String
|
||||
{
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc2_.writeUTFBytes(param1);
|
||||
return encodeByteArray(_loc2_);
|
||||
}
|
||||
|
||||
public static function encodeByteArray(param1:ByteArray) : String
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
var _loc5_:uint = 0;
|
||||
var _loc6_:uint = 0;
|
||||
var _loc7_:uint = 0;
|
||||
var _loc2_:String = "";
|
||||
var _loc4_:Array = new Array(4);
|
||||
param1.position = 0;
|
||||
while(param1.bytesAvailable > 0)
|
||||
{
|
||||
_loc3_ = new Array();
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 3 && param1.bytesAvailable > 0)
|
||||
{
|
||||
_loc3_[_loc5_] = param1.readUnsignedByte();
|
||||
_loc5_++;
|
||||
}
|
||||
_loc4_[0] = (_loc3_[0] & 0xFC) >> 2;
|
||||
_loc4_[1] = (_loc3_[0] & 3) << 4 | _loc3_[1] >> 4;
|
||||
_loc4_[2] = (_loc3_[1] & 0x0F) << 2 | _loc3_[2] >> 6;
|
||||
_loc4_[3] = _loc3_[2] & 0x3F;
|
||||
_loc6_ = _loc3_.length;
|
||||
while(_loc6_ < 3)
|
||||
{
|
||||
_loc4_[_loc6_ + 1] = 64;
|
||||
_loc6_++;
|
||||
}
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc4_.length)
|
||||
{
|
||||
_loc2_ += BASE64_CHARS.charAt(_loc4_[_loc7_]);
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function decode(param1:String) : String
|
||||
{
|
||||
var _loc2_:ByteArray = decodeToByteArray(param1);
|
||||
return _loc2_.readUTFBytes(_loc2_.length);
|
||||
}
|
||||
|
||||
public static function decodeToByteArray(param1:String) : ByteArray
|
||||
{
|
||||
var _loc6_:uint = 0;
|
||||
var _loc7_:uint = 0;
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
var _loc3_:Array = new Array(4);
|
||||
var _loc4_:Array = new Array(3);
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < param1.length)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < 4 && _loc5_ + _loc6_ < param1.length)
|
||||
{
|
||||
_loc3_[_loc6_] = BASE64_CHARS.indexOf(param1.charAt(_loc5_ + _loc6_));
|
||||
_loc6_++;
|
||||
}
|
||||
_loc4_[0] = (_loc3_[0] << 2) + ((_loc3_[1] & 0x30) >> 4);
|
||||
_loc4_[1] = ((_loc3_[1] & 0x0F) << 4) + ((_loc3_[2] & 0x3C) >> 2);
|
||||
_loc4_[2] = ((_loc3_[2] & 3) << 6) + _loc3_[3];
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc4_.length)
|
||||
{
|
||||
if(_loc3_[_loc7_ + 1] == 64)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc2_.writeByte(_loc4_[_loc7_]);
|
||||
_loc7_++;
|
||||
}
|
||||
_loc5_ += 4;
|
||||
}
|
||||
_loc2_.position = 0;
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.hurlant.util
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class Hex
|
||||
{
|
||||
|
||||
public function Hex()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function toArray(param1:String) : ByteArray
|
||||
{
|
||||
param1 = param1.replace(/\s|:/gm,"");
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
if(param1.length & 1 == 1)
|
||||
{
|
||||
param1 = "0" + param1;
|
||||
}
|
||||
var _loc3_:uint = 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 _loc3_:String = "";
|
||||
var _loc4_:uint = 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,424 @@
|
||||
package com.sbi.analytics
|
||||
{
|
||||
import com.carlcalderon.arthropod.Debug;
|
||||
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.Timer;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
public class SBTracker
|
||||
{
|
||||
|
||||
private static var _lastPage:String;
|
||||
|
||||
private static var _pageStack:Array;
|
||||
|
||||
private static var _batchTimer:Timer;
|
||||
|
||||
private static var _previousDurationTime:Number;
|
||||
|
||||
private static var _isExternalAvailable:Boolean;
|
||||
|
||||
private static var _couldNotConnect:Boolean;
|
||||
|
||||
private static var _containsAnUndefined:Boolean;
|
||||
|
||||
private static var _pageView:String;
|
||||
|
||||
private static var _socket:Socket;
|
||||
|
||||
private static var _timeOffset:Number;
|
||||
|
||||
private static var _isFromLogin:Boolean;
|
||||
|
||||
private static var _holdingObject:Object;
|
||||
|
||||
private static var _retryLimit:int;
|
||||
|
||||
private static var _latestTimeStamp:Number;
|
||||
|
||||
private static var _lastBatchCallback:Function;
|
||||
|
||||
private static var _errorPageView:String;
|
||||
|
||||
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;
|
||||
}
|
||||
_holdingObject = null;
|
||||
_pageView = null;
|
||||
_lastPage = null;
|
||||
_pageStack = [];
|
||||
_previousDurationTime = 0;
|
||||
_latestTimeStamp = 0;
|
||||
_socket = new Socket();
|
||||
_socket.addEventListener(Event.CLOSE,closeHandler);
|
||||
_socket.addEventListener(Event.CONNECT,connectHandler);
|
||||
_socket.addEventListener(DataEvent.DATA,dataHandler);
|
||||
_socket.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
|
||||
_socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler);
|
||||
_batchTimer = new Timer(10000);
|
||||
_batchTimer.addEventListener(TimerEvent.TIMER,onBatchTimer,false,0,true);
|
||||
_batchTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
public static function receiveClose() : String
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
var _loc2_:String = null;
|
||||
_batchTimer.stop();
|
||||
_batchTimer.removeEventListener(TimerEvent.TIMER,onBatchTimer);
|
||||
if(_pageView != null)
|
||||
{
|
||||
if(_holdingObject != null)
|
||||
{
|
||||
_loc1_ = _previousDurationTime;
|
||||
_previousDurationTime = getTimer();
|
||||
_loc1_ = _previousDurationTime - _loc1_;
|
||||
_loc2_ = _holdingObject.time + "\n" + _holdingObject.order + "\n" + Math.round(_loc1_ / 100) + "\n" + _holdingObject.sessionId + "\n" + _holdingObject.uri + "\n" + _holdingObject.uriParams + "\n" + _holdingObject.pop + "\n";
|
||||
_pageView += _loc2_;
|
||||
}
|
||||
return _pageView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function onError() : void
|
||||
{
|
||||
if(_isExternalAvailable)
|
||||
{
|
||||
ExternalInterface.call("reportAnalyticsError","Error Timeout",gMainFrame.clientInfo.sessionId);
|
||||
}
|
||||
Debug.log("Sending analytics error",Debug.RED);
|
||||
}
|
||||
|
||||
public static function trackPageview(param1:String, param2:int = -1) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:Boolean = false;
|
||||
var _loc8_:Object = null;
|
||||
var _loc9_:String = null;
|
||||
var _loc10_:String = null;
|
||||
if(_isExternalAvailable && !_couldNotConnect)
|
||||
{
|
||||
_lastPage = param1;
|
||||
param1 = param1.replace("\'","");
|
||||
_loc3_ = param1.split(/#/i);
|
||||
_loc4_ = _previousDurationTime;
|
||||
_previousDurationTime = getTimer();
|
||||
_loc4_ = _previousDurationTime - _loc4_;
|
||||
if(gMainFrame.clientInfo.sessionId == undefined)
|
||||
{
|
||||
_containsAnUndefined = true;
|
||||
_isFromLogin = param2 != -1;
|
||||
if(_isFromLogin)
|
||||
{
|
||||
gMainFrame.clientInfo.sessionId = Math.floor(Math.random() * (int.MAX_VALUE + 1));
|
||||
}
|
||||
}
|
||||
if(_isFromLogin)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
}
|
||||
else if(gMainFrame.clientInfo.dbUserId == undefined)
|
||||
{
|
||||
_loc5_ = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = int(gMainFrame.clientInfo.dbUserId);
|
||||
}
|
||||
_loc6_ = Math.floor(new Date().valueOf() / 1000 + _timeOffset);
|
||||
_loc7_ = _loc6_ - _latestTimeStamp == 0;
|
||||
_latestTimeStamp = _loc6_;
|
||||
_loc8_ = {
|
||||
"userId":_loc5_,
|
||||
"time":_loc6_,
|
||||
"order":(_holdingObject != null && _loc7_ ? (_holdingObject.order = _holdingObject.order + 1) : 0),
|
||||
"duration":Math.round(_loc4_ / 100),
|
||||
"sessionId":gMainFrame.clientInfo.sessionId,
|
||||
"uri":_loc3_[0],
|
||||
"uriParams":(_loc3_[1] != null ? _loc3_[1] : ""),
|
||||
"pop":(_loc3_[2] != null ? 1 : 0)
|
||||
};
|
||||
if(_holdingObject != null)
|
||||
{
|
||||
_loc9_ = _holdingObject.userId + "\n" + _holdingObject.time + "\n" + _loc8_.order + "\n" + _loc8_.duration + "\n" + _holdingObject.sessionId + "\n" + _holdingObject.uri + "\n" + _holdingObject.uriParams + "\n" + _holdingObject.pop + "\n";
|
||||
_holdingObject = {
|
||||
"userId":_loc8_.userId,
|
||||
"time":_loc8_.time,
|
||||
"order":_loc8_.order,
|
||||
"duration:":-1,
|
||||
"sessionId":_loc8_.sessionId,
|
||||
"uri":_loc8_.uri,
|
||||
"uriParams":_loc8_.uriParams,
|
||||
"pop":_loc8_.pop
|
||||
};
|
||||
if(_pageView != null)
|
||||
{
|
||||
_pageView += _loc9_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_pageView = _loc9_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_holdingObject = _loc8_;
|
||||
}
|
||||
_loc10_ = _loc8_.userId + "\n" + _loc8_.time + "\n" + _loc8_.order + "\n" + _loc8_.duration + "\n" + _loc8_.sessionId + "\n" + _loc8_.uri + "\n" + _loc8_.uriParams + "\n" + _loc8_.pop + "\n";
|
||||
Debug.log(_loc10_,Debug.PINK);
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleErrorTracking(param1:int, param2:int, param3:int, param4:int, param5:Number, param6:String, param7:String, param8:int) : void
|
||||
{
|
||||
if(_socket == null)
|
||||
{
|
||||
_socket = new Socket();
|
||||
_socket.addEventListener(Event.CLOSE,closeHandler);
|
||||
_socket.addEventListener(Event.CONNECT,errorConnectHandler);
|
||||
_socket.addEventListener(DataEvent.DATA,dataHandler);
|
||||
_socket.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
|
||||
_socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
_socket.removeEventListener(Event.CONNECT,connectHandler);
|
||||
_socket.addEventListener(Event.CONNECT,errorConnectHandler);
|
||||
}
|
||||
var _loc9_:Number = Number(gMainFrame.clientInfo.sessionId);
|
||||
if(gMainFrame.clientInfo.sessionId == undefined)
|
||||
{
|
||||
_loc9_ = Math.round(Math.random() * (int.MAX_VALUE + 1));
|
||||
}
|
||||
var _loc10_:Number = isNaN(_previousDurationTime) ? 0 : _previousDurationTime;
|
||||
_previousDurationTime = getTimer();
|
||||
_loc10_ = _previousDurationTime - _loc10_;
|
||||
var _loc11_:Object = {
|
||||
"userId":(param1 == -1 ? (gMainFrame.clientInfo.dbUserId != undefined ? gMainFrame.clientInfo.dbUserId : -1) : param1),
|
||||
"time":(param2 == -1 ? Math.floor(new Date().valueOf() / 1000 + _timeOffset) : param2),
|
||||
"order":param3,
|
||||
"duration":(param4 == -1 ? _loc10_ : param4),
|
||||
"sessionId":(param5 == -1 ? _loc9_ : param5),
|
||||
"uri":param6,
|
||||
"uriParams":param7,
|
||||
"pop":(param8 == -1 ? 0 : param8)
|
||||
};
|
||||
var _loc12_:String = _loc11_.userId + "\n" + _loc11_.time + "\n" + _loc11_.order + "\n" + _loc11_.duration + "\n" + _loc11_.sessionId + "\n" + _loc11_.uri + "\n" + _loc11_.uriParams + "\n" + _loc11_.pop + "\n";
|
||||
if(_errorPageView != null)
|
||||
{
|
||||
_errorPageView += _loc12_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_errorPageView = _loc12_;
|
||||
}
|
||||
if(_errorPageView != null && Boolean(_socket))
|
||||
{
|
||||
if(_batchTimer)
|
||||
{
|
||||
_batchTimer.reset();
|
||||
}
|
||||
_socket.connect(gMainFrame.clientInfo.sbTrackerIp,5050);
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleOnKickOrLogout() : void
|
||||
{
|
||||
if(_isExternalAvailable && _pageView != null)
|
||||
{
|
||||
ExternalInterface.call("handleLogout",_pageView);
|
||||
}
|
||||
}
|
||||
|
||||
public static function push() : void
|
||||
{
|
||||
if(Boolean(_pageStack) && _lastPage != null)
|
||||
{
|
||||
_pageStack.push(_lastPage + "#pop");
|
||||
}
|
||||
}
|
||||
|
||||
public static function pop() : void
|
||||
{
|
||||
if(Boolean(_pageStack) && Boolean(_pageStack.length))
|
||||
{
|
||||
trackPageview(_pageStack.pop());
|
||||
}
|
||||
}
|
||||
|
||||
public static function flush(param1:Boolean = false) : void
|
||||
{
|
||||
if(Boolean(_pageStack) && Boolean(_pageStack.length))
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
trackPageview(_pageStack[0]);
|
||||
}
|
||||
_pageStack = [];
|
||||
}
|
||||
}
|
||||
|
||||
public static function completeLastTrackingBatch(param1:Function) : void
|
||||
{
|
||||
_lastBatchCallback = param1;
|
||||
if(_batchTimer)
|
||||
{
|
||||
_batchTimer.stop();
|
||||
onBatchTimer(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onBatchTimer(param1:TimerEvent) : void
|
||||
{
|
||||
if(!_isFromLogin)
|
||||
{
|
||||
if(gMainFrame.clientInfo.dbUserId == undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(gMainFrame.clientInfo.dbUserId % gMainFrame.clientInfo.sbTrackerModulator != 0)
|
||||
{
|
||||
_batchTimer.stop();
|
||||
_batchTimer.removeEventListener(TimerEvent.TIMER,onBatchTimer);
|
||||
_couldNotConnect = true;
|
||||
_pageView = null;
|
||||
_socket = null;
|
||||
_isExternalAvailable = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(_lastBatchCallback != null && _retryLimit > 0)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
if(Boolean(_pageView != null) && Boolean(_socket) && (gMainFrame.clientInfo.sessionId != undefined || _isFromLogin))
|
||||
{
|
||||
if(_containsAnUndefined && !_isFromLogin)
|
||||
{
|
||||
_pageView = _pageView.replace(/undefined/gixm,gMainFrame.clientInfo.sessionId);
|
||||
_pageView = _pageView.replace(/-1/gixm,gMainFrame.clientInfo.dbUserId);
|
||||
}
|
||||
_containsAnUndefined = false;
|
||||
_batchTimer.reset();
|
||||
_socket.connect(gMainFrame.clientInfo.sbTrackerIp,5050);
|
||||
}
|
||||
else if(_lastBatchCallback != null)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function closeHandler(param1:Event) : void
|
||||
{
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
private static function connectHandler(param1:Event) : void
|
||||
{
|
||||
Debug.log(_pageView,Debug.YELLOW);
|
||||
_socket.writeUTFBytes(_pageView);
|
||||
_socket.flush();
|
||||
_socket.close();
|
||||
_pageView = null;
|
||||
_retryLimit = 0;
|
||||
_batchTimer.start();
|
||||
if(_lastBatchCallback != null)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function errorConnectHandler(param1:Event) : void
|
||||
{
|
||||
Debug.log(_errorPageView,Debug.RED);
|
||||
_socket.writeUTFBytes(_errorPageView);
|
||||
_socket.flush();
|
||||
_socket.close();
|
||||
_errorPageView = null;
|
||||
_retryLimit = 0;
|
||||
_socket.addEventListener(Event.CONNECT,connectHandler);
|
||||
_socket.removeEventListener(Event.CONNECT,errorConnectHandler);
|
||||
if(_batchTimer)
|
||||
{
|
||||
_batchTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
private static function dataHandler(param1:DataEvent) : void
|
||||
{
|
||||
}
|
||||
|
||||
private static function ioErrorHandler(param1:IOErrorEvent) : void
|
||||
{
|
||||
if(_lastBatchCallback != null)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
if(_retryLimit < 3)
|
||||
{
|
||||
++_retryLimit;
|
||||
Debug.log("IO error - retrying analytics connection",Debug.RED);
|
||||
_socket.connect(gMainFrame.clientInfo.sbTrackerIp,5050);
|
||||
return;
|
||||
}
|
||||
_couldNotConnect = true;
|
||||
}
|
||||
|
||||
private static function securityErrorHandler(param1:SecurityErrorEvent) : void
|
||||
{
|
||||
if(_lastBatchCallback != null)
|
||||
{
|
||||
_lastBatchCallback();
|
||||
_lastBatchCallback = null;
|
||||
}
|
||||
if(_retryLimit < 3)
|
||||
{
|
||||
Debug.log("Security error - retrying analytics connection",Debug.RED);
|
||||
++_retryLimit;
|
||||
_socket.connect(gMainFrame.clientInfo.sbTrackerIp,5050);
|
||||
return;
|
||||
}
|
||||
if(_batchTimer)
|
||||
{
|
||||
_batchTimer.stop();
|
||||
_batchTimer.removeEventListener(TimerEvent.TIMER,onBatchTimer);
|
||||
}
|
||||
_couldNotConnect = true;
|
||||
_pageView = null;
|
||||
_socket = null;
|
||||
onError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.sbi.client
|
||||
{
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import flash.display.*;
|
||||
import flash.events.*;
|
||||
import flash.utils.Timer;
|
||||
|
||||
public class KeepAlive
|
||||
{
|
||||
|
||||
public static var popupLayer:DisplayObjectContainer;
|
||||
|
||||
private static var _keepAliveTimer:Timer;
|
||||
|
||||
private static var _timeLeftTimer:Timer;
|
||||
|
||||
private static var _bInputReceived:Boolean;
|
||||
|
||||
private static var _mcsToKeepAlive:Array;
|
||||
|
||||
private static var _lastMsgSentToServer:Number;
|
||||
|
||||
private static var _inputTimer:Timer;
|
||||
|
||||
private static var _kickWarningPopupShowing:Boolean;
|
||||
|
||||
private static var _isConnected:Function;
|
||||
|
||||
private static var _disconnectClient:Function;
|
||||
|
||||
private static var _playIdleWarningSound:Function;
|
||||
|
||||
private static var KICK_INTERVAL:int = 300000;
|
||||
|
||||
private static var SEND_MSG_INTERVAL:int = 120000;
|
||||
|
||||
private static var NOTIFY_USER_INTERVAL:int = 10000;
|
||||
|
||||
private static var NOTIFY_USER_TIME:int = 30000;
|
||||
|
||||
public function KeepAlive()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:DisplayObjectContainer, param2:Function, param3:Function = null, param4:Function = null) : void
|
||||
{
|
||||
popupLayer = param1;
|
||||
_keepAliveTimer = new Timer(SEND_MSG_INTERVAL);
|
||||
_keepAliveTimer.addEventListener(TimerEvent.TIMER,sendKeepAliveMsg);
|
||||
_timeLeftTimer = new Timer(NOTIFY_USER_INTERVAL);
|
||||
_timeLeftTimer.addEventListener(TimerEvent.TIMER,timeLeftTimer);
|
||||
_timeLeftTimer.start();
|
||||
_lastMsgSentToServer = new Date().getTime();
|
||||
_mcsToKeepAlive = new Array();
|
||||
_isConnected = param2;
|
||||
_disconnectClient = param3;
|
||||
_playIdleWarningSound = param4;
|
||||
}
|
||||
|
||||
public static function startKATimer(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
param1.addEventListener(MouseEvent.MOUSE_DOWN,inputReceivedHandler,false,0,true);
|
||||
param1.addEventListener(KeyboardEvent.KEY_DOWN,inputReceivedHandler,false,0,true);
|
||||
_mcsToKeepAlive.push(param1);
|
||||
_bInputReceived = true;
|
||||
sendKeepAliveMsg(null);
|
||||
_keepAliveTimer.start();
|
||||
}
|
||||
|
||||
public static function stopKATimer(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("ka",[],gMainFrame.server.isWorldZone);
|
||||
_keepAliveTimer.stop();
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < _mcsToKeepAlive.length)
|
||||
{
|
||||
if(_mcsToKeepAlive[_loc2_] == param1)
|
||||
{
|
||||
_mcsToKeepAlive[_loc2_].removeEventListener(MouseEvent.MOUSE_DOWN,inputReceivedHandler);
|
||||
_mcsToKeepAlive[_loc2_].removeEventListener(KeyboardEvent.KEY_DOWN,inputReceivedHandler);
|
||||
_mcsToKeepAlive.splice(_loc2_,1);
|
||||
break;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
|
||||
public static function restartTimeLeftTimer() : void
|
||||
{
|
||||
if(_timeLeftTimer)
|
||||
{
|
||||
_lastMsgSentToServer = new Date().getTime();
|
||||
_timeLeftTimer.stop();
|
||||
_timeLeftTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
private static function sendKeepAliveMsg(param1:TimerEvent) : void
|
||||
{
|
||||
if(_bInputReceived)
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("ka",[],gMainFrame.server.isWorldZone);
|
||||
_lastMsgSentToServer = new Date().getTime();
|
||||
_bInputReceived = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static function timeLeftTimer(param1:TimerEvent) : void
|
||||
{
|
||||
var _loc3_:DisplayObject = null;
|
||||
var _loc2_:Number = new Date().getTime() - _lastMsgSentToServer;
|
||||
if(!_kickWarningPopupShowing && _loc2_ > KICK_INTERVAL - NOTIFY_USER_TIME)
|
||||
{
|
||||
_loc3_ = new SBOkPopup(popupLayer,"Are you still there? Click OK to keep playing.",true,onKickWarningPopup);
|
||||
_kickWarningPopupShowing = true;
|
||||
if(_playIdleWarningSound != null)
|
||||
{
|
||||
_playIdleWarningSound();
|
||||
}
|
||||
if(gMainFrame.userInfo.isModerator)
|
||||
{
|
||||
_bInputReceived = true;
|
||||
sendKeepAliveMsg(null);
|
||||
_kickWarningPopupShowing = false;
|
||||
SBOkPopup.destroyInParentChain(_loc3_);
|
||||
}
|
||||
}
|
||||
if(_loc2_ > KICK_INTERVAL)
|
||||
{
|
||||
if(_isConnected())
|
||||
{
|
||||
if(_disconnectClient != null)
|
||||
{
|
||||
_disconnectClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onKickWarningPopup(param1:MouseEvent) : void
|
||||
{
|
||||
_bInputReceived = true;
|
||||
sendKeepAliveMsg(null);
|
||||
param1.stopPropagation();
|
||||
SBOkPopup.destroyInParentChain(param1.target.parent);
|
||||
_kickWarningPopupShowing = false;
|
||||
}
|
||||
|
||||
public static function inputReceivedHandler(param1:Event) : void
|
||||
{
|
||||
if(!_bInputReceived)
|
||||
{
|
||||
_bInputReceived = true;
|
||||
}
|
||||
if(new Date().getTime() - _lastMsgSentToServer > SEND_MSG_INTERVAL)
|
||||
{
|
||||
sendKeepAliveMsg(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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