mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,226 @@
|
||||
package com.sbi.corelib
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class Set
|
||||
{
|
||||
|
||||
private var _set:Dictionary;
|
||||
|
||||
private var _size:uint;
|
||||
|
||||
public function Set()
|
||||
{
|
||||
super();
|
||||
_set = new Dictionary();
|
||||
}
|
||||
|
||||
public function add(param1:Object) : Boolean
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!contains(param1))
|
||||
{
|
||||
_set[param1] = true;
|
||||
_size = _size + 1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addAll(param1:Object) : Boolean
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc3_:Boolean = false;
|
||||
if(param1 != null)
|
||||
{
|
||||
if(param1 is Set)
|
||||
{
|
||||
for(_loc2_ in (param1 as Set).dictionary)
|
||||
{
|
||||
if(add(_loc2_))
|
||||
{
|
||||
_loc3_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for each(_loc2_ in param1)
|
||||
{
|
||||
if(add(_loc2_))
|
||||
{
|
||||
_loc3_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function clear() : void
|
||||
{
|
||||
if(!isEmpty())
|
||||
{
|
||||
for(var _loc1_:Object in _set)
|
||||
{
|
||||
delete _set[_loc1_];
|
||||
}
|
||||
_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function contains(param1:Object) : Boolean
|
||||
{
|
||||
return param1 != null && _set[param1] != null;
|
||||
}
|
||||
|
||||
public function containsAll(param1:Object) : Boolean
|
||||
{
|
||||
if(param1 == null || isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!(param1 is Set))
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc5_:Object = param1;
|
||||
var _loc2_:Object;
|
||||
do
|
||||
{
|
||||
if(§§hasnext(_loc5_,_loc6_))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
while(_loc2_ = §§nextvalue(_loc6_,_loc5_), contains(_loc2_));
|
||||
return false;
|
||||
}
|
||||
for(_loc2_ in (param1 as Set).dictionary)
|
||||
{
|
||||
if(!contains(_loc2_))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isEmpty() : Boolean
|
||||
{
|
||||
return _size == 0;
|
||||
}
|
||||
|
||||
public function remove(param1:Object) : Object
|
||||
{
|
||||
var _loc2_:Boolean = contains(param1);
|
||||
if(_loc2_)
|
||||
{
|
||||
delete _set[param1];
|
||||
_size = _size - 1;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function removeAll(param1:Object) : Boolean
|
||||
{
|
||||
if(param1 == null || isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc3_:Boolean = false;
|
||||
if(param1 is Set)
|
||||
{
|
||||
for(var _loc2_:Object in (param1 as Set).dictionary)
|
||||
{
|
||||
if(remove(_loc2_))
|
||||
{
|
||||
_loc3_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for each(_loc2_ in param1)
|
||||
{
|
||||
if(remove(_loc2_))
|
||||
{
|
||||
_loc3_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function retainAll(param1:Object) : Boolean
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc3_:Set = null;
|
||||
if(param1 == null || isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc4_:Boolean = false;
|
||||
if(param1 is Set)
|
||||
{
|
||||
_loc3_ = param1 as Set;
|
||||
if(_loc3_.isEmpty())
|
||||
{
|
||||
clear();
|
||||
_loc4_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(_loc2_ in _set)
|
||||
{
|
||||
if(!_loc3_.contains(_loc2_))
|
||||
{
|
||||
remove(_loc2_);
|
||||
_loc4_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(param1.length == 0)
|
||||
{
|
||||
clear();
|
||||
_loc4_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(_loc2_ in _set)
|
||||
{
|
||||
if(param1.indexOf(_loc2_) == -1)
|
||||
{
|
||||
remove(_loc2_);
|
||||
_loc4_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
public function size() : uint
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
public function toArray() : Array
|
||||
{
|
||||
var _loc2_:Array = [];
|
||||
for(var _loc1_:Object in _set)
|
||||
{
|
||||
_loc2_.push(_loc1_);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function get dictionary() : Dictionary
|
||||
{
|
||||
return _set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.sbi.corelib
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.loader.ResourceStack;
|
||||
|
||||
public class Utils
|
||||
{
|
||||
|
||||
public function Utils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getDefByName(param1:String) : Class
|
||||
{
|
||||
var _loc2_:Class = null;
|
||||
try
|
||||
{
|
||||
_loc2_ = ResourceStack.hudAssetsLoaderInfo.applicationDomain.getDefinition(param1) as Class;
|
||||
}
|
||||
catch(re:ReferenceError)
|
||||
{
|
||||
DebugUtility.debugTrace("WARNING: Missing class definition \"" + param1 + "\"!");
|
||||
_loc2_ = null;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function damerauLevenshteinDistance(param1:Array, param2:Array, param3:int) : int
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc12_:int = 0;
|
||||
var _loc15_:int = 0;
|
||||
var _loc13_:int = 0;
|
||||
var _loc11_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc4_:int = param1.length + param2.length;
|
||||
var _loc10_:SimpleMatrix = new SimpleMatrix(param1.length + 2,param2.length + 2);
|
||||
_loc10_[0][0] = _loc4_;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ <= param1.length)
|
||||
{
|
||||
_loc10_[_loc5_ + 1][1] = _loc5_;
|
||||
_loc10_[_loc5_ + 1][0] = _loc4_;
|
||||
_loc5_++;
|
||||
}
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ <= param2.length)
|
||||
{
|
||||
_loc10_[1][_loc6_ + 1] = _loc6_;
|
||||
_loc10_[0][_loc6_ + 1] = _loc4_;
|
||||
_loc6_++;
|
||||
}
|
||||
var _loc14_:Array = new Array(param3);
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < param3)
|
||||
{
|
||||
_loc14_[_loc8_] = 0;
|
||||
_loc8_++;
|
||||
}
|
||||
_loc12_ = 1;
|
||||
while(_loc12_ <= param1.length)
|
||||
{
|
||||
_loc15_ = 0;
|
||||
_loc13_ = 1;
|
||||
while(_loc13_ <= param2.length)
|
||||
{
|
||||
_loc11_ = int(_loc14_[param2[_loc13_ - 1]]);
|
||||
_loc9_ = _loc15_;
|
||||
_loc7_ = param1[_loc12_ - 1] == param2[_loc13_ - 1] ? 0 : 1;
|
||||
if(_loc7_ == 0)
|
||||
{
|
||||
_loc15_ = _loc13_;
|
||||
}
|
||||
_loc10_[_loc12_ + 1][_loc13_ + 1] = Math.min(_loc10_[_loc12_][_loc13_] + _loc7_,_loc10_[_loc12_ + 1][_loc13_] + 1,_loc10_[_loc12_][_loc13_ + 1] + 1,_loc10_[_loc11_][_loc9_] + (_loc12_ - _loc11_ - 1) + 1 + (_loc13_ - _loc9_ - 1));
|
||||
_loc13_++;
|
||||
}
|
||||
_loc14_[param1[_loc12_ - 1]] = _loc12_;
|
||||
_loc12_++;
|
||||
}
|
||||
return _loc10_[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)
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
super(param1);
|
||||
if(param2 == -1)
|
||||
{
|
||||
param2 = param1;
|
||||
}
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1)
|
||||
{
|
||||
this[_loc3_] = new Array(param2);
|
||||
_loc3_++;
|
||||
}
|
||||
rows = param1;
|
||||
cols = param2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,374 @@
|
||||
package com.sbi.corelib.audio
|
||||
{
|
||||
import flash.media.SoundTransform;
|
||||
import flash.net.SharedObject;
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class SBAudio
|
||||
{
|
||||
|
||||
private static var _isMusicMuted:Boolean = false;
|
||||
|
||||
private static var _areSoundsMuted:Boolean = false;
|
||||
|
||||
private static var _isInitialized:Boolean = false;
|
||||
|
||||
private static var _volume:Number = 1;
|
||||
|
||||
private static var _cachedSounds:Dictionary;
|
||||
|
||||
private static var _sharedObj:SharedObject;
|
||||
|
||||
private static var _muteCallback:Function;
|
||||
|
||||
private static var _guiManager:Object;
|
||||
|
||||
private static var _sounds:Array = [];
|
||||
|
||||
private static var _music:Array = [];
|
||||
|
||||
public function SBAudio()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:Object, param2:Function, param3:Object) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
_guiManager = param3;
|
||||
_cachedSounds = new Dictionary();
|
||||
for(var _loc5_:String in param1)
|
||||
{
|
||||
_loc4_ = param1[_loc5_];
|
||||
addCachedSound(_loc5_,_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.volume)
|
||||
{
|
||||
setVolumeAll(_sharedObj.data.volume);
|
||||
}
|
||||
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 * _volume);
|
||||
}
|
||||
|
||||
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 get currentVolume() : Number
|
||||
{
|
||||
return _volume;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if(_isMusicMuted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc3_:SBSound = _cachedSounds[param1];
|
||||
if(!_loc3_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_loc3_.play(0,param2,new SoundTransform(_volume));
|
||||
}
|
||||
|
||||
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);
|
||||
_volume = param1;
|
||||
}
|
||||
|
||||
public static function setVolumeSounds(param1:Number) : void
|
||||
{
|
||||
for each(var _loc2_:SBSound in _sounds)
|
||||
{
|
||||
_loc2_.volume = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getVolumeMusic() : Number
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
for each(var _loc2_:Object in _music)
|
||||
{
|
||||
_loc1_ = Number(_loc2_.volume);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public static function setVolumeMusic(param1:Number) : void
|
||||
{
|
||||
for each(var _loc2_:Object 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);
|
||||
if(_guiManager != null)
|
||||
{
|
||||
if(_isMusicMuted)
|
||||
{
|
||||
_guiManager.mainHud.soundBtn.upToDownState();
|
||||
}
|
||||
else
|
||||
{
|
||||
_guiManager.mainHud.soundBtn.downToUpState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
for each(var _loc1_:Object in _music)
|
||||
{
|
||||
_loc1_.toggleMute();
|
||||
}
|
||||
_isMusicMuted = !_isMusicMuted;
|
||||
setSharedObjMusicMuted(_isMusicMuted);
|
||||
}
|
||||
|
||||
public static function muteMusic(param1:Boolean = true) : void
|
||||
{
|
||||
for each(var _loc2_:Object in _music)
|
||||
{
|
||||
_loc2_.mute();
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
_isMusicMuted = true;
|
||||
setSharedObjMusicMuted(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static function unmuteMusic(param1:Boolean = true) : void
|
||||
{
|
||||
for each(var _loc2_:Object 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
|
||||
{
|
||||
for each(var _loc1_:SBSound in _sounds)
|
||||
{
|
||||
_loc1_.togglePause();
|
||||
}
|
||||
}
|
||||
|
||||
public static function pauseSounds() : void
|
||||
{
|
||||
for each(var _loc1_:SBSound in _sounds)
|
||||
{
|
||||
_loc1_.pause();
|
||||
}
|
||||
}
|
||||
|
||||
public static function unpauseSounds() : void
|
||||
{
|
||||
for each(var _loc1_:SBSound in _sounds)
|
||||
{
|
||||
_loc1_.unpause();
|
||||
}
|
||||
}
|
||||
|
||||
public static function togglePauseMusic() : void
|
||||
{
|
||||
for each(var _loc1_:Object in _music)
|
||||
{
|
||||
_loc1_.togglePause();
|
||||
}
|
||||
}
|
||||
|
||||
public static function pauseMusic() : void
|
||||
{
|
||||
for each(var _loc1_:Object in _music)
|
||||
{
|
||||
_loc1_.pause();
|
||||
}
|
||||
}
|
||||
|
||||
public static function unpauseMusic() : void
|
||||
{
|
||||
for each(var _loc1_:Object in _music)
|
||||
{
|
||||
_loc1_.unpause();
|
||||
}
|
||||
}
|
||||
|
||||
public static function stopAll() : void
|
||||
{
|
||||
stopSounds();
|
||||
stopMusic();
|
||||
}
|
||||
|
||||
public static function stopSounds() : void
|
||||
{
|
||||
for each(var _loc1_:SBSound in _sounds)
|
||||
{
|
||||
_loc1_.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public static function stopMusic() : void
|
||||
{
|
||||
for each(var _loc1_:Object in _music)
|
||||
{
|
||||
_loc1_.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
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();
|
||||
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
|
||||
{
|
||||
_previouslyPlayedFilename = _currFilename;
|
||||
_currFilename = param1;
|
||||
_previousVolume = _currVolume;
|
||||
_currVolume = param3 * SBAudio.currentVolume;
|
||||
var _loc6_:URLRequest = LoaderCache.fetchCDNURLRequest("audio/" + param1);
|
||||
if(s)
|
||||
{
|
||||
s.removeEventListener("ioError",handleIOError);
|
||||
s = null;
|
||||
}
|
||||
if(sc)
|
||||
{
|
||||
sc.stop();
|
||||
sc = null;
|
||||
}
|
||||
s = new Sound(_loc6_,new SoundLoaderContext(param4,param5));
|
||||
volume = _currVolume;
|
||||
if(param2)
|
||||
{
|
||||
play();
|
||||
}
|
||||
else
|
||||
{
|
||||
stop();
|
||||
}
|
||||
s.addEventListener("ioError",handleIOError,false,0,true);
|
||||
}
|
||||
|
||||
public function play(param1:Number = 0, param2:int = 2147483647, param3:SoundTransform = null) : void
|
||||
{
|
||||
if(s == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sc = s.play(param1,param2,param3);
|
||||
if(sc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setTransformVolume(playVolume);
|
||||
}
|
||||
|
||||
public function get volume() : Number
|
||||
{
|
||||
return sc ? sc.soundTransform.volume : -1;
|
||||
}
|
||||
|
||||
public function set volume(param1:Number) : void
|
||||
{
|
||||
if(muted)
|
||||
{
|
||||
mutedVolume = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
playVolume = param1;
|
||||
}
|
||||
if(sc)
|
||||
{
|
||||
setTransformVolume(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function toggleMute() : void
|
||||
{
|
||||
if(muted)
|
||||
{
|
||||
unmute();
|
||||
}
|
||||
else
|
||||
{
|
||||
mute();
|
||||
}
|
||||
}
|
||||
|
||||
public function mute() : void
|
||||
{
|
||||
if(!muted)
|
||||
{
|
||||
mutedVolume = volume;
|
||||
volume = 0;
|
||||
muted = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function unmute() : void
|
||||
{
|
||||
if(muted)
|
||||
{
|
||||
volume = mutedVolume;
|
||||
muted = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function togglePause() : void
|
||||
{
|
||||
if(paused)
|
||||
{
|
||||
unpause();
|
||||
}
|
||||
else
|
||||
{
|
||||
pause();
|
||||
}
|
||||
}
|
||||
|
||||
public function pause() : void
|
||||
{
|
||||
if(s && sc && !paused)
|
||||
{
|
||||
position = sc.position;
|
||||
sc.stop();
|
||||
paused = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function unpause() : void
|
||||
{
|
||||
if(s && sc && paused)
|
||||
{
|
||||
sc = s.play(position);
|
||||
setTransformVolume(playVolume);
|
||||
paused = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function stop() : void
|
||||
{
|
||||
if(sc)
|
||||
{
|
||||
sc.stop();
|
||||
}
|
||||
paused = false;
|
||||
muted = false;
|
||||
}
|
||||
|
||||
public function get previouslyPlayedFilename() : String
|
||||
{
|
||||
return _previouslyPlayedFilename;
|
||||
}
|
||||
|
||||
public function get previousVolume() : Number
|
||||
{
|
||||
return _previousVolume;
|
||||
}
|
||||
|
||||
public function get currFilename() : String
|
||||
{
|
||||
return _currFilename;
|
||||
}
|
||||
|
||||
public function get currVolume() : Number
|
||||
{
|
||||
return _currVolume;
|
||||
}
|
||||
|
||||
private function setTransformVolume(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = sc.soundTransform;
|
||||
_loc2_.volume = param1;
|
||||
sc.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
private function handleIOError(param1:IOErrorEvent) : void
|
||||
{
|
||||
if(s)
|
||||
{
|
||||
trace("WARNING - IOError while attempting to load music:" + s.url);
|
||||
s = null;
|
||||
}
|
||||
if(sc)
|
||||
{
|
||||
sc.stop();
|
||||
sc = null;
|
||||
}
|
||||
SBAudio.removeMusic(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
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;
|
||||
|
||||
private var _onSoundComplete:Function;
|
||||
|
||||
public function SBSound(param1:Class, param2:Boolean = true, param3:Number = 1)
|
||||
{
|
||||
super();
|
||||
s = new param1();
|
||||
volume = param3;
|
||||
if(param2)
|
||||
{
|
||||
play();
|
||||
}
|
||||
else
|
||||
{
|
||||
stop();
|
||||
}
|
||||
SBAudio.addSound(this);
|
||||
}
|
||||
|
||||
public function play(param1:Number = 0, param2:int = 0, param3:SoundTransform = null, param4:Function = null) : void
|
||||
{
|
||||
if(param2 == -1)
|
||||
{
|
||||
param2 = 2147483647;
|
||||
}
|
||||
if(s == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sc = s.play(param1,param2,param3);
|
||||
if(sc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_soundPlaying = true;
|
||||
_onSoundComplete = param4;
|
||||
sc.addEventListener("soundComplete",soundStoppedHandler,false,0,true);
|
||||
setTransformVolume(playVolume);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
stop();
|
||||
sc = null;
|
||||
s = null;
|
||||
SBAudio.removeSound(this);
|
||||
}
|
||||
|
||||
public function get volume() : Number
|
||||
{
|
||||
return sc ? sc.soundTransform.volume : -1;
|
||||
}
|
||||
|
||||
public function set volume(param1:Number) : void
|
||||
{
|
||||
playVolume = param1;
|
||||
if(sc)
|
||||
{
|
||||
setTransformVolume(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function get isPlaying() : Boolean
|
||||
{
|
||||
return _soundPlaying;
|
||||
}
|
||||
|
||||
public function togglePause() : void
|
||||
{
|
||||
if(paused)
|
||||
{
|
||||
unpause();
|
||||
}
|
||||
else
|
||||
{
|
||||
pause();
|
||||
}
|
||||
}
|
||||
|
||||
public function pause() : void
|
||||
{
|
||||
if(sc && !paused)
|
||||
{
|
||||
sc.stop();
|
||||
paused = true;
|
||||
_soundPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function unpause() : void
|
||||
{
|
||||
if(s && sc && paused)
|
||||
{
|
||||
sc = s.play(sc.position);
|
||||
if(sc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_soundPlaying = true;
|
||||
sc.addEventListener("soundComplete",soundStoppedHandler,false,0,true);
|
||||
setTransformVolume(playVolume);
|
||||
paused = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function stop() : void
|
||||
{
|
||||
if(sc)
|
||||
{
|
||||
sc.stop();
|
||||
}
|
||||
paused = false;
|
||||
_soundPlaying = false;
|
||||
}
|
||||
|
||||
private function setTransformVolume(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = sc.soundTransform;
|
||||
if(SBAudio.isMusicMuted)
|
||||
{
|
||||
_loc2_.volume = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.volume = param1;
|
||||
}
|
||||
sc.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
private function soundStoppedHandler(param1:Event) : void
|
||||
{
|
||||
_soundPlaying = false;
|
||||
if(_onSoundComplete != null)
|
||||
{
|
||||
_onSoundComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.sbi.corelib.crypto
|
||||
{
|
||||
import com.hurlant.crypto.Crypto;
|
||||
import com.hurlant.crypto.hash.HMAC;
|
||||
import com.hurlant.crypto.hash.SHA256;
|
||||
import com.hurlant.crypto.symmetric.ICipher;
|
||||
import com.hurlant.crypto.symmetric.IVMode;
|
||||
import com.hurlant.crypto.symmetric.PKCS5;
|
||||
import com.hurlant.util.Base64;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class SBCrypto
|
||||
{
|
||||
|
||||
public function SBCrypto()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function hmacSha256(param1:String, param2:String) : String
|
||||
{
|
||||
return param1 != null && param2 != null && param2.length > 0 ? Base64.encodeByteArray(new HMAC(new SHA256()).compute(getUTFBytes(param1),getUTFBytes(param2))) : "";
|
||||
}
|
||||
|
||||
public static function getUTFBytes(param1:String) : ByteArray
|
||||
{
|
||||
var _loc2_:ByteArray = new ByteArray();
|
||||
_loc2_.writeUTFBytes(param1);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function encrypt(param1:String, param2:String) : String
|
||||
{
|
||||
var _loc5_:ByteArray = new SHA256().hash(getUTFBytes(param2));
|
||||
var _loc4_:ByteArray = getUTFBytes(param1);
|
||||
var _loc3_:ICipher = Crypto.getCipher("aes-256-cbc",_loc5_,new PKCS5());
|
||||
_loc3_.encrypt(_loc4_);
|
||||
var _loc7_:IVMode = _loc3_ as IVMode;
|
||||
var _loc6_:ByteArray = _loc7_.IV;
|
||||
_loc6_.writeBytes(_loc4_);
|
||||
return Base64.encodeByteArray(_loc6_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,454 @@
|
||||
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.TextLineMetrics;
|
||||
import flash.utils.setTimeout;
|
||||
import gui.EmoticonUtility;
|
||||
|
||||
public class SBTextField extends TextField
|
||||
{
|
||||
|
||||
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;
|
||||
|
||||
private var _hasOnlyOneEmote:Boolean;
|
||||
|
||||
private var _textDisplayMC:MovieClip;
|
||||
|
||||
public function SBTextField(param1:TextField, param2:TextField, param3:MovieClip, param4:Boolean = false, param5:Boolean = false, param6:Function = null)
|
||||
{
|
||||
super();
|
||||
_inputTxt = param1;
|
||||
_outputTxt = param2;
|
||||
_clearOutput = param4;
|
||||
_updateSizeFunction = param6;
|
||||
_outputTxt.addEventListener("scroll",scrollListener);
|
||||
if(_inputTxt)
|
||||
{
|
||||
_inputTxt.text = "";
|
||||
}
|
||||
_smileyHistory = "";
|
||||
_smileyarray = [];
|
||||
_stringIndex = 0;
|
||||
_textDisplayMC = param3;
|
||||
_smileyHolder = new MovieClip();
|
||||
_smileyHolder.graphics.beginFill(0,0);
|
||||
_smileyHolder.graphics.drawRect(param3.x,param3.y,param2.width,param2.height);
|
||||
_smileyHolder.graphics.endFill();
|
||||
_smileyHolder.mouseChildren = false;
|
||||
_smileyHolder.mouseEnabled = false;
|
||||
if(!_clearOutput)
|
||||
{
|
||||
_smileyMask = new MovieClip();
|
||||
_smileyMask.graphics.beginFill(16777215,1);
|
||||
_smileyMask.graphics.drawRect(param3.x,param3.y,param3.width,param3.height);
|
||||
_smileyMask.graphics.endFill();
|
||||
_smileyHolder.mask = _smileyMask;
|
||||
}
|
||||
if(param3.parent)
|
||||
{
|
||||
param3.parent.addChild(_smileyHolder);
|
||||
if(!_clearOutput)
|
||||
{
|
||||
param3.parent.addChild(_smileyMask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
param3.addChild(_smileyHolder);
|
||||
if(!_clearOutput)
|
||||
{
|
||||
param3.addChild(_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 _loc2_:String = _outputTxt.text;
|
||||
var _loc1_:int = _loc2_.indexOf("\r") + 1;
|
||||
_loc2_ = _loc2_.substr(_loc1_);
|
||||
clear();
|
||||
appendText(_loc2_);
|
||||
}
|
||||
|
||||
public function adjustSmileys(param1:Number) : void
|
||||
{
|
||||
_smileyHolder.y -= param1;
|
||||
}
|
||||
|
||||
override public function get autoSize() : String
|
||||
{
|
||||
return _outputTxt.autoSize;
|
||||
}
|
||||
|
||||
override public function set autoSize(param1:String) : void
|
||||
{
|
||||
_outputTxt.autoSize = param1;
|
||||
}
|
||||
|
||||
override public function get text() : String
|
||||
{
|
||||
return _outputTxt.text;
|
||||
}
|
||||
|
||||
override public function set text(param1:String) : void
|
||||
{
|
||||
if(_clearOutput || param1 == "")
|
||||
{
|
||||
clear();
|
||||
}
|
||||
addText(param1);
|
||||
}
|
||||
|
||||
override public function get textColor() : uint
|
||||
{
|
||||
return _outputTxt.textColor;
|
||||
}
|
||||
|
||||
override public function set textColor(param1:uint) : void
|
||||
{
|
||||
_outputTxt.textColor = param1;
|
||||
}
|
||||
|
||||
override public function get x() : Number
|
||||
{
|
||||
return _outputTxt.x;
|
||||
}
|
||||
|
||||
override public function set x(param1:Number) : void
|
||||
{
|
||||
_outputTxt.x = param1;
|
||||
}
|
||||
|
||||
override public function get y() : Number
|
||||
{
|
||||
return _outputTxt.y;
|
||||
}
|
||||
|
||||
override public function set y(param1:Number) : void
|
||||
{
|
||||
_outputTxt.y = param1;
|
||||
}
|
||||
|
||||
override public function get height() : Number
|
||||
{
|
||||
return _outputTxt.height;
|
||||
}
|
||||
|
||||
override public function set height(param1:Number) : void
|
||||
{
|
||||
_outputTxt.height = param1;
|
||||
}
|
||||
|
||||
override public function get width() : Number
|
||||
{
|
||||
return _outputTxt.width;
|
||||
}
|
||||
|
||||
override public function set width(param1:Number) : void
|
||||
{
|
||||
_outputTxt.width = param1;
|
||||
}
|
||||
|
||||
override public function get visible() : Boolean
|
||||
{
|
||||
return _outputTxt.visible;
|
||||
}
|
||||
|
||||
override public function set visible(param1:Boolean) : void
|
||||
{
|
||||
_outputTxt.visible = param1;
|
||||
}
|
||||
|
||||
override public function get alpha() : Number
|
||||
{
|
||||
return _outputTxt.alpha;
|
||||
}
|
||||
|
||||
override public function set alpha(param1:Number) : void
|
||||
{
|
||||
_outputTxt.alpha = param1;
|
||||
}
|
||||
|
||||
override public function appendText(param1:String) : void
|
||||
{
|
||||
if(_clearOutput || param1 == "")
|
||||
{
|
||||
clear();
|
||||
}
|
||||
addText(param1);
|
||||
}
|
||||
|
||||
override public function set scrollV(param1:int) : void
|
||||
{
|
||||
_outputTxt.scrollV = param1;
|
||||
}
|
||||
|
||||
override public function get scrollV() : int
|
||||
{
|
||||
return _outputTxt.scrollV;
|
||||
}
|
||||
|
||||
override public function get maxScrollV() : int
|
||||
{
|
||||
return _outputTxt.maxScrollV;
|
||||
}
|
||||
|
||||
override public function get length() : int
|
||||
{
|
||||
return _outputTxt.length;
|
||||
}
|
||||
|
||||
override public function set defaultTextFormat(param1:TextFormat) : void
|
||||
{
|
||||
param1.align = "left";
|
||||
_outputTxt.defaultTextFormat = param1;
|
||||
}
|
||||
|
||||
override public function setTextFormat(param1:TextFormat, param2:int = -1, param3:int = -1) : void
|
||||
{
|
||||
param1.align = "left";
|
||||
_outputTxt.setTextFormat(param1,param2,param3);
|
||||
_outputTxt.defaultTextFormat = param1;
|
||||
}
|
||||
|
||||
override public function get numLines() : int
|
||||
{
|
||||
return _outputTxt.numLines;
|
||||
}
|
||||
|
||||
override public function get selectable() : Boolean
|
||||
{
|
||||
return _outputTxt.selectable;
|
||||
}
|
||||
|
||||
override public function set selectable(param1:Boolean) : void
|
||||
{
|
||||
_outputTxt.selectable = param1;
|
||||
}
|
||||
|
||||
override public function getTextFormat(param1:int = -1, param2:int = -1) : TextFormat
|
||||
{
|
||||
return _outputTxt.getTextFormat(param1,param2);
|
||||
}
|
||||
|
||||
private function addText(param1:String) : void
|
||||
{
|
||||
var _loc5_:* = null;
|
||||
var _loc10_:* = null;
|
||||
var _loc9_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc2_:Boolean = false;
|
||||
var _loc7_:Object = null;
|
||||
var _loc3_:TextField = null;
|
||||
var _loc8_:String = null;
|
||||
var _loc6_:int = 0;
|
||||
if(param1 != "")
|
||||
{
|
||||
_normalStringHistory += param1;
|
||||
updateAllEmotes = true;
|
||||
_loc7_ = EmoticonUtility.formatStringForSmiley(param1,_stringIndex,_smileyarray,updateAllEmotes);
|
||||
param1 = _loc7_.str;
|
||||
_stringIndex = _loc7_.stringIndex;
|
||||
_smileyarray = _loc7_.smileyArray;
|
||||
_hasOnlyOneEmote = _loc7_.hasOnlyOne;
|
||||
_outputTxt.appendText(param1);
|
||||
if(_outputTxt.scrollV + 1 >= _outputTxt.maxScrollV)
|
||||
{
|
||||
_outputTxt.scrollV = _outputTxt.maxScrollV;
|
||||
}
|
||||
if(numLines >= 100)
|
||||
{
|
||||
_outputTxt.text = _normalStringHistory;
|
||||
_loc3_ = _outputTxt;
|
||||
while(_loc3_.numLines > 100 * 0.5)
|
||||
{
|
||||
_loc6_ = _loc3_.text.indexOf("\r") + 1;
|
||||
_loc3_.text = _loc3_.text.substr(_loc6_);
|
||||
}
|
||||
_loc8_ = _loc3_.text.split("\r").join("\n");
|
||||
updateAllEmotes = true;
|
||||
clear();
|
||||
text = _loc8_;
|
||||
_loc3_ = null;
|
||||
return;
|
||||
}
|
||||
setTimeout(setupSmileys,41.666666666666664,param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function setupSmileys(param1:String) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc5_:Rectangle = null;
|
||||
var _loc7_:TextLineMetrics = null;
|
||||
var _loc6_:MovieClip = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc8_:Number = 0;
|
||||
var _loc4_:Array = [];
|
||||
for(; _loc2_ < _smileyarray.length; _loc2_++)
|
||||
{
|
||||
if(_smileyarray[_loc2_] != null)
|
||||
{
|
||||
if(!_smileyarray[_loc2_].added)
|
||||
{
|
||||
_loc5_ = _outputTxt.getCharBoundaries(_smileyarray[_loc2_].strindex);
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc7_ = _outputTxt.getLineMetrics(_outputTxt.numLines - 1);
|
||||
_loc6_ = _smileyarray[_loc2_].emoticon;
|
||||
if(_hasOnlyOneEmote)
|
||||
{
|
||||
_loc6_.scaleX = _loc6_.scaleY = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_.height = _loc7_.height;
|
||||
_loc6_.scaleX = _loc6_.scaleY;
|
||||
}
|
||||
_loc3_ = _loc5_.x + _loc6_.width * 0.5;
|
||||
if(_loc3_ > _outputTxt.width)
|
||||
{
|
||||
_loc5_ = _outputTxt.getCharBoundaries(_smileyarray[_loc2_].strindex + 1);
|
||||
if(!_loc5_)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_loc6_.x = _loc5_.x + _textDisplayMC.x + _loc6_.width * 0.5 - 5;
|
||||
_loc6_.y = _loc5_.y + _textDisplayMC.y + _loc6_.height * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_.x = _loc5_.x + _textDisplayMC.x + _loc6_.width * 0.5;
|
||||
_loc6_.y = _loc5_.y + _textDisplayMC.y + _loc6_.height * 0.5;
|
||||
}
|
||||
_smileyHolder.addChild(_loc6_);
|
||||
_smileyarray[_loc2_].added = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_smileyHistory == "")
|
||||
{
|
||||
_smileyHistory = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_smileyHistory += "\n" + param1;
|
||||
}
|
||||
_smileyarray = [];
|
||||
if(_updateSizeFunction != null)
|
||||
{
|
||||
_updateSizeFunction();
|
||||
}
|
||||
}
|
||||
|
||||
private function clear() : void
|
||||
{
|
||||
if(_inputTxt)
|
||||
{
|
||||
_inputTxt.text = "";
|
||||
}
|
||||
_smileyHolder.y = 0;
|
||||
while(_smileyHolder.numChildren > 0)
|
||||
{
|
||||
_smileyHolder.removeChildAt(0);
|
||||
}
|
||||
_outputTxt.text = "";
|
||||
_smileyarray = [];
|
||||
_smileyHistory = "";
|
||||
_stringIndex = 0;
|
||||
_normalStringHistory = "";
|
||||
_hasOnlyOneEmote = false;
|
||||
}
|
||||
|
||||
private function removeSpace(param1:String) : String
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:String = "";
|
||||
var _loc4_:Array = param1.split("");
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc4_.length)
|
||||
{
|
||||
if(_loc2_ == " ")
|
||||
{
|
||||
if(_loc4_[_loc3_] == " ")
|
||||
{
|
||||
_loc4_[_loc3_] = "";
|
||||
_loc2_ = " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = _loc4_[_loc3_];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = _loc4_[_loc3_];
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return _loc4_.join("");
|
||||
}
|
||||
|
||||
private function scrollListener(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:TextLineMetrics = null;
|
||||
var _loc2_:Number = NaN;
|
||||
if(!_clearOutput)
|
||||
{
|
||||
_loc2_ = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _outputTxt.scrollV - 1)
|
||||
{
|
||||
_loc4_ = _outputTxt.getLineMetrics(_loc3_);
|
||||
_loc2_ += _loc4_.height;
|
||||
_loc3_++;
|
||||
}
|
||||
_smileyHolder.y = -_loc2_;
|
||||
}
|
||||
}
|
||||
|
||||
private function setSize(param1:Number, param2:Number) : void
|
||||
{
|
||||
_smileyMask.width = param1;
|
||||
_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 _loc11_:Number = param2.x - param1.x;
|
||||
var _loc13_:Number = param2.y - param1.y;
|
||||
var _loc6_:Number = param4.x - param3.x;
|
||||
var _loc8_:Number = param4.y - param3.y;
|
||||
var _loc5_:Number = _loc11_ * _loc8_ - _loc13_ * _loc6_;
|
||||
if(_loc5_ == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc9_:Number = param3.x - param1.x;
|
||||
var _loc12_:Number = param3.y - param1.y;
|
||||
var _loc7_:Number = (_loc9_ * _loc8_ - _loc12_ * _loc6_) / _loc5_;
|
||||
if(_loc7_ < 0 || _loc7_ > 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc10_:Number = (_loc9_ * _loc13_ - _loc12_ * _loc11_) / _loc5_;
|
||||
if(_loc10_ < 0 || _loc10_ > 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Point(param1.x + _loc7_ * _loc11_,param1.y + _loc7_ * _loc13_);
|
||||
}
|
||||
|
||||
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 _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 _loc5_ < param3 * param3;
|
||||
}
|
||||
|
||||
public static function movingCircleVsRay(param1:Point, param2:Number, param3:Point, param4:Number, param5:Point, param6:Point) : Number
|
||||
{
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc23_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc24_:Number = NaN;
|
||||
var _loc21_:Point = null;
|
||||
var _loc11_:Point = null;
|
||||
var _loc10_:Point = null;
|
||||
var _loc12_:Point = param6.subtract(param5);
|
||||
var _loc20_:Point = param1.subtract(param5);
|
||||
var _loc9_:Point = new Point();
|
||||
var _loc14_:Point = new Point(param3.x * param4,param3.y * param4);
|
||||
var _loc16_:Number = param3.x * param3.y;
|
||||
var _loc18_:Number;
|
||||
var _loc7_:Number = _loc18_ = _loc14_.x * _loc12_.y - _loc14_.y * _loc12_.x;
|
||||
if(_loc7_ == 0)
|
||||
{
|
||||
_loc8_ = _loc20_.x * _loc12_.x + _loc20_.y * _loc12_.y;
|
||||
_loc9_.x = _loc20_.x - _loc12_.x * _loc8_;
|
||||
_loc9_.y = _loc20_.y - _loc12_.y * _loc8_;
|
||||
param4 = 0;
|
||||
return _loc9_.x * _loc9_.y <= param2 ? -1 : 1;
|
||||
}
|
||||
_loc18_ /= _loc7_;
|
||||
_loc8_ = 0;
|
||||
if(_loc8_ <= param2)
|
||||
{
|
||||
_loc17_ = _loc20_.x * _loc12_.y - _loc20_.y * _loc12_.x;
|
||||
_loc23_ = -(_loc17_ * _loc18_) / _loc7_;
|
||||
_loc13_ = -(_loc18_ * _loc12_.y);
|
||||
_loc15_ = _loc18_ * _loc12_.x;
|
||||
_loc19_ = _loc13_ * _loc13_ + _loc15_ * _loc15_;
|
||||
if(_loc19_)
|
||||
{
|
||||
_loc19_ = Math.sqrt(_loc19_);
|
||||
_loc13_ /= _loc19_;
|
||||
_loc15_ /= _loc19_;
|
||||
}
|
||||
_loc22_ = Math.abs(param2 / (_loc14_.x * _loc13_ + _loc14_.y * _loc15_));
|
||||
if(_loc23_ < -_loc22_)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(_loc23_ - _loc22_ > 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
_loc24_ = _loc23_ - _loc22_ < 0 ? 0 : _loc23_ - _loc22_;
|
||||
_loc21_ = new Point(param1.x + param3.x * _loc24_,param1.y + param3.y * _loc24_);
|
||||
_loc11_ = _loc21_.subtract(param5);
|
||||
_loc10_ = _loc21_.subtract(param6);
|
||||
if(_loc11_.x * _loc12_.x + _loc11_.y * _loc12_.y < 0)
|
||||
{
|
||||
return Ray_Vs_Sphere(param1,param3,param4,param5,param2);
|
||||
}
|
||||
if(_loc10_.x * _loc12_.x + _loc10_.y * _loc12_.y > 0)
|
||||
{
|
||||
return Ray_Vs_Sphere(param1,param3,param4,param6,param2);
|
||||
}
|
||||
return _loc24_;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function rayHitCircle(param1:Point, param2:Number, param3:Point, param4:Point) : Boolean
|
||||
{
|
||||
var _loc5_:Point = param1.subtract(param3);
|
||||
var _loc9_:Point = param4.subtract(param3);
|
||||
var _loc6_:Number = (_loc5_.x * _loc9_.x + _loc5_.y * _loc9_.y) / (_loc9_.x * _loc9_.x + _loc9_.y * _loc9_.y);
|
||||
if(_loc6_ < 0)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
}
|
||||
if(_loc6_ > 1)
|
||||
{
|
||||
_loc6_ = 1;
|
||||
}
|
||||
var _loc10_:Point = new Point(param3.x + _loc6_ * _loc9_.x,param3.y + _loc6_ * _loc9_.y);
|
||||
var _loc7_:Point = param1.subtract(_loc10_);
|
||||
var _loc8_:Number = _loc7_.x * _loc7_.x + _loc7_.y * _loc7_.y;
|
||||
return _loc8_ <= param2 * param2;
|
||||
}
|
||||
|
||||
public static function Ray_Vs_Sphere(param1:Point, param2:Point, param3:Number, param4:Point, param5:Number) : Number
|
||||
{
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc10_:Point = null;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc8_:Number = param5 * param5;
|
||||
var _loc7_:Point = param4.subtract(param1);
|
||||
var _loc23_:Number = _loc7_.x * _loc7_.x + _loc7_.y * _loc7_.y;
|
||||
var _loc9_:Point = new Point(param2.x * param3,param2.y * param3);
|
||||
var _loc6_:Point = _loc9_.add(param1);
|
||||
var _loc12_:Number = _loc9_.x * _loc7_.x + _loc9_.y * _loc7_.y;
|
||||
var _loc15_:Point = param4.subtract(_loc6_);
|
||||
var _loc11_:Number = _loc9_.x * _loc15_.x + _loc9_.y * _loc15_.y;
|
||||
var _loc13_:Number = (_loc15_.x + _loc15_.y) * (_loc15_.x + _loc15_.y);
|
||||
var _loc14_:Number = _loc9_.x * _loc7_.y - _loc9_.y * _loc7_.x;
|
||||
var _loc18_:Number = _loc14_ * _loc14_;
|
||||
var _loc16_:Number = _loc9_.x * _loc9_.x + _loc9_.y * _loc9_.y;
|
||||
if(_loc12_ > 0 && (_loc11_ < 0 || _loc13_ < _loc8_) && _loc18_ < _loc8_ * _loc16_ && _loc16_ > 0.00001)
|
||||
{
|
||||
_loc22_ = Math.sqrt(_loc8_ - _loc18_ / _loc16_);
|
||||
_loc19_ = Math.sqrt(_loc16_);
|
||||
_loc17_ = 1 / _loc19_;
|
||||
_loc10_ = new Point(_loc9_.x * _loc17_,_loc9_.y * _loc17_);
|
||||
_loc20_ = _loc10_.x * _loc7_.x + _loc10_.y * _loc7_.y;
|
||||
_loc21_ = param3 * (_loc20_ - _loc22_) * _loc17_;
|
||||
return _loc21_ < 0 ? 0 : _loc21_;
|
||||
}
|
||||
if(_loc23_ < _loc8_)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.sbi.corelib.math
|
||||
{
|
||||
public class RandomSeed
|
||||
{
|
||||
|
||||
protected static var _instance:RandomSeed;
|
||||
|
||||
protected var _seed:uint = 0;
|
||||
|
||||
protected var _currentSeed:uint = 0;
|
||||
|
||||
public function RandomSeed(param1:uint = 1)
|
||||
{
|
||||
super();
|
||||
_seed = _currentSeed = param1;
|
||||
}
|
||||
|
||||
public static function get instance() : RandomSeed
|
||||
{
|
||||
if(_instance == null)
|
||||
{
|
||||
_instance = new RandomSeed();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public static function get seed() : uint
|
||||
{
|
||||
return instance.seed;
|
||||
}
|
||||
|
||||
public static function set seed(param1:uint) : void
|
||||
{
|
||||
instance.seed = param1;
|
||||
}
|
||||
|
||||
public static function get currentSeed() : uint
|
||||
{
|
||||
return instance.currentSeed;
|
||||
}
|
||||
|
||||
public static function random() : Number
|
||||
{
|
||||
return instance.random();
|
||||
}
|
||||
|
||||
public static function float(param1:Number, param2:Number = NaN) : Number
|
||||
{
|
||||
return instance.float(param1,param2);
|
||||
}
|
||||
|
||||
public static function boolean(param1:Number = 0.5) : Boolean
|
||||
{
|
||||
return instance.boolean(param1);
|
||||
}
|
||||
|
||||
public static function sign(param1:Number = 0.5) : int
|
||||
{
|
||||
return instance.sign(param1);
|
||||
}
|
||||
|
||||
public static function bit(param1:Number = 0.5) : int
|
||||
{
|
||||
return instance.bit(param1);
|
||||
}
|
||||
|
||||
public static function integer(param1:Number, param2:Number = NaN) : int
|
||||
{
|
||||
return instance.integer(param1,param2);
|
||||
}
|
||||
|
||||
public static function reset() : void
|
||||
{
|
||||
instance.reset();
|
||||
}
|
||||
|
||||
public function get seed() : uint
|
||||
{
|
||||
return _seed;
|
||||
}
|
||||
|
||||
public function set seed(param1:uint) : void
|
||||
{
|
||||
_seed = _currentSeed = param1;
|
||||
}
|
||||
|
||||
public function get currentSeed() : uint
|
||||
{
|
||||
return _currentSeed;
|
||||
}
|
||||
|
||||
public function random() : Number
|
||||
{
|
||||
return (_currentSeed = _currentSeed * 16807 % 2147483647) / 2147483647 + 2.33e-10;
|
||||
}
|
||||
|
||||
public function float(param1:Number, param2:Number = NaN) : Number
|
||||
{
|
||||
if(isNaN(param2))
|
||||
{
|
||||
param2 = param1;
|
||||
param1 = 0;
|
||||
}
|
||||
return random() * (param2 - param1) + param1;
|
||||
}
|
||||
|
||||
public function boolean(param1:Number = 0.5) : Boolean
|
||||
{
|
||||
return random() < param1;
|
||||
}
|
||||
|
||||
public function sign(param1:Number = 0.5) : int
|
||||
{
|
||||
return random() < param1 ? 1 : -1;
|
||||
}
|
||||
|
||||
public function bit(param1:Number = 0.5) : int
|
||||
{
|
||||
return random() < param1 ? 1 : 0;
|
||||
}
|
||||
|
||||
public function integer(param1:Number, param2:Number = NaN) : int
|
||||
{
|
||||
if(isNaN(param2))
|
||||
{
|
||||
param2 = param1;
|
||||
param1 = 0;
|
||||
}
|
||||
return Math.floor(float(param1,param2));
|
||||
}
|
||||
|
||||
public function reset() : void
|
||||
{
|
||||
_seed = _currentSeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user