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,165 @@
|
||||
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;
|
||||
|
||||
private var _loadProgressFunc:Function;
|
||||
|
||||
public function BaseFileServer(param1:String)
|
||||
{
|
||||
super();
|
||||
_contentPath = param1;
|
||||
_loaderArray = [];
|
||||
_cacheArray = [];
|
||||
}
|
||||
|
||||
public function updatePath(param1:String) : void
|
||||
{
|
||||
_contentPath = param1;
|
||||
}
|
||||
|
||||
public function clearFromCache(param1:String, param2:Object) : void
|
||||
{
|
||||
if(_cacheArray[param1])
|
||||
{
|
||||
if(_cacheArray[param1][param2])
|
||||
{
|
||||
delete _cacheArray[param1][param2];
|
||||
}
|
||||
}
|
||||
if(_loaderArray[param1])
|
||||
{
|
||||
if(_loaderArray[param1][param2])
|
||||
{
|
||||
delete _loaderArray[param1][param2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function requestFile(param1:Object, param2:Boolean = false, param3:int = 0, param4:Boolean = true, param5:Function = null) : void
|
||||
{
|
||||
var _loc6_:LoaderCacheEntry_URL = null;
|
||||
if(param2 || getFromCache(param1) == false)
|
||||
{
|
||||
if(!(_loaderArray[_contentPath] ? _loaderArray[_contentPath][param1] : false))
|
||||
{
|
||||
_loc6_ = new LoaderCacheEntry_URL(_contentPath + param1,false);
|
||||
_loc6_.id = param1;
|
||||
_loc6_.contentType = param3;
|
||||
_loc6_.addEventListener("OnLoadComplete",onResultGetData);
|
||||
_loadProgressFunc = param5;
|
||||
if(_loadProgressFunc != null)
|
||||
{
|
||||
_loc6_.addEventListener("OnLoadProgress",_loadProgressFunc);
|
||||
}
|
||||
_loc6_.load("binary",param4);
|
||||
if(_loaderArray[_contentPath] == null)
|
||||
{
|
||||
_loaderArray[_contentPath] = [];
|
||||
}
|
||||
_loaderArray[_contentPath][param1] = {
|
||||
"l":_loc6_,
|
||||
"c":1
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
_loaderArray[_contentPath][param1].c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function requestFiles(param1:Array) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < param1.length)
|
||||
{
|
||||
requestFile(param1[_loc2_]);
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function getFromCache(param1:Object) : Boolean
|
||||
{
|
||||
var _loc2_:Object = searchCache(param1);
|
||||
if(_loc2_)
|
||||
{
|
||||
newEvent(_loc2_.id,_loc2_.data,true,_loc2_.contentType);
|
||||
}
|
||||
return _loc2_ == null ? false : true;
|
||||
}
|
||||
|
||||
private function searchCache(param1:Object) : Object
|
||||
{
|
||||
return _cacheArray[_contentPath] ? _cacheArray[_contentPath][param1] : null;
|
||||
}
|
||||
|
||||
private function onResultGetData(param1:LoaderEvent) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:FileServerEvent = new FileServerEvent("OnNewData");
|
||||
_loc3_.id = param1.entry.id;
|
||||
_loc3_.contentType = param1.entry.contentType;
|
||||
var _loc5_:Object = param1.entry.data;
|
||||
if(_loc5_ == null)
|
||||
{
|
||||
_loc3_.success = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_.data = _loc5_;
|
||||
if(_cacheArray[_contentPath] == null)
|
||||
{
|
||||
_cacheArray[_contentPath] = [];
|
||||
}
|
||||
_cacheArray[_contentPath][_loc3_.id] = {
|
||||
"id":_loc3_.id,
|
||||
"data":_loc5_,
|
||||
"contentType":_loc3_.contentType
|
||||
};
|
||||
}
|
||||
var _loc4_:Object = _loaderArray[_contentPath][_loc3_.id];
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc4_.l.removeEventListener("OnLoadComplete",onResultGetData);
|
||||
if(_loadProgressFunc != null)
|
||||
{
|
||||
_loc4_.l.removeEventListener("OnLoadProgress",_loadProgressFunc);
|
||||
}
|
||||
_loc2_ = int(_loc4_.c);
|
||||
_loaderArray[_contentPath][_loc3_.id] = null;
|
||||
while(_loc2_-- > 0)
|
||||
{
|
||||
newEvent(_loc3_.id,_loc3_.data,_loc3_.success,_loc3_.contentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function newEvent(param1:Object, param2:*, param3:Boolean, param4:int = 0) : void
|
||||
{
|
||||
var _loc5_:FileServerEvent = new FileServerEvent("OnNewData");
|
||||
_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:Object;
|
||||
|
||||
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,45 @@
|
||||
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
|
||||
{
|
||||
var _loc1_:ImageServerEvent = new ImageServerEvent(type);
|
||||
_loc1_.id = id;
|
||||
_loc1_.layer = layer;
|
||||
_loc1_.imageData = imageData;
|
||||
_loc1_.versionNum = versionNum;
|
||||
_loc1_.genericData = genericData;
|
||||
_loc1_.frames = frames;
|
||||
_loc1_.success = success;
|
||||
return _loc1_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
package com.sbi.loader
|
||||
{
|
||||
import com.sbi.corelib.Set;
|
||||
import com.sbi.graphics.ImageArrayHelper;
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import com.sbi.graphics.PaletteHelper;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.Timer;
|
||||
|
||||
public class ImageServerURL extends EventDispatcher
|
||||
{
|
||||
|
||||
private static const IMAGE_ARRAY_PATH:String = "imageArrays/";
|
||||
|
||||
private static const PALETTE_NAME:String = "paletteData";
|
||||
|
||||
private static const CACHE_CLEANUP_INTERVAL_SECONDS:int = 10;
|
||||
|
||||
public static const CACHE_TTL:int = 30;
|
||||
|
||||
private static var _instance:ImageServerURL;
|
||||
|
||||
private var _imageCacheArray:Array;
|
||||
|
||||
private var _loaderCacheArray:Array;
|
||||
|
||||
private var _layerInfo:Object;
|
||||
|
||||
private var _timer:Timer;
|
||||
|
||||
public function ImageServerURL(param1:Class)
|
||||
{
|
||||
super();
|
||||
if(param1 != SingletonLock)
|
||||
{
|
||||
throw new Error("Invalid Singleton access. Use ImageServerURL.instance.");
|
||||
}
|
||||
_imageCacheArray = [];
|
||||
_loaderCacheArray = [];
|
||||
_timer = new Timer(10 * 1000);
|
||||
_timer.addEventListener("timer",heartbeat);
|
||||
_timer.start();
|
||||
}
|
||||
|
||||
public static function get instance() : ImageServerURL
|
||||
{
|
||||
if(!_instance)
|
||||
{
|
||||
_instance = new ImageServerURL(SingletonLock);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public function set layerInfo(param1:Object) : void
|
||||
{
|
||||
_layerInfo = param1;
|
||||
}
|
||||
|
||||
public function getLayerIndex(param1:int) : int
|
||||
{
|
||||
return _layerInfo[param1];
|
||||
}
|
||||
|
||||
public function requestGlobalPalette() : void
|
||||
{
|
||||
var _loc1_:ImageServerEvent = null;
|
||||
var _loc2_:LoaderCacheEntry_URL = null;
|
||||
if(isGlobalPaletteCached())
|
||||
{
|
||||
_loc1_ = new ImageServerEvent("OnGlobalPalette");
|
||||
_loc1_.imageData = null;
|
||||
trace("imageServer dispatching cached game palette");
|
||||
dispatchEvent(_loc1_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = _loaderCacheArray["palette"] = new LoaderCacheEntry_URL("paletteData");
|
||||
_loc2_.addEventListener("OnLoadComplete",onResultGetGamePalette,false,0,true);
|
||||
_loc2_.load();
|
||||
}
|
||||
}
|
||||
|
||||
public function requestImage(param1:uint, param2:Boolean = true) : void
|
||||
{
|
||||
var _loc3_:LoaderCacheEntry_URL = null;
|
||||
if(!param2 || getFromCache(param1) == false)
|
||||
{
|
||||
if(!_loaderCacheArray[param1])
|
||||
{
|
||||
_loc3_ = _loaderCacheArray[param1] = new LoaderCacheEntry_URL("imageArrays/" + param1);
|
||||
_loc3_.id = param1;
|
||||
_loc3_.addEventListener("OnLoadComplete",onResultGetImageData,false,0,true);
|
||||
_loc3_.load();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function requestImages(param1:Array) : void
|
||||
{
|
||||
for each(var _loc2_:uint in param1)
|
||||
{
|
||||
requestImage(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private function heartbeat(param1:TimerEvent) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc3_:Set = LayerAnim.trimAnims();
|
||||
for(var _loc4_ in _imageCacheArray)
|
||||
{
|
||||
if(!_loc3_.contains(_loc4_))
|
||||
{
|
||||
_loc2_ = _imageCacheArray[_loc4_];
|
||||
if(_loc2_.ttl-- < 1)
|
||||
{
|
||||
delete _imageCacheArray[_loc4_];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getFromCache(param1:uint) : Boolean
|
||||
{
|
||||
var _loc2_:Object = searchCache(param1);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.ttl = 30;
|
||||
dispatchEvent(_loc2_.event.clone());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isGlobalPaletteCached() : Boolean
|
||||
{
|
||||
return Boolean(PaletteHelper.gamePalette);
|
||||
}
|
||||
|
||||
private function searchCache(param1:uint) : Object
|
||||
{
|
||||
return _imageCacheArray[param1];
|
||||
}
|
||||
|
||||
private function onResultGetGamePalette(param1:LoaderEvent) : void
|
||||
{
|
||||
var _loc7_:ImageServerEvent = null;
|
||||
var _loc8_:ByteArray = null;
|
||||
var _loc6_:ByteArray = null;
|
||||
var _loc3_:ByteArray = null;
|
||||
var _loc4_:ByteArray = null;
|
||||
var _loc2_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
if(param1)
|
||||
{
|
||||
_loaderCacheArray["palette"].removeEventListener("OnLoadComplete",onResultGetGamePalette);
|
||||
delete _loaderCacheArray["palette"];
|
||||
_loc7_ = new ImageServerEvent("OnGlobalPalette");
|
||||
_loc8_ = param1.entry.data as ByteArray;
|
||||
_loc6_ = new ByteArray();
|
||||
_loc3_ = new ByteArray();
|
||||
_loc4_ = new ByteArray();
|
||||
_loc8_.position = 0;
|
||||
_loc2_ = _loc8_.readInt();
|
||||
_loc5_ = 4;
|
||||
_loc6_.writeBytes(_loc8_,_loc5_,_loc2_);
|
||||
_loc6_.position = 0;
|
||||
_loc5_ += _loc2_;
|
||||
_loc8_.position = _loc5_;
|
||||
_loc2_ = _loc8_.readInt();
|
||||
_loc5_ += 4;
|
||||
_loc3_.writeBytes(_loc8_,_loc5_,_loc2_);
|
||||
_loc3_.position = 0;
|
||||
_loc5_ += _loc2_;
|
||||
_loc8_.position = _loc5_;
|
||||
_loc2_ = _loc8_.readInt();
|
||||
_loc5_ += 4;
|
||||
_loc4_.writeBytes(_loc8_,_loc5_,_loc2_);
|
||||
_loc4_.position = 0;
|
||||
_loc7_.genericData = {
|
||||
"palette":_loc6_,
|
||||
"avatarPalette1":_loc3_,
|
||||
"avatarPalette2":_loc4_
|
||||
};
|
||||
dispatchEvent(_loc7_);
|
||||
return;
|
||||
}
|
||||
throw new Error("Got 0 for GetGamePalette request!");
|
||||
}
|
||||
|
||||
private function onResultGetImageData(param1:LoaderEvent) : void
|
||||
{
|
||||
_loaderCacheArray[param1.entry.id].removeEventListener("OnLoadComplete",onResultGetImageData);
|
||||
delete _loaderCacheArray[param1.entry.id];
|
||||
var _loc2_:ImageServerEvent = new ImageServerEvent("OnNewData");
|
||||
_loc2_.id = param1.entry.id;
|
||||
var _loc3_:Object = param1.entry.data;
|
||||
if(_loc3_ == null)
|
||||
{
|
||||
_imageCacheArray[_loc2_.id] = {
|
||||
"event":_loc2_,
|
||||
"ttl":30
|
||||
};
|
||||
_loc2_.success = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc3_.v != 117967104)
|
||||
{
|
||||
throw new Error("ERROR: Unrecognized version number(" + _loc3_.v.toString(16) + ")!");
|
||||
}
|
||||
_loc2_.imageData = _loc3_;
|
||||
_loc2_.layer = _layerInfo[ImageArrayHelper.layerId(_loc2_.id)];
|
||||
_loc2_.frames = _loc3_.f.length;
|
||||
_imageCacheArray[_loc2_.id] = {
|
||||
"event":_loc2_,
|
||||
"ttl":30
|
||||
};
|
||||
}
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SingletonLock
|
||||
{
|
||||
|
||||
public function SingletonLock()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package com.sbi.loader
|
||||
{
|
||||
import com.adobe.crypto.MD5;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.net.URLRequest;
|
||||
|
||||
public class LoaderCache
|
||||
{
|
||||
|
||||
public static var buildVersion:String = "0";
|
||||
|
||||
public static var deployVersion:String = "0";
|
||||
|
||||
public static var localMode:Boolean = true;
|
||||
|
||||
public static var cdnSalt:String;
|
||||
|
||||
public static var mainClassNames:Array;
|
||||
|
||||
private static var _contentURL:String = "https://dev-content.animaljam.com/content/";
|
||||
|
||||
private var _list:Array = null;
|
||||
|
||||
public function LoaderCache()
|
||||
{
|
||||
super();
|
||||
_list = [];
|
||||
}
|
||||
|
||||
public static function get contentURL() : String
|
||||
{
|
||||
return _contentURL;
|
||||
}
|
||||
|
||||
public static function set contentURL(param1:String) : void
|
||||
{
|
||||
_contentURL = param1;
|
||||
}
|
||||
|
||||
public static function fetchCDNURL(param1:String, param2:String = "/", param3:Boolean = true) : String
|
||||
{
|
||||
var _loc7_:String = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc8_:String = null;
|
||||
var _loc6_:String = "";
|
||||
var _loc5_:String = deployVersion;
|
||||
if(_loc5_ != "0" && param3)
|
||||
{
|
||||
_loc6_ = _loc5_ + "/";
|
||||
}
|
||||
var _loc9_:Array = param1.split("/");
|
||||
if(_loc5_ == "0" || !param3)
|
||||
{
|
||||
_loc4_ = param1;
|
||||
}
|
||||
else if(_loc9_.length == 1)
|
||||
{
|
||||
_loc4_ = hashIt(_loc9_[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = _loc9_.pop();
|
||||
_loc4_ = _loc9_.join("/") + "/" + hashIt(_loc8_);
|
||||
}
|
||||
if(param3)
|
||||
{
|
||||
if(_loc5_ == "0")
|
||||
{
|
||||
_loc7_ = contentURL + _loc6_ + param1 + "?v=" + LoaderCache.buildVersion;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_ = contentURL + _loc6_ + _loc4_ + "?v=" + LoaderCache.buildVersion;
|
||||
}
|
||||
}
|
||||
else if(_loc5_ == "0")
|
||||
{
|
||||
_loc7_ = contentURL + _loc6_ + param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_ = contentURL + _loc6_ + _loc4_;
|
||||
}
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
public static function hashIt(param1:String) : String
|
||||
{
|
||||
return hashItV2(param1);
|
||||
}
|
||||
|
||||
private static function hashItV1(param1:String) : String
|
||||
{
|
||||
return MD5.hash(param1);
|
||||
}
|
||||
|
||||
private static function hashItV2(param1:String) : String
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:String = "";
|
||||
param1 = "W3 7r4Ck h4X0r3rs" + param1;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
if(_loc3_ % 2 == 0)
|
||||
{
|
||||
_loc2_ += param1.charAt(_loc3_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = param1.charAt(_loc3_) + _loc2_;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return MD5.hash(_loc2_);
|
||||
}
|
||||
|
||||
public static function fetchCDNURLRequest(param1:String, param2:String = "/", param3:Boolean = true) : URLRequest
|
||||
{
|
||||
var _loc5_:String = fetchCDNURL(param1,param2,param3);
|
||||
return new URLRequest(_loc5_);
|
||||
}
|
||||
|
||||
public function openFile(param1:String, param2:Function, param3:Function = null, param4:String = "binary") : void
|
||||
{
|
||||
var _loc5_:* = undefined;
|
||||
if(!findFile(param1))
|
||||
{
|
||||
_loc5_ = createLoaderCacheEntry(param1);
|
||||
_list[param1] = _loc5_;
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("*LoaderCache name collision: " + param1);
|
||||
}
|
||||
_list[param1].setCompleteCallback(param2);
|
||||
if(param3 != null)
|
||||
{
|
||||
_list[param1].setProgressCallback(param3);
|
||||
}
|
||||
_list[param1].load(param4);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
for(var _loc1_:Object in _list)
|
||||
{
|
||||
remove(String(_loc1_));
|
||||
}
|
||||
}
|
||||
|
||||
private function findFile(param1:String) : Boolean
|
||||
{
|
||||
return _list[param1] == null ? false : true;
|
||||
}
|
||||
|
||||
public function remove(param1:String) : void
|
||||
{
|
||||
_list[param1].destroy();
|
||||
_list[param1] = null;
|
||||
}
|
||||
|
||||
private function createLoaderCacheEntry(param1:String) : *
|
||||
{
|
||||
var _loc4_:* = undefined;
|
||||
var _loc3_:int = param1.lastIndexOf(".");
|
||||
var _loc2_:String = param1.slice(_loc3_ + 1,param1.length).toLowerCase();
|
||||
switch(_loc2_)
|
||||
{
|
||||
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();
|
||||
_swf = param1;
|
||||
}
|
||||
|
||||
public function set parent(param1:LoaderCache) : void
|
||||
{
|
||||
_parent = param1;
|
||||
}
|
||||
|
||||
public function set id(param1:*) : void
|
||||
{
|
||||
_id = param1;
|
||||
}
|
||||
|
||||
public function get id() : *
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public function set contentType(param1:int) : void
|
||||
{
|
||||
_contentType = param1;
|
||||
}
|
||||
|
||||
public function get contentType() : int
|
||||
{
|
||||
return _contentType;
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return _swf;
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function load(param1:String = "binary", param2:Boolean = true) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function setCompleteCallback(param1:Function) : void
|
||||
{
|
||||
if(_completeCallback != param1)
|
||||
{
|
||||
if(_completeCallback != null)
|
||||
{
|
||||
removeEventListener("OnLoadComplete",_completeCallback);
|
||||
}
|
||||
addEventListener("OnLoadComplete",param1,false,0,true);
|
||||
_completeCallback = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function setProgressCallback(param1:Function) : void
|
||||
{
|
||||
if(_progressCallback != param1)
|
||||
{
|
||||
if(_progressCallback != null)
|
||||
{
|
||||
removeEventListener("OnLoadProgress",_progressCallback);
|
||||
}
|
||||
addEventListener("OnLoadProgress",param1,false,0,true);
|
||||
_progressCallback = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get progress() : Number
|
||||
{
|
||||
return _percent;
|
||||
}
|
||||
|
||||
public function get loader() : Loader
|
||||
{
|
||||
return _loader;
|
||||
}
|
||||
|
||||
public function get data() : Object
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
protected function onLoadCompleteEvent() : void
|
||||
{
|
||||
var _loc1_:LoaderEvent = new LoaderEvent("OnLoadComplete");
|
||||
_loc1_.status = true;
|
||||
_loc1_.entry = this;
|
||||
dispatchEvent(_loc1_);
|
||||
if(_parent)
|
||||
{
|
||||
_parent.remove(_swf);
|
||||
}
|
||||
}
|
||||
|
||||
protected function onLoadProgressEvent() : void
|
||||
{
|
||||
var _loc1_:LoaderEvent = new LoaderEvent("OnLoadProgress");
|
||||
_loc1_.status = true;
|
||||
_loc1_.entry = this;
|
||||
_loc1_.percent = _percent;
|
||||
dispatchEvent(_loc1_);
|
||||
}
|
||||
|
||||
protected function loadProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
_percent = param1.bytesLoaded / param1.bytesTotal;
|
||||
_percent *= 100;
|
||||
onLoadProgressEvent();
|
||||
}
|
||||
|
||||
protected function ioError(param1:IOErrorEvent) : void
|
||||
{
|
||||
var _loc2_:LoaderEvent = new LoaderEvent("OnLoadComplete");
|
||||
_loc2_.status = false;
|
||||
_loc2_.entry = this;
|
||||
_loc2_.message = param1.text;
|
||||
dispatchEvent(_loc2_);
|
||||
if(_parent)
|
||||
{
|
||||
_parent.remove(_swf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.sbi.loader
|
||||
{
|
||||
import flash.display.Loader;
|
||||
import flash.display.LoaderInfo;
|
||||
import flash.events.Event;
|
||||
import flash.net.URLRequest;
|
||||
import flash.system.ApplicationDomain;
|
||||
import flash.system.Capabilities;
|
||||
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("progress",loadProgress,false,0,true);
|
||||
_loader.contentLoaderInfo.addEventListener("complete",loadComplete,false,0,true);
|
||||
_loader.contentLoaderInfo.addEventListener("ioError",ioError,false,0,true);
|
||||
}
|
||||
|
||||
override public function destroy() : void
|
||||
{
|
||||
_loader.contentLoaderInfo.removeEventListener("progress",loadProgress);
|
||||
_loader.contentLoaderInfo.removeEventListener("complete",loadComplete);
|
||||
_loader.contentLoaderInfo.removeEventListener("ioError",ioError);
|
||||
if(_completeCallback != null)
|
||||
{
|
||||
removeEventListener("OnLoadComplete",_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);
|
||||
_loc4_.allowCodeImport = true;
|
||||
if(!LoaderCache.localMode && Capabilities.playerType !== "Desktop")
|
||||
{
|
||||
_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 com.sbi.debug.DebugUtility;
|
||||
import flash.events.Event;
|
||||
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);
|
||||
_isObj = param2;
|
||||
_loader = new URLLoader();
|
||||
_loader.addEventListener("progress",loadProgress,false,0,true);
|
||||
_loader.addEventListener("complete",loadComplete,false,0,true);
|
||||
_loader.addEventListener("ioError",ioError,false,0,true);
|
||||
}
|
||||
|
||||
override public function destroy() : void
|
||||
{
|
||||
_loader.removeEventListener("progress",loadProgress);
|
||||
_loader.removeEventListener("complete",loadComplete);
|
||||
_loader.removeEventListener("ioError",ioError);
|
||||
if(_completeCallback != null)
|
||||
{
|
||||
removeEventListener("OnLoadComplete",_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;
|
||||
DebugUtility.debugTrace("LoaderCacheEntry_URL - URLLoader.load being called for cdnURL:" + _loc3_.url + " 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(_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,149 @@
|
||||
package com.sbi.loader
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.display.LoaderInfo;
|
||||
|
||||
public class ResourceStack
|
||||
{
|
||||
|
||||
public static var hudAssetsLoaderInfo:LoaderInfo;
|
||||
|
||||
private var _stack:Array;
|
||||
|
||||
private var _callback:Function;
|
||||
|
||||
private var _path:String;
|
||||
|
||||
private var _openFile:Function;
|
||||
|
||||
public function ResourceStack(param1:String, param2:Function)
|
||||
{
|
||||
super();
|
||||
_path = param1;
|
||||
_openFile = param2;
|
||||
_stack = [];
|
||||
}
|
||||
|
||||
public function pushFile(param1:String, param2:Boolean = false) : void
|
||||
{
|
||||
_stack.push({
|
||||
"type":"file",
|
||||
"data":param1,
|
||||
"isBlocking":param2,
|
||||
"inProgress":false
|
||||
});
|
||||
}
|
||||
|
||||
public function pushClass(param1:IResourceStackable, param2:Boolean = false) : void
|
||||
{
|
||||
_stack.push({
|
||||
"type":"class",
|
||||
"data":param1,
|
||||
"isBlocking":param2,
|
||||
"inProgress":false
|
||||
});
|
||||
}
|
||||
|
||||
public function start(param1:Function) : void
|
||||
{
|
||||
_callback = param1;
|
||||
fifo();
|
||||
}
|
||||
|
||||
private function fifo() : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:Object = null;
|
||||
var _loc1_:int = int(_stack.length);
|
||||
DebugUtility.debugTrace("ResourceStack fifo len:" + _loc1_);
|
||||
if(!_loc1_)
|
||||
{
|
||||
DebugUtility.debugTrace("ResourceStack _callback:" + _callback);
|
||||
if(_callback != null)
|
||||
{
|
||||
_callback();
|
||||
_callback = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _loc1_)
|
||||
{
|
||||
_loc3_ = _stack[_loc2_];
|
||||
DebugUtility.debugTrace("ResourceStack fifo next - o:" + _loc3_ + " o.inProgress:" + _loc3_.inProgress + " o.type:" + _loc3_.type + " o.data:" + _loc3_.data + " o.isBlocking:" + _loc3_.isBlocking);
|
||||
if(!_loc3_.inProgress)
|
||||
{
|
||||
_loc3_.inProgress = true;
|
||||
switch(_loc3_.type)
|
||||
{
|
||||
case "file":
|
||||
loadFile(_loc3_.data);
|
||||
break;
|
||||
case "class":
|
||||
_loc3_.data.init(onInitClassComplete);
|
||||
}
|
||||
_loc2_ = -1;
|
||||
_loc1_ = int(_stack.length);
|
||||
}
|
||||
else if(_loc3_.isBlocking)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function loadFile(param1:String) : void
|
||||
{
|
||||
var _loc2_:String = _path + param1;
|
||||
_openFile(_loc2_,onLoadComplete,onLoadProgress);
|
||||
}
|
||||
|
||||
private function onLoadComplete(param1:LoaderEvent) : void
|
||||
{
|
||||
if(param1.status)
|
||||
{
|
||||
DebugUtility.debugTrace("ResourceStack onLoadComplete e:" + param1 + " name:" + param1.entry.name);
|
||||
if(param1.entry.name == "assets/HUDAssets.swf")
|
||||
{
|
||||
hudAssetsLoaderInfo = param1.entry.loader.contentLoaderInfo;
|
||||
}
|
||||
removeResource("file",param1.entry.name);
|
||||
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
|
||||
{
|
||||
removeResource("class",param1);
|
||||
fifo();
|
||||
}
|
||||
|
||||
private function removeResource(param1:String, param2:*) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:Object = null;
|
||||
var _loc4_:int = int(_stack.length);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc4_)
|
||||
{
|
||||
_loc3_ = _stack[_loc5_];
|
||||
if(_loc3_.type == param1 && _loc3_.data == param2)
|
||||
{
|
||||
_stack.splice(_loc5_,1);
|
||||
break;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,355 @@
|
||||
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;
|
||||
import flash.utils.Dictionary;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class SceneLoader extends EventDispatcher
|
||||
{
|
||||
|
||||
public static const LOAD_STATE_NOTLOADED:int = 0;
|
||||
|
||||
public static const LOAD_STATE_LOADING:int = 1;
|
||||
|
||||
public static const LOAD_STATE_LOADED:int = 2;
|
||||
|
||||
private var _offset:Point;
|
||||
|
||||
private var _scene:Object;
|
||||
|
||||
private var _loaderCount:int;
|
||||
|
||||
private var _loader:Array;
|
||||
|
||||
private var _loadedAssets:Dictionary;
|
||||
|
||||
private var _loaderLUT:Dictionary;
|
||||
|
||||
private var _initCount:int;
|
||||
|
||||
private var _loadProgressCallback:Function;
|
||||
|
||||
public var _useDynamicLoading:Boolean;
|
||||
|
||||
public function SceneLoader(param1:Function = null)
|
||||
{
|
||||
super();
|
||||
_loader = [];
|
||||
_loadProgressCallback = param1;
|
||||
}
|
||||
|
||||
public function getOffset(param1:DisplayObject) : Point
|
||||
{
|
||||
var _loc5_:* = null;
|
||||
var _loc3_:Loader = null;
|
||||
var _loc2_:Rectangle = null;
|
||||
var _loc4_:Array = getActorList("ActorLayer");
|
||||
for each(_loc5_ in _loc4_)
|
||||
{
|
||||
_loc3_ = _loc5_.s;
|
||||
_loc2_ = _loc3_.getBounds(param1);
|
||||
if(_loc2_.x < _offset.x)
|
||||
{
|
||||
_offset.x = _loc2_.x;
|
||||
}
|
||||
if(_loc2_.y < _offset.y)
|
||||
{
|
||||
_offset.y = _loc2_.y;
|
||||
}
|
||||
}
|
||||
return _offset;
|
||||
}
|
||||
|
||||
public function get isValid() : Boolean
|
||||
{
|
||||
return _scene != null;
|
||||
}
|
||||
|
||||
public function get sceneObject() : Object
|
||||
{
|
||||
return _scene;
|
||||
}
|
||||
|
||||
public function setScene(param1:Object, param2:Boolean = false) : void
|
||||
{
|
||||
release();
|
||||
_scene = param1;
|
||||
_loadedAssets = new Dictionary();
|
||||
_loaderLUT = new Dictionary();
|
||||
if(param1)
|
||||
{
|
||||
loadLayers(param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function getActorList(param1:String) : Array
|
||||
{
|
||||
return _scene.actors[param1];
|
||||
}
|
||||
|
||||
public function getLayer(param1:String) : Object
|
||||
{
|
||||
return findLayer(param1);
|
||||
}
|
||||
|
||||
public function cloneAsset(param1:String) : Object
|
||||
{
|
||||
var _loc2_:Loader = null;
|
||||
var _loc3_:Object = findLayer(param1);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc2_ = newAsset(_loc3_.assetName);
|
||||
_loc2_.x = _loc3_.x;
|
||||
_loc2_.y = _loc3_.y;
|
||||
_loc3_.loader = _loc2_;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function release() : void
|
||||
{
|
||||
var _loc1_:Loader = null;
|
||||
while(_loader.length)
|
||||
{
|
||||
_loc1_ = _loader.pop();
|
||||
_loc1_.unloadAndStop();
|
||||
}
|
||||
}
|
||||
|
||||
public function releaseCloneAsset(param1:Loader) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:Loader = null;
|
||||
while(_loc2_ < _loader.length)
|
||||
{
|
||||
_loc3_ = _loader[_loc2_];
|
||||
if(_loc3_ == param1)
|
||||
{
|
||||
param1.unloadAndStop();
|
||||
_loader.splice(_loc2_,1);
|
||||
break;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function forceLoadComplete() : void
|
||||
{
|
||||
_loadProgressCallback();
|
||||
}
|
||||
|
||||
private function findLayer(param1:String) : Object
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:Array = getActorList("ActorLayer");
|
||||
param1 = param1.toLowerCase();
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc2_.length)
|
||||
{
|
||||
if(_loc2_[_loc3_].name == param1)
|
||||
{
|
||||
_loc4_ = {};
|
||||
_loc4_.assetName = _loc2_[_loc3_].assetName;
|
||||
_loc4_.loader = _loc2_[_loc3_].s;
|
||||
_loc4_.height = _loc2_[_loc3_].s.height;
|
||||
_loc4_.width = _loc2_[_loc3_].s.width;
|
||||
_loc4_.x = _loc2_[_loc3_].s.x;
|
||||
_loc4_.y = _loc2_[_loc3_].s.y;
|
||||
_loc4_.flip = _loc2_[_loc3_].flip;
|
||||
break;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
trace("Layer Not Found: " + param1);
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
private function newAsset(param1:String) : Loader
|
||||
{
|
||||
var _loc4_:Loader = null;
|
||||
var _loc3_:int = 0;
|
||||
param1 = param1.toLowerCase();
|
||||
var _loc2_:Array = _scene.assets;
|
||||
while(_loc3_ < _loc2_.length)
|
||||
{
|
||||
if(_loc2_[_loc3_].name.toLowerCase() == param1)
|
||||
{
|
||||
_loc4_ = new Loader();
|
||||
_loc4_.loadBytes(_loc2_[_loc3_].ba);
|
||||
_loc4_.contentLoaderInfo.addEventListener("complete",onNewLoaderComplete);
|
||||
_loader.push(_loc4_);
|
||||
return _loc4_;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
private function onNewLoaderComplete(param1:Event) : void
|
||||
{
|
||||
var _loc2_:LoaderInfo = param1.target as LoaderInfo;
|
||||
_loc2_.removeEventListener("complete",onLoaderComplete);
|
||||
if(!Utility.doesItAnimate(_loc2_.content))
|
||||
{
|
||||
_loc2_.content.cacheAsBitmap = true;
|
||||
}
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
|
||||
public function loadLayer(param1:Object) : void
|
||||
{
|
||||
param1.loaded = 1;
|
||||
_loaderLUT[param1.s] = param1;
|
||||
var _loc2_:Loader = loadAsset(param1.assetName,param1.s);
|
||||
_initCount = _initCount + 1;
|
||||
}
|
||||
|
||||
public function isValidDynamicAsset(param1:Object) : Boolean
|
||||
{
|
||||
return param1.name == "" && param1.typeIndex != 1 && param1.typeIndex != 2 && param1.dx == 1 && param1.dy == 1;
|
||||
}
|
||||
|
||||
private function loadLayers(param1:Boolean = false) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc6_:Object = null;
|
||||
var _loc5_:Loader = null;
|
||||
_offset = new Point(9999999,9999999);
|
||||
var _loc2_:Array = getActorList("ActorLayer");
|
||||
_loaderCount = _loc2_.length;
|
||||
_initCount = 0;
|
||||
if(_loc2_.length > 0 && _loc2_[0].hasOwnProperty("top") && !param1)
|
||||
{
|
||||
_useDynamicLoading = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_useDynamicLoading = false;
|
||||
}
|
||||
var _loc3_:Boolean = false;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc2_.length)
|
||||
{
|
||||
_loc6_ = _loc2_[_loc4_];
|
||||
_loc6_.dx = _loc6_.scrollX;
|
||||
_loc6_.dy = _loc6_.scrollY;
|
||||
if(_useDynamicLoading)
|
||||
{
|
||||
_loc6_.offsetX = _loc6_.left - _loc6_.x;
|
||||
_loc6_.offsetY = _loc6_.top - _loc6_.y;
|
||||
if(_loc6_.flip & 1)
|
||||
{
|
||||
_loc6_.offsetX -= _loc6_.width;
|
||||
}
|
||||
if(_loc6_.flip & 2)
|
||||
{
|
||||
_loc6_.offsetY -= _loc6_.height;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_.offsetX = 0;
|
||||
_loc6_.offsetY = 0;
|
||||
}
|
||||
if(_useDynamicLoading && _loc3_ && isValidDynamicAsset(_loc6_))
|
||||
{
|
||||
_loaderCount = _loaderCount - 1;
|
||||
_loc5_ = new Loader();
|
||||
_loc6_.loaded = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_.loaded = 1;
|
||||
_loadedAssets[_loc6_.assetName] = _loc5_ = loadAsset(_loc6_.assetName);
|
||||
_loc3_ = true;
|
||||
}
|
||||
_loc6_.s = _loc5_;
|
||||
_loaderLUT[_loc5_] = _loc6_;
|
||||
_loc5_.x = Math.round(_loc6_.x);
|
||||
_loc5_.y = Math.round(_loc6_.y);
|
||||
_loc5_.rotation = _loc6_.rot;
|
||||
_loc5_.scaleX = _loc6_.scaleX;
|
||||
_loc5_.scaleY = _loc6_.scaleY;
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function loadAsset(param1:String, param2:Loader = null) : Loader
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:LoaderContext = null;
|
||||
var _loc6_:Loader = param2;
|
||||
param1 = param1.toLowerCase();
|
||||
var _loc3_:Array = _scene.assets;
|
||||
while(_loc4_ < _loc3_.length)
|
||||
{
|
||||
if(_loc3_[_loc4_].name.toLowerCase() == param1)
|
||||
{
|
||||
if(_loc6_ == null)
|
||||
{
|
||||
_loc6_ = new Loader();
|
||||
}
|
||||
if(_loc3_[_loc4_].ba)
|
||||
{
|
||||
_loc5_ = new LoaderContext(false,ApplicationDomain.currentDomain);
|
||||
_loc5_.allowCodeImport = true;
|
||||
_loc6_.loadBytes(_loc3_[_loc4_].ba,_loc5_);
|
||||
_loc6_.contentLoaderInfo.addEventListener("complete",onLoaderComplete);
|
||||
_loader.push(_loc6_);
|
||||
}
|
||||
return _loc6_;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
private function onLoaderComplete(param1:Event) : void
|
||||
{
|
||||
var _loc2_:LoaderInfo = param1.target as LoaderInfo;
|
||||
_loc2_.removeEventListener("complete",onLoaderComplete);
|
||||
if(_loc2_.content is MovieClip)
|
||||
{
|
||||
LocalizationManager.findAllTextfields(_loc2_.content);
|
||||
if(!Utility.doesItAnimate(_loc2_.content))
|
||||
{
|
||||
_loc2_.content.cacheAsBitmap = true;
|
||||
}
|
||||
}
|
||||
_loaderCount = _loaderCount - 1;
|
||||
_loaderLUT[_loc2_.loader].loaded = 2;
|
||||
if(_initCount > 0)
|
||||
{
|
||||
_initCount = _initCount - 1;
|
||||
if(_initCount == 0)
|
||||
{
|
||||
_loadProgressCallback();
|
||||
}
|
||||
}
|
||||
if(_loaderCount == 0)
|
||||
{
|
||||
allLoadingComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private function allLoadingComplete() : void
|
||||
{
|
||||
var _loc1_:Event = new Event("complete");
|
||||
dispatchEvent(_loc1_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user