Brought up to date with the private repository (feea4c7)

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

No files matched your search

@@ -0,0 +1,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);
}
}
}
}
@@ -0,0 +1,962 @@
package com.sbi.client
{
import com.sbi.debug.DebugUtility;
import flash.events.EventDispatcher;
import flash.external.ExternalInterface;
import it.gotoandplay.smartfoxserver.SFSEvent;
import it.gotoandplay.smartfoxserver.SmartFoxClient;
import it.gotoandplay.smartfoxserver.data.Room;
import it.gotoandplay.smartfoxserver.data.User;
public class SFClient extends EventDispatcher
{
public static const STATUS_ONLINE:int = 1;
public static const STATUS_OFFLINE_ACTIVE:int = 0;
public static const STATUS_OFFLINE_ARCHIVED:int = -1;
public static const STATUS_OFFLINE_UNKNOWN:int = -2;
public static const INIT_ROOM_ID:int = 1;
protected var _sfs:SmartFoxClient;
protected var _serverIps:Array;
protected var _blueboxIps:Array;
protected var _serverIp:String;
protected var _serverPort:int;
private var _isConnected:Boolean;
private var _isLoggedIn:Boolean;
private var _isWorldLoggedIn:Boolean;
private var _currSubRoom:SFRoom;
private var _currRoom:SFRoom;
private var _currentPrimaryRoomId:int = -1;
private var _currentSubRoomId:int = -1;
private var _currentPrimaryRoomUsers:Object;
private var _currentSubRoomUsers:Object;
private var _triggerWhenWorldXtReadyCmd:String;
private var _triggerWhenWorldXtReadyObj:Array;
private var _roomIds:Array;
private var _userName:String;
private var _myUser:User;
private var _gemCount:int;
private var _password:String;
private var _zone:String;
private var _hashKey:String;
private var _isWorldZone:Boolean;
private var _pingTimeAvg:uint;
private var _pingTimeTotal:uint;
private var _pingTimeCount:uint;
public function SFClient()
{
super();
this._roomIds = new Array();
this.setUpServer();
}
private function setUpServer() : void
{
this._isConnected = false;
this._hashKey = null;
this._isLoggedIn = false;
this._isWorldLoggedIn = false;
this._sfs = new SmartFoxClient(false);
this._sfs.smartConnect = false;
this._sfs.addEventListener(SFSEvent.onConnection,this.onConnection);
this._sfs.addEventListener(SFSEvent.onConnectionLost,this.onConnectionLost);
this._sfs.addEventListener(SFSEvent.onLogin,this.onLogin);
this._sfs.addEventListener(SFSEvent.onExtensionResponse,this.onExtensionResponse);
this._sfs.addEventListener(SFSEvent.onLogout,this.onLogout);
this._sfs.addEventListener(SFSEvent.onRoomListUpdate,this.onRoomListUpdate);
this._sfs.addEventListener(SFSEvent.onRoomAdded,this.onRoomAdded);
this._sfs.addEventListener(SFSEvent.onCreateRoomError,this.onCreateRoomError);
this._sfs.addEventListener(SFSEvent.onRoomDeleted,this.onRoomDeleted);
this._sfs.addEventListener(SFSEvent.onUserEnterRoom,this.onUserEnterRoom);
this._sfs.addEventListener(SFSEvent.onUserLeaveRoom,this.onUserLeaveRoom);
this._sfs.addEventListener(SFSEvent.onRoomLeft,this.onRoomLeft);
this._sfs.addEventListener(SFSEvent.onUserCountChange,this.onUserCountChange);
this._sfs.addEventListener(SFSEvent.onBuddyList,this.onBuddyList);
this._sfs.addEventListener(SFSEvent.onBuddyListError,this.onBuddyListError);
this._sfs.addEventListener(SFSEvent.onBuddyListUpdate,this.onBuddyListUpdate);
this._sfs.addEventListener(SFSEvent.onBuddyPermissionRequest,this.onBuddyPermissionRequest);
this._sfs.addEventListener(SFSEvent.onBuddyRoom,this.onBuddyRoom);
this._sfs.addEventListener(SFSEvent.onAdminMessage,this.onAdminMessage);
this._sfs.addEventListener(SFSEvent.onModeratorMessage,this.onModeratorMessage);
this._sfs.addEventListener(SFSEvent.onPrivateMessage,this.onPrivateMessage);
this._sfs.addEventListener(SFSEvent.onPublicMessage,this.onPublicMessage);
this._sfs.addEventListener(SFSEvent.onRandomKey,this.onRandomKey);
}
public function setServerConfig(param1:Array, param2:int, param3:Array, param4:int, param5:String) : void
{
this._serverIps = param1;
this._serverIp = param1[0];
this._serverPort = param2;
this._blueboxIps = param3;
this._sfs.blueBoxIpAddress = param3[0];
this._sfs.blueBoxPort = param4;
this._sfs.debug = param5 == "true";
}
public function setNewServer(param1:int) : void
{
if(!this.autoAttemptHttp)
{
this._serverIp = this._serverIps[param1];
}
else
{
this._sfs.blueBoxIpAddress = this._serverIp = this._blueboxIps[param1];
}
}
public function switchServerNode(param1:String) : void
{
this._serverIp = param1;
if(this.autoAttemptHttp)
{
this._sfs.blueBoxIpAddress = this._serverIp;
}
}
public function isBlueboxMode() : Boolean
{
return this._sfs.getConnectionMode() == SmartFoxClient.CONNECTION_MODE_HTTP;
}
public function connect() : void
{
if(!this._isConnected)
{
this._sfs.connect(this._serverIp,this._serverPort);
}
else
{
this.getKey();
}
}
public function logIn(param1:String, param2:String, param3:String) : void
{
if(this._hashKey == null)
{
return;
}
this._userName = param2;
this._zone = param1;
this._isWorldZone = this._zone == "sbiLogin";
this._password = param3;
this._sfs.login(this._zone,param2,param3);
}
public function logOut() : void
{
this._sfs.logout();
}
public function disconnect() : void
{
this._isLoggedIn = false;
this._isWorldLoggedIn = false;
this._isConnected = false;
this._hashKey = null;
this._sfs.disconnect();
}
public function get serverIps() : Array
{
return this._serverIps;
}
public function get serverIp() : String
{
return this._serverIp;
}
public function get serverPort() : int
{
return this._sfs.port;
}
public function get blueboxIps() : Array
{
return this._blueboxIps;
}
public function get blueboxServerIp() : String
{
return this._sfs.blueBoxIpAddress;
}
public function get blueboxServerPort() : int
{
return this._sfs.blueBoxPort;
}
public function get isWorldXtReady() : Boolean
{
return this._isWorldLoggedIn;
}
public function triggerCmdWhenWorldXtReady(param1:String, param2:Array) : void
{
this._triggerWhenWorldXtReadyCmd = param1;
this._triggerWhenWorldXtReadyObj = param2;
}
public function triggerWorldXtReadyCmd() : void
{
if(this._triggerWhenWorldXtReadyCmd != null && this._triggerWhenWorldXtReadyObj != null)
{
this.setXtObject_Str(this._triggerWhenWorldXtReadyCmd,this._triggerWhenWorldXtReadyObj);
this._triggerWhenWorldXtReadyCmd = null;
this._triggerWhenWorldXtReadyObj = null;
}
}
public function setXtObject_Str(param1:String, param2:Array, param3:Boolean = true, param4:Boolean = false, param5:Boolean = true) : void
{
if(param2 == null)
{
param2 = [];
}
var _loc6_:String = param3 ? "o" : "a";
this._sfs.sendXtMessage(_loc6_,param1,param2,SmartFoxClient.XTMSG_TYPE_STR,this.getCurrentRoomId(param4));
if(param5)
{
KeepAlive.restartTimeLeftTimer();
}
}
public function setXtObject_XML(param1:String, param2:String, param3:Object, param4:Boolean = false) : void
{
if(param3 == null)
{
param3 = {};
}
this._sfs.sendXtMessage(param1,param2,param3,SmartFoxClient.XTMSG_TYPE_XML,this.getCurrentRoomId(param4));
}
public function setXtObject_JSON(param1:String, param2:Object, param3:Boolean = false) : void
{
if(param2 == null)
{
param2 = {};
}
this._sfs.sendXtMessage("a",param1,param2,SmartFoxClient.XTMSG_TYPE_JSON,this.getCurrentRoomId(param3));
}
public function getKey() : void
{
var _loc1_:SFEvent = null;
if(this._hashKey == null)
{
this._sfs.getRandomKey();
}
else
{
_loc1_ = new SFEvent(SFEvent.ON_CONNECT);
_loc1_.status = true;
dispatchEvent(_loc1_);
}
}
public function createRoom(param1:String, param2:uint, param3:uint, param4:Boolean, param5:Boolean, param6:String, param7:String) : void
{
throw new Error("createRoom on client should not be used if at all possible!");
}
public function setToJoinIRG(param1:Boolean) : void
{
this._currentSubRoomId = param1 ? 0 : -1;
}
public function leaveRoom(param1:int) : void
{
this._sfs.leaveRoom(param1);
}
public function leaveCurrentRoom(param1:Boolean = false) : void
{
this._sfs.leaveRoom(param1 ? this._currentSubRoomId : this._currentPrimaryRoomId);
this._currentSubRoomId = -1;
}
public function sendMessage(param1:String, param2:int = -2, param3:int = -1) : void
{
if(param3 >= 0)
{
this._sfs.sendPrivateMessage(param1,param3,param2);
}
else
{
if(param2 == -2)
{
param2 = this._currentPrimaryRoomId;
}
this._sfs.sendPublicMessage(param1,param2);
KeepAlive.restartTimeLeftTimer();
}
}
public function isInMyRoom(param1:int, param2:Boolean) : Boolean
{
if(!param2 && this._currentPrimaryRoomUsers == null)
{
return false;
}
if(param2 && this._currentSubRoomUsers == null)
{
return false;
}
return Boolean(param2 ? this._currentSubRoomUsers[param1] != undefined : this._currentPrimaryRoomUsers[param1] != undefined);
}
public function loadBuddyList() : void
{
this._sfs.loadBuddyList();
}
public function getBuddyById(param1:int) : Object
{
return this._sfs.getBuddyById(param1);
}
public function getBuddyByName(param1:String) : Object
{
return this._sfs.getBuddyByName(param1);
}
public function sendBuddyPermissionResponse(param1:Boolean, param2:String) : void
{
this._sfs.sendBuddyPermissionResponse(param1,param2);
}
public function setBuddyBlockStatus(param1:String, param2:Boolean) : void
{
this._sfs.setBuddyBlockStatus(param1,param2);
}
public function getBuddyRoomByName(param1:String) : void
{
var _loc2_:Object = this._sfs.getBuddyByName(param1);
this._sfs.getBuddyRoom(_loc2_);
}
public function getBuddyRoomById(param1:int) : void
{
var _loc2_:Object = this._sfs.getBuddyById(param1);
this._sfs.getBuddyRoom(_loc2_);
}
public function getBuddyRoom(param1:Object) : void
{
var _loc3_:Object = null;
if(!param1)
{
throw new Error("Invalid buddy obj used to request buddy room! userobj:" + param1);
}
if(!param1.hasOwnProperty("id"))
{
throw new Error("Invalid buddy obj used to request buddy room! userobj.hasOwnProperty(\"id\"):" + param1.hasOwnProperty("id"));
}
var _loc2_:Boolean = false;
for each(_loc3_ in this._sfs.buddyList)
{
if(_loc3_.id == param1.id)
{
_loc2_ = true;
break;
}
}
if(_loc2_)
{
this._sfs.getBuddyRoom(_loc3_);
return;
}
throw new Error("Invalid buddy obj used to request buddy room! Could not find match in client buddy list. userobj.id:" + param1.id);
}
public function removeBuddy(param1:String) : void
{
this._sfs.removeBuddy(param1);
}
public function getCurrentRoom(param1:Boolean = false) : SFRoom
{
return param1 ? this._currSubRoom : this._currRoom;
}
public function getCurrentRoomId(param1:Boolean = false) : int
{
if(!param1)
{
return this._currentPrimaryRoomId;
}
if(this._currentSubRoomId <= 0)
{
throw new Error("Attempt to send message to sub room without valid subRoomId! (no in-room game room currently joined?)");
}
return this._currentSubRoomId;
}
public function getPvpSubRoomId() : int
{
return this._currentSubRoomId;
}
public function setCurrSubRoomId(param1:int) : void
{
if(this._currentSubRoomId != -1)
{
DebugUtility.debugTrace("WARNING: setting currSubRoomId to " + param1 + " but _currSubRoomId was not -1. It was " + this._currentSubRoomId);
}
this._currentSubRoomId = param1;
}
public function getCurrentRoomName(param1:Boolean = false) : String
{
var _loc2_:SFRoom = this.getCurrentRoom(param1);
if(!_loc2_)
{
return null;
}
return _loc2_.name;
}
public function setInitRoom() : void
{
var _loc1_:Array = this._sfs.getAllRooms();
if(_loc1_.length > 0)
{
return;
}
_loc1_[INIT_ROOM_ID] = new Room(INIT_ROOM_ID,"_init",10000,0,false,false,false,true);
}
public function setRoomList(param1:Object) : void
{
var _loc6_:Room = null;
var _loc8_:int = 0;
var _loc2_:Array = this._sfs.getAllRooms();
_loc2_.splice(0,_loc2_.length);
var _loc3_:* = 2;
var _loc4_:int = int(param1[_loc3_++]);
var _loc5_:int = 0;
while(_loc5_ < _loc4_)
{
_loc8_ = int(param1[_loc3_++]);
_loc2_[_loc8_] = new Room(_loc8_,param1[_loc3_++],int(param1[_loc3_++]),0,param1[_loc3_++] == "1",param1[_loc3_++] == "1",false,_loc5_ < 1,int(param1[_loc3_++]));
_loc5_++;
}
this._roomIds.splice(0,this._roomIds.length);
for each(_loc6_ in _loc2_)
{
this._roomIds.push(_loc6_.getId());
}
if(this._currentPrimaryRoomId != -1)
{
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
else if(this._roomIds.length == 1)
{
this._currentPrimaryRoomId = this.roomIds[0];
}
if(this._currentSubRoomId > 0)
{
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
}
var _loc7_:SFEvent = new SFEvent(SFEvent.ON_ROOM_LIST);
_loc7_.status = true;
dispatchEvent(_loc7_);
}
public function setAPIUserList(param1:int, param2:Object) : void
{
var _loc5_:String = null;
var _loc3_:Room = this._sfs.getRoom(param1);
if(!_loc3_)
{
return;
}
var _loc4_:Array = _loc3_.getUserList();
if(!_loc4_)
{
return;
}
_loc4_.splice(0,_loc4_.length);
if(!param2)
{
return;
}
for(_loc5_ in param2)
{
_loc4_[_loc5_] = param2[_loc5_];
}
}
private function onConnection(param1:SFSEvent) : void
{
var _loc3_:SFEvent = null;
this._currentPrimaryRoomId = -1;
this._currentSubRoomId = -1;
if(ExternalInterface.available)
{
ExternalInterface.call("mrc",["dm","SFClient onConnection"]);
}
var _loc2_:Boolean = Boolean(param1.params.success);
if(_loc2_)
{
this._isConnected = true;
this.getKey();
}
else
{
_loc3_ = new SFEvent(SFEvent.ON_CONNECT);
_loc3_.status = false;
dispatchEvent(_loc3_);
}
}
private function onConnectionLost(param1:SFSEvent) : void
{
this._isConnected = false;
this._hashKey = null;
this._isLoggedIn = false;
this._isWorldLoggedIn = false;
this._currentPrimaryRoomId = -1;
this._currentSubRoomId = -1;
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CONNECTION_LOST);
_loc2_.status = true;
dispatchEvent(_loc2_);
}
private function onLogin(param1:SFSEvent) : void
{
var _loc2_:Boolean = Boolean(param1.params.success);
if(_loc2_)
{
this._isLoggedIn = true;
}
this._currentPrimaryRoomId = -1;
this._currentSubRoomId = -1;
var _loc3_:SFEvent = new SFEvent(SFEvent.ON_LOGIN);
_loc3_.status = _loc2_;
_loc3_.userName = param1.params.name;
dispatchEvent(_loc3_);
}
private function onExtensionResponse(param1:SFSEvent) : void
{
var _loc2_:Object = param1.params.dataObj;
var _loc3_:SFEvent = null;
if(_loc2_._cmd == "login")
{
if(ExternalInterface.available)
{
ExternalInterface.call("mrc",["dm","SFClient xtResponse - ON_LOGIN"]);
}
_loc3_ = new SFEvent(SFEvent.ON_LOGIN);
_loc3_.status = true;
_loc3_.obj = _loc2_.params;
this._currentPrimaryRoomId = -1;
this._currentSubRoomId = -1;
if(_loc2_.status == "1")
{
this._myUser = new User(this._sfs.myUserId = _loc2_.params.userId,this._sfs.myUserName = _loc2_.params.userName);
_loc3_.userName = _loc2_.params.userName;
this._isLoggedIn = true;
this._isWorldLoggedIn = true;
}
else
{
_loc3_.status = false;
_loc3_.message = _loc2_.message;
_loc3_.statusId = _loc2_.statusId;
}
dispatchEvent(_loc3_);
}
else
{
_loc3_ = new SFEvent(SFEvent.ON_XT_REPLY);
_loc3_.status = true;
_loc3_.obj = param1.params.dataObj;
dispatchEvent(_loc3_);
}
}
private function onLogout(param1:SFSEvent) : void
{
this._isLoggedIn = false;
this._isWorldLoggedIn = false;
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_LOGOUT);
_loc2_.status = true;
dispatchEvent(_loc2_);
}
private function onRoomListUpdate(param1:SFSEvent) : void
{
var _loc2_:Room = null;
this._roomIds.splice(0,this._roomIds.length);
for each(_loc2_ in param1.params.roomList)
{
this._roomIds.push(_loc2_.getId());
}
if(this._currentPrimaryRoomId != -1)
{
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
else if(this._roomIds.length == 1)
{
this._currentPrimaryRoomId = this.roomIds[0];
}
if(this._currentSubRoomId > 0)
{
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
}
var _loc3_:SFEvent = new SFEvent(SFEvent.ON_ROOM_LIST);
_loc3_.status = true;
dispatchEvent(_loc3_);
}
private function onRoomAdded(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_ROOM_CREATED);
_loc2_.status = true;
_loc2_.roomId = param1.params.room.getId();
dispatchEvent(_loc2_);
}
private function onRoomDeleted(param1:SFSEvent) : void
{
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_ROOM_DELETED);
_loc2_.status = true;
if(Boolean(param1) && Boolean(param1.params) && Boolean(param1.params.room))
{
_loc2_.roomId = param1.params.room.getId();
}
dispatchEvent(_loc2_);
}
private function onCreateRoomError(param1:SFSEvent) : void
{
this._currentSubRoomUsers = null;
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
this._currentSubRoomId = -1;
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_ROOM_CREATED);
_loc2_.status = false;
_loc2_.message = param1.params.error;
dispatchEvent(_loc2_);
}
public function handleRoomJoin(param1:SFRoom) : void
{
var _loc4_:Room = null;
var _loc2_:int = param1.id;
if(this._currentSubRoomId == 0)
{
this._currSubRoom = param1;
this._currentSubRoomId = _loc2_;
}
else
{
this._currRoom = param1;
this._currentPrimaryRoomId = _loc2_;
}
if(ExternalInterface.available)
{
ExternalInterface.call("mrc",["dm","handleRoomJoin called"]);
}
var _loc3_:Array = this._sfs.getAllRooms();
(_loc3_[_loc2_] = new Room(_loc2_,param1.name,param1.maxUsers,param1.maxSpectators,param1.isTemp,param1.isGame,param1.isPrivate,param1.isLimbo,param1.users,param1.spectators)).addUser(this._myUser,this._myUser.getId());
this._sfs.activeRoomId = _loc2_;
var _loc5_:SFEvent = new SFEvent(SFEvent.ON_JOIN_ROOM);
_loc5_.status = true;
_loc5_.roomId = _loc2_;
_loc5_.obj = {};
_loc5_.obj.room = param1;
_loc5_.obj.subRoom = this._currSubRoom;
dispatchEvent(_loc5_);
}
public function handleRoomJoinError(param1:String, param2:String = "") : void
{
var _loc3_:SFEvent = new SFEvent(SFEvent.ON_JOIN_ROOM);
_loc3_.status = false;
_loc3_.message = param1;
_loc3_.obj = {};
_loc3_.obj.roomFull = param1 == "This room is currently full";
_loc3_.obj.denOwner = param2;
dispatchEvent(_loc3_);
}
public function handleSubRoomExit() : void
{
if(this._currentSubRoomId <= 0)
{
throw new Error("Trying to leave a sub room when not in one?");
}
this._currentSubRoomId = -1;
this._currSubRoom = null;
}
private function onRoomLeft(param1:SFSEvent) : void
{
if(this._currentSubRoomId == 0)
{
throw new Error("Left a room while in the middle of making a sub room?!");
}
if(param1.params.roomId == this._currentSubRoomId)
{
this._currentSubRoomUsers = null;
this._currentSubRoomId = -1;
}
else
{
this._currentPrimaryRoomUsers = null;
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_LEFT_ROOM);
_loc2_.status = true;
_loc2_.roomId = param1.params.roomId;
dispatchEvent(_loc2_);
}
private function onUserEnterRoom(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_USER_ENTERED_ROOM);
_loc2_.status = true;
_loc2_.userId = param1.params.user.getId();
_loc2_.userName = param1.params.user.getName();
_loc2_.roomId = param1.params.roomId;
if(_loc2_.roomId == this._currentPrimaryRoomId)
{
this._currentPrimaryRoomUsers[_loc2_.userId] = param1.params.user;
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
else if(_loc2_.roomId == this._currentSubRoomId)
{
this._currentSubRoomUsers[_loc2_.userId] = param1.params.user;
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
}
dispatchEvent(_loc2_);
}
private function onUserLeaveRoom(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_USER_LEFT_ROOM);
_loc2_.status = true;
_loc2_.userId = param1.params.userId;
_loc2_.roomId = param1.params.roomId;
if(_loc2_.roomId == this._currentPrimaryRoomId)
{
delete this._currentPrimaryRoomUsers[_loc2_.userId];
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
else if(_loc2_.roomId == this._currentSubRoomId)
{
delete this._currentSubRoomUsers[_loc2_.userId];
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
}
dispatchEvent(_loc2_);
}
private function onUserCountChange(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_ROOM_POPULATION_CHANGE);
_loc2_.status = true;
_loc2_.roomId = param1.params.room.getId();
dispatchEvent(_loc2_);
}
private function onBuddyList(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_LIST);
_loc2_.status = true;
_loc2_.obj = param1.params.list;
_loc2_.message = param1.params.error;
dispatchEvent(_loc2_);
}
private function onBuddyListError(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_LIST);
_loc2_.status = false;
_loc2_.message = param1.params.error;
dispatchEvent(_loc2_);
}
private function onBuddyListUpdate(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_LIST_UPDATE);
_loc2_.status = true;
_loc2_.userName = param1.params.buddy.name;
_loc2_.obj = param1.params.buddy;
_loc2_.message = param1.params.error;
dispatchEvent(_loc2_);
}
private function onBuddyPermissionRequest(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_REQUEST);
_loc2_.status = true;
_loc2_.userName = param1.params.sender;
dispatchEvent(_loc2_);
}
private function onBuddyRoom(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_ROOM);
_loc2_.status = true;
_loc2_.roomId = param1.params.idList[0];
dispatchEvent(_loc2_);
}
private function onAdminMessage(param1:SFSEvent) : void
{
DebugUtility.debugTrace("onAdminMessage:" + param1.params.message);
}
private function onModeratorMessage(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CHAT_MESSAGE);
_loc2_.status = true;
_loc2_.message = param1.params.message;
dispatchEvent(_loc2_);
}
private function onPrivateMessage(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CHAT_MESSAGE);
_loc2_.status = true;
_loc2_.message = param1.params.message;
dispatchEvent(_loc2_);
}
private function onPublicMessage(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CHAT_MESSAGE);
_loc2_.status = true;
_loc2_.message = param1.params.message;
dispatchEvent(_loc2_);
}
private function onRandomKey(param1:SFSEvent) : void
{
this._hashKey = param1.params.key;
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CONNECT);
_loc2_.status = true;
dispatchEvent(_loc2_);
}
public function get autoAttemptHttp() : Boolean
{
return this._sfs.smartConnect;
}
public function set autoAttemptHttp(param1:Boolean) : void
{
this._sfs.smartConnect = param1;
}
public function get isWorldZone() : Boolean
{
return this._isWorldZone;
}
public function get userId() : int
{
return this._sfs.myUserId;
}
public function get userName() : String
{
return this._sfs.myUserName;
}
public function get gemCount() : int
{
return this._gemCount;
}
public function set gemCount(param1:int) : void
{
this._gemCount = param1;
}
public function get signInUserName() : String
{
return this._userName;
}
public function get password() : String
{
return this._password;
}
public function get roomIds() : Array
{
return this._roomIds;
}
public function get buddyList() : Array
{
return this._sfs.buddyList;
}
public function get rawProtocolSeparator() : String
{
return this._sfs.rawProtocolSeparator;
}
public function get isLoggedIn() : Boolean
{
return this._isLoggedIn;
}
public function get isConnected() : Boolean
{
return this._isConnected;
}
public function getIsConnected() : Boolean
{
return this._isConnected;
}
public function get hashKey() : String
{
return this._hashKey;
}
}
}
@@ -0,0 +1,75 @@
package com.sbi.client
{
import flash.events.Event;
public class SFEvent extends Event
{
public static const ON_CONNECT:String = "OnConnect";
public static const ON_LOGIN:String = "OnLogin";
public static const ON_LOGOUT:String = "OnLogOut";
public static const ON_CONNECTION_LOST:String = "OnConectionLost";
public static const ON_CHAT_MESSAGE:String = "OnChatMessage";
public static const ON_RECEIVED_OBJECT:String = "OnReceivedObject";
public static const ON_ROOM_LIST:String = "OnRoomList";
public static const ON_CREATE_ROOM:String = "OnCreateRoom";
public static const ON_ROOM_CREATED:String = "onRoomCreated";
public static const ON_JOIN_ROOM:String = "OnJoinRoom";
public static const ON_LEFT_ROOM:String = "OnLeftRoom";
public static const ON_USER_ENTERED_ROOM:String = "OnUserEnteredRoom";
public static const ON_USER_LEFT_ROOM:String = "OnUserLeftRoom";
public static const ON_ROOM_POPULATION_CHANGE:String = "onRoomPopulationChange";
public static const ON_BUDDY_LIST:String = "onBuddyList";
public static const ON_BUDDY_LIST_UPDATE:String = "onBuddyListUpdate";
public static const ON_BUDDY_REQUEST:String = "onBuddyRequest";
public static const ON_BUDDY_ROOM:String = "onBuddyRoom";
public static const ON_XT_REPLY:String = "OnXtReply";
public static const ON_ROOM_DELETED:String = "onRoomDeleted";
public static const ON_ROOM_VAR:String = "OnRoomVar";
public var status:Boolean;
public var message:String;
public var statusId:int;
public var userId:int;
public var roomId:int;
public var userName:String;
public var obj:*;
public function SFEvent(param1:String)
{
super(param1);
}
override public function clone() : Event
{
return new SFEvent(type);
}
}
}
@@ -0,0 +1,32 @@
package com.sbi.client
{
public class SFRoom
{
public var name:String;
public var id:int;
public var users:int;
public var maxUsers:int;
public var spectators:int;
public var maxSpectators:int;
public var isPrivate:Boolean;
public var isGame:Boolean;
public var isLimbo:Boolean;
public var isTemp:Boolean;
public function SFRoom()
{
super();
}
}
}
@@ -0,0 +1,109 @@
package com.sbi.corelib
{
import com.sbi.debug.DebugUtility;
import flash.utils.getDefinitionByName;
public class Utils
{
public function Utils()
{
super();
}
public static function getDefByName(param1:String) : Class
{
var returnClass:Class = null;
var getClassName:String = param1;
try
{
returnClass = getDefinitionByName(getClassName) as Class;
}
catch(re:ReferenceError)
{
DebugUtility.debugTrace("WARNING: Missing class definition \"" + getClassName + "\"!");
returnClass = null;
}
return returnClass;
}
public static function damerauLevenshteinDistance(param1:Array, param2:Array, param3:int) : int
{
var _loc11_:int = 0;
var _loc12_:int = 0;
var _loc13_:int = 0;
var _loc14_:int = 0;
var _loc15_:int = 0;
var _loc4_:int = param1.length + param2.length;
var _loc5_:SimpleMatrix = new SimpleMatrix(param1.length + 2,param2.length + 2);
_loc5_[0][0] = _loc4_;
var _loc6_:int = 0;
while(_loc6_ <= param1.length)
{
_loc5_[_loc6_ + 1][1] = _loc6_;
_loc5_[_loc6_ + 1][0] = _loc4_;
_loc6_++;
}
var _loc7_:int = 0;
while(_loc7_ <= param2.length)
{
_loc5_[1][_loc7_ + 1] = _loc7_;
_loc5_[0][_loc7_ + 1] = _loc4_;
_loc7_++;
}
var _loc8_:Array = new Array(param3);
var _loc9_:int = 0;
while(_loc9_ < param3)
{
_loc8_[_loc9_] = 0;
_loc9_++;
}
var _loc10_:int = 1;
while(_loc10_ <= param1.length)
{
_loc11_ = 0;
_loc12_ = 1;
while(_loc12_ <= param2.length)
{
_loc13_ = int(_loc8_[param2[_loc12_ - 1]]);
_loc14_ = _loc11_;
_loc15_ = param1[_loc10_ - 1] == param2[_loc12_ - 1] ? 0 : 1;
if(_loc15_ == 0)
{
_loc11_ = _loc12_;
}
_loc5_[_loc10_ + 1][_loc12_ + 1] = Math.min(_loc5_[_loc10_][_loc12_] + _loc15_,_loc5_[_loc10_ + 1][_loc12_] + 1,_loc5_[_loc10_][_loc12_ + 1] + 1,_loc5_[_loc13_][_loc14_] + (_loc10_ - _loc13_ - 1) + 1 + (_loc12_ - _loc14_ - 1));
_loc12_++;
}
_loc8_[param1[_loc10_ - 1]] = _loc10_;
_loc10_++;
}
return _loc5_[param1.length + 1][param2.length + 1];
}
}
}
dynamic class SimpleMatrix extends Array
{
public var rows:int;
public var cols:int;
public function SimpleMatrix(param1:int = 0, param2:int = -1)
{
super(param1);
if(param2 == -1)
{
param2 = param1;
}
var _loc3_:int = 0;
while(_loc3_ < param1)
{
this[_loc3_] = new Array(param2);
_loc3_++;
}
this.rows = param1;
this.cols = param2;
}
}
@@ -0,0 +1,358 @@
package com.sbi.corelib.audio
{
import flash.net.SharedObject;
import flash.utils.Dictionary;
public class SBAudio
{
private static var _cachedSounds:Dictionary;
private static var _sharedObj:SharedObject;
private static var _muteCallback:Function;
private static var _sounds:Array = [];
private static var _music:Array = [];
private static var _isMusicMuted:Boolean = false;
private static var _areSoundsMuted:Boolean = false;
private static var _isInitialized:Boolean = false;
public function SBAudio()
{
super();
}
public static function init(param1:Object, param2:Function) : void
{
var _loc3_:String = null;
var _loc4_:Object = null;
_cachedSounds = new Dictionary();
for(_loc3_ in param1)
{
_loc4_ = param1[_loc3_];
addCachedSound(_loc3_,_loc4_.className,_loc4_.volume);
}
_muteCallback = param2;
_isInitialized = true;
}
public static function setupSharedObject(param1:SharedObject) : void
{
if(_sharedObj == null && param1 != null)
{
_sharedObj = param1;
if(_sharedObj.data.isMusicMuted)
{
muteMusic();
}
if(_sharedObj.data.areSoundsMuted)
{
muteSounds();
}
}
}
public static function addCachedSound(param1:String, param2:Class, param3:Number = 0.3) : void
{
_cachedSounds[param1] = new SBSound(param2,false,param3);
}
public static function get isMusicMuted() : Boolean
{
return _isMusicMuted;
}
public static function get areSoundsMuted() : Boolean
{
return _areSoundsMuted;
}
public static function get isInitialized() : Boolean
{
return _isInitialized;
}
public static function addSound(param1:SBSound) : void
{
_sounds.push(param1);
}
public static function removeSound(param1:SBSound) : void
{
_sounds.splice(_sounds.indexOf(param1),1);
}
public static function addMusic(param1:Object) : void
{
_music.push(param1);
}
public static function removeMusic(param1:Object) : void
{
_music.splice(_music.indexOf(param1),1);
}
public static function playCachedSound(param1:String, param2:int = 1) : void
{
var _loc3_:SBSound = _cachedSounds[param1];
if(!_loc3_)
{
return;
}
_loc3_.play(0,param2);
}
public static function stopCachedSound(param1:String) : void
{
var _loc2_:SBSound = _cachedSounds[param1];
if(!_loc2_)
{
return;
}
_loc2_.stop();
}
public static function setVolumeAll(param1:Number) : void
{
setVolumeSounds(param1);
setVolumeMusic(param1);
}
public static function setVolumeSounds(param1:Number) : void
{
var _loc2_:SBSound = null;
for each(_loc2_ in _sounds)
{
_loc2_.volume = param1;
}
}
public static function getVolumeMusic() : Number
{
var _loc1_:Number = NaN;
var _loc2_:Object = null;
for each(_loc2_ in _music)
{
_loc1_ = Number(_loc2_.volume);
}
return _loc1_;
}
public static function setVolumeMusic(param1:Number) : void
{
var _loc2_:Object = null;
for each(_loc2_ in _music)
{
_loc2_.volume = param1;
}
}
private static function setSharedObjMusicMuted(param1:Boolean) : void
{
if(_sharedObj != null && _sharedObj.data.isMusicMuted != param1)
{
_sharedObj.data.isMusicMuted = param1;
try
{
_sharedObj.flush();
}
catch(e:Error)
{
}
}
}
private static function setSharedObjSoundsMuted(param1:Boolean) : void
{
if(_sharedObj != null && _sharedObj.data.areSoundsMuted != param1)
{
_sharedObj.data.areSoundsMuted = param1;
try
{
_sharedObj.flush();
}
catch(e:Error)
{
}
}
}
public static function toggleMuteAll() : void
{
toggleMuteSounds();
toggleMuteMusic();
_muteCallback(_isMusicMuted);
}
public static function muteAll() : void
{
muteSounds();
muteMusic();
}
public static function unmuteAll() : void
{
unmuteSounds();
unmuteMusic();
}
public static function toggleMuteSounds() : void
{
_areSoundsMuted = !_areSoundsMuted;
setSharedObjSoundsMuted(_areSoundsMuted);
}
public static function muteSounds() : void
{
_areSoundsMuted = true;
setSharedObjSoundsMuted(true);
}
public static function unmuteSounds() : void
{
_areSoundsMuted = false;
setSharedObjSoundsMuted(false);
}
public static function toggleMuteMusic() : void
{
var _loc1_:Object = null;
for each(_loc1_ in _music)
{
_loc1_.toggleMute();
}
_isMusicMuted = !_isMusicMuted;
setSharedObjMusicMuted(_isMusicMuted);
}
public static function muteMusic(param1:Boolean = true) : void
{
var _loc2_:Object = null;
for each(_loc2_ in _music)
{
_loc2_.mute();
}
if(param1)
{
_isMusicMuted = true;
setSharedObjMusicMuted(true);
}
}
public static function unmuteMusic(param1:Boolean = true) : void
{
var _loc2_:Object = null;
for each(_loc2_ in _music)
{
_loc2_.unmute();
}
if(param1)
{
_isMusicMuted = false;
setSharedObjMusicMuted(false);
}
}
public static function togglePauseAll() : void
{
togglePauseSounds();
togglePauseMusic();
}
public static function pauseAll() : void
{
pauseSounds();
pauseMusic();
}
public static function unpauseAll() : void
{
unpauseSounds();
unpauseMusic();
}
public static function togglePauseSounds() : void
{
var _loc1_:SBSound = null;
for each(_loc1_ in _sounds)
{
_loc1_.togglePause();
}
}
public static function pauseSounds() : void
{
var _loc1_:SBSound = null;
for each(_loc1_ in _sounds)
{
_loc1_.pause();
}
}
public static function unpauseSounds() : void
{
var _loc1_:SBSound = null;
for each(_loc1_ in _sounds)
{
_loc1_.unpause();
}
}
public static function togglePauseMusic() : void
{
var _loc1_:Object = null;
for each(_loc1_ in _music)
{
_loc1_.togglePause();
}
}
public static function pauseMusic() : void
{
var _loc1_:Object = null;
for each(_loc1_ in _music)
{
_loc1_.pause();
}
}
public static function unpauseMusic() : void
{
var _loc1_:Object = null;
for each(_loc1_ in _music)
{
_loc1_.unpause();
}
}
public static function stopAll() : void
{
stopSounds();
stopMusic();
}
public static function stopSounds() : void
{
var _loc1_:SBSound = null;
for each(_loc1_ in _sounds)
{
_loc1_.stop();
}
}
public static function stopMusic() : void
{
var _loc1_:Object = null;
for each(_loc1_ in _music)
{
_loc1_.stop();
}
}
}
}
@@ -0,0 +1,215 @@
package com.sbi.corelib.audio
{
import com.sbi.loader.LoaderCache;
import flash.events.IOErrorEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundLoaderContext;
import flash.media.SoundTransform;
import flash.net.URLRequest;
public class SBMusic
{
private var _hashKey:String;
private var _previouslyPlayedFilename:String;
private var _currFilename:String;
private var _previousVolume:Number;
private var _currVolume:Number;
public var paused:Boolean = false;
public var muted:Boolean = false;
public var mutedVolume:Number = 1;
public var playVolume:Number = 1;
public var s:Sound;
public var sc:SoundChannel;
public var position:Number;
public function SBMusic(param1:String, param2:Boolean = true, param3:Number = 1, param4:Number = 1000, param5:Boolean = true)
{
super();
this.playNewMusic(param1,param2,param3,param4,param5);
SBAudio.addMusic(this);
}
public function playNewMusic(param1:String, param2:Boolean = true, param3:Number = 1, param4:Number = 1000, param5:Boolean = true) : void
{
this._previouslyPlayedFilename = this._currFilename;
this._currFilename = param1;
this._previousVolume = this._currVolume;
this._currVolume = param3;
var _loc6_:URLRequest = LoaderCache.fetchCDNURLRequest("audio/" + param1);
if(this.s)
{
this.s.removeEventListener(IOErrorEvent.IO_ERROR,this.handleIOError);
this.s = null;
}
if(this.sc)
{
this.sc.stop();
this.sc = null;
}
this.s = new Sound(_loc6_,new SoundLoaderContext(param4,param5));
this.volume = param3;
if(param2)
{
this.play();
}
else
{
this.stop();
}
this.s.addEventListener(IOErrorEvent.IO_ERROR,this.handleIOError,false,0,true);
}
public function play(param1:Number = 0, param2:int = 2147483647, param3:SoundTransform = null) : void
{
if(this.s == null)
{
return;
}
this.sc = this.s.play(param1,param2,param3);
if(this.sc == null)
{
return;
}
this.setTransformVolume(this.playVolume);
}
public function get volume() : Number
{
return this.sc ? this.sc.soundTransform.volume : -1;
}
public function set volume(param1:Number) : void
{
if(this.muted)
{
this.mutedVolume = param1;
}
else
{
this.playVolume = param1;
}
if(this.sc)
{
this.setTransformVolume(param1);
}
}
public function toggleMute() : void
{
if(this.muted)
{
this.unmute();
}
else
{
this.mute();
}
}
public function mute() : void
{
if(!this.muted)
{
this.mutedVolume = this.volume;
this.volume = 0;
this.muted = true;
}
}
public function unmute() : void
{
if(this.muted)
{
this.volume = this.mutedVolume;
this.muted = false;
}
}
public function togglePause() : void
{
if(this.paused)
{
this.unpause();
}
else
{
this.pause();
}
}
public function pause() : void
{
if(Boolean(this.s) && Boolean(this.sc) && !this.paused)
{
this.position = this.sc.position;
this.sc.stop();
this.paused = true;
}
}
public function unpause() : void
{
if(Boolean(this.s) && Boolean(this.sc) && this.paused)
{
this.sc = this.s.play(this.position);
this.setTransformVolume(this.playVolume);
this.paused = false;
}
}
public function stop() : void
{
if(this.sc)
{
this.sc.stop();
}
this.paused = false;
this.muted = false;
}
public function get previouslyPlayedFilename() : String
{
return this._previouslyPlayedFilename;
}
public function get previousVolume() : Number
{
return this._previousVolume;
}
private function setTransformVolume(param1:Number) : void
{
var _loc2_:SoundTransform = this.sc.soundTransform;
_loc2_.volume = param1;
this.sc.soundTransform = _loc2_;
}
private function handleIOError(param1:IOErrorEvent) : void
{
if(this.s)
{
this.s = null;
}
if(this.sc)
{
this.sc.stop();
this.sc = null;
}
SBAudio.removeMusic(this);
}
}
}
@@ -0,0 +1,152 @@
package com.sbi.corelib.audio
{
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
public class SBSound
{
public var paused:Boolean = false;
public var playVolume:Number = 1;
public var s:Sound;
public var sc:SoundChannel;
private var _soundPlaying:Boolean;
public function SBSound(param1:Class, param2:Boolean = true, param3:Number = 1)
{
super();
this.s = new param1();
this.volume = param3;
if(param2)
{
this.play();
}
else
{
this.stop();
}
SBAudio.addSound(this);
}
public function play(param1:Number = 0, param2:int = 0, param3:SoundTransform = null) : void
{
if(param2 == -1)
{
param2 = int.MAX_VALUE;
}
if(this.s == null)
{
return;
}
this.sc = this.s.play(param1,param2,param3);
if(this.sc == null)
{
return;
}
this._soundPlaying = true;
this.sc.addEventListener(Event.SOUND_COMPLETE,this.soundStoppedHandler,false,0,true);
this.setTransformVolume(this.playVolume);
}
public function destroy() : void
{
this.stop();
this.sc = null;
this.s = null;
SBAudio.removeSound(this);
}
public function get volume() : Number
{
return this.sc ? this.sc.soundTransform.volume : -1;
}
public function set volume(param1:Number) : void
{
this.playVolume = param1;
if(this.sc)
{
this.setTransformVolume(param1);
}
}
public function get isPlaying() : Boolean
{
return this._soundPlaying;
}
public function togglePause() : void
{
if(this.paused)
{
this.unpause();
}
else
{
this.pause();
}
}
public function pause() : void
{
if(Boolean(this.sc) && !this.paused)
{
this.sc.stop();
this.paused = true;
this._soundPlaying = false;
}
}
public function unpause() : void
{
if(Boolean(this.s) && Boolean(this.sc) && this.paused)
{
this.sc = this.s.play(this.sc.position);
if(this.sc == null)
{
return;
}
this._soundPlaying = true;
this.sc.addEventListener(Event.SOUND_COMPLETE,this.soundStoppedHandler,false,0,true);
this.setTransformVolume(this.playVolume);
this.paused = false;
}
}
public function stop() : void
{
if(this.sc)
{
this.sc.stop();
}
this.paused = false;
this._soundPlaying = false;
}
private function setTransformVolume(param1:Number) : void
{
var _loc2_:SoundTransform = this.sc.soundTransform;
if(SBAudio.isMusicMuted)
{
_loc2_.volume = 0;
}
else
{
_loc2_.volume = param1;
}
this.sc.soundTransform = _loc2_;
}
private function soundStoppedHandler(param1:Event) : void
{
this._soundPlaying = false;
}
}
}
@@ -0,0 +1,36 @@
package com.sbi.corelib.crypto
{
import com.hurlant.crypto.Crypto;
import com.hurlant.crypto.hash.SHA256;
import com.hurlant.crypto.symmetric.ICipher;
import com.hurlant.crypto.symmetric.IPad;
import com.hurlant.crypto.symmetric.IVMode;
import com.hurlant.crypto.symmetric.PKCS5;
import com.hurlant.util.Base64;
import com.hurlant.util.Hex;
import flash.utils.ByteArray;
public class SBCrypto
{
public function SBCrypto()
{
super();
}
public static function encrypt(param1:String, param2:String) : String
{
var _loc3_:SHA256 = new SHA256();
var _loc4_:ByteArray = _loc3_.hash(Hex.toArray(Hex.fromString(param2)));
var _loc5_:ByteArray = Hex.toArray(Hex.fromString(param1));
var _loc6_:IPad = new PKCS5();
var _loc7_:ICipher = Crypto.getCipher("aes-256-cbc",_loc4_,_loc6_);
_loc7_.encrypt(_loc5_);
var _loc8_:IVMode = _loc7_ as IVMode;
var _loc9_:ByteArray = _loc8_.IV;
_loc9_.writeBytes(_loc5_);
return Base64.encodeByteArray(_loc9_);
}
}
}
@@ -0,0 +1,451 @@
package com.sbi.corelib.input
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.text.TextLineMetrics;
import flash.utils.setTimeout;
import gui.EmoticonUtility;
public class SBTextField extends MovieClip
{
private const CHAT_BUFFER_SIZE:int = 100;
private var _inputTxt:TextField;
private var _outputTxt:TextField;
private var _smileyHolder:MovieClip;
private var _smileyMask:MovieClip;
private var _smileyHistory:String;
private var _clearOutput:Boolean;
private var _smileyarray:Array;
private var _stringIndex:int;
private var _normalStringHistory:String;
private var _updateSizeFunction:Function;
private var updateAllEmotes:Boolean;
public function SBTextField(param1:TextField, param2:TextField, param3:MovieClip, param4:Boolean = false, param5:Boolean = false, param6:Function = null)
{
super();
this._inputTxt = param1;
this._outputTxt = param2;
this._clearOutput = param4;
this._updateSizeFunction = param6;
this._outputTxt.addEventListener(Event.SCROLL,this.scrollListener);
if(this._inputTxt)
{
this._inputTxt.text = "";
}
this._smileyHistory = "";
this._smileyarray = new Array();
this._stringIndex = 0;
this._smileyHolder = new MovieClip();
this._smileyHolder.graphics.beginFill(0,0);
this._smileyHolder.graphics.drawRect(param3.x,param3.y,param2.width,param2.height);
this._smileyHolder.graphics.endFill();
this._smileyHolder.mouseChildren = false;
this._smileyHolder.mouseEnabled = false;
if(!this._clearOutput)
{
this._smileyMask = new MovieClip();
this._smileyMask.graphics.beginFill(16777215,1);
this._smileyMask.graphics.drawRect(param3.x,param3.y,param3.width,param3.height);
this._smileyMask.graphics.endFill();
this._smileyHolder.mask = this._smileyMask;
}
if(param3.parent)
{
param3.parent.addChild(this._smileyHolder);
if(!this._clearOutput)
{
param3.parent.addChild(this._smileyMask);
}
}
else
{
param3.addChild(this._smileyHolder);
if(!this._clearOutput)
{
param3.addChild(this._smileyMask);
}
}
if(param2 == null || param3 == null)
{
throw new Error("Output Textfield and/or text display movie clip cannot be null. Output Textfield = " + param2 + " text Display MC = " + param3);
}
}
public function destroy() : void
{
}
public function trimHistory() : void
{
var _loc1_:String = this._outputTxt.text;
var _loc2_:int = _loc1_.indexOf("\r") + 1;
_loc1_ = _loc1_.substr(_loc2_);
this.clear();
this.appendText(_loc1_);
}
public function adjustSmileys(param1:Number) : void
{
this._smileyHolder.y -= param1;
}
public function get autoSize() : String
{
return this._outputTxt.autoSize;
}
public function set autoSize(param1:String) : void
{
this._outputTxt.autoSize = param1;
}
public function get text() : String
{
return this._outputTxt.text;
}
public function set text(param1:String) : void
{
if(this._clearOutput || param1 == "")
{
this.clear();
}
this.addText(param1);
}
public function get textColor() : uint
{
return this._outputTxt.textColor;
}
public function set textColor(param1:uint) : void
{
this._outputTxt.textColor = param1;
}
override public function get x() : Number
{
return this._outputTxt.x;
}
override public function set x(param1:Number) : void
{
this._outputTxt.x = param1;
}
override public function get y() : Number
{
return this._outputTxt.y;
}
override public function set y(param1:Number) : void
{
this._outputTxt.y = param1;
}
override public function get height() : Number
{
return this._outputTxt.height;
}
override public function set height(param1:Number) : void
{
this._outputTxt.height = param1;
}
override public function get width() : Number
{
return this._outputTxt.width;
}
override public function set width(param1:Number) : void
{
this._outputTxt.width = param1;
}
override public function get visible() : Boolean
{
return this._outputTxt.visible;
}
override public function set visible(param1:Boolean) : void
{
this._outputTxt.visible = param1;
}
override public function get alpha() : Number
{
return this._outputTxt.alpha;
}
override public function set alpha(param1:Number) : void
{
this._outputTxt.alpha = param1;
}
public function appendText(param1:String) : void
{
if(this._clearOutput || param1 == "")
{
this.clear();
}
this.addText(param1);
}
public function set scrollV(param1:int) : void
{
this._outputTxt.scrollV = param1;
}
public function get scrollV() : int
{
return this._outputTxt.scrollV;
}
public function get maxScrollV() : int
{
return this._outputTxt.maxScrollV;
}
public function get length() : int
{
return this._outputTxt.length;
}
public function set defaultTextFormat(param1:TextFormat) : void
{
param1.align = TextFormatAlign.LEFT;
this._outputTxt.defaultTextFormat = param1;
}
public function setTextFormat(param1:TextFormat, param2:int = -1, param3:int = -1) : void
{
param1.align = TextFormatAlign.LEFT;
this._outputTxt.setTextFormat(param1,param2,param3);
this._outputTxt.defaultTextFormat = param1;
}
public function get numLines() : int
{
return this._outputTxt.numLines;
}
public function get selectable() : Boolean
{
return this._outputTxt.selectable;
}
public function set selectable(param1:Boolean) : void
{
this._outputTxt.selectable = param1;
}
public function getTextFormat(param1:int = -1, param2:int = -1) : TextFormat
{
return this._outputTxt.getTextFormat(param1,param2);
}
private function addText(param1:String) : void
{
var _loc2_:String = null;
var _loc3_:String = null;
var _loc4_:int = 0;
var _loc5_:String = null;
var _loc6_:Boolean = false;
var _loc7_:Object = null;
var _loc8_:TextField = null;
var _loc9_:String = null;
var _loc10_:int = 0;
if(param1 != "")
{
this._normalStringHistory += param1;
_loc7_ = EmoticonUtility.formatStringForSmiley(param1,this._stringIndex,this._smileyarray,this.updateAllEmotes);
param1 = _loc7_.str;
this._stringIndex = _loc7_.stringIndex;
this._smileyarray = _loc7_.smileyArray;
this.updateAllEmotes = false;
this._outputTxt.appendText(param1);
if(this._outputTxt.scrollV + 1 >= this._outputTxt.maxScrollV)
{
this._outputTxt.scrollV = this._outputTxt.maxScrollV;
}
if(this.numLines >= this.CHAT_BUFFER_SIZE)
{
this._outputTxt.text = this._normalStringHistory;
_loc8_ = this._outputTxt;
while(_loc8_.numLines > this.CHAT_BUFFER_SIZE * 0.5)
{
_loc10_ = _loc8_.text.indexOf("\r") + 1;
_loc8_.text = _loc8_.text.substr(_loc10_);
}
_loc9_ = _loc8_.text.split("\r").join("\n");
this.updateAllEmotes = true;
this.clear();
this.text = _loc9_;
_loc8_ = null;
return;
}
setTimeout(this.setupSmileys,1000 / 24,param1);
}
}
private function setupSmileys(param1:String) : void
{
var _loc4_:int = 0;
var _loc5_:Rectangle = null;
var _loc6_:TextLineMetrics = null;
var _loc7_:MovieClip = null;
var _loc8_:Number = NaN;
var _loc2_:Number = 0;
var _loc3_:Array = [];
for(; _loc4_ < this._smileyarray.length; _loc4_++)
{
if(this._smileyarray[_loc4_] != null)
{
if(!this._smileyarray[_loc4_].added)
{
_loc5_ = this._outputTxt.getCharBoundaries(this._smileyarray[_loc4_].strindex);
if(_loc5_)
{
_loc6_ = this._outputTxt.getLineMetrics(this._outputTxt.numLines - 1);
_loc7_ = this._smileyarray[_loc4_].emoticon;
_loc7_.height = _loc6_.height;
_loc7_.scaleX = _loc7_.scaleY;
_loc8_ = _loc5_.x + _loc7_.width * 0.5;
if(_loc8_ > this._outputTxt.width)
{
_loc5_ = this._outputTxt.getCharBoundaries(this._smileyarray[_loc4_].strindex + 1);
if(!_loc5_)
{
continue;
}
_loc7_.x = _loc5_.x + this._outputTxt.x + _loc7_.width * 0.5 - 5;
_loc7_.y = _loc5_.y + this._outputTxt.y + _loc7_.height * 0.5;
}
else
{
_loc7_.x = _loc5_.x + this._outputTxt.x + _loc7_.width * 0.5;
_loc7_.y = _loc5_.y + this._outputTxt.y + _loc7_.height * 0.5;
}
this._smileyHolder.addChild(_loc7_);
this._smileyarray[_loc4_].added = true;
}
}
}
}
if(this._smileyHistory == "")
{
this._smileyHistory = param1;
}
else
{
this._smileyHistory += "\n" + param1;
}
this._smileyarray = [];
if(this._updateSizeFunction != null)
{
this._updateSizeFunction();
}
}
private function addSmileys(param1:Array) : void
{
var _loc2_:int = 0;
while(_loc2_ < param1.length)
{
this._smileyHolder.addChild(param1[_loc2_]);
_loc2_++;
}
}
private function clear() : void
{
if(this._inputTxt)
{
this._inputTxt.text = "";
}
this._smileyHolder.y = 0;
while(this._smileyHolder.numChildren > 0)
{
this._smileyHolder.removeChildAt(0);
}
this._outputTxt.text = "";
this._smileyarray = [];
this._smileyHistory = "";
this._stringIndex = 0;
this._normalStringHistory = "";
}
private function removeSpace(param1:String) : String
{
var _loc2_:int = 0;
var _loc3_:String = "";
var _loc4_:Array = param1.split("");
_loc2_ = 0;
while(_loc2_ < _loc4_.length)
{
if(_loc3_ == " ")
{
if(_loc4_[_loc2_] == " ")
{
_loc4_[_loc2_] = "";
_loc3_ = " ";
}
else
{
_loc3_ = _loc4_[_loc2_];
}
}
else
{
_loc3_ = _loc4_[_loc2_];
}
_loc2_++;
}
return _loc4_.join("");
}
private function scrollListener(param1:Event) : void
{
var _loc2_:int = 0;
var _loc3_:TextLineMetrics = null;
var _loc4_:Number = NaN;
if(!this._clearOutput)
{
_loc4_ = 0;
_loc2_ = 0;
while(_loc2_ < this._outputTxt.scrollV - 1)
{
_loc3_ = this._outputTxt.getLineMetrics(_loc2_);
_loc4_ += _loc3_.height;
_loc2_++;
}
this._smileyHolder.y = -_loc4_;
}
}
private function setSize(param1:Number, param2:Number) : void
{
this._smileyMask.width = param1;
this._smileyMask.height = param2 - 6;
}
}
}
@@ -0,0 +1,179 @@
package com.sbi.corelib.math
{
import flash.geom.Point;
public class Collision
{
public function Collision()
{
super();
}
public static function segIntersection(param1:Point, param2:Point, param3:Point, param4:Point) : Point
{
var _loc5_:Number = param2.x - param1.x;
var _loc6_:Number = param2.y - param1.y;
var _loc7_:Number = param4.x - param3.x;
var _loc8_:Number = param4.y - param3.y;
var _loc9_:Number = _loc5_ * _loc8_ - _loc6_ * _loc7_;
if(_loc9_ == 0)
{
return null;
}
var _loc10_:Number = param3.x - param1.x;
var _loc11_:Number = param3.y - param1.y;
var _loc12_:Number = (_loc10_ * _loc8_ - _loc11_ * _loc7_) / _loc9_;
if(_loc12_ < 0 || _loc12_ > 1)
{
return null;
}
var _loc13_:Number = (_loc10_ * _loc6_ - _loc11_ * _loc5_) / _loc9_;
if(_loc13_ < 0 || _loc13_ > 1)
{
return null;
}
return new Point(param1.x + _loc12_ * _loc5_,param1.y + _loc12_ * _loc6_);
}
public static function circleHitCircle(param1:Point, param2:Number, param3:Point, param4:Number) : Boolean
{
var _loc5_:Point = param3.subtract(param1);
var _loc6_:Number = _loc5_.x * _loc5_.x + _loc5_.y * _loc5_.y;
return Boolean(_loc6_ < (param2 + param4) * (param2 + param4));
}
public static function pointHitCircle(param1:Point, param2:Point, param3:Number) : Boolean
{
var _loc4_:Point = param1.subtract(param2);
var _loc5_:Number = _loc4_.x * _loc4_.x + _loc4_.y * _loc4_.y;
return Boolean(_loc5_ < param3 * param3);
}
public static function movingCircleVsRay(param1:Point, param2:Number, param3:Point, param4:Number, param5:Point, param6:Point) : Number
{
var _loc9_:Number = NaN;
var _loc15_:Number = NaN;
var _loc16_:Number = NaN;
var _loc17_:Number = NaN;
var _loc18_:Number = NaN;
var _loc19_:Number = NaN;
var _loc20_:Number = NaN;
var _loc21_:Number = NaN;
var _loc22_:Point = null;
var _loc23_:Point = null;
var _loc24_:Point = null;
var _loc7_:Point = param6.subtract(param5);
var _loc8_:Point = param1.subtract(param5);
var _loc10_:Point = new Point();
var _loc11_:Point = new Point(param3.x * param4,param3.y * param4);
var _loc12_:Number = param3.x * param3.y;
var _loc13_:Number;
var _loc14_:Number = _loc13_ = _loc11_.x * _loc7_.y - _loc11_.y * _loc7_.x;
if(_loc14_ == 0)
{
_loc9_ = _loc8_.x * _loc7_.x + _loc8_.y * _loc7_.y;
_loc10_.x = _loc8_.x - _loc7_.x * _loc9_;
_loc10_.y = _loc8_.y - _loc7_.y * _loc9_;
param4 = 0;
return _loc10_.x * _loc10_.y <= param2 ? -1 : 1;
}
_loc13_ /= _loc14_;
_loc9_ = 0;
if(_loc9_ <= param2)
{
_loc15_ = _loc8_.x * _loc7_.y - _loc8_.y * _loc7_.x;
_loc16_ = -(_loc15_ * _loc13_) / _loc14_;
_loc17_ = -(_loc13_ * _loc7_.y);
_loc18_ = _loc13_ * _loc7_.x;
_loc19_ = _loc17_ * _loc17_ + _loc18_ * _loc18_;
if(_loc19_)
{
_loc19_ = Math.sqrt(_loc19_);
_loc17_ /= _loc19_;
_loc18_ /= _loc19_;
}
_loc20_ = Math.abs(param2 / (_loc11_.x * _loc17_ + _loc11_.y * _loc18_));
if(_loc16_ < -_loc20_)
{
return -1;
}
if(_loc16_ - _loc20_ > 1)
{
return -1;
}
_loc21_ = _loc16_ - _loc20_ < 0 ? 0 : _loc16_ - _loc20_;
_loc22_ = new Point(param1.x + param3.x * _loc21_,param1.y + param3.y * _loc21_);
_loc23_ = _loc22_.subtract(param5);
_loc24_ = _loc22_.subtract(param6);
if(_loc23_.x * _loc7_.x + _loc23_.y * _loc7_.y < 0)
{
return Ray_Vs_Sphere(param1,param3,param4,param5,param2);
}
if(_loc24_.x * _loc7_.x + _loc24_.y * _loc7_.y > 0)
{
return Ray_Vs_Sphere(param1,param3,param4,param6,param2);
}
return _loc21_;
}
return -1;
}
public static function rayHitCircle(param1:Point, param2:Number, param3:Point, param4:Point) : Boolean
{
var _loc5_:Point = param1.subtract(param3);
var _loc6_:Point = param4.subtract(param3);
var _loc7_:Number = (_loc5_.x * _loc6_.x + _loc5_.y * _loc6_.y) / (_loc6_.x * _loc6_.x + _loc6_.y * _loc6_.y);
if(_loc7_ < 0)
{
_loc7_ = 0;
}
if(_loc7_ > 1)
{
_loc7_ = 1;
}
var _loc8_:Point = new Point(param3.x + _loc7_ * _loc6_.x,param3.y + _loc7_ * _loc6_.y);
var _loc9_:Point = param1.subtract(_loc8_);
var _loc10_:Number = _loc9_.x * _loc9_.x + _loc9_.y * _loc9_.y;
return Boolean(_loc10_ <= param2 * param2);
}
public static function Ray_Vs_Sphere(param1:Point, param2:Point, param3:Number, param4:Point, param5:Number) : Number
{
var _loc18_:Number = NaN;
var _loc19_:Number = NaN;
var _loc20_:Number = NaN;
var _loc21_:Point = null;
var _loc22_:Number = NaN;
var _loc23_:Number = NaN;
var _loc6_:Number = param5 * param5;
var _loc7_:Point = param4.subtract(param1);
var _loc8_:Number = _loc7_.x * _loc7_.x + _loc7_.y * _loc7_.y;
var _loc9_:Point = new Point(param2.x * param3,param2.y * param3);
var _loc10_:Point = _loc9_.add(param1);
var _loc11_:Number = _loc9_.x * _loc7_.x + _loc9_.y * _loc7_.y;
var _loc12_:Point = param4.subtract(_loc10_);
var _loc13_:Number = _loc9_.x * _loc12_.x + _loc9_.y * _loc12_.y;
var _loc14_:Number = (_loc12_.x + _loc12_.y) * (_loc12_.x + _loc12_.y);
var _loc15_:Number = _loc9_.x * _loc7_.y - _loc9_.y * _loc7_.x;
var _loc16_:Number = _loc15_ * _loc15_;
var _loc17_:Number = _loc9_.x * _loc9_.x + _loc9_.y * _loc9_.y;
if(_loc11_ > 0 && (_loc13_ < 0 || _loc14_ < _loc6_) && _loc16_ < _loc6_ * _loc17_ && _loc17_ > 0.00001)
{
_loc18_ = Math.sqrt(_loc6_ - _loc16_ / _loc17_);
_loc19_ = Math.sqrt(_loc17_);
_loc20_ = 1 / _loc19_;
_loc21_ = new Point(_loc9_.x * _loc20_,_loc9_.y * _loc20_);
_loc22_ = _loc21_.x * _loc7_.x + _loc21_.y * _loc7_.y;
_loc23_ = param3 * (_loc22_ - _loc18_) * _loc20_;
return _loc23_ < 0 ? 0 : _loc23_;
}
if(_loc8_ < _loc6_)
{
return 0;
}
return -1;
}
}
}
@@ -0,0 +1,32 @@
package com.sbi.debug
{
import com.carlcalderon.arthropod.Debug;
import flash.display.DisplayObjectContainer;
public class DebugUtility
{
public function DebugUtility()
{
super();
}
public static function debugTrace(param1:String, param2:uint = 16711422) : void
{
Debug.log(param1,param2);
}
public static function debugTraceObject(param1:String, param2:Object, param3:int = 0) : void
{
}
public static function debugTraceArray(param1:String, param2:Array, param3:Boolean = false) : void
{
}
public static function debugTraceDisplayObjectContainer(param1:String, param2:DisplayObjectContainer, param3:Boolean = false, param4:int = 0) : void
{
}
}
}
@@ -0,0 +1,466 @@
package com.sbi.graphics
{
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
public class BitmapByteArray
{
private static const PALETTE_ALPHA_OFFSET:int = 25;
private static const SHADOW_GRADIENT_SCALE:int = 3;
private const TRANS:int = 0;
private var _palette:Array;
private var _h:int;
private var _w:int;
private var _offX:int;
private var _offY:int;
private var _ba:Vector.<int>;
public function BitmapByteArray()
{
super();
this._palette = PaletteHelper.getAnimalPalette();
}
public static function scaleAndPackImage(param1:BitmapData) : Object
{
var _loc2_:BitmapByteArray = new BitmapByteArray();
_loc2_.loadBitmap(param1);
_loc2_.halfImage();
_loc2_.crop();
return _loc2_.processPackImage();
}
public static function scaleAndPackShadow(param1:BitmapData, param2:int, param3:int, param4:int, param5:int) : Object
{
var _loc6_:BitmapByteArray = new BitmapByteArray();
return _loc6_.scaleShadow(param1,param2,param3,param4,param5);
}
private function loadBitmap(param1:BitmapData) : void
{
var _loc2_:uint = 0;
var _loc3_:uint = 0;
var _loc7_:uint = 0;
this._w = param1.width;
this._h = param1.height;
this._ba = new Vector.<int>(this._w * this._h,true);
var _loc4_:uint = 0;
var _loc5_:int = -1;
var _loc6_:* = 0;
_loc3_ = 0;
while(_loc3_ < this._h)
{
_loc2_ = 0;
while(_loc2_ < this._w)
{
_loc7_ = param1.getPixel32(_loc2_,_loc3_);
if(_loc4_ != _loc7_ || _loc5_ < 0)
{
_loc4_ = _loc7_;
_loc5_ = int(this.findPaletteColor(_loc7_));
}
var _loc8_:Number;
this._ba[_loc8_ = _loc6_++] = _loc5_;
_loc2_++;
}
_loc3_++;
}
}
private function scaleShadow(param1:BitmapData, param2:int, param3:int, param4:int, param5:int) : Object
{
var _loc7_:uint = 0;
var _loc8_:uint = 0;
var _loc9_:uint = 0;
var _loc10_:uint = 0;
var _loc16_:int = 0;
var _loc17_:* = 0;
this._w = param1.width;
this._h = param1.height;
var _loc6_:Vector.<uint> = param1.getVector(new Rectangle(0,0,this._w,this._h));
var _loc11_:Vector.<int> = new Vector.<int>(this._w * this._h * 0.25,true);
var _loc12_:int = 0;
var _loc13_:* = 0;
var _loc14_:int = 0;
while(_loc14_ < this._h)
{
_loc16_ = 0;
while(_loc16_ < this._w)
{
_loc12_ = _loc16_ + _loc14_ * this._w;
_loc7_ = _loc6_[_loc12_];
_loc8_ = _loc6_[_loc12_ + 1];
_loc12_ += this._w;
_loc9_ = _loc6_[_loc12_];
_loc10_ = _loc6_[_loc12_ + 1];
var _loc18_:Number;
_loc11_[_loc18_ = _loc13_++] = this.blendShadowColors(_loc7_,_loc8_,_loc9_,_loc10_);
_loc16_ += 2;
}
_loc14_ += 2;
}
this._ba = _loc11_;
this._h /= 2;
this._w /= 2;
if(param4 != this._w || param5 != this._h)
{
_loc13_ = 0;
_loc11_ = new Vector.<int>(param4 * param5,true);
_loc14_ = param3;
while(_loc14_ < param3 + param5)
{
_loc17_ = int(_loc14_ * this._w + param2);
_loc16_ = 0;
while(_loc16_ < param4)
{
_loc12_ = this._ba[_loc17_++];
_loc11_[_loc18_ = _loc13_++] = _loc12_;
_loc16_++;
}
_loc14_++;
}
this._w = param4;
this._h = param5;
this._offX = param2;
this._offY = param3;
this._ba = _loc11_;
}
var _loc15_:Object = this.processPackImage();
_loc15_.sm = SHADOW_GRADIENT_SCALE;
return _loc15_;
}
private function halfImage() : void
{
var _loc1_:int = 0;
var _loc2_:int = 0;
var _loc3_:int = 0;
var _loc4_:int = 0;
var _loc9_:int = 0;
var _loc5_:Vector.<int> = new Vector.<int>(this._w * this._h * 0.25,true);
var _loc6_:int = 0;
var _loc7_:* = 0;
var _loc8_:int = 0;
while(_loc8_ < this._h)
{
_loc9_ = 0;
while(_loc9_ < this._w)
{
_loc6_ = _loc9_ + _loc8_ * this._w;
_loc1_ = this._ba[_loc6_];
_loc2_ = this._ba[_loc6_ + 1];
_loc6_ += this._w;
_loc3_ = this._ba[_loc6_];
_loc4_ = this._ba[_loc6_ + 1];
var _loc10_:Number;
_loc5_[_loc10_ = _loc7_++] = this.blendColors(_loc1_,_loc2_,_loc3_,_loc4_);
_loc9_ += 2;
}
_loc8_ += 2;
}
this._ba = _loc5_;
this._h /= 2;
this._w /= 2;
}
private function crop() : void
{
var _loc1_:uint = 0;
var _loc2_:int = 0;
var _loc3_:int = 0;
var _loc11_:Vector.<int> = null;
var _loc12_:* = 0;
var _loc4_:int = this._w;
var _loc5_:int = 0;
var _loc6_:int = this._h;
var _loc7_:int = 0;
var _loc8_:* = 0;
_loc3_ = 0;
while(_loc3_ < this._h)
{
_loc2_ = 0;
while(_loc2_ < this._w)
{
_loc1_ = uint(this._ba[_loc8_++]);
if(_loc1_ > 0)
{
if(_loc2_ < _loc4_)
{
_loc4_ = _loc2_;
}
if(_loc2_ > _loc5_)
{
_loc5_ = _loc2_;
}
if(_loc3_ < _loc6_)
{
_loc6_ = _loc3_;
}
if(_loc3_ > _loc7_)
{
_loc7_ = _loc3_;
}
}
_loc2_++;
}
_loc3_++;
}
this._offX = _loc4_;
this._offY = _loc6_;
var _loc9_:uint = _loc5_ - _loc4_ + 1;
var _loc10_:uint = _loc7_ - _loc6_ + 1;
if(_loc4_ == this._w && _loc6_ == this._h)
{
this._w = 0;
this._h = 0;
this._ba = null;
return;
}
_loc8_ = 0;
if(_loc9_ != this._w || _loc10_ != this._h)
{
_loc11_ = new Vector.<int>(_loc9_ * _loc10_,true);
_loc3_ = _loc6_;
while(_loc3_ < _loc6_ + _loc10_)
{
_loc12_ = int(_loc3_ * this._w + this._offX);
_loc2_ = 0;
while(_loc2_ < _loc9_)
{
_loc1_ = uint(this._ba[_loc12_++]);
var _loc13_:Number;
_loc11_[_loc13_ = _loc8_++] = _loc1_;
_loc2_++;
}
_loc3_++;
}
this._w = _loc9_;
this._h = _loc10_;
this._ba = _loc11_;
}
}
private function processPackImage() : Object
{
var _loc2_:int = 0;
var _loc3_:int = 0;
var _loc4_:String = null;
var _loc10_:uint = 0;
if(this._ba == null)
{
return null;
}
var _loc1_:Object = {
"x":this._offX,
"y":this._offY,
"w":this._w,
"h":this._h
};
var _loc5_:ByteArray = new ByteArray();
_loc1_.b = _loc5_;
var _loc6_:int = int(this._ba.length);
var _loc7_:uint = 256;
var _loc8_:uint = 0;
var _loc9_:* = 0;
while(_loc9_ < _loc6_)
{
_loc10_ = uint(this._ba[_loc9_++]);
if(_loc7_ == 256)
{
_loc7_ = _loc10_;
}
else if(_loc10_ != _loc7_)
{
if(_loc8_)
{
_loc7_ |= 128;
while(_loc8_ > 255)
{
_loc5_.writeByte(_loc7_);
_loc5_.writeByte(uint(255));
_loc8_ -= 256;
}
if(_loc8_ > 0)
{
_loc5_.writeByte(_loc7_);
_loc5_.writeByte(_loc8_);
}
else
{
_loc5_.writeByte(uint(_loc7_ & 0x7F));
}
}
else
{
_loc5_.writeByte(_loc7_);
}
_loc7_ = _loc10_;
_loc8_ = 0;
}
else
{
_loc8_++;
}
}
if(Boolean(_loc8_) || _loc6_ == 1)
{
_loc7_ |= 128;
while(_loc8_ > 255)
{
_loc5_.writeByte(_loc7_);
_loc5_.writeByte(uint(255));
_loc8_ -= 256;
}
if(_loc8_ > 0)
{
_loc5_.writeByte(_loc7_);
_loc5_.writeByte(_loc8_);
}
else
{
_loc5_.writeByte(uint(_loc7_ & 0x7F));
}
}
return _loc1_;
}
private function findPaletteColor(param1:uint) : uint
{
var _loc2_:uint = uint((param1 & 0xFF000000) >> 24);
if(_loc2_ < 160)
{
return this.TRANS;
}
param1 |= 4278190080;
var _loc3_:uint = 0;
while(_loc3_ < PALETTE_ALPHA_OFFSET)
{
if(this._palette[_loc3_] == param1)
{
return _loc3_;
}
_loc3_++;
}
var _loc4_:int = param1 >> 16 & 0xFF;
var _loc5_:int = param1 >> 8 & 0xFF;
var _loc6_:int = param1 & 0xFF;
return this.findClosetPaletteIndex(_loc4_,_loc5_,_loc6_);
}
private function findClosetPaletteIndex(param1:int, param2:int, param3:int) : int
{
var _loc6_:int = 0;
var _loc7_:int = 0;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc12_:uint = 0;
var _loc4_:int = 10000000;
var _loc5_:int = 0;
var _loc11_:uint = 0;
while(_loc11_ < PALETTE_ALPHA_OFFSET)
{
_loc12_ = uint(this._palette[_loc11_]);
_loc7_ = (_loc12_ >> 16 & 0xFF) - param1;
_loc8_ = (_loc12_ >> 8 & 0xFF) - param2;
_loc9_ = (_loc12_ & 0xFF) - param3;
_loc10_ = _loc7_ * _loc7_ + _loc8_ * _loc8_ + _loc9_ * _loc9_;
if(_loc10_ < _loc4_)
{
_loc4_ = _loc10_;
_loc5_ = int(_loc11_);
}
_loc11_++;
}
return _loc5_;
}
private function blendColors(param1:uint, param2:uint, param3:uint, param4:uint) : uint
{
var _loc5_:uint = 0;
var _loc6_:int = 0;
var _loc7_:Array = null;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc11_:int = 0;
var _loc12_:int = 0;
if(param1 == this.TRANS)
{
_loc6_++;
}
if(param2 == this.TRANS)
{
_loc6_++;
}
if(param3 == this.TRANS)
{
_loc6_++;
}
if(param4 == this.TRANS)
{
_loc6_++;
}
if(_loc6_ == 4)
{
return 0;
}
if(param1 == param2 && param1 == param3 && param1 == param4)
{
_loc5_ = param1;
}
else
{
_loc7_ = [param1,param2,param3,param4];
while(_loc12_ < 4)
{
if(_loc7_[_loc12_] != this.TRANS)
{
param1 = uint(this._palette[_loc7_[_loc12_]]);
_loc9_ += param1 >> 16 & 0xFF;
_loc10_ += param1 >> 8 & 0xFF;
_loc11_ += param1 & 0xFF;
_loc8_++;
}
_loc12_++;
}
_loc9_ /= _loc8_;
_loc10_ /= _loc8_;
_loc11_ /= _loc8_;
_loc5_ = uint(this.findClosetPaletteIndex(_loc9_,_loc10_,_loc11_));
}
return uint(_loc5_ + _loc6_ * PALETTE_ALPHA_OFFSET);
}
private function blendShadowColors(param1:uint, param2:uint, param3:uint, param4:uint) : int
{
var _loc5_:uint = ((param1 >> 24 & 0xFF) + (param2 >> 24 & 0xFF) + (param3 >> 24 & 0xFF) + (param4 >> 24 & 0xFF)) / 4;
var _loc6_:uint = ((param1 & 0xFF & 0xFF) + (param2 & 0xFF & 0xFF) + (param3 & 0xFF & 0xFF) + (param4 & 0xFF & 0xFF)) / 4;
if(_loc5_)
{
_loc6_ += (255 - _loc6_) * ((255 - _loc5_) / 255);
_loc6_ = uint(_loc6_ >> BitmapByteArray.SHADOW_GRADIENT_SCALE);
if(_loc6_ == 0)
{
_loc6_ = 1;
}
}
else
{
_loc6_ = 0;
}
return _loc6_;
}
}
}
@@ -0,0 +1,100 @@
package com.sbi.graphics
{
import flash.display.BitmapData;
import flash.utils.ByteArray;
public class ImageArray
{
public static const VERSION:uint = 117967104;
private var _frames:Array;
public function ImageArray()
{
super();
this._frames = new Array();
}
public function get length() : int
{
return this._frames.length;
}
public function release() : void
{
this._frames.splice(0,this._frames.length);
}
public function addBitmap(param1:BitmapData) : void
{
var _loc2_:Object = BitmapByteArray.scaleAndPackImage(param1);
this._frames.push(_loc2_);
}
public function attachShadow(param1:BitmapData) : void
{
var _loc2_:Object = null;
var _loc3_:Object = null;
if(this._frames.length)
{
_loc2_ = this._frames[this._frames.length - 1];
_loc3_ = BitmapByteArray.scaleAndPackShadow(param1,_loc2_.x,_loc2_.y,_loc2_.w,_loc2_.h);
_loc2_.s = _loc3_.b;
_loc2_.sm = _loc3_.sm;
}
}
public function addFrame(param1:Object) : void
{
this._frames.push(param1);
}
public function loadPackage(param1:ByteArray) : void
{
this.release();
param1.position = 0;
try
{
param1.uncompress();
}
catch(err:Error)
{
}
var _loc2_:Object = param1.readObject();
if(_loc2_.v == ImageArray.VERSION)
{
this._frames = _loc2_.f;
return;
}
}
public function getFrame(param1:int) : Object
{
return this._frames[param1];
}
public function getPackage(param1:Boolean = true) : ByteArray
{
var _loc2_:int = 0;
var _loc3_:ByteArray = null;
var _loc4_:Object = null;
if(this._frames.length)
{
_loc4_ = {
"v":ImageArray.VERSION,
"f":this._frames
};
_loc3_ = new ByteArray();
_loc3_.writeObject(_loc4_);
_loc3_.position = 0;
if(param1)
{
_loc3_.compress();
}
}
return _loc3_;
}
}
}
@@ -0,0 +1,32 @@
package com.sbi.graphics
{
public class ImageArrayHelper
{
public function ImageArrayHelper()
{
super();
}
public static function packId(param1:int, param2:int, param3:int) : uint
{
return param1 << 24 | param2 << 16 | param3;
}
public static function avatarId(param1:uint) : int
{
return param1 >> 24 & 0xFF;
}
public static function categoryId(param1:uint) : int
{
return param1 >> 16 & 0xFF;
}
public static function layerId(param1:uint) : int
{
return param1 & 0xFFFF;
}
}
}
@@ -0,0 +1,20 @@
package com.sbi.graphics
{
import flash.events.Event;
import flash.utils.ByteArray;
public class JPEGAsyncCompleteEvent extends Event
{
public static const JPEGASYNC_COMPLETE:String = "JPEGAsyncComplete";
public var ImageData:ByteArray;
public function JPEGAsyncCompleteEvent(param1:ByteArray)
{
this.ImageData = param1;
super(JPEGASYNC_COMPLETE);
}
}
}
@@ -0,0 +1,756 @@
package com.sbi.graphics
{
import flash.display.BitmapData;
import flash.events.EventDispatcher;
import flash.events.ProgressEvent;
import flash.utils.ByteArray;
import flash.utils.setTimeout;
public class JpegAsynchEncoder extends EventDispatcher
{
public static const CONTENT_TYPE:String = "image/jpeg";
private var ZigZag:Array = [0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63];
private var std_dc_luminance_nrcodes:Array = [0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0];
private var std_dc_luminance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11];
private var std_ac_luminance_nrcodes:Array = [0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125];
private var std_ac_luminance_values:Array = [1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250];
private var std_dc_chrominance_nrcodes:Array = [0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0];
private var std_dc_chrominance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11];
private var std_ac_chrominance_nrcodes:Array = [0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119];
private var std_ac_chrominance_values:Array = [0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];
private var YTable:Array = new Array(64);
private var UVTable:Array = new Array(64);
private var fdtbl_Y:Array = new Array(64);
private var fdtbl_UV:Array = new Array(64);
private var YDC_HT:Array;
private var UVDC_HT:Array;
private var YAC_HT:Array;
private var UVAC_HT:Array;
private var YDU:Array = new Array(64);
private var UDU:Array = new Array(64);
private var VDU:Array = new Array(64);
private var DU:Array = new Array(64);
private var bitcode:Array = new Array(65535);
private var category:Array = new Array(65535);
private var byteout:ByteArray;
private var bytenew:int = 0;
private var bytepos:int = 7;
private var DCY:Number = 0;
private var DCU:Number = 0;
private var DCV:Number = 0;
private var SrcWidth:int = 0;
private var SrcHeight:int = 0;
private var Source:Object = null;
private var TotalSize:int = 0;
private var PixelsPerIter:int = 128;
private var PercentageInc:int = 0;
private var NextProgressAt:int = 0;
private var CurrentTotalPos:int = 0;
private var Working:Boolean = false;
public function JpegAsynchEncoder()
{
super();
}
public function JPEGAsyncEncoder(param1:Number = 50) : void
{
if(param1 <= 0)
{
param1 = 1;
}
if(param1 > 100)
{
param1 = 100;
}
var _loc2_:int = 0;
if(param1 < 50)
{
_loc2_ = int(5000 / param1);
}
else
{
_loc2_ = int(200 - param1 * 2);
}
this.initHuffmanTbl();
this.initCategoryNumber();
this.initQuantTables(_loc2_);
}
public function get contentType() : String
{
return CONTENT_TYPE;
}
public function get PixelsPerIteration() : int
{
return this.PixelsPerIter;
}
public function set PixelsPerIteration(param1:int) : void
{
this.PixelsPerIter = param1;
}
public function get ImageData() : ByteArray
{
return this.byteout;
}
public function encodeByteArray(param1:ByteArray, param2:int, param3:int) : Boolean
{
return this.internalEncode(param1,param2,param3);
}
public function encode(param1:BitmapData) : Boolean
{
return this.internalEncode(param1,param1.width,param1.height);
}
private function internalEncode(param1:Object, param2:int, param3:int) : Boolean
{
if(this.Working)
{
return false;
}
this.Working = true;
this.Source = param1;
this.SrcWidth = param2;
this.SrcHeight = param3;
this.TotalSize = param2 * param3;
this.PercentageInc = this.TotalSize / 100;
this.NextProgressAt = this.PercentageInc;
this.CurrentTotalPos = 0;
setTimeout(this.StartEncode,10);
return true;
}
private function StartEncode() : void
{
this.byteout = new ByteArray();
this.bytenew = 0;
this.bytepos = 7;
this.writeWord(65496);
this.writeAPP0();
this.writeDQT();
this.writeSOF0(this.SrcWidth,this.SrcHeight);
this.writeDHT();
this.writeSOS();
this.DCY = 0;
this.DCV = 0;
this.DCU = 0;
this.bytenew = 0;
this.bytepos = 7;
this.dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS,false,false,0,this.TotalSize));
setTimeout(this.AsyncLoop,10,0,0);
}
private function AsyncLoop(param1:int, param2:int) : void
{
var _loc3_:int = 0;
while(_loc3_ < this.PixelsPerIter)
{
this.RGB2YUV(this.Source,param1,param2,this.SrcWidth,this.SrcHeight);
this.DCY = this.processDU(this.YDU,this.fdtbl_Y,this.DCY,this.YDC_HT,this.YAC_HT);
this.DCU = this.processDU(this.UDU,this.fdtbl_UV,this.DCU,this.UVDC_HT,this.UVAC_HT);
this.DCV = this.processDU(this.VDU,this.fdtbl_UV,this.DCV,this.UVDC_HT,this.UVAC_HT);
param1 += 8;
if(param1 >= this.SrcWidth)
{
param1 = 0;
param2 += 8;
}
if(param2 >= this.SrcHeight)
{
setTimeout(this.FinishEncode,10);
return;
}
this.CurrentTotalPos += 64;
if(this.CurrentTotalPos >= this.NextProgressAt)
{
this.dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS,false,false,this.CurrentTotalPos,this.TotalSize));
this.NextProgressAt += this.PercentageInc;
}
_loc3_++;
}
setTimeout(this.AsyncLoop,10,param1,param2);
}
private function FinishEncode() : void
{
var _loc1_:BitString = null;
if(this.bytepos >= 0)
{
_loc1_ = new BitString();
_loc1_.len = this.bytepos + 1;
_loc1_.val = (1 << this.bytepos + 1) - 1;
this.writeBits(_loc1_);
}
this.writeWord(65497);
this.dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS,false,false,this.TotalSize,this.TotalSize));
this.dispatchEvent(new JPEGAsyncCompleteEvent(this.byteout));
this.Working = false;
}
private function initQuantTables(param1:int) : void
{
var _loc3_:Number = NaN;
var _loc8_:int = 0;
var _loc2_:int = 0;
var _loc4_:Array = [16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99];
_loc2_ = 0;
while(_loc2_ < 64)
{
_loc3_ = Math.floor((_loc4_[_loc2_] * param1 + 50) / 100);
if(_loc3_ < 1)
{
_loc3_ = 1;
}
else if(_loc3_ > 255)
{
_loc3_ = 255;
}
this.YTable[this.ZigZag[_loc2_]] = _loc3_;
_loc2_++;
}
var _loc5_:Array = [17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99];
_loc2_ = 0;
while(_loc2_ < 64)
{
_loc3_ = Math.floor((_loc5_[_loc2_] * param1 + 50) / 100);
if(_loc3_ < 1)
{
_loc3_ = 1;
}
else if(_loc3_ > 255)
{
_loc3_ = 255;
}
this.UVTable[this.ZigZag[_loc2_]] = _loc3_;
_loc2_++;
}
var _loc6_:Array = [1,1.387039845,1.306562965,1.175875602,1,0.785694958,0.5411961,0.275899379];
_loc2_ = 0;
var _loc7_:int = 0;
while(_loc7_ < 8)
{
_loc8_ = 0;
while(_loc8_ < 8)
{
this.fdtbl_Y[_loc2_] = 1 / (this.YTable[this.ZigZag[_loc2_]] * _loc6_[_loc7_] * _loc6_[_loc8_] * 8);
this.fdtbl_UV[_loc2_] = 1 / (this.UVTable[this.ZigZag[_loc2_]] * _loc6_[_loc7_] * _loc6_[_loc8_] * 8);
_loc2_++;
_loc8_++;
}
_loc7_++;
}
}
private function computeHuffmanTbl(param1:Array, param2:Array) : Array
{
var _loc7_:int = 0;
var _loc3_:int = 0;
var _loc4_:int = 0;
var _loc5_:Array = new Array();
var _loc6_:int = 1;
while(_loc6_ <= 16)
{
_loc7_ = 1;
while(_loc7_ <= param1[_loc6_])
{
_loc5_[param2[_loc4_]] = new BitString();
_loc5_[param2[_loc4_]].val = _loc3_;
_loc5_[param2[_loc4_]].len = _loc6_;
_loc4_++;
_loc3_++;
_loc7_++;
}
_loc3_ *= 2;
_loc6_++;
}
return _loc5_;
}
private function initHuffmanTbl() : void
{
this.YDC_HT = this.computeHuffmanTbl(this.std_dc_luminance_nrcodes,this.std_dc_luminance_values);
this.UVDC_HT = this.computeHuffmanTbl(this.std_dc_chrominance_nrcodes,this.std_dc_chrominance_values);
this.YAC_HT = this.computeHuffmanTbl(this.std_ac_luminance_nrcodes,this.std_ac_luminance_values);
this.UVAC_HT = this.computeHuffmanTbl(this.std_ac_chrominance_nrcodes,this.std_ac_chrominance_values);
}
private function initCategoryNumber() : void
{
var _loc1_:int = 0;
var _loc2_:int = 1;
var _loc3_:int = 2;
var _loc4_:int = 1;
while(_loc4_ <= 15)
{
_loc1_ = _loc2_;
while(_loc1_ < _loc3_)
{
this.category[32767 + _loc1_] = _loc4_;
this.bitcode[32767 + _loc1_] = new BitString();
this.bitcode[32767 + _loc1_].len = _loc4_;
this.bitcode[32767 + _loc1_].val = _loc1_;
_loc1_++;
}
_loc1_ = -(_loc3_ - 1);
while(_loc1_ <= -_loc2_)
{
this.category[32767 + _loc1_] = _loc4_;
this.bitcode[32767 + _loc1_] = new BitString();
this.bitcode[32767 + _loc1_].len = _loc4_;
this.bitcode[32767 + _loc1_].val = _loc3_ - 1 + _loc1_;
_loc1_++;
}
_loc2_ <<= 1;
_loc3_ <<= 1;
_loc4_++;
}
}
private function writeBits(param1:BitString) : void
{
var _loc2_:int = param1.val;
var _loc3_:* = int(param1.len - 1);
while(_loc3_ >= 0)
{
if(_loc2_ & uint(1 << _loc3_))
{
this.bytenew |= uint(1 << this.bytepos);
}
_loc3_--;
--this.bytepos;
if(this.bytepos < 0)
{
if(this.bytenew == 255)
{
this.writeByte(255);
this.writeByte(0);
}
else
{
this.writeByte(this.bytenew);
}
this.bytepos = 7;
this.bytenew = 0;
}
}
}
private function writeByte(param1:int) : void
{
this.byteout.writeByte(param1);
}
private function writeWord(param1:int) : void
{
this.writeByte(param1 >> 8 & 0xFF);
this.writeByte(param1 & 0xFF);
}
private function fDCTQuant(param1:Array, param2:Array) : Array
{
var _loc4_:int = 0;
var _loc5_:Number = NaN;
var _loc6_:Number = NaN;
var _loc7_:Number = NaN;
var _loc8_:Number = NaN;
var _loc9_:Number = NaN;
var _loc10_:Number = NaN;
var _loc11_:Number = NaN;
var _loc12_:Number = NaN;
var _loc13_:Number = NaN;
var _loc14_:Number = NaN;
var _loc15_:Number = NaN;
var _loc16_:Number = NaN;
var _loc17_:Number = NaN;
var _loc18_:Number = NaN;
var _loc19_:Number = NaN;
var _loc20_:Number = NaN;
var _loc21_:Number = NaN;
var _loc22_:Number = NaN;
var _loc23_:Number = NaN;
var _loc3_:int = 0;
_loc4_ = 0;
while(_loc4_ < 8)
{
_loc5_ = param1[_loc3_ + 0] + param1[_loc3_ + 7];
_loc6_ = param1[_loc3_ + 0] - param1[_loc3_ + 7];
_loc7_ = param1[_loc3_ + 1] + param1[_loc3_ + 6];
_loc8_ = param1[_loc3_ + 1] - param1[_loc3_ + 6];
_loc9_ = param1[_loc3_ + 2] + param1[_loc3_ + 5];
_loc10_ = param1[_loc3_ + 2] - param1[_loc3_ + 5];
_loc11_ = param1[_loc3_ + 3] + param1[_loc3_ + 4];
_loc12_ = param1[_loc3_ + 3] - param1[_loc3_ + 4];
_loc13_ = _loc5_ + _loc11_;
_loc14_ = _loc5_ - _loc11_;
_loc15_ = _loc7_ + _loc9_;
_loc16_ = _loc7_ - _loc9_;
param1[_loc3_ + 0] = _loc13_ + _loc15_;
param1[_loc3_ + 4] = _loc13_ - _loc15_;
_loc17_ = (_loc16_ + _loc14_) * 0.707106781;
param1[_loc3_ + 2] = _loc14_ + _loc17_;
param1[_loc3_ + 6] = _loc14_ - _loc17_;
_loc13_ = _loc12_ + _loc10_;
_loc15_ = _loc10_ + _loc8_;
_loc16_ = _loc8_ + _loc6_;
_loc18_ = (_loc13_ - _loc16_) * 0.382683433;
_loc19_ = 0.5411961 * _loc13_ + _loc18_;
_loc20_ = 1.306562965 * _loc16_ + _loc18_;
_loc21_ = _loc15_ * 0.707106781;
_loc22_ = _loc6_ + _loc21_;
_loc23_ = _loc6_ - _loc21_;
param1[_loc3_ + 5] = _loc23_ + _loc19_;
param1[_loc3_ + 3] = _loc23_ - _loc19_;
param1[_loc3_ + 1] = _loc22_ + _loc20_;
param1[_loc3_ + 7] = _loc22_ - _loc20_;
_loc3_ += 8;
_loc4_++;
}
_loc3_ = 0;
_loc4_ = 0;
while(_loc4_ < 8)
{
_loc5_ = param1[_loc3_ + 0] + param1[_loc3_ + 56];
_loc6_ = param1[_loc3_ + 0] - param1[_loc3_ + 56];
_loc7_ = param1[_loc3_ + 8] + param1[_loc3_ + 48];
_loc8_ = param1[_loc3_ + 8] - param1[_loc3_ + 48];
_loc9_ = param1[_loc3_ + 16] + param1[_loc3_ + 40];
_loc10_ = param1[_loc3_ + 16] - param1[_loc3_ + 40];
_loc11_ = param1[_loc3_ + 24] + param1[_loc3_ + 32];
_loc12_ = param1[_loc3_ + 24] - param1[_loc3_ + 32];
_loc13_ = _loc5_ + _loc11_;
_loc14_ = _loc5_ - _loc11_;
_loc15_ = _loc7_ + _loc9_;
_loc16_ = _loc7_ - _loc9_;
param1[_loc3_ + 0] = _loc13_ + _loc15_;
param1[_loc3_ + 32] = _loc13_ - _loc15_;
_loc17_ = (_loc16_ + _loc14_) * 0.707106781;
param1[_loc3_ + 16] = _loc14_ + _loc17_;
param1[_loc3_ + 48] = _loc14_ - _loc17_;
_loc13_ = _loc12_ + _loc10_;
_loc15_ = _loc10_ + _loc8_;
_loc16_ = _loc8_ + _loc6_;
_loc18_ = (_loc13_ - _loc16_) * 0.382683433;
_loc19_ = 0.5411961 * _loc13_ + _loc18_;
_loc20_ = 1.306562965 * _loc16_ + _loc18_;
_loc21_ = _loc15_ * 0.707106781;
_loc22_ = _loc6_ + _loc21_;
_loc23_ = _loc6_ - _loc21_;
param1[_loc3_ + 40] = _loc23_ + _loc19_;
param1[_loc3_ + 24] = _loc23_ - _loc19_;
param1[_loc3_ + 8] = _loc22_ + _loc20_;
param1[_loc3_ + 56] = _loc22_ - _loc20_;
_loc3_++;
_loc4_++;
}
_loc4_ = 0;
while(_loc4_ < 64)
{
param1[_loc4_] = Math.round(param1[_loc4_] * param2[_loc4_]);
_loc4_++;
}
return param1;
}
private function writeAPP0() : void
{
this.writeWord(65504);
this.writeWord(16);
this.writeByte(74);
this.writeByte(70);
this.writeByte(73);
this.writeByte(70);
this.writeByte(0);
this.writeByte(1);
this.writeByte(1);
this.writeByte(0);
this.writeWord(1);
this.writeWord(1);
this.writeByte(0);
this.writeByte(0);
}
private function writeSOF0(param1:int, param2:int) : void
{
this.writeWord(65472);
this.writeWord(17);
this.writeByte(8);
this.writeWord(param2);
this.writeWord(param1);
this.writeByte(3);
this.writeByte(1);
this.writeByte(17);
this.writeByte(0);
this.writeByte(2);
this.writeByte(17);
this.writeByte(1);
this.writeByte(3);
this.writeByte(17);
this.writeByte(1);
}
private function writeDQT() : void
{
var _loc1_:int = 0;
this.writeWord(65499);
this.writeWord(132);
this.writeByte(0);
_loc1_ = 0;
while(_loc1_ < 64)
{
this.writeByte(this.YTable[_loc1_]);
_loc1_++;
}
this.writeByte(1);
_loc1_ = 0;
while(_loc1_ < 64)
{
this.writeByte(this.UVTable[_loc1_]);
_loc1_++;
}
}
private function writeDHT() : void
{
var _loc1_:int = 0;
this.writeWord(65476);
this.writeWord(418);
this.writeByte(0);
_loc1_ = 0;
while(_loc1_ < 16)
{
this.writeByte(this.std_dc_luminance_nrcodes[_loc1_ + 1]);
_loc1_++;
}
_loc1_ = 0;
while(_loc1_ <= 11)
{
this.writeByte(this.std_dc_luminance_values[_loc1_]);
_loc1_++;
}
this.writeByte(16);
_loc1_ = 0;
while(_loc1_ < 16)
{
this.writeByte(this.std_ac_luminance_nrcodes[_loc1_ + 1]);
_loc1_++;
}
_loc1_ = 0;
while(_loc1_ <= 161)
{
this.writeByte(this.std_ac_luminance_values[_loc1_]);
_loc1_++;
}
this.writeByte(1);
_loc1_ = 0;
while(_loc1_ < 16)
{
this.writeByte(this.std_dc_chrominance_nrcodes[_loc1_ + 1]);
_loc1_++;
}
_loc1_ = 0;
while(_loc1_ <= 11)
{
this.writeByte(this.std_dc_chrominance_values[_loc1_]);
_loc1_++;
}
this.writeByte(17);
_loc1_ = 0;
while(_loc1_ < 16)
{
this.writeByte(this.std_ac_chrominance_nrcodes[_loc1_ + 1]);
_loc1_++;
}
_loc1_ = 0;
while(_loc1_ <= 161)
{
this.writeByte(this.std_ac_chrominance_values[_loc1_]);
_loc1_++;
}
}
private function writeSOS() : void
{
this.writeWord(65498);
this.writeWord(12);
this.writeByte(3);
this.writeByte(1);
this.writeByte(0);
this.writeByte(2);
this.writeByte(17);
this.writeByte(3);
this.writeByte(17);
this.writeByte(0);
this.writeByte(63);
this.writeByte(0);
}
private function processDU(param1:Array, param2:Array, param3:Number, param4:Array, param5:Array) : Number
{
var _loc8_:int = 0;
var _loc12_:int = 0;
var _loc13_:int = 0;
var _loc14_:int = 0;
var _loc6_:BitString = param5[0];
var _loc7_:BitString = param5[240];
var _loc9_:Array = this.fDCTQuant(param1,param2);
_loc8_ = 0;
while(_loc8_ < 64)
{
this.DU[this.ZigZag[_loc8_]] = _loc9_[_loc8_];
_loc8_++;
}
var _loc10_:int = this.DU[0] - param3;
param3 = Number(this.DU[0]);
if(_loc10_ == 0)
{
this.writeBits(param4[0]);
}
else
{
this.writeBits(param4[this.category[32767 + _loc10_]]);
this.writeBits(this.bitcode[32767 + _loc10_]);
}
var _loc11_:* = 63;
while(_loc11_ > 0 && this.DU[_loc11_] == 0)
{
_loc11_--;
}
if(_loc11_ == 0)
{
this.writeBits(_loc6_);
return param3;
}
_loc8_ = 1;
while(_loc8_ <= _loc11_)
{
_loc12_ = _loc8_;
while(this.DU[_loc8_] == 0 && _loc8_ <= _loc11_)
{
_loc8_++;
}
_loc13_ = _loc8_ - _loc12_;
if(_loc13_ >= 16)
{
_loc14_ = 1;
while(_loc14_ <= _loc13_ / 16)
{
this.writeBits(_loc7_);
_loc14_++;
}
_loc13_ = int(_loc13_ & 0x0F);
}
this.writeBits(param5[_loc13_ * 16 + this.category[32767 + this.DU[_loc8_]]]);
this.writeBits(this.bitcode[32767 + this.DU[_loc8_]]);
_loc8_++;
}
if(_loc11_ != 63)
{
this.writeBits(_loc6_);
}
return param3;
}
private function RGB2YUV(param1:Object, param2:int, param3:int, param4:int = 0, param5:int = 0) : void
{
var _loc8_:int = 0;
var _loc9_:uint = 0;
var _loc10_:Number = NaN;
var _loc11_:Number = NaN;
var _loc12_:Number = NaN;
var _loc6_:int = 0;
var _loc7_:int = 0;
while(_loc7_ < 8)
{
_loc8_ = 0;
while(_loc8_ < 8)
{
_loc9_ = this.getPixel32(param1,param2 + _loc8_,param3 + _loc7_,param4,param5);
_loc10_ = Number(_loc9_ >> 16 & 0xFF);
_loc11_ = Number(_loc9_ >> 8 & 0xFF);
_loc12_ = Number(_loc9_ & 0xFF);
this.YDU[_loc6_] = 0.299 * _loc10_ + 0.587 * _loc11_ + 0.114 * _loc12_ - 128;
this.UDU[_loc6_] = -0.16874 * _loc10_ + -0.33126 * _loc11_ + 0.5 * _loc12_;
this.VDU[_loc6_] = 0.5 * _loc10_ + -0.41869 * _loc11_ + -0.08131 * _loc12_;
_loc6_++;
_loc8_++;
}
_loc7_++;
}
}
private function getPixel32(param1:Object, param2:int, param3:int, param4:int = 0, param5:int = 0) : uint
{
var _loc6_:BitmapData = null;
var _loc7_:ByteArray = null;
if(param1 is BitmapData)
{
_loc6_ = param1 as BitmapData;
return _loc6_.getPixel32(param2,param3);
}
if(param1 is ByteArray)
{
_loc7_ = param1 as ByteArray;
_loc7_.position = param3 * param4 * 4 + param2 * 4;
return _loc7_.readUnsignedInt();
}
throw new ArgumentError("The source argument must be an instance of flash.display.BitmapData or flash.utils.ByteArray.");
}
}
}
class BitString
{
public var len:int = 0;
public var val:int = 0;
public function BitString()
{
super();
}
}
@@ -0,0 +1,700 @@
package com.sbi.graphics
{
import com.sbi.loader.ImageServerEvent;
import com.sbi.loader.ImageServerURL;
import flash.display.DisplayObjectContainer;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
public class LayerAnim
{
private static var _activePool:Array;
private static var _freePool:Array;
private static var _avOffsets:Array;
private static var _lastEntry:int;
private static var _useMaxThrottle:Function;
public static const PLAY_LOOP:int = 0;
public static const PLAY_ONE_SHOT:int = 1;
public static const PLAY_LOOP__KEEP_CURRENT_FRAME:int = 2;
public static const AN_SIT_NNE:int = 1;
public static const AN_SIT_NE:int = 2;
public static const AN_SIT_E:int = 3;
public static const AN_SIT_SE:int = 4;
public static const AN_SIT_SSE:int = 5;
public static const AN_MOVE_NNE:int = 7;
public static const AN_MOVE_NE:int = 8;
public static const AN_MOVE_E:int = 9;
public static const AN_MOVE_SE:int = 10;
public static const AN_MOVE_SSE:int = 11;
public static const AN_BBCARD:int = 13;
public static const AN_IDLE_SE:int = 14;
public static const AN_HUD_AVT:int = 15;
public static const AN_IDLE_NE:int = 16;
public static const AN_HOP:int = 17;
public static const AN_SLEEP:int = 22;
public static const AN_DANCE:int = 23;
public static const AN_PLAY:int = 6;
public static const AN_SWIM_N:int = 36;
public static const AN_SWIM_NE:int = 34;
public static const AN_SWIM_E:int = 29;
public static const AN_SWIM_SE:int = 35;
public static const AN_SWIM_S:int = 37;
public static const AN_FLOAT:int = 32;
public static const AN_WATER_DIVE:int = 41;
public static const AN_WATER_PLAY:int = 39;
public static const AN_WATER_SPIN:int = 33;
public static const AN_WATER_JIG:int = 38;
public static const AN_WATER_POSE:int = 40;
public static const AN_PHOTO:int = 42;
public static const AN_PARACHUTE_IDLE:int = 19;
public static const AN_PARACHUTE_JUMP:int = 24;
public static const AN_PARACHUTE_DISTRESS:int = 20;
public static const AN_PARACHUTE_LAND:int = 21;
public static const AN_WINDRIDER_JUMP:int = 28;
public static const AN_WINDRIDER_IDLE:int = 29;
public static const AN_WINDRIDER_FALL:int = 30;
public static const AN_WINDRIDER_START:int = 31;
public static const AN_WINDRIDER_DISTRESS:int = 20;
public static const AVATAR_BITMAP_OFFSET_X:int = 375;
public static const AVATAR_BITMAP_OFFSET_Y:int = 365;
private static var _throttle:int = 8;
private var _bitmap:LayerBitmap;
private var _avDefId:int;
private var _animId:int;
private var _frame:int;
private var _hFlip:Boolean;
private var _totalFrames:int;
private var _x:int;
private var _y:int;
private var _rotation:int;
private var _xOff:int;
private var _yOff:int;
private var _bPause:Boolean;
private var _layers:Array;
private var _colors:Array;
private var _callback:Function;
private var _mode:int;
private var _tStep:int;
private var _bRedraw:Boolean;
private var _bReload:Boolean;
private var _bBaseLayer:Boolean;
private var _bNewAnim:Boolean;
private var _requestAnimId:int;
private var _receivedData:Array;
private var _requestedIds:Array;
private var _requestCallback:Function;
private var _requestMode:int;
private var _preloadRequestedIds:Array;
private var _preloadCallback:Function;
public function LayerAnim(param1:Class)
{
super();
if(param1 != SingletonLock)
{
throw new Error("Invalid access. Use LayerAnim.getNew");
}
this._requestedIds = new Array();
this._colors = new Array();
}
public static function set avOffsets(param1:Array) : void
{
_avOffsets = param1;
}
public static function getAvOffset(param1:int) : Point
{
if(_avOffsets[param1])
{
return _avOffsets[param1];
}
return new Point(-100,-100);
}
public static function set throttle(param1:int) : void
{
_throttle = param1;
}
public static function getNew() : LayerAnim
{
var _loc1_:LayerAnim = null;
if(!_activePool)
{
_activePool = new Array();
_freePool = new Array();
}
if(_freePool.length)
{
_loc1_ = _freePool.pop();
}
else
{
_loc1_ = new LayerAnim(SingletonLock);
}
_activePool.push(_loc1_);
_loc1_.init();
return _loc1_;
}
public static function destroy(param1:LayerAnim) : void
{
var _loc2_:int = _activePool.indexOf(param1);
if(_loc2_ >= 0)
{
_activePool.splice(_loc2_,1);
param1.destroy();
_freePool.push(param1);
}
}
public static function heartbeat() : void
{
var _loc1_:int = 0;
var _loc2_:* = 0;
var _loc3_:* = 0;
var _loc4_:* = 0;
var _loc5_:LayerAnim = null;
var _loc6_:int = 0;
if(Boolean(_activePool) && Boolean(_activePool.length))
{
_loc1_ = int(_activePool.length);
_loc2_ = _loc1_;
_loc3_ = int(_loc1_ * 0.5);
if(_loc3_ < 1 || Boolean(_useMaxThrottle) && Boolean(_useMaxThrottle()))
{
_loc3_ = 1;
}
if(_loc3_ > _throttle)
{
_loc3_ = _throttle;
}
_loc4_ = _lastEntry;
for each(_loc5_ in _activePool)
{
++_loc5_._tStep;
}
while(_loc3_ > 0 && _loc2_ > 0)
{
if(_loc4_ >= _loc1_)
{
_loc4_ = 0;
}
_loc5_ = _activePool[_loc4_++];
_loc6_ = _loc5_._tStep;
if(_loc6_ >= 2)
{
if((_loc5_._requestMode == PLAY_ONE_SHOT || isOnscreen(_loc5_)) && _loc5_.heartbeat())
{
_loc5_._tStep = 0;
_loc3_--;
}
}
_loc2_--;
}
_lastEntry = _loc4_;
}
}
private static function isOnscreen(param1:LayerAnim) : Boolean
{
var _loc3_:int = 0;
var _loc4_:int = 0;
var _loc5_:int = 0;
var _loc6_:int = 0;
var _loc7_:Rectangle = null;
var _loc2_:DisplayObjectContainer = param1.bitmap.parent;
if(_loc2_)
{
_loc3_ = 0;
_loc4_ = 900;
_loc5_ = 0;
_loc6_ = 550;
_loc7_ = _loc2_.getBounds(gMainFrame.stage);
return _loc7_.height == 0 || !(_loc6_ < _loc7_.top || _loc5_ > _loc7_.bottom || _loc4_ < _loc7_.left || _loc3_ > _loc7_.right);
}
return true;
}
public static function set useMaxThrottle(param1:Function) : void
{
_useMaxThrottle = param1;
}
private function init() : void
{
this._bitmap = new LayerBitmap();
this._layers = null;
this._requestAnimId = -1;
this._avDefId = -1;
this._animId = -1;
this._bNewAnim = false;
this._totalFrames = 0;
this._bReload = true;
this._tStep = 1;
}
private function destroy() : void
{
this._bitmap = null;
this._layers = null;
if(this._requestedIds.length != 0)
{
ImageServerURL.instance.removeEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
this._requestedIds.splice(0,this._requestedIds.length);
}
}
public function set avDefId(param1:int) : void
{
if(param1 != this._avDefId)
{
this._avDefId = param1;
this._xOff = -getAvOffset(this._avDefId).x - AVATAR_BITMAP_OFFSET_X;
this._yOff = -getAvOffset(this._avDefId).y - AVATAR_BITMAP_OFFSET_Y;
this._bReload = true;
}
}
public function get layers() : Array
{
return this._layers;
}
public function get avDefId() : int
{
return this._avDefId;
}
public function get animId() : int
{
return this._animId;
}
public function get hFlip() : Boolean
{
return this._hFlip;
}
public function get frame() : int
{
return this._frame;
}
public function set frame(param1:int) : void
{
this._frame = param1;
}
public function set layers(param1:Array) : void
{
var _loc2_:int = 0;
var _loc5_:Object = null;
var _loc6_:int = 0;
var _loc3_:Boolean = true;
var _loc4_:Boolean = false;
if(Boolean(this._layers) && this._layers.length == param1.length)
{
_loc3_ = false;
_loc2_ = 0;
while(_loc2_ < param1.length)
{
if(this._layers[_loc2_].l != param1[_loc2_].l)
{
_loc3_ = true;
break;
}
if(this._layers[_loc2_].c != param1[_loc2_].c)
{
_loc4_ = true;
}
_loc2_++;
}
if(!_loc3_ && !_loc4_)
{
return;
}
}
if(param1.length > 0)
{
this._layers = param1;
if(_loc3_)
{
this._bReload = true;
}
else if(_loc4_)
{
for each(_loc5_ in param1)
{
_loc6_ = ImageServerURL.instance.getLayerIndex(_loc5_.l);
this._bitmap.setLayerColor(_loc6_,_loc5_.c);
}
this._bRedraw = true;
}
}
}
public function get x() : int
{
return this._x;
}
public function get y() : int
{
return this._y;
}
public function set x(param1:int) : void
{
this._x = param1;
}
public function set y(param1:int) : void
{
this._y = param1;
}
public function set alpha(param1:Number) : void
{
this._bitmap.alpha = param1;
}
public function set rotation(param1:Number) : void
{
this._rotation = param1;
}
public function set hFlip(param1:Boolean) : void
{
if(param1 != this._hFlip)
{
this._hFlip = param1;
this._bRedraw = true;
}
}
public function set visible(param1:Boolean) : void
{
this._bitmap.visible = param1;
}
public function set pause(param1:Boolean) : void
{
this._bPause = param1;
}
public function get bitmap() : LayerBitmap
{
return this._bitmap;
}
public function playAnim(param1:int, param2:int = 0, param3:Function = null) : void
{
if(this._requestAnimId == -1 && param1 != this._animId || this._requestAnimId != param1)
{
this._requestCallback = param3;
this._requestMode = param2;
this._requestAnimId = param1;
this._bReload = true;
}
}
public function preload(param1:Array, param2:Function) : void
{
var _loc3_:int = 0;
this._preloadCallback = param2;
this._preloadRequestedIds = [];
while(_loc3_ < param1.length)
{
this.buildRequestArray(param1[_loc3_],this._preloadRequestedIds,null);
_loc3_++;
}
ImageServerURL.instance.addEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
ImageServerURL.instance.requestImages(this._preloadRequestedIds.slice());
}
private function heartbeat() : Boolean
{
var _loc1_:Boolean = false;
if(this._bReload)
{
this.loadAnim();
}
if(this._totalFrames == 0)
{
return false;
}
if(this._frame >= this._totalFrames)
{
if(this._mode == PLAY_ONE_SHOT)
{
this._frame = this._totalFrames > 0 ? int(this._totalFrames - 1) : 0;
}
else
{
this._frame = 0;
}
if(this._callback != null)
{
this._callback(this,this._animId);
if(this._mode == PLAY_ONE_SHOT)
{
this._callback = null;
}
}
}
if(this._bRedraw)
{
this._bitmap.invalidate();
this._bRedraw = false;
}
_loc1_ = this._bitmap.paint(this._frame,this._hFlip);
this.updateBitmapPos();
if(!this._bPause)
{
++this._frame;
}
return _loc1_;
}
private function loadAnim() : void
{
var _loc1_:int = 0;
if(this._layers != null && this._layers.length > 0)
{
_loc1_ = this._requestAnimId != -1 ? this._requestAnimId : this._animId;
if(_loc1_ >= 0)
{
this._requestAnimId = _loc1_;
this.requestAnim(_loc1_);
}
}
}
public function updateBitmapPos() : void
{
var _loc4_:Matrix = null;
var _loc1_:Point = this._bitmap.anchorPoint;
var _loc2_:int = this._x + _loc1_.x + this._xOff;
var _loc3_:int = this._y + _loc1_.y + this._yOff;
if(this._rotation)
{
_loc4_ = this._bitmap.transform.matrix;
_loc4_.identity();
_loc4_.translate(_loc1_.x + this._xOff,_loc1_.y + this._yOff);
_loc4_.rotate(this._rotation * (Math.PI / 180));
_loc4_.translate(_loc2_,_loc3_);
this._bitmap.transform.matrix = _loc4_;
}
else
{
if(this._bitmap.rotation != this._rotation)
{
this._bitmap.rotation = this._rotation;
}
this._bitmap.x = _loc2_;
this._bitmap.y = _loc3_;
}
}
private function requestAnim(param1:int) : void
{
this._bNewAnim = false;
this._requestedIds.splice(0,this._requestedIds.length);
this._colors = [];
this._receivedData = [];
this.buildRequestArray(param1,this._requestedIds,this._colors);
ImageServerURL.instance.addEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
ImageServerURL.instance.requestImages(this._requestedIds.slice());
this._bReload = false;
this._bBaseLayer = false;
}
private function buildRequestArray(param1:int, param2:Array, param3:Array) : void
{
var _loc4_:Object = null;
var _loc5_:uint = 0;
param2.push(ImageArrayHelper.packId(this._avDefId,param1,0));
for each(_loc4_ in this._layers)
{
_loc5_ = ImageArrayHelper.packId(this._avDefId,param1,_loc4_.l);
param2.push(_loc5_);
if(param3)
{
param3[_loc5_] = _loc4_.c;
}
}
}
private function onReceiveData(param1:ImageServerEvent) : void
{
var _loc2_:int = 0;
var _loc4_:uint = 0;
var _loc5_:Object = null;
var _loc3_:int = param1.layer;
if(Boolean(this._preloadRequestedIds) && Boolean(this._preloadRequestedIds.length))
{
_loc2_ = this._preloadRequestedIds.indexOf(param1.id);
if(_loc2_ >= 0)
{
this._preloadRequestedIds.splice(_loc2_,1);
if(this._preloadRequestedIds.length == 0)
{
this._preloadRequestedIds = null;
if(this._requestedIds.length == 0)
{
ImageServerURL.instance.removeEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
}
if(this._preloadCallback != null)
{
this._preloadCallback(this);
}
}
return;
}
}
_loc2_ = this._requestedIds.indexOf(param1.id);
if(_loc2_ >= 0)
{
this._requestedIds.splice(_loc2_,1);
if(_loc3_ > 0)
{
_loc4_ = uint(this._colors[param1.id]);
}
if(param1.success)
{
this._receivedData.push({
"l":_loc3_,
"d":param1.imageData,
"c":_loc4_
});
}
if(this._requestedIds.length == 0)
{
this._bNewAnim = true;
if(this._preloadRequestedIds == null)
{
ImageServerURL.instance.removeEventListener(ImageServerEvent.ON_NEW_DATA,this.onReceiveData);
}
}
if(_loc3_ == 1 || this._bNewAnim)
{
this._bBaseLayer = true;
if(this._mode == LayerAnim.PLAY_LOOP__KEEP_CURRENT_FRAME)
{
this._mode == LayerAnim.PLAY_LOOP;
}
else
{
this._frame = 0;
}
if(this._requestAnimId >= 0)
{
this._animId = this._requestAnimId;
}
this._callback = this._requestCallback;
this._mode = this._requestMode;
this._requestAnimId = -1;
this._bitmap.release();
}
if(this._bBaseLayer)
{
for each(_loc5_ in this._receivedData)
{
this._bitmap.setLayer(_loc5_.l,_loc5_.d,_loc5_.c);
}
this._totalFrames = this._bitmap.length;
}
}
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,651 @@
package com.sbi.graphics
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
public class LayerBitmap extends Bitmap
{
private const _backgroundColor:uint = 0;
private var _anchorPoint:Point;
private var _layers:Array;
private var _bmin:Point;
private var _bmax:Point;
private var _lastFrame:int;
private var _lastHFlip:Boolean;
private var _blendColor:uint;
private var _bColorChanged:Boolean;
public function LayerBitmap()
{
super();
this._layers = new Array();
this._anchorPoint = new Point();
this._bmin = new Point();
this._bmax = new Point();
}
public function get length() : int
{
var _loc1_:Object = this._layers[0];
if(!_loc1_)
{
_loc1_ = this._layers[1];
}
if(!_loc1_)
{
return 0;
}
return _loc1_.o.f.length;
}
public function release() : void
{
this._layers.splice(0,this._layers.length);
this._lastFrame = -1;
this._bColorChanged = false;
}
public function invalidate() : void
{
this._lastFrame = -1;
}
public function setLayer(param1:int, param2:Object, param3:uint) : void
{
if(param1 < 0 || param1 > 10)
{
return;
}
if(param2)
{
if(this._layers[param1] == null)
{
this._layers[param1] = {
"c":-1,
"lastColor":-1,
"blendColor":0
};
}
this._layers[param1].o = param2;
}
else
{
this._layers[param1] = null;
}
this.setLayerColor(param1,param3);
this._lastFrame = -1;
}
public function setLayerColor(param1:int, param2:uint) : void
{
var _loc3_:Object = this._layers[param1];
if(Boolean(_loc3_) && param2 != _loc3_.c)
{
_loc3_.c = param2;
this._bColorChanged = true;
}
}
public function setBlendColor(param1:uint) : void
{
if(this._blendColor != param1)
{
this._blendColor = param1;
this._bColorChanged = true;
}
}
public function get anchorPoint() : Point
{
return this._anchorPoint;
}
private function refreshLayerPalette(param1:int) : void
{
var _loc3_:uint = 0;
var _loc4_:Array = null;
var _loc5_:int = 0;
var _loc6_:int = 0;
var _loc7_:int = 0;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc2_:Object = this._layers[param1];
if(Boolean(_loc2_) && (_loc2_.lastColor != _loc2_.c || _loc2_.blendColor != this._blendColor))
{
_loc3_ = uint(_loc2_.c);
_loc4_ = PaletteHelper.gamePalette;
_loc5_ = _loc3_ >> 24 & 0xFF;
_loc6_ = _loc3_ >> 16 & 0xFF;
_loc7_ = _loc3_ >> 8 & 0xFF;
_loc8_ = _loc3_ & 0xFF;
if(!_loc2_.pal)
{
_loc2_.pal = [];
}
PaletteHelper.BuildAnimalPalette(_loc2_.pal,_loc4_[_loc5_],_loc4_[_loc6_],_loc4_[_loc7_],_loc4_[_loc8_]);
_loc9_ = this._blendColor >> 24 & 0xFF;
if(param1 != 3)
{
if(_loc9_ > 0)
{
PaletteHelper.adjustPaletteColor(_loc2_.pal,this._blendColor);
}
_loc2_.blendColor = this._blendColor;
}
_loc2_.lastColor = _loc3_;
this._lastFrame = -1;
}
}
private function refreshAllPalettes() : void
{
var _loc1_:int = 1;
while(_loc1_ <= 10)
{
this.refreshLayerPalette(_loc1_);
_loc1_++;
}
this._bColorChanged = false;
}
private function calcBounds(param1:int) : void
{
var _loc3_:Object = null;
var _loc4_:Object = null;
var _loc5_:int = 0;
var _loc6_:Object = null;
var _loc7_:int = 0;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
this._bmin.x = 1000;
this._bmin.y = 1000;
this._bmax.x = 0;
this._bmax.y = 0;
var _loc2_:int = 1;
while(_loc2_ < this._layers.length)
{
_loc3_ = this._layers[_loc2_];
if(_loc3_ != null)
{
_loc4_ = _loc3_.o;
if(_loc4_.v != ImageArray.VERSION)
{
return;
}
_loc5_ = int(_loc4_.f.length);
if(param1 < _loc5_)
{
_loc6_ = _loc4_.f[param1];
if(_loc6_)
{
_loc7_ = int(_loc6_.x);
_loc8_ = int(_loc6_.y);
_loc9_ = int(_loc6_.w);
_loc10_ = int(_loc6_.h);
if(_loc7_ < this._bmin.x)
{
this._bmin.x = _loc7_;
}
if(_loc8_ < this._bmin.y)
{
this._bmin.y = _loc8_;
}
if(_loc7_ + _loc9_ > this._bmax.x)
{
this._bmax.x = _loc7_ + _loc9_;
}
if(_loc8_ + _loc10_ > this._bmax.y)
{
this._bmax.y = _loc8_ + _loc10_;
}
}
}
}
_loc2_++;
}
if(this._bmin.x == 1000 || this._bmin.y == 1000)
{
if(this.bitmapData)
{
this.bitmapData = new BitmapData(1,1,true,this._backgroundColor);
}
return;
}
this.resizeBitmap(1 + this._bmax.x - this._bmin.x,1 + this._bmax.y - this._bmin.y,true);
this._anchorPoint.x = this._bmin.x;
this._anchorPoint.y = this._bmin.y;
}
public function paint(param1:int, param2:Boolean = false, param3:Boolean = true) : Boolean
{
var _loc4_:Object = null;
var _loc5_:Boolean = false;
var _loc6_:int = 0;
if(param3 && this._layers[0] != null)
{
_loc4_ = this._layers[0];
param1 = int(_loc4_.o.f[param1]);
}
if(param1 != this._lastFrame || param2 != this._lastHFlip || this._bColorChanged)
{
if(this._bColorChanged)
{
this.refreshAllPalettes();
}
this._lastFrame = param1;
this._lastHFlip = param2;
this.calcBounds(param1);
_loc6_ = 1;
while(_loc6_ < this._layers.length)
{
_loc4_ = this._layers[_loc6_];
if(_loc4_ != null)
{
this.paintFrame(_loc4_.o,param1,_loc4_.pal,param2);
}
_loc6_++;
}
_loc5_ = true;
if(param2)
{
this._anchorPoint.x = 500 - this._bmax.x;
}
}
return _loc5_;
}
private function paintFrame(param1:Object, param2:int, param3:Array, param4:Boolean) : void
{
var _loc15_:int = 0;
var _loc16_:int = 0;
var _loc17_:uint = 0;
var _loc18_:uint = 0;
var _loc19_:int = 0;
var _loc20_:int = 0;
var _loc21_:int = 0;
var _loc22_:int = 0;
var _loc23_:int = 0;
var _loc24_:int = 0;
var _loc25_:int = 0;
var _loc26_:int = 0;
var _loc28_:int = 0;
var _loc29_:Number = NaN;
var _loc30_:uint = 0;
var _loc31_:int = 0;
if(param2 >= param1.f.length)
{
return;
}
var _loc5_:Object = param1.f[param2];
if(!_loc5_)
{
return;
}
var _loc6_:BitmapData = this.bitmapData;
var _loc7_:ByteArray = _loc5_.b;
var _loc8_:int = int(_loc5_.x);
var _loc9_:int = int(_loc5_.y);
var _loc10_:int = int(_loc5_.w);
var _loc11_:int = int(_loc5_.h);
_loc8_ -= this._bmin.x;
_loc9_ -= this._bmin.y;
_loc10_ += _loc8_;
_loc7_.position = 0;
var _loc12_:int = int(_loc7_.length);
var _loc13_:* = _loc8_;
var _loc14_:int = _loc9_;
this.bitmapData.lock();
var _loc27_:int = _loc10_ - _loc8_;
if(!param4)
{
while(_loc7_.position < _loc12_)
{
_loc15_ = int(_loc7_.readUnsignedByte());
_loc16_ = 1;
if((_loc15_ & 0x80) == 128)
{
_loc15_ &= 127;
_loc16_ = _loc7_.readUnsignedByte() + 1;
}
if(_loc15_ == 0)
{
_loc13_ += _loc16_;
if(_loc13_ >= _loc10_)
{
_loc16_ = _loc13_ - _loc10_;
_loc13_ = int(_loc8_ + _loc16_ % _loc27_);
_loc14_ += _loc16_ / _loc27_ + 1;
}
}
else
{
_loc17_ = uint(param3[_loc15_]);
if(_loc17_ >= 4278190080)
{
if(_loc13_ + _loc16_ < _loc10_)
{
while(--_loc16_ > -1)
{
_loc6_.setPixel32(_loc13_++,_loc14_,_loc17_);
}
}
else
{
while(--_loc16_ > -1)
{
_loc6_.setPixel32(_loc13_++,_loc14_,_loc17_);
if(_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
else
{
while(--_loc16_ > -1)
{
_loc18_ = _loc6_.getPixel32(_loc13_,_loc14_);
if(_loc18_ != this._backgroundColor)
{
_loc19_ = _loc17_ >> 24 & 0xFF;
_loc20_ = _loc17_ >> 16 & 0xFF;
_loc21_ = _loc17_ >> 8 & 0xFF;
_loc22_ = _loc17_ & 0xFF;
_loc23_ = _loc18_ >> 24 & 0xFF;
_loc24_ = _loc18_ >> 16 & 0xFF;
_loc25_ = _loc18_ >> 8 & 0xFF;
_loc26_ = _loc18_ & 0xFF;
if(_loc19_ == 192)
{
_loc20_ = (_loc20_ + _loc20_ + _loc20_ + _loc24_) * 0.25;
_loc21_ = (_loc21_ + _loc21_ + _loc21_ + _loc25_) * 0.25;
_loc22_ = (_loc22_ + _loc22_ + _loc22_ + _loc26_) * 0.25;
}
else if(_loc19_ == 128)
{
_loc20_ = (_loc20_ + _loc24_) * 0.5;
_loc21_ = (_loc21_ + _loc25_) * 0.5;
_loc22_ = (_loc22_ + _loc26_) * 0.5;
}
else
{
_loc20_ = (_loc20_ + _loc24_ + _loc24_ + _loc24_) * 0.25;
_loc21_ = (_loc21_ + _loc25_ + _loc25_ + _loc25_) * 0.25;
_loc22_ = (_loc22_ + _loc26_ + _loc26_ + _loc26_) * 0.25;
}
if(_loc23_ > _loc19_)
{
_loc19_ = _loc23_;
}
_loc17_ = uint(_loc19_ << 24 | _loc20_ << 16 | _loc21_ << 8 | _loc22_);
}
_loc6_.setPixel32(_loc13_++,_loc14_,_loc17_);
if(_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
}
}
else
{
_loc28_ = this._bmax.x - this._bmin.x;
while(_loc7_.position < _loc12_)
{
_loc15_ = int(_loc7_.readUnsignedByte());
_loc16_ = 1;
if((_loc15_ & 0x80) == 128)
{
_loc15_ &= 127;
_loc16_ = _loc7_.readUnsignedByte() + 1;
}
if(_loc15_ == 0)
{
_loc13_ += _loc16_;
if(_loc13_ >= _loc10_)
{
_loc16_ = _loc13_ - _loc10_;
_loc13_ = int(_loc8_ + _loc16_ % _loc27_);
_loc14_ += _loc16_ / _loc27_ + 1;
}
}
else
{
_loc17_ = uint(param3[_loc15_]);
if(_loc17_ >= 4278190080)
{
if(_loc13_ + _loc16_ < _loc10_)
{
while(--_loc16_ > -1)
{
_loc6_.setPixel32(_loc28_ - _loc13_++,_loc14_,_loc17_);
}
}
else
{
while(--_loc16_ > -1)
{
_loc6_.setPixel32(_loc28_ - _loc13_++,_loc14_,_loc17_);
if(_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
else
{
while(--_loc16_ > -1)
{
_loc18_ = _loc6_.getPixel32(_loc28_ - _loc13_,_loc14_);
if(_loc18_ != this._backgroundColor)
{
_loc19_ = _loc17_ >> 24 & 0xFF;
_loc20_ = _loc17_ >> 16 & 0xFF;
_loc21_ = _loc17_ >> 8 & 0xFF;
_loc22_ = _loc17_ & 0xFF;
_loc23_ = _loc18_ >> 24 & 0xFF;
_loc24_ = _loc18_ >> 16 & 0xFF;
_loc25_ = _loc18_ >> 8 & 0xFF;
_loc26_ = _loc18_ & 0xFF;
switch(_loc19_)
{
case 192:
_loc20_ = (_loc20_ + _loc20_ + _loc20_ + _loc24_) * 0.25;
_loc21_ = (_loc21_ + _loc21_ + _loc21_ + _loc25_) * 0.25;
_loc22_ = (_loc22_ + _loc22_ + _loc22_ + _loc26_) * 0.25;
break;
case 128:
_loc20_ = (_loc20_ + _loc24_) * 0.5;
_loc21_ = (_loc21_ + _loc25_) * 0.5;
_loc22_ = (_loc22_ + _loc26_) * 0.5;
break;
case 64:
_loc20_ = (_loc20_ + _loc24_ + _loc24_ + _loc24_) * 0.25;
_loc21_ = (_loc21_ + _loc25_ + _loc25_ + _loc25_) * 0.25;
_loc22_ = (_loc22_ + _loc26_ + _loc26_ + _loc26_) * 0.25;
}
if(_loc23_ > _loc19_)
{
_loc19_ = _loc23_;
}
_loc17_ = uint(_loc19_ << 24 | _loc20_ << 16 | _loc21_ << 8 | _loc22_);
}
_loc6_.setPixel32(_loc28_ - _loc13_++,_loc14_,_loc17_);
if(_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
}
}
if(_loc5_.hasOwnProperty("s"))
{
_loc31_ = int(_loc5_.sm);
_loc7_ = _loc5_.s;
_loc12_ = int(_loc7_.length);
_loc7_.position = 0;
_loc13_ = _loc8_;
_loc14_ = _loc9_;
if(!param4)
{
while(_loc7_.position < _loc12_)
{
_loc15_ = int(_loc7_.readUnsignedByte());
_loc16_ = 1;
if((_loc15_ & 0x80) == 128)
{
_loc15_ &= 127;
_loc16_ = _loc7_.readUnsignedByte() + 1;
}
if(_loc15_ == 0)
{
_loc13_ += _loc16_;
if(_loc13_ >= _loc10_)
{
_loc16_ = _loc13_ - _loc10_;
_loc13_ = int(_loc8_ + _loc16_ % _loc27_);
_loc14_ += _loc16_ / _loc27_ + 1;
}
}
else
{
_loc17_ = uint(_loc15_ << _loc31_);
_loc17_ = _loc17_ + 24;
if(_loc17_ > 255)
{
_loc29_ = 1;
}
else
{
_loc29_ = _loc17_ / 255;
}
while(--_loc16_ > -1)
{
_loc18_ = _loc6_.getPixel32(_loc13_,_loc14_);
if(_loc18_ != this._backgroundColor)
{
_loc19_ = _loc18_ >> 24 & 0xFF;
_loc20_ = (_loc18_ >> 16 & 0xFF) * _loc29_;
_loc21_ = (_loc18_ >> 8 & 0xFF) * _loc29_;
_loc22_ = (_loc18_ & 0xFF) * _loc29_;
_loc30_ = uint(_loc19_ << 24 | _loc20_ << 16 | _loc21_ << 8 | _loc22_);
_loc6_.setPixel32(_loc13_,_loc14_,_loc30_);
}
if(++_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
}
else
{
_loc28_ = this._bmax.x - this._bmin.x;
while(_loc7_.position < _loc12_)
{
_loc15_ = int(_loc7_.readUnsignedByte());
_loc16_ = 1;
if((_loc15_ & 0x80) == 128)
{
_loc15_ &= 127;
_loc16_ = _loc7_.readUnsignedByte() + 1;
}
if(_loc15_ == 0)
{
_loc13_ += _loc16_;
if(_loc13_ >= _loc10_)
{
_loc16_ = _loc13_ - _loc10_;
_loc13_ = int(_loc8_ + _loc16_ % _loc27_);
_loc14_ += _loc16_ / _loc27_ + 1;
}
}
else
{
_loc17_ = uint(_loc15_ << _loc31_);
_loc17_ = _loc17_ + 24;
if(_loc17_ > 255)
{
_loc29_ = 1;
}
else
{
_loc29_ = _loc17_ / 255;
}
while(--_loc16_ > -1)
{
_loc18_ = _loc6_.getPixel32(_loc28_ - _loc13_,_loc14_);
if(_loc18_ != this._backgroundColor)
{
_loc19_ = _loc18_ >> 24 & 0xFF;
_loc20_ = (_loc18_ >> 16 & 0xFF) * _loc29_;
_loc21_ = (_loc18_ >> 8 & 0xFF) * _loc29_;
_loc22_ = (_loc18_ & 0xFF) * _loc29_;
_loc30_ = uint(_loc19_ << 24 | _loc20_ << 16 | _loc21_ << 8 | _loc22_);
_loc6_.setPixel32(_loc28_ - _loc13_,_loc14_,_loc30_);
}
if(++_loc13_ == _loc10_)
{
_loc13_ = _loc8_;
_loc14_++;
}
}
}
}
}
}
_loc6_.unlock();
}
private function resizeBitmap(param1:int, param2:int, param3:Boolean) : void
{
var _loc4_:int = param1;
var _loc5_:int = param2;
if(!this.bitmapData)
{
param3 = true;
}
var _loc6_:Rectangle = new Rectangle(0,0,_loc4_,_loc5_);
var _loc7_:ByteArray = null;
if(!param3)
{
_loc7_ = this.bitmapData.getPixels(_loc6_);
}
if(this.bitmapData)
{
this.bitmapData.dispose();
}
this.bitmapData = new BitmapData(param1,param2,true,this._backgroundColor);
if(!param3)
{
this.bitmapData.setPixels(_loc6_,_loc7_);
}
}
}
}
@@ -0,0 +1,246 @@
package com.sbi.graphics
{
import flash.utils.ByteArray;
public class PaletteHelper
{
public static var gamePalette:Array;
public static var avatarPalette1:Array;
public static var avatarPalette2:Array;
private static const PALETTE_ALPHA_OFFSET:int = 25;
public function PaletteHelper()
{
super();
}
public static function setGamePalette(param1:ByteArray, param2:ByteArray = null, param3:ByteArray = null) : void
{
var _loc4_:int = param1.length / 4;
gamePalette = new Array(_loc4_);
var _loc5_:* = 0;
while(_loc5_ < _loc4_)
{
var _loc6_:Number;
gamePalette[_loc6_ = _loc5_++] = param1.readUnsignedInt();
}
if(param2)
{
_loc4_ = int(param2.length);
avatarPalette1 = new Array(_loc4_);
_loc5_ = 0;
while(_loc5_ < _loc4_)
{
avatarPalette1[_loc6_ = _loc5_++] = param2.readUnsignedByte();
}
}
if(param3)
{
param3.position = 0;
_loc4_ = int(param3.length);
avatarPalette2 = new Array(_loc4_);
_loc5_ = 0;
while(_loc5_ < _loc4_)
{
avatarPalette2[_loc6_ = _loc5_++] = param3.readUnsignedByte();
}
}
}
public static function mixColors(param1:uint, param2:uint) : uint
{
var _loc3_:uint = uint(param1 >> 16 & 0xFF);
var _loc4_:uint = uint(param1 >> 8 & 0xFF);
var _loc5_:uint = uint(param1 & 0xFF);
var _loc6_:uint = uint(param2 >> 16 & 0xFF);
var _loc7_:uint = uint(param2 >> 8 & 0xFF);
var _loc8_:uint = uint(param2 & 0xFF);
_loc3_ = (_loc3_ + _loc6_) / 2;
_loc4_ = (_loc4_ + _loc7_) / 2;
_loc5_ = (_loc5_ + _loc8_) / 2;
return _loc3_ << 16 | _loc4_ << 8 | _loc5_;
}
public static function setColorGradient(param1:Array, param2:uint, param3:uint, param4:uint) : void
{
var _loc13_:uint = 0;
var _loc5_:uint = uint(param2 >> 16 & 0xFF);
var _loc6_:uint = uint(param2 >> 8 & 0xFF);
var _loc7_:uint = uint(param2 & 0xFF);
var _loc8_:uint = _loc5_ / (param4 + 2);
var _loc9_:uint = _loc6_ / (param4 + 2);
var _loc10_:uint = _loc7_ / (param4 + 2);
var _loc11_:* = int(param3 + param4 - 1);
var _loc12_:uint = 0;
while(_loc12_ < param4)
{
_loc13_ = uint(_loc5_ << 16 | _loc6_ << 8 | _loc7_);
param1[_loc11_] = _loc13_ | 255 << 24;
param1[_loc11_ + PALETTE_ALPHA_OFFSET] = _loc13_ | 192 << 24;
param1[_loc11_ + PALETTE_ALPHA_OFFSET * 2] = _loc13_ | 128 << 24;
param1[_loc11_ + PALETTE_ALPHA_OFFSET * 3] = _loc13_ | 64 << 24;
_loc5_ -= _loc8_;
_loc6_ -= _loc9_;
_loc7_ -= _loc10_;
_loc11_--;
_loc12_++;
}
}
public static function AddRGB(param1:uint, param2:int, param3:int, param4:int) : uint
{
var _loc5_:int = param1 >> 24 & 0xFF;
var _loc6_:int = param1 >> 16 & 0xFF;
var _loc7_:int = param1 >> 8 & 0xFF;
var _loc8_:int = param1 & 0xFF;
_loc6_ += param2;
if(_loc6_ < 0)
{
_loc6_ = 0;
}
else if(_loc6_ > 255)
{
_loc6_ = 255;
}
_loc7_ += param3;
if(_loc7_ < 0)
{
_loc7_ = 0;
}
else if(_loc7_ > 255)
{
_loc7_ = 255;
}
_loc8_ += param4;
if(_loc8_ < 0)
{
_loc8_ = 0;
}
else if(_loc8_ > 255)
{
_loc8_ = 255;
}
return uint(_loc5_ << 24 | _loc6_ << 16 | _loc7_ << 8 | _loc8_);
}
public static function getAnimalPalette() : Array
{
var _loc4_:int = 0;
var _loc5_:uint = 0;
var _loc6_:uint = 0;
var _loc1_:Array = new Array(uint(4278255615),uint(4286513152),uint(4290707456),uint(4294901760),uint(4278222592),uint(4278238976),uint(4278255360),uint(4278190207),uint(4278190271),uint(4278190335),uint(4286545791),uint(4290756543),uint(4294967295),uint(4282400768),uint(4286611456),uint(4278206528),uint(4278222976),uint(4282384448),uint(4286578816),uint(4286595136),uint(4294934656),uint(4282417216),uint(4286644096),uint(4282400896),uint(4286611711),uint(4278190080));
var _loc2_:uint = uint(192 << 24);
var _loc3_:int = 0;
while(_loc3_ < 3)
{
_loc4_ = 1;
while(_loc4_ <= PALETTE_ALPHA_OFFSET)
{
_loc5_ = uint(_loc1_[_loc4_] & 0xFFFFFF);
_loc6_ = uint(_loc5_ | _loc2_);
_loc1_.push(_loc6_);
_loc4_++;
}
_loc2_ -= 64 << 24;
_loc3_++;
}
return _loc1_;
}
public static function BuildAnimalPalette(param1:Array, param2:uint, param3:uint, param4:uint, param5:uint) : void
{
setColorGradient(param1,param2,1,3);
setColorGradient(param1,param3,4,3);
setColorGradient(param1,param4,7,3);
setColorGradient(param1,param5,10,3);
setColorGradient(param1,PaletteHelper.mixColors(param2,param3),13,2);
setColorGradient(param1,PaletteHelper.mixColors(param3,param4),15,2);
setColorGradient(param1,PaletteHelper.mixColors(param2,param4),17,2);
setColorGradient(param1,PaletteHelper.mixColors(param2,param5),19,2);
setColorGradient(param1,PaletteHelper.mixColors(param3,param5),21,2);
setColorGradient(param1,PaletteHelper.mixColors(param4,param5),23,2);
}
public static function adjustPaletteColor(param1:Array, param2:uint) : void
{
var _loc7_:int = 0;
var _loc8_:uint = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc11_:int = 0;
var _loc12_:int = 0;
var _loc13_:Number = NaN;
var _loc3_:Number = (param2 >> 24 & 0xFF) / 255;
var _loc4_:int = param2 >> 16 & 0xFF;
var _loc5_:int = param2 >> 8 & 0xFF;
var _loc6_:int = param2 & 0xFF;
while(_loc7_ < param1.length)
{
_loc8_ = uint(param1[_loc7_]);
_loc9_ = _loc8_ >> 24 & 0xFF;
_loc10_ = _loc8_ >> 16 & 0xFF;
_loc11_ = _loc8_ >> 8 & 0xFF;
_loc12_ = _loc8_ & 0xFF;
_loc13_ = _loc4_ - _loc10_;
_loc13_ = _loc13_ * _loc3_;
_loc10_ += _loc13_;
if(_loc10_ < 0)
{
_loc10_ = 0;
}
else if(_loc10_ > 255)
{
_loc10_ = 255;
}
_loc13_ = _loc5_ - _loc11_;
_loc13_ = _loc13_ * _loc3_;
_loc11_ += _loc13_;
if(_loc11_ < 0)
{
_loc11_ = 0;
}
else if(_loc11_ > 255)
{
_loc11_ = 255;
}
_loc13_ = _loc6_ - _loc12_;
_loc13_ = _loc13_ * _loc3_;
_loc12_ += _loc13_;
if(_loc12_ < 0)
{
_loc12_ = 0;
}
else if(_loc12_ > 255)
{
_loc12_ = 255;
}
param1[_loc7_] = uint(_loc9_ << 24 | _loc10_ << 16 | _loc11_ << 8 | _loc12_);
_loc7_++;
}
}
public static function getRGBColors(param1:uint) : Array
{
var _loc2_:Array = [];
_loc2_[0] = decToRGBObj(gamePalette[param1 >> 24 & 0xFF]);
_loc2_[1] = decToRGBObj(gamePalette[param1 >> 16 & 0xFF]);
_loc2_[2] = decToRGBObj(gamePalette[param1 >> 8 & 0xFF]);
_loc2_[3] = decToRGBObj(gamePalette[param1 & 0xFF]);
return _loc2_;
}
private static function decToRGBObj(param1:uint) : Object
{
return {
"r":param1 >> 16 & 0xFF,
"g":param1 >> 8 & 0xFF,
"b":param1 & 0xFF
};
}
}
}
@@ -0,0 +1,194 @@
package com.sbi.graphics
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.geom.Rectangle;
import flash.utils.Dictionary;
public class SortLayer extends Sprite
{
private var _bottoms:Dictionary;
private var _nudge:Number = 0;
public function SortLayer()
{
super();
this._bottoms = new Dictionary(true);
}
override public function addChild(param1:DisplayObject) : DisplayObject
{
var _loc2_:int = int(param1.name);
param1.name = (this.getNudge() + _loc2_).toString();
return super.addChild(param1);
}
override public function addChildAt(param1:DisplayObject, param2:int) : DisplayObject
{
var _loc3_:int = int(param1.name);
param1.name = (this.getNudge() + _loc3_).toString();
return super.addChildAt(param1,param2);
}
public function release() : void
{
this._nudge = 0;
this._bottoms = new Dictionary(true);
}
public function depthSort(param1:DisplayObject, param2:DisplayObject) : int
{
return this._bottoms[param1] - this._bottoms[param2];
}
public function heartbeat() : void
{
var _loc1_:int = 0;
var _loc3_:Rectangle = null;
var _loc4_:Boolean = false;
var _loc7_:DisplayObject = null;
var _loc8_:Number = NaN;
var _loc9_:Number = NaN;
var _loc2_:int = this.numChildren;
var _loc5_:Number = -999999999;
if(_loc2_ < 2)
{
return;
}
var _loc6_:Array = [_loc2_];
_loc1_ = 0;
while(_loc1_ < _loc2_)
{
_loc7_ = this.getChildAt(_loc1_);
_loc6_[_loc1_] = _loc7_;
_loc3_ = _loc7_.getBounds(this);
_loc8_ = _loc3_.bottom;
_loc9_ = Number(_loc7_.name);
if(!_loc9_)
{
_loc9_ = this.getNudge();
_loc7_.name = _loc9_.toString();
}
_loc8_ -= _loc9_;
this._bottoms[_loc7_] = _loc8_;
if(!_loc4_)
{
if(_loc8_ < _loc5_)
{
_loc4_ = true;
}
_loc5_ = _loc8_;
}
_loc1_++;
}
if(_loc4_)
{
_loc6_.sort(this.depthSort);
_loc1_ = 0;
while(_loc1_ < _loc2_)
{
this.setChildIndex(_loc6_[_loc1_],_loc1_);
_loc1_++;
}
}
}
private function getNudge() : Number
{
this._nudge += 0.001;
if(this._nudge > 0.9)
{
this._nudge = 0;
}
return this._nudge;
}
private function sort(param1:Vector.<Number>) : void
{
this.quickSort(param1,0,param1.length - 1);
this.InsertionSort(param1,0,param1.length - 1);
}
private function quickSort(param1:Vector.<Number>, param2:int, param3:int) : void
{
var _loc5_:int = 0;
var _loc6_:int = 0;
var _loc7_:Number = NaN;
var _loc4_:int = 4;
if(param3 - param2 > _loc4_)
{
_loc5_ = (param3 + param2) / 2;
if(param1[param2] > param1[_loc5_])
{
this.swap(param1,param2,_loc5_);
}
if(param1[param2] > param1[param3])
{
this.swap(param1,param2,param3);
}
if(param1[_loc5_] > param1[param3])
{
this.swap(param1,_loc5_,param3);
}
_loc6_ = param3 - 1;
this.swap(param1,_loc5_,_loc6_);
_loc5_ = param2;
_loc7_ = param1[_loc6_];
while(true)
{
while(param1[++_loc5_] < _loc7_)
{
}
while(param1[--_loc6_] > _loc7_)
{
}
if(_loc6_ < _loc5_)
{
break;
}
this.swap(param1,_loc5_,_loc6_);
}
this.swap(param1,_loc5_,param3 - 1);
this.quickSort(param1,param2,_loc6_);
this.quickSort(param1,_loc5_ + 1,param3);
}
}
private function swap(param1:Vector.<Number>, param2:int, param3:int) : void
{
var _loc4_:Number = NaN;
_loc4_ = param1[param2];
param1[param2] = param1[param3];
param1[param3] = _loc4_;
swapChildrenAt(param2,param3);
}
private function move(param1:Vector.<Number>, param2:int, param3:int) : void
{
param1[param3] = param1[param2];
this.addChildAt(getChildAt(param2),param3);
}
private function InsertionSort(param1:Vector.<Number>, param2:int, param3:int) : void
{
var _loc4_:int = 0;
var _loc5_:* = 0;
var _loc6_:Number = NaN;
_loc4_ = param2 + 1;
while(_loc4_ <= param3)
{
_loc6_ = param1[_loc4_];
_loc5_ = _loc4_;
while(_loc5_ > param2 && param1[_loc5_ - 1] > _loc6_)
{
this.move(param1,_loc5_ - 1,_loc5_);
_loc5_--;
}
_loc4_++;
}
}
}
}
@@ -0,0 +1,181 @@
package com.sbi.graphics
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.system.System;
import flash.text.StyleSheet;
import flash.text.TextField;
import flash.utils.getTimer;
public class Stats extends Sprite
{
protected const WIDTH:uint = 70;
protected const HEIGHT:uint = 100;
protected var xml:XML;
protected var text:TextField;
protected var style:StyleSheet;
protected var timer:uint;
protected var fps:uint;
protected var ms:uint;
protected var ms_prev:uint;
protected var mem:Number;
protected var mem_max:Number;
protected var graph:Bitmap;
protected var rectangle:Rectangle;
protected var fps_graph:uint;
protected var mem_graph:uint;
protected var mem_max_graph:uint;
protected var theme:Object = {
"bg":51,
"fps":16776960,
"ms":65280,
"mem":65535,
"memmax":16711792
};
public function Stats(param1:Object = null)
{
super();
if(param1)
{
if(param1.bg != null)
{
this.theme.bg = param1.bg;
}
if(param1.fps != null)
{
this.theme.fps = param1.fps;
}
if(param1.ms != null)
{
this.theme.ms = param1.ms;
}
if(param1.mem != null)
{
this.theme.mem = param1.mem;
}
if(param1.memmax != null)
{
this.theme.memmax = param1.memmax;
}
}
this.mem_max = 0;
this.xml = <xml><fps>FPS:</fps><ms>MS:</ms><mem>MEM:</mem><memMax>MAX:</memMax></xml>;
this.style = new StyleSheet();
this.style.setStyle("xml",{
"fontSize":"9px",
"fontFamily":"_sans",
"leading":"-2px"
});
this.style.setStyle("fps",{"color":this.hex2css(this.theme.fps)});
this.style.setStyle("ms",{"color":this.hex2css(this.theme.ms)});
this.style.setStyle("mem",{"color":this.hex2css(this.theme.mem)});
this.style.setStyle("memMax",{"color":this.hex2css(this.theme.memmax)});
this.text = new TextField();
this.text.width = this.WIDTH;
this.text.height = 50;
this.text.styleSheet = this.style;
this.text.condenseWhite = true;
this.text.selectable = false;
this.text.mouseEnabled = false;
this.graph = new Bitmap();
this.graph.y = 50;
this.rectangle = new Rectangle(this.WIDTH - 1,0,1,this.HEIGHT - 50);
addEventListener(Event.ADDED_TO_STAGE,this.init,false,0,true);
addEventListener(Event.REMOVED_FROM_STAGE,this.destroy,false,0,true);
}
private function init(param1:Event) : void
{
graphics.beginFill(this.theme.bg);
graphics.drawRect(0,0,this.WIDTH,this.HEIGHT);
graphics.endFill();
addChild(this.text);
this.graph.bitmapData = new BitmapData(this.WIDTH,this.HEIGHT - 50,false,this.theme.bg);
addChild(this.graph);
addEventListener(MouseEvent.CLICK,this.onClick);
addEventListener(Event.ENTER_FRAME,this.update);
}
private function destroy(param1:Event) : void
{
graphics.clear();
while(numChildren > 0)
{
removeChildAt(0);
}
this.graph.bitmapData.dispose();
removeEventListener(MouseEvent.CLICK,this.onClick);
removeEventListener(Event.ENTER_FRAME,this.update);
}
private function update(param1:Event) : void
{
this.timer = getTimer();
if(this.timer - 1000 > this.ms_prev)
{
this.ms_prev = this.timer;
this.mem = Number((System.totalMemory * 9.54e-7).toFixed(3));
this.mem_max = this.mem_max > this.mem ? this.mem_max : this.mem;
this.fps_graph = Math.min(this.graph.height,this.fps / stage.frameRate * this.graph.height);
this.mem_graph = Math.min(this.graph.height,Math.sqrt(Math.sqrt(this.mem * 5000))) - 2;
this.mem_max_graph = Math.min(this.graph.height,Math.sqrt(Math.sqrt(this.mem_max * 5000))) - 2;
this.graph.bitmapData.scroll(-1,0);
this.graph.bitmapData.fillRect(this.rectangle,this.theme.bg);
this.graph.bitmapData.setPixel(this.graph.width - 1,this.graph.height - this.fps_graph,this.theme.fps);
this.graph.bitmapData.setPixel(this.graph.width - 1,this.graph.height - (this.timer - this.ms >> 1),this.theme.ms);
this.graph.bitmapData.setPixel(this.graph.width - 1,this.graph.height - this.mem_graph,this.theme.mem);
this.graph.bitmapData.setPixel(this.graph.width - 1,this.graph.height - this.mem_max_graph,this.theme.memmax);
this.xml.fps = "FPS: " + this.fps + " / " + stage.frameRate;
this.xml.mem = "MEM: " + this.mem;
this.xml.memMax = "MAX: " + this.mem_max;
this.fps = 0;
}
++this.fps;
this.xml.ms = "MS: " + (this.timer - this.ms);
this.ms = this.timer;
this.text.htmlText = this.xml;
}
private function onClick(param1:MouseEvent) : void
{
if(mouseY / height > 0.5)
{
--stage.frameRate;
}
else
{
++stage.frameRate;
}
this.xml.fps = "FPS: " + this.fps + " / " + stage.frameRate;
this.text.htmlText = this.xml;
}
private function hex2css(param1:int) : String
{
return "#" + param1.toString(16);
}
}
}
@@ -0,0 +1,154 @@
package com.sbi.loader
{
import flash.events.EventDispatcher;
public class BaseFileServer extends EventDispatcher
{
private var _contentPath:String;
private var _loaderArray:Array;
private var _cacheArray:Array;
public function BaseFileServer(param1:String)
{
super();
this._contentPath = param1;
this._loaderArray = new Array();
this._cacheArray = new Array();
}
public function updatePath(param1:String) : void
{
this._contentPath = param1;
}
public function clearFromCache(param1:String, param2:int) : void
{
if(this._cacheArray[param1])
{
if(this._cacheArray[param1][param2])
{
delete this._cacheArray[param1][param2];
}
}
if(this._loaderArray[param1])
{
if(this._loaderArray[param1][param2])
{
delete this._loaderArray[param1][param2];
}
}
}
public function requestFile(param1:uint, param2:Boolean = false, param3:int = 0, param4:Boolean = true) : void
{
var _loc5_:LoaderCacheEntry_URL = null;
if(param2 || this.getFromCache(param1) == false)
{
if(!(this._loaderArray[this._contentPath] ? this._loaderArray[this._contentPath][param1] : false))
{
_loc5_ = new LoaderCacheEntry_URL(this._contentPath + param1,false);
_loc5_.id = param1;
_loc5_.contentType = param3;
_loc5_.addEventListener(LoaderEvent.ON_LOAD_COMPLETE,this.onResultGetData);
_loc5_.load("binary",param4);
if(this._loaderArray[this._contentPath] == null)
{
this._loaderArray[this._contentPath] = [];
}
this._loaderArray[this._contentPath][param1] = {
"l":_loc5_,
"c":1
};
}
else
{
++this._loaderArray[this._contentPath][param1].c;
}
}
}
public function requestFiles(param1:Array) : void
{
var _loc2_:int = 0;
while(_loc2_ < param1.length)
{
this.requestFile(param1[_loc2_]);
_loc2_++;
}
}
private function getFromCache(param1:uint) : Boolean
{
var _loc2_:Object = this.searchCache(param1);
if(_loc2_)
{
this.newEvent(_loc2_.id,_loc2_.data,true,_loc2_.contentType);
}
return _loc2_ == null ? false : true;
}
private function searchCache(param1:uint) : Object
{
return this._cacheArray[this._contentPath] ? this._cacheArray[this._contentPath][param1] : null;
}
private function onResultGetData(param1:LoaderEvent) : void
{
var _loc5_:* = 0;
var _loc2_:FileServerEvent = new FileServerEvent(FileServerEvent.ON_NEW_DATA);
_loc2_.id = param1.entry.id;
_loc2_.contentType = param1.entry.contentType;
var _loc3_:Object = param1.entry.data;
if(_loc3_ == null)
{
_loc2_.success = false;
}
else
{
_loc2_.data = _loc3_;
if(this._cacheArray[this._contentPath] == null)
{
this._cacheArray[this._contentPath] = [];
}
this._cacheArray[this._contentPath][_loc2_.id] = {
"id":_loc2_.id,
"data":_loc3_,
"contentType":_loc2_.contentType
};
}
var _loc4_:Object = this._loaderArray[this._contentPath][_loc2_.id];
if(_loc4_)
{
_loc4_.l.removeEventListener(LoaderEvent.ON_LOAD_COMPLETE,this.onResultGetData);
_loc5_ = int(_loc4_.c);
this._loaderArray[this._contentPath][_loc2_.id] = null;
while(_loc5_-- > 0)
{
this.newEvent(_loc2_.id,_loc2_.data,_loc2_.success,_loc2_.contentType);
}
}
}
private function newEvent(param1:int, param2:*, param3:Boolean, param4:int = 0) : void
{
var _loc5_:FileServerEvent = new FileServerEvent(FileServerEvent.ON_NEW_DATA);
_loc5_.id = param1;
_loc5_.data = param2;
_loc5_.success = param3;
_loc5_.contentType = param4;
dispatchEvent(_loc5_);
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,35 @@
package com.sbi.loader
{
import flash.events.Event;
public class FileServerEvent extends Event
{
public static const ON_NEW_DATA:String = "OnNewData";
public static const JSON_TYPE:int = 0;
public static const PLAIN_TEXT_TYPE:int = 1;
public static const AMF3_TYPE:int = 2;
public var id:uint;
public var data:*;
public var success:Boolean = true;
public var contentType:int = 0;
public function FileServerEvent(param1:String)
{
super(param1);
}
override public function clone() : Event
{
return new FileServerEvent(type);
}
}
}
@@ -0,0 +1,9 @@
package com.sbi.loader
{
public interface IResourceStackable
{
function init(param1:Function) : void;
}
}
@@ -0,0 +1,37 @@
package com.sbi.loader
{
import flash.events.Event;
public class ImageServerEvent extends Event
{
public static const ON_NEW_DATA:String = "OnNewData";
public static const ON_GLOBAL_PALETTE:String = "OnGlobalPalette";
public var id:uint;
public var layer:int;
public var imageData:*;
public var versionNum:int;
public var genericData:*;
public var frames:int;
public var success:Boolean = true;
public function ImageServerEvent(param1:String)
{
super(param1);
}
override public function clone() : Event
{
return new ImageServerEvent(type);
}
}
}
@@ -0,0 +1,235 @@
package com.sbi.loader
{
import com.sbi.graphics.ImageArray;
import com.sbi.graphics.ImageArrayHelper;
import com.sbi.graphics.PaletteHelper;
import flash.events.EventDispatcher;
import flash.utils.ByteArray;
public class ImageServerURL extends EventDispatcher
{
private static var _instance:ImageServerURL;
private static const IMAGE_ARRAY_PATH:String = "imageArrays/";
private static const PALETTE_NAME:String = "paletteData";
private var _imageCacheArray:Array;
private var _loaderCacheArray:Array;
private var _layerInfo:Object;
public function ImageServerURL(param1:Class)
{
super();
if(param1 != SingletonLock)
{
throw new Error("Invalid Singleton access. Use ImageServerURL.instance.");
}
this._imageCacheArray = new Array();
this._loaderCacheArray = new Array();
}
public static function get instance() : ImageServerURL
{
if(!_instance)
{
_instance = new ImageServerURL(SingletonLock);
}
return _instance;
}
public function set layerInfo(param1:Object) : void
{
this._layerInfo = param1;
}
public function getLayerIndex(param1:int) : int
{
return this._layerInfo[param1];
}
public function requestGlobalPalette() : void
{
var _loc1_:ImageServerEvent = null;
var _loc2_:LoaderCacheEntry_URL = null;
if(this.isGlobalPaletteCached())
{
_loc1_ = new ImageServerEvent(ImageServerEvent.ON_GLOBAL_PALETTE);
_loc1_.imageData = null;
dispatchEvent(_loc1_);
}
else
{
_loc2_ = new LoaderCacheEntry_URL(PALETTE_NAME);
_loc2_.addEventListener(LoaderEvent.ON_LOAD_COMPLETE,this.onResultGetGamePalette);
_loc2_.load();
this._loaderCacheArray["palette"] = {"l":_loc2_};
}
}
public function requestImage(param1:uint, param2:Boolean = true) : void
{
var _loc3_:LoaderCacheEntry_URL = null;
if(!param2 || this.getFromCache(param1) == false)
{
if(!this._loaderCacheArray[param1])
{
_loc3_ = new LoaderCacheEntry_URL(IMAGE_ARRAY_PATH + param1);
_loc3_.id = param1;
_loc3_.addEventListener(LoaderEvent.ON_LOAD_COMPLETE,this.onResultGetImageData);
_loc3_.load();
this._loaderCacheArray[param1] = {
"l":_loc3_,
"c":1
};
}
else
{
++this._loaderCacheArray[param1].c;
}
}
}
public function requestImages(param1:Array) : void
{
var _loc2_:int = 0;
while(_loc2_ < param1.length)
{
this.requestImage(param1[_loc2_]);
_loc2_++;
}
}
private function getFromCache(param1:uint) : Boolean
{
var _loc3_:ImageServerEvent = null;
var _loc2_:Object = this.searchCache(param1);
if(_loc2_)
{
_loc3_ = new ImageServerEvent(ImageServerEvent.ON_NEW_DATA);
_loc3_.id = _loc2_.id;
_loc3_.imageData = _loc2_.imageData;
_loc3_.frames = _loc2_.frames;
_loc3_.layer = _loc2_.layer;
_loc3_.success = _loc3_.imageData == null ? false : true;
dispatchEvent(_loc3_);
}
return _loc2_ == null ? false : true;
}
private function isGlobalPaletteCached() : Boolean
{
return Boolean(PaletteHelper.gamePalette);
}
private function searchCache(param1:uint) : Object
{
return this._imageCacheArray[param1];
}
private function onResultGetGamePalette(param1:LoaderEvent) : void
{
var _loc2_:ImageServerEvent = null;
var _loc3_:ByteArray = null;
var _loc4_:ByteArray = null;
var _loc5_:ByteArray = null;
var _loc6_:ByteArray = null;
var _loc7_:int = 0;
var _loc8_:int = 0;
if(param1)
{
this._loaderCacheArray["palette"].l.removeEventListener(LoaderEvent.ON_LOAD_COMPLETE,this.onResultGetGamePalette);
this._loaderCacheArray["palette"] = null;
_loc2_ = new ImageServerEvent(ImageServerEvent.ON_GLOBAL_PALETTE);
_loc3_ = param1.entry.data as ByteArray;
_loc4_ = new ByteArray();
_loc5_ = new ByteArray();
_loc6_ = new ByteArray();
_loc3_.position = 0;
_loc7_ = _loc3_.readInt();
_loc8_ = 4;
_loc4_.writeBytes(_loc3_,_loc8_,_loc7_);
_loc4_.position = 0;
_loc8_ += _loc7_;
_loc3_.position = _loc8_;
_loc7_ = _loc3_.readInt();
_loc8_ += 4;
_loc5_.writeBytes(_loc3_,_loc8_,_loc7_);
_loc5_.position = 0;
_loc8_ += _loc7_;
_loc3_.position = _loc8_;
_loc7_ = _loc3_.readInt();
_loc8_ += 4;
_loc6_.writeBytes(_loc3_,_loc8_,_loc7_);
_loc6_.position = 0;
_loc2_.genericData = {
"palette":_loc4_,
"avatarPalette1":_loc5_,
"avatarPalette2":_loc6_
};
dispatchEvent(_loc2_);
return;
}
throw new Error("Got 0 for GetGamePalette request!");
}
private function onResultGetImageData(param1:LoaderEvent) : void
{
var _loc5_:ImageServerEvent = null;
var _loc2_:ImageServerEvent = new ImageServerEvent(ImageServerEvent.ON_NEW_DATA);
_loc2_.id = param1.entry.id;
var _loc3_:Object = param1.entry.data;
if(_loc3_ == null)
{
this._imageCacheArray[_loc2_.id] = {
"id":_loc2_.id,
"imageData":null,
"layer":0,
"frames":0
};
_loc2_.success = false;
}
else
{
if(_loc3_.v != ImageArray.VERSION)
{
throw new Error("ERROR: Unrecognized version number(" + _loc3_.v.toString(16) + ")!");
}
_loc2_.imageData = _loc3_;
_loc2_.layer = this._layerInfo[ImageArrayHelper.layerId(_loc2_.id)];
_loc2_.frames = _loc3_.f.length;
this._imageCacheArray[_loc2_.id] = {
"id":_loc2_.id,
"imageData":_loc3_,
"layer":_loc2_.layer,
"frames":_loc2_.frames
};
}
this._loaderCacheArray[_loc2_.id].l.removeEventListener(LoaderEvent.ON_LOAD_COMPLETE,this.onResultGetImageData);
var _loc4_:* = int(this._loaderCacheArray[_loc2_.id].c);
this._loaderCacheArray[_loc2_.id] = null;
while(_loc4_-- > 0)
{
_loc5_ = new ImageServerEvent(ImageServerEvent.ON_NEW_DATA);
_loc5_.id = _loc2_.id;
_loc5_.imageData = _loc2_.imageData;
_loc5_.layer = _loc2_.layer;
_loc5_.frames = _loc2_.frames;
_loc5_.success = _loc2_.success;
dispatchEvent(_loc5_);
}
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,148 @@
package com.sbi.loader
{
import com.adobe.crypto.MD5;
import com.sbi.debug.DebugUtility;
import flash.net.URLRequest;
public class LoaderCache
{
public static var cdnSalt:String;
public static var mainClassNames:Array;
public static var _contentURL:String = "http://dev-sfs01.smartbombinteractive.com:8008/animal/";
public static var buildVersion:String = "0";
public static var deployVersion:String = "0";
public static var localMode:Boolean = true;
private static var _clientIp:String = "127.0.0.1";
private var _list:Array = null;
public function LoaderCache()
{
super();
this._list = new Array();
}
public static function get contentURL() : String
{
return _contentURL;
}
public static function set contentURL(param1:String) : void
{
_contentURL = param1;
}
public static function get clientIp() : String
{
return _clientIp;
}
public static function set clientIp(param1:String) : void
{
_clientIp = param1;
}
public static function fetchCDNHash(param1:String, param2:String = "/") : String
{
var _loc3_:String = cdnSalt + param2 + param1 + clientIp;
return MD5.hash(_loc3_);
}
public static function fetchCDNURL(param1:String, param2:String = "/", param3:Boolean = true) : String
{
var _loc8_:String = null;
var _loc4_:String = param2;
var _loc5_:String = "";
var _loc6_:String = deployVersion;
if(_loc6_ != "0" && param3)
{
_loc5_ = _loc6_ + "/";
_loc4_ += _loc5_;
}
var _loc7_:String = fetchCDNHash(param1,_loc4_);
if(param3)
{
_loc8_ = contentURL + _loc5_ + param1 + "?px-hash=" + _loc7_ + "&v=" + LoaderCache.buildVersion;
}
else
{
_loc8_ = contentURL + _loc5_ + param1 + "?px-hash=" + _loc7_;
}
return _loc8_;
}
public static function fetchCDNURLRequest(param1:String, param2:String = "/", param3:Boolean = true) : URLRequest
{
var _loc4_:String = fetchCDNURL(param1,param2,param3);
return new URLRequest(_loc4_);
}
public function openFile(param1:String, param2:Function, param3:Function = null, param4:String = "binary") : void
{
var _loc5_:* = undefined;
if(!this.findFile(param1))
{
_loc5_ = this.createLoaderCacheEntry(param1);
this._list[param1] = _loc5_;
}
else
{
DebugUtility.debugTrace("*LoaderCache name collision: " + param1);
}
this._list[param1].setCompleteCallback(param2);
if(param3 != null)
{
this._list[param1].setProgressCallback(param3);
}
this._list[param1].load(param4);
}
public function destroy() : void
{
var _loc1_:Object = null;
for(_loc1_ in this._list)
{
this.remove(String(_loc1_));
}
}
private function findFile(param1:String) : Boolean
{
return this._list[param1] == null ? false : true;
}
public function remove(param1:String) : void
{
this._list[param1].destroy();
this._list[param1] = null;
}
private function createLoaderCacheEntry(param1:String) : *
{
var _loc4_:* = undefined;
var _loc2_:int = param1.lastIndexOf(".");
var _loc3_:String = param1.slice(_loc2_ + 1,param1.length).toLowerCase();
switch(_loc3_)
{
case "swf":
case "png":
case "jpg":
case "jpeg":
_loc4_ = new LoaderCacheEntry_Loader(param1);
break;
default:
_loc4_ = new LoaderCacheEntry_URL(param1);
}
_loc4_.parent = this;
return _loc4_;
}
}
}
@@ -0,0 +1,160 @@
package com.sbi.loader
{
import flash.display.Loader;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
public class LoaderCacheEntry_Base extends EventDispatcher
{
protected var _parent:LoaderCache;
protected var _loader:*;
protected var _swf:String;
protected var _isLoaded:Boolean;
protected var _completeCallback:Function;
protected var _data:Object;
protected var _id:*;
protected var _contentType:int;
private var _percent:Number;
private var _err:String;
private var _progressCallback:Function;
public function LoaderCacheEntry_Base(param1:String)
{
super();
this._swf = param1;
}
public function set parent(param1:LoaderCache) : void
{
this._parent = param1;
}
public function set id(param1:*) : void
{
this._id = param1;
}
public function get id() : *
{
return this._id;
}
public function set contentType(param1:int) : void
{
this._contentType = param1;
}
public function get contentType() : int
{
return this._contentType;
}
public function get name() : String
{
return this._swf;
}
public function destroy() : void
{
}
public function load(param1:String = "binary", param2:Boolean = true) : void
{
}
public function setCompleteCallback(param1:Function) : void
{
if(this._completeCallback != param1)
{
if(this._completeCallback != null)
{
removeEventListener(LoaderEvent.ON_LOAD_COMPLETE,this._completeCallback);
}
addEventListener(LoaderEvent.ON_LOAD_COMPLETE,param1,false,0,true);
this._completeCallback = param1;
}
}
public function setProgressCallback(param1:Function) : void
{
if(this._progressCallback != param1)
{
if(this._progressCallback != null)
{
removeEventListener(LoaderEvent.ON_LOAD_PROGRESS,this._progressCallback);
}
addEventListener(LoaderEvent.ON_LOAD_PROGRESS,param1,false,0,true);
this._progressCallback = param1;
}
}
public function get progress() : Number
{
return this._percent;
}
public function get loader() : Loader
{
return this._loader;
}
public function get data() : Object
{
return this._data;
}
protected function onLoadCompleteEvent() : void
{
var _loc1_:LoaderEvent = new LoaderEvent(LoaderEvent.ON_LOAD_COMPLETE);
_loc1_.status = true;
_loc1_.entry = this;
dispatchEvent(_loc1_);
if(this._parent)
{
this._parent.remove(this._swf);
}
}
protected function onLoadProgressEvent() : void
{
var _loc1_:LoaderEvent = new LoaderEvent(LoaderEvent.ON_LOAD_PROGRESS);
_loc1_.status = true;
_loc1_.entry = this;
_loc1_.percent = this._percent;
dispatchEvent(_loc1_);
}
protected function loadProgress(param1:ProgressEvent) : void
{
this._percent = param1.bytesLoaded / param1.bytesTotal;
this._percent = Math.round(this._percent * 100);
this.onLoadProgressEvent();
}
protected function ioError(param1:IOErrorEvent) : void
{
var _loc2_:LoaderEvent = new LoaderEvent(LoaderEvent.ON_LOAD_COMPLETE);
_loc2_.status = false;
_loc2_.entry = this;
_loc2_.message = param1.text;
dispatchEvent(_loc2_);
if(this._parent)
{
this._parent.remove(this._swf);
}
}
}
}
@@ -0,0 +1,73 @@
package com.sbi.loader
{
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.system.SecurityDomain;
public class LoaderCacheEntry_Loader extends LoaderCacheEntry_Base
{
public function LoaderCacheEntry_Loader(param1:String)
{
super(param1);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loadProgress,false,0,true);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.loadComplete,false,0,true);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,ioError,false,0,true);
}
override public function destroy() : void
{
_loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,loadProgress);
_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,this.loadComplete);
_loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,ioError);
if(_completeCallback != null)
{
removeEventListener(LoaderEvent.ON_LOAD_COMPLETE,_completeCallback);
_completeCallback = null;
}
}
override public function load(param1:String = "binary", param2:Boolean = true) : void
{
var _loc3_:URLRequest = null;
var _loc4_:LoaderContext = null;
if(!_isLoaded)
{
if(LoaderCache.localMode && (_swf.slice(0,7) == "assets/" || _swf.slice(0,6) == "games/" || _swf.indexOf("/") == -1))
{
_loc3_ = new URLRequest(_swf);
}
else
{
_loc3_ = LoaderCache.fetchCDNURLRequest(_swf,"/",param2);
}
_loc4_ = new LoaderContext(true,ApplicationDomain.currentDomain);
if(!LoaderCache.localMode)
{
_loc4_.securityDomain = SecurityDomain.currentDomain;
}
_loader.load(_loc3_,_loc4_);
}
else
{
onLoadCompleteEvent();
}
}
private function loadComplete(param1:Event) : void
{
_isLoaded = true;
var _loc2_:LoaderInfo = param1.target as LoaderInfo;
_data = _loc2_.content;
onLoadCompleteEvent();
}
}
}
@@ -0,0 +1,91 @@
package com.sbi.loader
{
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.utils.ByteArray;
public class LoaderCacheEntry_URL extends LoaderCacheEntry_Base
{
private var _isObj:Boolean;
public function LoaderCacheEntry_URL(param1:String, param2:Boolean = true)
{
super(param1);
this._isObj = param2;
_loader = new URLLoader();
_loader.addEventListener(ProgressEvent.PROGRESS,loadProgress,false,0,true);
_loader.addEventListener(Event.COMPLETE,this.loadComplete,false,0,true);
_loader.addEventListener(IOErrorEvent.IO_ERROR,ioError,false,0,true);
}
override public function destroy() : void
{
_loader.removeEventListener(ProgressEvent.PROGRESS,loadProgress);
_loader.removeEventListener(Event.COMPLETE,this.loadComplete);
_loader.removeEventListener(IOErrorEvent.IO_ERROR,ioError);
if(_completeCallback != null)
{
removeEventListener(LoaderEvent.ON_LOAD_COMPLETE,_completeCallback);
_completeCallback = null;
}
}
override public function load(param1:String = "binary", param2:Boolean = true) : void
{
var _loc3_:URLRequest = null;
if(!_isLoaded)
{
_loc3_ = LoaderCache.fetchCDNURLRequest(_swf,"/",param2);
_loader.dataFormat = param1;
_loader.load(_loc3_);
}
else
{
onLoadCompleteEvent();
}
}
private function loadComplete(param1:Event) : void
{
var _loc2_:ByteArray = null;
var _loc3_:Object = null;
_isLoaded = true;
_data = _loader.data;
if(_data is ByteArray)
{
_loc2_ = _loader.data as ByteArray;
try
{
_loc2_.uncompress();
}
catch(err:Error)
{
}
_loc2_.position = 0;
if(this._isObj)
{
_loc3_ = _loc2_.readObject();
if(_loc2_.bytesAvailable == 0)
{
_data = _loc3_;
}
else
{
_loc2_.position = 0;
_data = _loc2_;
}
}
else
{
_data = _loc2_;
}
}
onLoadCompleteEvent();
}
}
}
@@ -0,0 +1,31 @@
package com.sbi.loader
{
import flash.events.Event;
public class LoaderEvent extends Event
{
public static const ON_LOAD_COMPLETE:String = "OnLoadComplete";
public static const ON_LOAD_PROGRESS:String = "OnLoadProgress";
public var status:Boolean;
public var entry:LoaderCacheEntry_Base;
public var message:String;
public var percent:Number;
public function LoaderEvent(param1:String)
{
super(param1);
}
override public function clone() : Event
{
return new LoaderEvent(type);
}
}
}
@@ -0,0 +1,138 @@
package com.sbi.loader
{
import com.sbi.debug.DebugUtility;
public class ResourceStack
{
private var _stack:Array;
private var _callback:Function;
private var _path:String;
private var _openFile:Function;
public function ResourceStack(param1:String, param2:Function)
{
super();
this._path = param1;
this._openFile = param2;
this._stack = new Array();
}
public function pushFile(param1:String, param2:Boolean = false) : void
{
this._stack.push({
"type":"file",
"data":param1,
"isBlocking":param2,
"inProgress":false
});
}
public function pushClass(param1:IResourceStackable, param2:Boolean = false) : void
{
this._stack.push({
"type":"class",
"data":param1,
"isBlocking":param2,
"inProgress":false
});
}
public function start(param1:Function) : void
{
this._callback = param1;
this.fifo();
}
private function fifo() : void
{
var _loc2_:int = 0;
var _loc3_:Object = null;
var _loc1_:int = int(this._stack.length);
DebugUtility.debugTrace("ResourceStack fifo len:" + _loc1_);
if(!_loc1_)
{
if(this._callback != null)
{
this._callback();
this._callback = null;
}
}
else
{
_loc2_ = 0;
while(_loc2_ < _loc1_)
{
_loc3_ = this._stack[_loc2_];
if(!_loc3_.inProgress)
{
_loc3_.inProgress = true;
switch(_loc3_.type)
{
case "file":
this.loadFile(_loc3_.data);
break;
case "class":
_loc3_.data.init(this.onInitClassComplete);
}
_loc2_ = -1;
_loc1_ = int(this._stack.length);
}
else if(_loc3_.isBlocking)
{
break;
}
_loc2_++;
}
}
}
private function loadFile(param1:String) : void
{
var _loc2_:String = this._path + param1;
this._openFile(_loc2_,this.onLoadComplete,this.onLoadProgress);
}
private function onLoadComplete(param1:LoaderEvent) : void
{
if(param1.status)
{
this.removeResource("file",param1.entry.name);
this.fifo();
return;
}
throw new Error("could not load required resource!!! msg:" + param1.message);
}
private function onLoadProgress(param1:LoaderEvent) : void
{
}
private function onInitClassComplete(param1:IResourceStackable) : void
{
this.removeResource("class",param1);
this.fifo();
}
private function removeResource(param1:String, param2:*) : void
{
var _loc5_:Object = null;
var _loc3_:int = int(this._stack.length);
var _loc4_:int = 0;
while(_loc4_ < _loc3_)
{
_loc5_ = this._stack[_loc4_];
if(_loc5_.type == param1 && _loc5_.data == param2)
{
this._stack.splice(_loc4_,1);
break;
}
_loc4_++;
}
}
}
}
@@ -0,0 +1,255 @@
package com.sbi.loader
{
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
public class SceneLoader extends EventDispatcher
{
private var _offset:Point;
private var _scene:Object;
private var _loaderCount:int;
private var _loader:Array;
public function SceneLoader()
{
super();
this._loader = new Array();
}
public function getOffset(param1:DisplayObject) : Point
{
var _loc2_:Object = null;
var _loc4_:Loader = null;
var _loc5_:Rectangle = null;
var _loc3_:Array = this.getActorList("ActorLayer");
for each(_loc2_ in _loc3_)
{
_loc4_ = _loc2_.s;
_loc5_ = _loc4_.getBounds(param1);
if(_loc5_.x < this._offset.x)
{
this._offset.x = _loc5_.x;
}
if(_loc5_.y < this._offset.y)
{
this._offset.y = _loc5_.y;
}
}
return this._offset;
}
public function get isValid() : Boolean
{
return this._scene != null;
}
public function setScene(param1:Object) : void
{
this.release();
this._scene = param1;
if(param1)
{
this.loadLayers();
}
}
public function getActorList(param1:String) : Array
{
return this._scene.actors[param1];
}
public function getLayer(param1:String) : Object
{
return this.findLayer(param1);
}
public function cloneAsset(param1:String) : Object
{
var _loc3_:Loader = null;
var _loc2_:Object = this.findLayer(param1);
if(_loc2_)
{
_loc3_ = this.newAsset(_loc2_.assetName);
_loc3_.x = _loc2_.x;
_loc3_.y = _loc2_.y;
_loc2_.loader = _loc3_;
}
return _loc2_;
}
public function release() : void
{
var _loc1_:Loader = null;
while(this._loader.length)
{
_loc1_ = this._loader.pop();
_loc1_.unloadAndStop();
}
}
public function releaseCloneAsset(param1:Loader) : void
{
var _loc2_:int = 0;
var _loc3_:Loader = null;
while(_loc2_ < this._loader.length)
{
_loc3_ = this._loader[_loc2_];
if(_loc3_ == param1)
{
param1.unloadAndStop();
this._loader.splice(_loc2_,1);
break;
}
_loc2_++;
}
}
private function findLayer(param1:String) : Object
{
var _loc2_:Object = null;
var _loc4_:int = 0;
var _loc3_:Array = this.getActorList("ActorLayer");
param1 = param1.toLowerCase();
_loc4_ = 0;
while(_loc4_ < _loc3_.length)
{
if(_loc3_[_loc4_].name == param1)
{
_loc2_ = new Object();
_loc2_.assetName = _loc3_[_loc4_].assetName;
_loc2_.loader = _loc3_[_loc4_].s;
_loc2_.height = _loc3_[_loc4_].s.height;
_loc2_.width = _loc3_[_loc4_].s.width;
_loc2_.x = _loc3_[_loc4_].s.x;
_loc2_.y = _loc3_[_loc4_].s.y;
_loc2_.flip = _loc3_[_loc4_].flip;
break;
}
_loc4_++;
}
if(_loc2_ == null)
{
}
return _loc2_;
}
private function newAsset(param1:String) : Loader
{
var _loc2_:Loader = null;
var _loc4_:int = 0;
param1 = param1.toLowerCase();
var _loc3_:Array = this._scene.assets;
while(_loc4_ < _loc3_.length)
{
if(_loc3_[_loc4_].name.toLowerCase() == param1)
{
_loc2_ = new Loader();
_loc2_.loadBytes(_loc3_[_loc4_].ba);
_loc2_.contentLoaderInfo.addEventListener(Event.COMPLETE,this.onNewLoaderComplete);
_loc2_.cacheAsBitmap = true;
this._loader.push(_loc2_);
return _loc2_;
}
_loc4_++;
}
return _loc2_;
}
private function onNewLoaderComplete(param1:Event) : void
{
var _loc2_:LoaderInfo = param1.target as LoaderInfo;
_loc2_.removeEventListener(Event.COMPLETE,this.onLoaderComplete);
if(_loc2_.content is MovieClip && MovieClip(_loc2_.content).totalFrames > 1)
{
_loc2_.content.cacheAsBitmap = false;
}
dispatchEvent(param1);
}
private function loadLayers() : void
{
var _loc2_:int = 0;
var _loc3_:Object = null;
var _loc4_:Loader = null;
this._offset = new Point(9999999,9999999);
var _loc1_:Array = this.getActorList("ActorLayer");
this._loaderCount = _loc1_.length;
_loc2_ = 0;
while(_loc2_ < _loc1_.length)
{
_loc3_ = _loc1_[_loc2_];
_loc3_.dx = _loc3_.scrollX;
_loc3_.dy = _loc3_.scrollY;
_loc4_ = this.loadAsset(_loc3_.assetName);
_loc3_.s = _loc4_;
_loc4_.x = Math.round(_loc3_.x);
_loc4_.y = Math.round(_loc3_.y);
_loc4_.rotation = _loc3_.rot;
_loc4_.scaleX = _loc3_.scaleX;
_loc4_.scaleY = _loc3_.scaleY;
_loc2_++;
}
}
private function loadAsset(param1:String) : Loader
{
var _loc2_:Loader = null;
var _loc4_:int = 0;
var _loc5_:LoaderContext = null;
param1 = param1.toLowerCase();
var _loc3_:Array = this._scene.assets;
while(_loc4_ < _loc3_.length)
{
if(_loc3_[_loc4_].name.toLowerCase() == param1)
{
_loc2_ = new Loader();
if(_loc3_[_loc4_].ba)
{
_loc5_ = new LoaderContext(false,ApplicationDomain.currentDomain);
_loc2_.loadBytes(_loc3_[_loc4_].ba,_loc5_);
_loc2_.contentLoaderInfo.addEventListener(Event.COMPLETE,this.onLoaderComplete);
_loc2_.cacheAsBitmap = true;
this._loader.push(_loc2_);
}
return _loc2_;
}
_loc4_++;
}
return _loc2_;
}
private function onLoaderComplete(param1:Event) : void
{
var _loc2_:LoaderInfo = param1.target as LoaderInfo;
_loc2_.removeEventListener(Event.COMPLETE,this.onLoaderComplete);
if(_loc2_.content is MovieClip && MovieClip(_loc2_.content).totalFrames > 1)
{
_loc2_.content.cacheAsBitmap = false;
}
--this._loaderCount;
if(this._loaderCount == 0)
{
this.allLoadingComplete();
}
}
private function allLoadingComplete() : void
{
var _loc1_:Event = new Event(Event.COMPLETE);
dispatchEvent(_loc1_);
}
}
}
@@ -0,0 +1,113 @@
package com.sbi.popup
{
import flash.display.*;
import flash.events.*;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.getDefinitionByName;
public dynamic class SBAJOkPopup extends SBPopup
{
protected var _messageText:TextField;
protected var _titleText:TextField;
protected var _skin:MovieClip;
protected var _content:MovieClip;
protected var _top:MovieClip;
protected var _mid:MovieClip;
protected var _bot:MovieClip;
private var _titleToMessageDifference:int = 5;
private var _btnTxtGap:int = 10;
private var _verticalOffset:int = 13;
private var _okBtn:MovieClip;
private var _okBtnCallback:Function;
public function SBAJOkPopup(param1:DisplayObjectContainer, param2:String = null, param3:String = null, param4:Function = null, param5:Boolean = true, param6:MovieClip = null, param7:MovieClip = null, param8:Boolean = true, param9:Boolean = true, param10:Boolean = false, param11:Boolean = false, param12:Number = undefined, param13:Number = undefined, param14:Number = undefined, param15:Number = undefined, param16:Array = null)
{
if(param4 != null)
{
this._okBtnCallback = param4;
}
else
{
this._okBtnCallback = this.onOkBtn;
}
this._skin = new (getDefinitionByName("BroadcastPopupSkin") as Class)();
this._content = new (getDefinitionByName("BroadcastPopupContent") as Class)();
this._top = this._skin.ba.t;
this._mid = this._skin.ba.m;
this._bot = this._skin.ba.b;
this._okBtn = this._content.okBtn;
this._okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this._okBtnCallback,false,0,true);
this._messageText = this._content.text;
this._titleText = this._content.titleTxt;
this._messageText.autoSize = TextFieldAutoSize.CENTER;
this._titleText.autoSize = TextFieldAutoSize.CENTER;
this.setMessageText(param2);
if(param3)
{
this._titleText.text = param3;
}
super(param1,this._skin,this._content,param8,param9,param10,param11,param5,param3,param12,param13,param14,param15,param16);
}
public static function destroyInParentChain(param1:DisplayObject) : void
{
while(Boolean(param1) && Boolean(param1 != gMainFrame.stage) && !(param1 is SBOkPopup))
{
param1 = param1.parent;
}
if(param1 is SBOkPopup)
{
SBOkPopup(param1).destroy();
}
}
override public function destroy() : void
{
this._okBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this._okBtnCallback);
super.destroy();
}
public function setMessageText(param1:String) : void
{
this._messageText.text = param1;
this.resize();
}
private function resize() : void
{
this._mid.height = Math.floor(this._messageText.height);
this._mid.y = Math.floor(-(this._mid.height * 0.5));
this._top.y = this._mid.y - this._top.height;
this._bot.y = this._mid.y + this._mid.height;
this._titleText.y = 0;
this._messageText.y = this._titleText.height + this._titleToMessageDifference;
this._okBtn.y = this._messageText.y + this._messageText.height + this._btnTxtGap + this._okBtn.height * 0.5;
this._skin.c.height = this._titleText.height + this._titleToMessageDifference + this._messageText.height + this._btnTxtGap + this._okBtn.height;
this._skin.c.y = -(this._skin.ba.height * 0.5) + this._verticalOffset;
this._content.x = this._skin.c.x;
this._content.y = this._skin.c.y;
this._content.width = this._skin.c.width;
this._content.height = this._skin.c.height;
}
private function onOkBtn(param1:MouseEvent) : void
{
param1.stopPropagation();
this.destroy();
}
}
}
@@ -0,0 +1,19 @@
package com.sbi.popup
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.text.TextField;
public dynamic class SBMessage extends SBPopup
{
public var messageTxt:TextField = new TextField();
public function SBMessage(param1:DisplayObjectContainer, param2:MovieClip, param3:String, param4:Boolean = true, param5:Boolean = true, param6:Boolean = false, param7:Boolean = true, param8:Boolean = false, param9:String = null, param10:Number = undefined, param11:Number = undefined, param12:Number = undefined, param13:Number = undefined, param14:Array = null)
{
this.messageTxt.text = param3;
super(param1,param2,this.messageTxt,param4,param5,param6,param7,param8,param9,param10,param11,param12,param13,param14);
}
}
}
@@ -0,0 +1,65 @@
package com.sbi.popup
{
import flash.display.*;
import flash.events.*;
import flash.utils.getDefinitionByName;
public dynamic class SBOkPopup extends SBStandardPopup
{
private var _okBtn:MovieClip;
private var _okBtnCallback:Function;
public function SBOkPopup(param1:DisplayObjectContainer, param2:String = null, param3:Boolean = true, param4:Function = null, param5:Boolean = true, param6:Boolean = true, param7:Boolean = false, param8:Boolean = false, param9:String = null, param10:Number = undefined, param11:Number = undefined, param12:Number = undefined, param13:Number = undefined, param14:Array = null)
{
_verticalOffset = -20;
_btnTxtGap = 6;
_btnHeight = 44;
if(param4 != null)
{
this._okBtnCallback = param4;
}
else
{
this._okBtnCallback = this.onOkBtn;
}
var _loc15_:MovieClip = new (getDefinitionByName("OkPopupSkin") as Class)();
var _loc16_:MovieClip = new (getDefinitionByName("OkPopupContent") as Class)();
this._okBtn = _loc16_.okBtn;
this._okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this._okBtnCallback,false,0,true);
_resizeCallback = this.onResize;
super(param1,param2,param3,_loc16_,_loc15_,param5,param6,param7,param8,param9,param10,param11,param12,param13,param14);
}
public static function destroyInParentChain(param1:DisplayObject) : void
{
while(Boolean(param1) && Boolean(param1 != gMainFrame.stage) && !(param1 is SBOkPopup))
{
param1 = param1.parent;
}
if(param1 is SBOkPopup)
{
SBOkPopup(param1).destroy();
}
}
override public function destroy() : void
{
this._okBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this._okBtnCallback);
super.destroy();
}
private function onResize() : void
{
this._okBtn.y = _text.height + _btnTxtGap + 0.5 * _btnHeight;
}
private function onOkBtn(param1:MouseEvent) : void
{
param1.stopPropagation();
this.destroy();
}
}
}
@@ -0,0 +1,184 @@
package com.sbi.popup
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextFieldAutoSize;
import gui.DarkenManager;
import loader.MediaHelper;
public dynamic class SBParchmentPopup
{
public static const TYPE_OK:int = 0;
public static const TYPE_YES_NO:int = 1;
public static const TYPE_CONTINUE_EXIT:int = 2;
public static const TYPE_CONTINUE_ONLY:int = 3;
private var _parent:DisplayObjectContainer;
private var _type:int;
private var _message:String;
private var _darken:Boolean;
private var _confirmCallback:Function;
private var _passback:Object;
private var _mediaHelper:MediaHelper;
private var _popup:MovieClip;
public function SBParchmentPopup(param1:DisplayObjectContainer, param2:int = 0, param3:String = null, param4:Boolean = true, param5:Function = null, param6:Object = null)
{
super();
DarkenManager.showLoadingSpiral(true);
this._parent = param1;
this._type = param2;
this._message = param3;
this._darken = param4;
this._confirmCallback = param5;
this._passback = param6;
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(2106,this.onMediaLoaded);
}
public function destroy() : void
{
var _loc1_:int = 0;
if(this._popup)
{
DarkenManager.unDarken(this._popup);
if(Boolean(this._parent) && Boolean(this._popup.parent) && this._popup.parent == this._parent)
{
this._parent.removeChild(this._popup);
}
this._popup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
switch(this._type)
{
case TYPE_CONTINUE_EXIT:
this._popup.contBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
this._popup.exitBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
break;
case TYPE_CONTINUE_ONLY:
this._popup.contOnlyBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
break;
case TYPE_OK:
this._popup.okBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
break;
case TYPE_YES_NO:
this._popup.yesBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
this._popup.noBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
}
_loc1_ = SBPopupManager.nonSBPopups.indexOf(this);
if(_loc1_ >= 0)
{
SBPopupManager.nonSBPopups.splice(_loc1_,1);
}
this._popup = null;
}
}
private function onMediaLoaded(param1:MovieClip) : void
{
var img:MovieClip = param1;
if(img)
{
DarkenManager.showLoadingSpiral(false);
this._popup = MovieClip(img.getChildAt(0));
this._mediaHelper.destroy();
this._mediaHelper = null;
switch(this._type)
{
case TYPE_CONTINUE_EXIT:
this._popup.okBtn.visible = false;
this._popup.yesBtn.visible = false;
this._popup.noBtn.visible = false;
this._popup.contOnlyBtn.visible = false;
this._popup.contBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
this._popup.exitBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
break;
case TYPE_CONTINUE_ONLY:
this._popup.okBtn.visible = false;
this._popup.yesBtn.visible = false;
this._popup.noBtn.visible = false;
this._popup.exitBtn.visible = false;
this._popup.contBtn.visible = false;
this._popup.contOnlyBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
break;
case TYPE_OK:
this._popup.yesBtn.visible = false;
this._popup.noBtn.visible = false;
this._popup.contBtn.visible = false;
this._popup.exitBtn.visible = false;
this._popup.contOnlyBtn.visible = false;
this._popup.okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
break;
case TYPE_YES_NO:
this._popup.okBtn.visible = false;
this._popup.contBtn.visible = false;
this._popup.exitBtn.visible = false;
this._popup.contOnlyBtn.visible = false;
this._popup.yesBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
this._popup.noBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
}
this._popup.txt.autoSize = TextFieldAutoSize.CENTER;
this._popup.txt.text = this._message;
with(this._popup.ba)
{
m.height = Math.floor(_popup.txt.height) + 44 + 8;
m.y = Math.floor(-(m.height * 0.5));
t.y = m.y - t.height;
b.y = m.y + m.height;
_popup.txt.y = m.y + 4;
_popup.yesBtn.y = m.y + _popup.txt.height + 13;
_popup.noBtn.y = m.y + _popup.txt.height + 13;
_popup.okBtn.y = m.y + _popup.txt.height + 9;
_popup.contBtn.y = m.y + _popup.txt.height + 13;
_popup.exitBtn.y = m.y + _popup.txt.height + 13;
_popup.contOnlyBtn.y = m.y + _popup.txt.height + 13;
}
this._popup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
this._popup.x = MainFrame.VIEW_WIDTH * 0.5;
this._popup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._parent.addChild(this._popup);
if(this._darken)
{
DarkenManager.darken(this._popup);
}
SBPopupManager.nonSBPopups.push(this);
}
}
private function onPopup(param1:MouseEvent) : void
{
param1.stopPropagation();
}
private function onBtnDown(param1:MouseEvent) : void
{
var _loc2_:Object = null;
param1.stopPropagation();
if(this._confirmCallback != null)
{
_loc2_ = {
"status":param1.currentTarget == this._popup.contBtn || param1.currentTarget == this._popup.contOnlyBtn || param1.currentTarget == this._popup.yesBtn || param1.currentTarget == this._popup.okBtn,
"passback":this._passback
};
this.destroy();
this._confirmCallback(_loc2_);
}
else
{
this.destroy();
}
}
}
}
@@ -0,0 +1,218 @@
package com.sbi.popup
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import gui.DarkenManager;
import gui.GuiRadioButtonGroup;
import loader.MediaHelper;
public dynamic class SBPollPopup
{
private static const POLL_POPUP_MEDIA_ID:int = 369;
private static const POLL_TY_POPUP_MEDIA_ID:int = 370;
private var _popupLayer:DisplayObjectContainer;
private var _tab:MovieClip;
private var _pollDef:Object;
private var _onVoteCallback:Function;
private var _onDoneCallback:Function;
private var _pollPopup:MovieClip;
private var _pollMediaHelper:MediaHelper;
private var _thankYouPopup:SBStandardTitlePopup;
private var _numOptions:int;
private var _randomizeOrder:Boolean;
private var _randOptionLookup:Array;
private var _answerSection:MovieClip;
private var _optionsGroup:GuiRadioButtonGroup;
public function SBPollPopup()
{
super();
}
public function init(param1:DisplayObjectContainer, param2:MovieClip, param3:Function, param4:Function, param5:Boolean) : void
{
this._popupLayer = param1;
this._tab = param2;
this._onVoteCallback = param3;
this._onDoneCallback = param4;
this._randomizeOrder = param5;
this._pollDef = this._tab.def;
this._randOptionLookup = [0,1,2,3];
this._thankYouPopup = new SBStandardTitlePopup(this._popupLayer,"We\'ll share all the Jammers\' results soon!",null,370,this._onDoneCallback,false);
this._pollMediaHelper = new MediaHelper();
this._pollMediaHelper.init(POLL_POPUP_MEDIA_ID,this.onMediaLoaded,true);
}
public function destroy() : void
{
this._pollPopup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onCloseBtnDown);
this._pollPopup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown);
this._pollPopup = null;
this._thankYouPopup.destroy();
this._thankYouPopup = null;
}
private function onMediaLoaded(param1:MovieClip) : void
{
if(param1)
{
if(param1.mediaHelper.id == POLL_POPUP_MEDIA_ID)
{
this._pollMediaHelper.destroy();
this._pollMediaHelper = null;
this._pollPopup = MovieClip(param1.getChildAt(0));
this.setUpPollPopup();
}
}
}
private function setUpPollPopup() : void
{
this._pollPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onCloseBtnDown,false,0,true);
this._pollPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown,false,0,true);
var _loc1_:String = this._pollDef.poll;
var _loc2_:int = _loc1_.indexOf("|");
this._pollPopup.bodyTxt.text = _loc1_.substring(0,_loc2_);
var _loc3_:Array = _loc1_.substring(_loc2_ + 1,_loc1_.length).split("|");
if(this._randomizeOrder)
{
_loc3_ = this.shuffleArray(_loc3_);
}
this._numOptions = _loc3_.length;
this._pollPopup.titleTxt.text = this._pollDef.title;
if(this._numOptions == 2)
{
this._answerSection = this._pollPopup.answer2;
this._pollPopup.answer2.visible = true;
this._pollPopup.answer3.visible = false;
this._pollPopup.answer4.visible = false;
}
else if(this._numOptions == 3)
{
this._answerSection = this._pollPopup.answer3;
this._pollPopup.answer2.visible = false;
this._pollPopup.answer3.visible = true;
this._pollPopup.answer4.visible = false;
}
else
{
this._answerSection = this._pollPopup.answer4;
this._pollPopup.answer2.visible = false;
this._pollPopup.answer3.visible = false;
this._pollPopup.answer4.visible = true;
}
this._optionsGroup = new GuiRadioButtonGroup(this._answerSection.options);
this._answerSection.voteBtn.activateGrayState(true);
this._answerSection.voteBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onVoteBtnDown,false,0,true);
var _loc4_:int = 1;
while(_loc4_ < this._numOptions + 1)
{
this._answerSection["answer" + _loc4_ + "Txt"].text = _loc3_[_loc4_ - 1];
this._answerSection.options["option" + _loc4_].addEventListener(MouseEvent.MOUSE_DOWN,this.onOptionSelected,false,0,true);
_loc4_++;
}
DarkenManager.showLoadingSpiral(false);
this.open(this._pollPopup);
}
private function shuffleArray(param1:Array) : Array
{
var _loc4_:String = null;
var _loc5_:int = 0;
var _loc6_:int = 0;
var _loc7_:int = 0;
var _loc2_:int = int(param1.length);
var _loc3_:Array = param1.slice();
while(_loc5_ < _loc2_)
{
_loc4_ = _loc3_[_loc5_];
_loc6_ = Math.floor(Math.random() * _loc2_);
if(_loc5_ != _loc6_)
{
_loc3_[_loc5_] = _loc3_[_loc6_];
_loc3_[_loc6_] = _loc4_;
_loc7_ = int(this._randOptionLookup[_loc5_]);
this._randOptionLookup[_loc5_] = this._randOptionLookup[_loc6_];
this._randOptionLookup[_loc6_] = _loc7_;
}
_loc5_++;
}
return _loc3_;
}
private function open(param1:MovieClip) : void
{
this._popupLayer.addChild(param1);
param1.x = MainFrame.VIEW_WIDTH * 0.5;
param1.y = MainFrame.VIEW_HEIGHT * 0.5;
DarkenManager.darken(param1);
param1.visible = true;
}
private function close(param1:MovieClip) : void
{
param1.visible = false;
DarkenManager.unDarken(param1);
this._popupLayer.removeChild(param1);
}
private function onVoteBtnDown(param1:MouseEvent) : void
{
param1.stopPropagation();
if(!param1.currentTarget.isGray)
{
if(this._onVoteCallback != null)
{
this._onVoteCallback(this._tab,this._randOptionLookup[this._optionsGroup.selected] + 1);
}
this.close(this._pollPopup);
this._thankYouPopup.open();
}
}
private function onCloseBtnDown(param1:MouseEvent) : void
{
param1.stopPropagation();
this.close(param1.currentTarget.parent);
this._onDoneCallback();
}
private function onOptionSelected(param1:MouseEvent) : void
{
param1.stopPropagation();
if(param1.currentTarget == this._answerSection.options.option1)
{
this._answerSection.options.option1._circle.visible = true;
}
var _loc2_:int = 1;
while(_loc2_ < this._numOptions + 1)
{
this._answerSection.options["option" + _loc2_].removeEventListener(MouseEvent.MOUSE_DOWN,this.onOptionSelected);
_loc2_++;
}
this._answerSection.voteBtn.activateGrayState(false);
}
private function onPopupDown(param1:MouseEvent) : void
{
param1.stopPropagation();
}
}
}
@@ -0,0 +1,353 @@
package com.sbi.popup
{
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
public dynamic class SBPopup extends Sprite
{
public var skin:SBPopupSkin;
public var content:DisplayObject;
public var popupFilters:Array;
public var _enabled:Boolean = true;
public var _selected:Boolean = true;
public var _modal:Boolean = false;
public var _darken:Boolean = false;
public var suppressMouseDown:Boolean = false;
public var closeCallback:Function;
public var restoreLastPos:Boolean = true;
public var lastPosX:Number;
public var lastPosY:Number;
public var draggable:Boolean = true;
public var soundsEnabled:Boolean = true;
public var bxClosesPopup:Boolean = true;
public function SBPopup(param1:DisplayObjectContainer, param2:MovieClip, param3:DisplayObject, param4:Boolean = true, param5:Boolean = true, param6:Boolean = false, param7:Boolean = false, param8:Boolean = false, param9:String = null, param10:Number = undefined, param11:Number = undefined, param12:Number = undefined, param13:Number = undefined, param14:Array = null, param15:Array = null)
{
super();
this.skin = new SBPopupSkin(param2);
this.addChild(this.skin.s);
if(param3)
{
this.content = param3;
this.content.name = "content";
this.content.x = this.skin.s["c"].x;
this.content.y = this.skin.s["c"].y;
this.content.width = this.skin.s["c"].width;
this.content.height = this.skin.s["c"].height;
this.skin.s.addChildAt(this.content,this.skin.s.getChildIndex(this.skin.s["c"]));
}
this.skin.s["c"].visible = false;
if(this.skin.s.getChildByName("bx"))
{
this.skin.s["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.bxHandler,false,0,true);
}
param1.addChild(this);
this.visible = false;
width = param12 ? param12 : this.skin.s.width;
height = param13 ? param13 : this.skin.s.height;
if(parent.stage)
{
x = param10 ? param10 : MainFrame.VIEW_WIDTH * 0.5;
y = param11 ? param11 : MainFrame.VIEW_HEIGHT * 0.5;
}
this.lastPosX = x;
this.lastPosY = y;
this.modal = param6;
this.draggable = param7;
this.enabled = param5;
this.suppressMouseDown = false;
this.popupFilters = param14;
SBPopupManager.popups.push(this);
if(param8)
{
this._darken = true;
}
if(param4)
{
this.open();
}
}
public static function isChildOf(param1:DisplayObjectContainer, param2:DisplayObjectContainer, param3:DisplayObject) : Boolean
{
var _loc4_:DisplayObject = param3;
while(_loc4_ != param2)
{
if(_loc4_ == param1)
{
return true;
}
_loc4_ = _loc4_.parent;
}
return false;
}
public function get darken() : Boolean
{
return this._darken;
}
public function get selected() : Boolean
{
return this._selected;
}
public function set selected(param1:Boolean) : void
{
if(param1)
{
}
this._selected = param1;
}
public function get enabled() : Boolean
{
return this._enabled;
}
public function set enabled(param1:Boolean) : void
{
if(param1)
{
mouseChildren = true;
}
else
{
mouseChildren = false;
}
this._enabled = param1;
}
override public function set visible(param1:Boolean) : void
{
if(param1)
{
if(this._modal)
{
SBPopupManager.modalSBPopup = this;
}
if(this._darken && SBPopupManager.darken != null)
{
SBPopupManager.darken(this);
}
}
else
{
if(this._modal && SBPopupManager.modalSBPopup == this)
{
SBPopupManager.modalSBPopup = null;
}
if(!this._darken && SBPopupManager.lighten != null)
{
SBPopupManager.lighten(this);
}
}
super.visible = param1;
}
public function get modal() : Boolean
{
return Boolean(this._modal && visible);
}
public function set modal(param1:Boolean) : void
{
if(param1)
{
if(visible)
{
if(Boolean(SBPopupManager.modalSBPopup) && Boolean(SBPopupManager.modalSBPopup != this) && SBPopupManager.modalSBPopup.modal)
{
throw new Error("Attempted to make two or more modal dialogs active at once!");
}
SBPopupManager.modalSBPopup = this;
}
}
else if(SBPopupManager.modalSBPopup == this)
{
SBPopupManager.modalSBPopup = null;
}
this._modal = param1;
}
public function addListeners() : void
{
addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDownHandler,false,0,true);
addEventListener(MouseEvent.MOUSE_UP,this.mouseUpHandler,false,0,true);
}
public function removeListeners() : void
{
removeEventListener(MouseEvent.MOUSE_DOWN,this.mouseDownHandler);
removeEventListener(MouseEvent.MOUSE_UP,this.mouseUpHandler);
}
public function open() : void
{
if(visible)
{
return;
}
if(this._darken)
{
if(Boolean(SBPopupManager) && SBPopupManager.darken != null)
{
SBPopupManager.darken(this);
}
}
this.addListeners();
this.setFilters(this.popupFilters);
if(0)
{
x = this.lastPosX;
y = this.lastPosY;
}
this.visible = true;
if(parent)
{
this.bringToFront();
}
if(this._modal)
{
SBPopupManager.modalSBPopup = this;
}
}
public function close() : void
{
if(!visible)
{
return;
}
if(this._darken)
{
if(Boolean(SBPopupManager) && SBPopupManager.lighten != null)
{
SBPopupManager.lighten(this);
}
}
this.removeListeners();
this.setFilters([]);
this.lastPosX = x;
this.lastPosY = y;
this.visible = false;
if(this._modal)
{
if(SBPopupManager.modalSBPopup == this)
{
SBPopupManager.modalSBPopup = null;
}
}
if(this.closeCallback != null)
{
this.closeCallback();
}
}
public function destroy() : void
{
if(visible)
{
this.close();
}
if(Boolean(this.skin) && Boolean(this.skin.s))
{
removeChild(this.skin.s);
if(this.content)
{
this.skin.s.removeChild(this.content);
this.content = null;
}
this.skin.s = null;
}
this.closeCallback = null;
if(parent)
{
parent.removeChild(this);
}
var _loc1_:int = SBPopupManager.popups.indexOf(this);
if(_loc1_ > 0)
{
SBPopupManager.popups.splice(_loc1_,1);
}
}
public function setFilters(param1:Array = null) : void
{
}
public function bxHandler(param1:MouseEvent) : void
{
param1.stopPropagation();
if(visible && this.bxClosesPopup)
{
this.close();
}
}
public function bringContentToFront() : void
{
this.skin.s.setChildIndex(this.content,this.skin.s.getChildIndex(this.skin.s["c"]));
}
public function mouseDownHandler(param1:MouseEvent) : void
{
param1.stopPropagation();
if(this.suppressMouseDown)
{
this.suppressMouseDown = false;
return;
}
if(!(param1.target is DisplayObject))
{
throw new Error("mouseDownHandler mouse event got a non-DisplayObject object!");
}
if(this.draggable && SBPopupManager.checkModalSBPopup(this,true) && (Boolean(SBPopup.isChildOf(this.skin.s["ba"],this,DisplayObject(param1.target)) || param1.target == this.content) || Boolean(this.content is DisplayObjectContainer && DisplayObjectContainer(this.content).getChildByName("titleDragBar") && param1.target == this.content["titleDragBar"])))
{
startDrag();
}
}
public function bringToFront() : void
{
parent.setChildIndex(this,parent.numChildren - 1);
}
public function mouseUpHandler(param1:MouseEvent) : void
{
param1.stopPropagation();
if(!(param1.target is DisplayObject))
{
throw new Error("mouseDownHandler mouse event got a non-DisplayObject object!");
}
if(this.draggable && SBPopupManager.checkModalSBPopup(this,false) && (Boolean(SBPopup.isChildOf(this.skin.s["ba"],this,DisplayObject(param1.target)) || param1.target == this.content) || Boolean(this.content is DisplayObjectContainer && DisplayObjectContainer(this.content).getChildByName("titleDragBar") && param1.target == this.content["titleDragBar"])))
{
stopDrag();
}
}
public function get closeBtn() : MovieClip
{
return this.skin.s["bx"];
}
}
}
@@ -0,0 +1,175 @@
package com.sbi.popup
{
import flash.filters.*;
public class SBPopupManager
{
public static var _selected:SBPopup;
public static var _modalSBPopup:SBPopup;
public static var _prevModalSBPopup:SBPopup;
public static var darken:Function;
public static var lighten:Function;
public static var popups:Array = [];
public static var nonSBPopups:Array = [];
public static var enabled:Boolean = true;
public function SBPopupManager()
{
super();
}
public static function get selected() : SBPopup
{
return _selected;
}
public static function set selected(param1:SBPopup) : void
{
if(param1.selected)
{
return;
}
param1.selected = true;
_selected = param1;
}
public static function get modalSBPopup() : SBPopup
{
return _modalSBPopup;
}
public static function set modalSBPopup(param1:SBPopup) : void
{
var _loc2_:SBPopup = null;
var _loc3_:SBPopup = null;
for each(_loc2_ in popups)
{
if(_loc2_ != param1)
{
_loc2_.enabled = param1 == null;
}
}
_loc3_ = _prevModalSBPopup;
if(Boolean(param1) && Boolean(_modalSBPopup) && param1 != _modalSBPopup)
{
_prevModalSBPopup = _modalSBPopup;
}
_modalSBPopup = param1;
if(_modalSBPopup == null && Boolean(_loc3_))
{
_modalSBPopup = _loc3_;
_prevModalSBPopup = null;
}
}
public static function checkModalSBPopup(param1:SBPopup, param2:Boolean) : Boolean
{
if(_modalSBPopup == null)
{
return true;
}
if(_modalSBPopup != param1)
{
if(param2)
{
_modalSBPopup.alpha = 0.5;
}
else
{
_modalSBPopup.alpha = 1;
}
return false;
}
return true;
}
public static function getBlurFilter(param1:Number = 2, param2:Number = 2, param3:int = 3) : BlurFilter
{
var _loc4_:BlurFilter = new BlurFilter();
_loc4_.blurX = param1;
_loc4_.blurY = param2;
_loc4_.quality = param3;
return _loc4_;
}
public static function getColorFilter(param1:Number = 1, param2:Number = 1, param3:Number = 1, param4:Number = 1) : ColorMatrixFilter
{
var _loc5_:Array = new Array();
_loc5_ = _loc5_.concat([param2,0,0,0,0]);
_loc5_ = _loc5_.concat([0,param3,0,0,0]);
_loc5_ = _loc5_.concat([0,0,param4,0,0]);
_loc5_ = _loc5_.concat([0,0,0,param1,0]);
return new ColorMatrixFilter(_loc5_);
}
public static function setAllPopupEffects(param1:Array = null) : void
{
var _loc2_:SBPopup = null;
for each(_loc2_ in popups)
{
_loc2_.setFilters(param1);
}
}
public static function setAllModalPopupEffects(param1:Array = null) : void
{
var _loc2_:SBPopup = null;
for each(_loc2_ in popups)
{
if(_loc2_.modal)
{
_loc2_.setFilters(param1);
}
}
}
public static function closeAll() : void
{
var _loc1_:SBPopup = null;
modalSBPopup = null;
for each(_loc1_ in popups)
{
if(_loc1_.visible)
{
_loc1_.close();
}
}
}
public static function destroyAll() : void
{
var _loc1_:SBPopup = null;
modalSBPopup = null;
for each(_loc1_ in popups)
{
_loc1_.destroy();
}
while(popups.length > 0)
{
popups.pop();
}
}
public static function destroyNonSBPopups() : void
{
var _loc1_:Object = null;
for each(_loc1_ in nonSBPopups)
{
_loc1_.destroy();
}
while(nonSBPopups.length > 0)
{
nonSBPopups.pop();
}
}
}
}
@@ -0,0 +1,21 @@
package com.sbi.popup
{
import flash.display.MovieClip;
public dynamic class SBPopupSkin
{
public var s:MovieClip;
public function SBPopupSkin(param1:MovieClip)
{
super();
this.s = param1;
if(!(Boolean(this.s["c"]) && Boolean(this.s["ba"])))
{
throw new Error("skin " + this.s.name + " is missing parts!");
}
}
}
}
@@ -0,0 +1,38 @@
package com.sbi.popup
{
import flash.display.MovieClip;
public class SBScreen
{
public var screenClip:MovieClip;
public var parentWizard:SBWizard;
public var onEnterFromPrev:Function;
public var onEnterFromNext:Function;
public var onLeaveToPrev:Function;
public var onLeaveToNext:Function;
public var onPlay:Function;
public var onClose:Function;
public function SBScreen(param1:MovieClip, param2:SBWizard)
{
super();
this.screenClip = param1;
this.parentWizard = param2;
}
public function destroy() : void
{
this.screenClip = null;
this.parentWizard = null;
}
}
}
@@ -0,0 +1,94 @@
package com.sbi.popup
{
import flash.display.*;
import flash.events.*;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.getDefinitionByName;
public dynamic class SBStandardPopup extends SBPopup
{
protected var _text:TextField;
protected var _skin:MovieClip;
protected var _content:MovieClip;
protected var _top:MovieClip;
protected var _mid:MovieClip;
protected var _bot:MovieClip;
protected var _verticalOffset:Number = 0;
protected var _btnTxtGap:Number = 0;
protected var _btnHeight:Number = 0;
protected var _resizeCallback:Function;
public function SBStandardPopup(param1:DisplayObjectContainer, param2:String = null, param3:Boolean = true, param4:MovieClip = null, param5:MovieClip = null, param6:Boolean = true, param7:Boolean = true, param8:Boolean = false, param9:Boolean = false, param10:String = null, param11:Number = undefined, param12:Number = undefined, param13:Number = undefined, param14:Number = undefined, param15:Array = null)
{
if(param5)
{
this._skin = param5;
}
else
{
this._skin = new (getDefinitionByName("PopupSkin") as Class)();
}
if(param4)
{
this._content = param4;
}
else
{
this._content = new (getDefinitionByName("PopupContent") as Class)();
}
this._top = this._skin.ba.t;
this._mid = this._skin.ba.m;
this._bot = this._skin.ba.b;
this._text = this._content.text;
this._text.autoSize = TextFieldAutoSize.CENTER;
if(param2)
{
this.setText(param2);
}
super(param1,this._skin,this._content,param6,param7,param8,param9,param3,param10,param11,param12,param13,param14,param15);
}
public function setText(param1:String) : void
{
this._text.text = param1;
this.resize();
}
public function setHtmlText(param1:String) : void
{
this._text.htmlText = param1;
this.resize();
}
private function resize() : void
{
this._mid.height = Math.floor(this._text.height);
this._mid.y = Math.floor(-(this._mid.height * 0.5) + this._verticalOffset);
this._top.y = this._mid.y - this._top.height;
this._bot.y = this._mid.y + this._mid.height;
this._text.y = 0;
this._skin.c.height = this._text.height + this._btnTxtGap + this._btnHeight;
this._skin.c.y = this._mid.y;
if(this._resizeCallback != null)
{
this._resizeCallback();
}
this._content.x = this._skin["c"].x;
this._content.y = this._skin["c"].y;
this._content.width = this._skin["c"].width;
this._content.height = this._skin["c"].height;
}
}
}
@@ -0,0 +1,148 @@
package com.sbi.popup
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextFieldAutoSize;
import gui.DarkenManager;
import loader.MediaHelper;
public dynamic class SBStandardTitlePopup
{
public static const THANK_YOU_MEDIA_ID:int = 370;
private var _popupMediaHelper:MediaHelper;
private var _openWasCalled:Boolean;
protected var _loadedMC:MovieClip;
protected var _top:MovieClip;
protected var _mid:MovieClip;
protected var _bot:MovieClip;
public function SBStandardTitlePopup(param1:DisplayObjectContainer, param2:String, param3:String = null, param4:int = 370, param5:Function = null, param6:Boolean = true, param7:Boolean = true)
{
super();
DarkenManager.showLoadingSpiral(true);
this._popupMediaHelper = new MediaHelper();
this._popupMediaHelper.init(param4,this.onMediaLoaded,{
"parent":param1,
"message":param2,
"title":param3,
"closeCallback":param5,
"autoOpen":param6,
"darken":param7
});
}
public function destroy() : void
{
DarkenManager.unDarken(this._loadedMC);
this._loadedMC.passback.parent.removeChild(this._loadedMC);
this._loadedMC.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
this._loadedMC.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
this._loadedMC = null;
this._top = null;
this._mid = null;
this._bot = null;
this._openWasCalled = false;
}
public function open() : void
{
if(this._loadedMC)
{
this._loadedMC.visible = true;
}
if(this._loadedMC.passback.darken)
{
DarkenManager.darken(this._loadedMC);
}
this._openWasCalled = true;
}
public function close() : void
{
if(this._loadedMC)
{
this._loadedMC.visible = false;
}
if(this._loadedMC.passback.darken)
{
DarkenManager.unDarken(this._loadedMC);
}
}
private function onMediaLoaded(param1:MovieClip) : void
{
DarkenManager.showLoadingSpiral(false);
if(param1)
{
this._loadedMC = param1;
this._popupMediaHelper.destroy();
this._popupMediaHelper = null;
this._loadedMC.x = MainFrame.VIEW_WIDTH * 0.5;
this._loadedMC.y = MainFrame.VIEW_HEIGHT * 0.5;
this._loadedMC.parent.x = this._loadedMC.x;
this._loadedMC.parent.y = this._loadedMC.y;
this._loadedMC.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
this._loadedMC.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
if(this._loadedMC.passback.title)
{
this._loadedMC.titleTxt.text = this._loadedMC.passback.title;
}
if(this._loadedMC.passback.message)
{
this._loadedMC.txt.bodyTxt.autoSize = TextFieldAutoSize.CENTER;
this._loadedMC.txt.bodyTxt.text = this._loadedMC.passback.message;
}
this._top = this._loadedMC.ba.t;
this._mid = this._loadedMC.ba.m;
this._bot = this._loadedMC.ba.b;
this.resize();
if(!this._loadedMC.passback.autoOpen && !this._openWasCalled)
{
this._loadedMC.visible = false;
}
else
{
this.open();
}
this._loadedMC.passback.parent.addChild(this._loadedMC);
}
}
private function onClose(param1:MouseEvent) : void
{
param1.stopPropagation();
if(this._loadedMC.passback.closeCallback)
{
this._loadedMC.passback.closeCallback();
}
else
{
this.destroy();
}
}
private function onPopup(param1:MouseEvent) : void
{
param1.stopPropagation();
}
private function resize() : void
{
this._mid.height = Math.floor(this._loadedMC.txt.height);
this._top.y = this._mid.y - this._mid.height * 0.5 - this._top.height * 0.5;
this._bot.y = this._mid.y + this._mid.height * 0.5 + this._bot.height * 0.5;
this._loadedMC.titleTxt.y = this._top.y - 23;
this._loadedMC.bx.y = this._loadedMC.titleTxt.y;
this._loadedMC.txt.y -= this._mid.height * 0.5 - 29;
}
}
}
@@ -0,0 +1,65 @@
package com.sbi.popup
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.utils.getDefinitionByName;
public dynamic class SBStayLeavePopup extends SBStandardPopup
{
private var _stayBtn:MovieClip;
private var _leaveBtn:MovieClip;
private var _confirmCallback:Function;
private var _passbackObject:Object;
public function SBStayLeavePopup(param1:DisplayObjectContainer, param2:String = null, param3:Boolean = true, param4:Function = null, param5:Object = null, param6:Boolean = true, param7:Boolean = true, param8:Boolean = false, param9:Boolean = false, param10:String = null, param11:Number = undefined, param12:Number = undefined, param13:Number = undefined, param14:Number = undefined, param15:Array = null)
{
this._confirmCallback = param4;
this._passbackObject = param5;
_verticalOffset = -20;
_btnTxtGap = 6;
_btnHeight = 44;
var _loc16_:MovieClip = new (getDefinitionByName("YesNoPopupSkin") as Class)();
var _loc17_:MovieClip = new (getDefinitionByName("LeaveStayPopupContent") as Class)();
this._stayBtn = _loc17_.stayBtn;
this._leaveBtn = _loc17_.leaveBtn;
this._stayBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onStayLeaveBtn,false,0,true);
this._leaveBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onStayLeaveBtn,false,0,true);
_resizeCallback = this.onResize;
super(param1,param2,param3,_loc17_,_loc16_,param6,param7,param8,param9,param10,param11,param12,param13,param14,param15);
}
override public function destroy() : void
{
this._stayBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onStayLeaveBtn);
this._leaveBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onStayLeaveBtn);
super.destroy();
}
private function onResize() : void
{
this._stayBtn.y = _text.height + _btnTxtGap + 0.5 * _btnHeight;
this._leaveBtn.y = this._stayBtn.y;
}
private function onStayLeaveBtn(param1:MouseEvent) : void
{
var _loc2_:Object = null;
param1.stopPropagation();
this.destroy();
if(this._confirmCallback != null)
{
_loc2_ = {
"status":param1.currentTarget == this._leaveBtn,
"passback":this._passbackObject
};
this._confirmCallback(_loc2_);
}
}
}
}
@@ -0,0 +1,245 @@
package com.sbi.popup
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
public class SBWizard
{
public var screens:Array;
private var _step:int;
private var _useSeparateScreens:Boolean;
public var wizClip:MovieClip;
public function SBWizard()
{
super();
}
public function init(param1:MovieClip, param2:Boolean = true, param3:int = 0, param4:Array = null, param5:Boolean = true, param6:Boolean = false, param7:Boolean = false) : void
{
var _loc9_:int = 0;
var _loc10_:DisplayObject = null;
var _loc11_:SBScreen = null;
var _loc12_:int = 0;
if(param1 == null)
{
throw new Error("invalid null initWizClip!");
}
this.wizClip = param1;
this._useSeparateScreens = param6;
if(!param2 && param6)
{
this.wizClip.visible = false;
}
var _loc8_:int = param6 == false ? int(param4.length) : this.wizClip.totalFrames;
if(param4)
{
this.screens = param4;
}
else
{
this.screens = [];
if(_loc8_ > 0)
{
_loc9_ = 0;
while(_loc9_ < _loc8_)
{
this.wizClip.gotoAndStop(_loc9_ + 1);
_loc10_ = this.wizClip.getChildAt(0);
_loc11_ = new SBScreen(_loc10_ as MovieClip,this);
_loc11_.screenClip.visible = false;
this.screens.push(_loc11_);
_loc9_++;
}
if(this.screens.length != uint(_loc8_))
{
throw new Error("SBWizard - Failed assertion: lengths must be equal- screens.length:" + this.screens.length + " uint(framesLength):" + uint(_loc8_));
}
}
}
this.wizClip.enabled = param5;
this.step = param3;
if(param6)
{
_loc12_ = 0;
while(_loc12_ < _loc8_)
{
this.wizClip.addChild(this.screens[_loc12_].screenClip);
_loc12_++;
}
if(param3 > 0 && param3 <= _loc8_)
{
this.screens[param3 - 1].screenClip.visible = true;
}
}
this.wizClip.stop();
}
public function destroy() : void
{
this.screens.splice(0,this.screens.length);
this.screens = null;
this.wizClip = null;
}
public function get step() : int
{
return this._step;
}
public function set step(param1:int) : void
{
if(param1 == this._step)
{
return;
}
this.jumpToStep(param1);
}
public function get currScreen() : SBScreen
{
return this.screens[this._step - 1];
}
public function get nextScreen() : SBScreen
{
if(Boolean(this.screens) && this._step < this.screens.length - 2)
{
return this.screens[int(this._step)];
}
return null;
}
public function get prevScreen() : SBScreen
{
if(Boolean(this._step > 0) && Boolean(this.screens) && this.screens.length >= this._step)
{
return this.screens[int(this._step - 2)];
}
return null;
}
public function jumpToStep(param1:int) : void
{
var _loc3_:SBScreen = null;
var _loc4_:Function = null;
var _loc5_:SBScreen = null;
var _loc6_:Function = null;
if(!this.screens || param1 < 0 || param1 > this.screens.length + 1)
{
throw new Error("illegal wizard step:" + param1 + " screens:" + (this.screens ? this.screens.length : this.screens));
}
if(!this.wizClip.enabled || param1 == this._step)
{
return;
}
var _loc2_:Boolean = Boolean(param1 > this._step);
if(this._step > 0 && this._step <= this.screens.length)
{
_loc3_ = this.screens[this._step - 1];
if(this._useSeparateScreens)
{
_loc3_.screenClip.visible = false;
}
_loc4_ = _loc2_ ? _loc3_.onLeaveToNext : _loc3_.onLeaveToPrev;
if(_loc4_ != null)
{
if(!_loc4_())
{
return;
}
}
}
this._step = param1;
if(param1 > 0 && param1 <= this.screens.length)
{
_loc5_ = this.screens[param1 - 1];
if(this._useSeparateScreens)
{
_loc5_.screenClip.visible = true;
}
_loc6_ = _loc2_ ? _loc5_.onEnterFromPrev : _loc5_.onEnterFromNext;
if(_loc6_ != null)
{
_loc6_();
}
}
}
public function jumpToScreen(param1:SBScreen) : void
{
var _loc2_:int = this.screens.indexOf(param1);
if(_loc2_ >= 0)
{
this.jumpToStep(_loc2_ + 1);
return;
}
throw new Error("SBWizard jumpToScreen - screen:" + param1 + " not found!");
}
public function next() : void
{
this.jumpToStep(this._step + 1);
}
public function prev() : void
{
this.jumpToStep(this._step - 1);
}
public function onPlay() : void
{
this.currScreen.onPlay();
}
public function onClose() : void
{
this.currScreen.onClose();
}
public function addScreen(param1:SBScreen, param2:int = 0) : void
{
if(!this.screens)
{
throw new Error("Tried to addScreen on an uninitialized wizard!");
}
if(param2 == 0)
{
this.screens.push(param1);
}
else
{
if(param2 < 0 || param2 > this.screens.length)
{
throw new Error("illegal step:" + param2 + " while trying to addScreen");
}
this.screens.splice(param2 - 1,0,param1);
}
}
public function removeScreen(param1:int = 0) : void
{
if(!this.screens || this.screens.length == 0)
{
throw new Error("Tried to removeScreen on an empty wizard!");
}
if(param1 == 0)
{
this.screens.pop();
}
else
{
if(param1 < 0 || param1 > this.screens.length)
{
throw new Error("illegal step:" + param1 + " while trying to removeScreen");
}
this.screens.splice(param1 - 1,1);
}
}
}
}
@@ -0,0 +1,71 @@
package com.sbi.popup
{
import flash.display.*;
import flash.events.*;
import flash.net.FileReference;
import flash.utils.getDefinitionByName;
public dynamic class SBYesNoPopup extends SBStandardPopup
{
private var _yesBtn:MovieClip;
private var _noBtn:MovieClip;
private var _confirmCallback:Function;
private var _passbackObject:Object;
public function SBYesNoPopup(param1:DisplayObjectContainer, param2:String = null, param3:Boolean = true, param4:Function = null, param5:Object = null, param6:Boolean = true, param7:Boolean = true, param8:Boolean = false, param9:Boolean = false, param10:String = null, param11:Number = undefined, param12:Number = undefined, param13:Number = undefined, param14:Number = undefined, param15:Array = null)
{
this._confirmCallback = param4;
this._passbackObject = param5;
_verticalOffset = -20;
_btnTxtGap = 6;
_btnHeight = 44;
var _loc16_:MovieClip = new (getDefinitionByName("YesNoPopupSkin") as Class)();
var _loc17_:MovieClip = new (getDefinitionByName("YesNoPopupContent") as Class)();
this._yesBtn = _loc17_.yesBtn;
this._noBtn = _loc17_.noBtn;
this._yesBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onYesNoBtn,false,0,true);
this._noBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onYesNoBtn,false,0,true);
_resizeCallback = this.onResize;
super(param1,param2,param3,_loc17_,_loc16_,param6,param7,param8,param9,param10,param11,param12,param13,param14,param15);
}
override public function destroy() : void
{
this._yesBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onYesNoBtn);
this._noBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onYesNoBtn);
super.destroy();
}
private function onResize() : void
{
this._yesBtn.y = _text.height + _btnTxtGap + 0.5 * _btnHeight;
this._noBtn.y = this._yesBtn.y;
}
private function onYesNoBtn(param1:MouseEvent) : void
{
var _loc2_:FileReference = null;
var _loc3_:Object = null;
param1.stopPropagation();
this.destroy();
if(Boolean(param1.currentTarget == this._yesBtn) && Boolean(this._passbackObject) && this._passbackObject.hasOwnProperty("FileReference"))
{
_loc2_ = new FileReference();
_loc2_.save(this._passbackObject.ImageData,this._passbackObject.SaveName);
}
if(this._confirmCallback != null)
{
_loc3_ = {
"status":param1.currentTarget == this._yesBtn,
"passback":this._passbackObject
};
this._confirmCallback(_loc3_);
}
}
}
}