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,137 @@
package loader
{
import com.adobe.serialization.json.JSON;
import com.sbi.loader.FileServerEvent;
import flash.utils.ByteArray;
public class DefPacksDefHelper
{
public static const DEF_ITEM:int = 1000;
public static const DEF_AVATAR:int = 1003;
public static const DEF_LOCALIZATION:int = 1023;
public static const DEF_NPC:int = 1025;
public static const DEF_LAYER:int = 1027;
public static const DEF_DEN_ITEM:int = 1030;
public static const DEF_MEDIA:int = 1033;
public static const DEF_FACT:int = 1035;
public static const DEF_EMOTICON:int = 1036;
public static const DEF_STREAM:int = 1037;
public static const DEF_GENERIC_LIST_TYPE:int = 1038;
public static const DEF_DEN_ROOM:int = 1040;
public static const DEF_PET:int = 1046;
public static const DEF_PARTY:int = 1047;
public static const DEF_AVAILABILITY:int = 1048;
public static const DEF_NAMEBAR_BADGE:int = 1049;
public static const DEF_BATTLE_CARD:int = 1050;
public static const DEF_CURRENCY_EXCHANGE:int = 1051;
public static const DEF_SCRIPT:int = 1052;
public static const DEF_MOVIE_NODE:int = 1053;
public static const DEF_DIAMOND:int = 1054;
public static const DEF_PREFERRED_LOCALIZATION:int = 1055;
public static const PREDICTIVE_TEXT_FILE_TO_APPEND_TO:int = 10;
public static const AUTO_CORRECT_TEXT_FILE_TO_APPEND_TO:int = 1;
public static var mediaArray:Array = [];
private var _id:uint;
private var _def:Object;
private var _callback:Function;
private var _passback:Object;
public function DefPacksDefHelper()
{
super();
}
public function get id() : int
{
return this._id;
}
public function get def() : Object
{
return this._def;
}
public function get passback() : Object
{
return this._passback;
}
public function init(id:uint, callback:Function = null, passback:Object = null, contentType:int = 0) : void
{
this._id = id;
this._callback = callback;
this._passback = passback;
DefPacksFileServer.instance.addEventListener(FileServerEvent.ON_NEW_DATA,this.handleData,false,0,true);
DefPacksFileServer.instance.requestFile(this._id,false,contentType);
}
public function destroy() : void
{
DefPacksFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
this._callback = null;
}
private function handleData(fse:FileServerEvent) : void
{
var fseDataCopy:* = undefined;
var copyBuffer:ByteArray = null;
if(fse.id == this._id && fse.success)
{
DefPacksFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
if(fse.contentType == FileServerEvent.JSON_TYPE)
{
fse.data.position = 0;
this._def = com.adobe.serialization.json.JSON.decode(fse.data);
}
else if(fse.contentType == FileServerEvent.AMF3_TYPE)
{
copyBuffer = new ByteArray();
copyBuffer.writeObject(fse.data);
copyBuffer.position = 0;
fseDataCopy = copyBuffer.readObject();
fseDataCopy.uncompress("deflate");
this._def = fseDataCopy.readObject();
}
else
{
this._def = fse.data;
}
if(this._callback != null)
{
this._callback(this);
this._callback = null;
}
}
}
}
}
@@ -0,0 +1,39 @@
package loader
{
import com.sbi.loader.BaseFileServer;
public class DefPacksFileServer extends BaseFileServer
{
private static var _instance:DefPacksFileServer;
private static const CONTENT_PATH:String = "defPacks/";
public function DefPacksFileServer(lock:Class)
{
super(CONTENT_PATH);
if(lock != SingletonLock)
{
throw new Error("Invalid Singleton access. Use DefPacksFileServer.instance.");
}
}
public static function get instance() : DefPacksFileServer
{
if(!_instance)
{
_instance = new DefPacksFileServer(SingletonLock);
}
return _instance;
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,338 @@
package loader
{
import avatar.AvatarManager;
import com.sbi.loader.FileServerEvent;
import den.DenItem;
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import pet.PetManager;
public class DenItemHelper
{
private var _id:uint;
private var _callback:Function;
private var _loader:Loader;
private var _sprite:Sprite;
private var _portalSprite:Sprite;
private var _sortOffset:int;
private var _minigameDefId:int;
private var _version:int;
private var _version2:int;
private var _version3:int;
private var _bFlipLabel:Boolean;
private var _onMouseDownCallback:Function;
private var _onMouseOverCallback:Function;
private var _onMouseOutCallback:Function;
private var _passback:Object;
public function DenItemHelper()
{
super();
}
public function get displayObject() : Sprite
{
return this._sprite;
}
public function get content() : DisplayObject
{
return this._loader.content;
}
public function get sortOffset() : int
{
return this._sortOffset;
}
public function get id() : int
{
return this._id;
}
public function get minigameDefId() : int
{
return this._minigameDefId;
}
public function get bFlipLabel() : Boolean
{
return this._bFlipLabel;
}
public function init(id:uint, callback:Function, version:int, mgDefId:int = 0, version2:int = 0, version3:int = 0) : void
{
this._id = id;
this._callback = callback;
this._minigameDefId = mgDefId;
this._bFlipLabel = false;
this._version = version;
this._version2 = version2;
this._version3 = version3;
this._loader = new Loader();
this._sprite = new Sprite();
this._portalSprite = new Sprite();
DenItemServer.instance.addEventListener(FileServerEvent.ON_NEW_DATA,this.handleData,false,0,true);
DenItemServer.instance.requestFile(this._id);
}
public function destroy() : void
{
DenItemServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
if(Boolean(this._loader))
{
if(Boolean(this._loader.parent))
{
this._loader.parent.removeChild(this._loader);
}
this._loader.unloadAndStop(true);
}
this._callback = null;
this._sprite = null;
}
public function setupItemWithEmotes(passback:Object) : void
{
this._passback = passback;
}
public function addPortalListeners(passback:Object, downCallback:Function, overCallback:Function = null, outCallback:Function = null) : void
{
this._passback = passback;
this._onMouseDownCallback = downCallback;
this._portalSprite.addEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDown,false,0,true);
if(overCallback != null)
{
this._onMouseOverCallback = overCallback;
this._portalSprite.addEventListener(MouseEvent.MOUSE_OVER,this.onMouseOver,false,0,true);
}
if(outCallback != null)
{
this._onMouseOutCallback = outCallback;
this._portalSprite.addEventListener(MouseEvent.MOUSE_OUT,this.onMouseOut,false,0,true);
}
}
public function addMouseListeners(passback:Object, downCallback:Function, overCallback:Function = null, outCallback:Function = null) : void
{
this._passback = passback;
this._onMouseDownCallback = downCallback;
this._sprite.addEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDown,false,0,true);
if(overCallback != null)
{
this._onMouseOverCallback = overCallback;
this._sprite.addEventListener(MouseEvent.MOUSE_OVER,this.onMouseOver,false,0,true);
}
if(outCallback != null)
{
this._onMouseOutCallback = outCallback;
this._sprite.addEventListener(MouseEvent.MOUSE_OUT,this.onMouseOut,false,0,true);
}
}
public function removeMouseListeners() : void
{
this._passback = null;
this._onMouseDownCallback = null;
this._sprite.removeEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDown);
if(this._onMouseOverCallback != null)
{
this._onMouseOverCallback = null;
this._sprite.removeEventListener(MouseEvent.MOUSE_OVER,this.onMouseOver);
}
if(this._onMouseOutCallback != null)
{
this._onMouseOutCallback = null;
this._sprite.removeEventListener(MouseEvent.MOUSE_OUT,this.onMouseOut);
}
}
public function removePortalListeners() : void
{
this._passback = null;
this._onMouseDownCallback = null;
this._portalSprite.removeEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDown);
if(this._onMouseOverCallback != null)
{
this._onMouseOverCallback = null;
this._portalSprite.removeEventListener(MouseEvent.MOUSE_OVER,this.onMouseOver);
}
if(this._onMouseOutCallback != null)
{
this._onMouseOutCallback = null;
this._portalSprite.removeEventListener(MouseEvent.MOUSE_OUT,this.onMouseOut);
}
}
public function getVersions() : Array
{
if(Boolean(this._loader) && Boolean(this._loader.content) && this._loader.content.hasOwnProperty("getVersions"))
{
return this._loader.content["getVersions"]();
}
return null;
}
public function setVersion(version:int, version2:int = 0, version3:int = 0) : void
{
this._version = version;
if(version2 > 0)
{
this._version2 = version2;
}
if(version3 > 0)
{
this._version3 = version3;
}
if(Boolean(this._loader) && Boolean(this._loader.content))
{
if(this._loader.content.hasOwnProperty("setVersion"))
{
if(this._version == -1)
{
this._version = this.getVersions()[0];
}
this._loader.content["setVersion"](version);
}
else if(this._loader.content.hasOwnProperty("pet"))
{
PetManager.setPetState(MovieClip(this._loader.content),this._version,this._version2,this._version3);
}
}
}
private function handleData(fse:FileServerEvent) : void
{
var o:Object = null;
if(fse.id == this._id && fse.success)
{
DenItemServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
this._loader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.onBytesLoaded);
fse.data.position = 0;
o = fse.data.readObject();
this._sortOffset = o.so;
this._loader.loadBytes(o.ba);
}
}
private function onBytesLoaded(evt:Event) : void
{
var o:Object = null;
this._loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,this.onBytesLoaded);
var totalFrames:int = int(this._loader.content["totalFrames"]);
var labels:Array = this._loader.content["currentLabels"];
if(totalFrames < 2)
{
this._loader.cacheAsBitmap = true;
}
else if(labels.length >= 0)
{
for each(o in labels)
{
if(o.name == "flip")
{
this._bFlipLabel = true;
break;
}
}
if(totalFrames == 2)
{
this._loader.cacheAsBitmap = true;
}
}
if(this._version == -1)
{
if(this._loader.content.hasOwnProperty("getVersions"))
{
this._version = this.getVersions()[0];
}
else
{
this._version = 0;
}
}
if(this._loader.content.hasOwnProperty("setVersion") && this._version >= 0)
{
MovieClip(this._loader.content).setVersion(this._version);
}
else if(this._loader.content.hasOwnProperty("pet"))
{
PetManager.setPetState(MovieClip(this._loader.content),this._version,this._version2,this._version3);
}
if(Boolean(MovieClip(this._loader.content).isMoveToDisabled))
{
this._loader.name = "moveToDisabled";
}
if(this._passback != null)
{
if(this._passback.specialType == DenItem.SPECIAL_TYPE_PORTAL)
{
this._portalSprite.addChild(MovieClip(this._loader.content).clickObject);
}
else if(this._passback.specialType == DenItem.SPECIAL_TYPE_EMOTE && this._loader.content.hasOwnProperty("setEmoteCallback"))
{
MovieClip(this._loader.content).setEmoteCallback(this.onEmoteItemClicked);
}
}
this._sprite.addChild(this._loader);
this._sprite.addChild(this._portalSprite);
if(this._callback != null)
{
this._callback(this);
this._callback = null;
}
}
private function onEmoteItemClicked(idToShow:int) : void
{
if(Boolean(AvatarManager.playerAvatarWorldView) && !AvatarManager.playerAvatarWorldView.isThisAttachmentOn(idToShow))
{
AvatarManager.setPlayerAttachmentEmot(idToShow);
}
}
private function onMouseDown(evt:MouseEvent) : void
{
if(this._onMouseDownCallback != null)
{
this._onMouseDownCallback(evt,this._minigameDefId);
}
}
private function onMouseOver(evt:MouseEvent) : void
{
if(this._onMouseOverCallback != null)
{
this._onMouseOverCallback(evt,this._passback,this._minigameDefId);
}
}
private function onMouseOut(evt:MouseEvent) : void
{
if(this._onMouseOutCallback != null)
{
this._onMouseOutCallback(evt);
}
}
}
}
@@ -0,0 +1,39 @@
package loader
{
import com.sbi.loader.BaseFileServer;
public class DenItemServer extends BaseFileServer
{
private static var _instance:DenItemServer;
private static const CONTENT_PATH:String = "items/";
public function DenItemServer(lock:Class)
{
super(CONTENT_PATH);
if(lock != SingletonLock)
{
throw new Error("Invalid Singleton access. Use DenItemServer.instance.");
}
}
public static function get instance() : DenItemServer
{
if(!_instance)
{
_instance = new DenItemServer(SingletonLock);
}
return _instance;
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,66 @@
package loader
{
import com.sbi.loader.FileServerEvent;
import flash.utils.ByteArray;
public class FeedbackDefHelper
{
private var _id:uint;
private var _def:Object;
private var _callback:Function;
public function FeedbackDefHelper()
{
super();
}
public function get id() : int
{
return this._id;
}
public function get def() : Object
{
return this._def;
}
public function init(id:uint, callback:Function = null) : void
{
this._id = id;
this._callback = callback;
FeedbackFileServer.instance.addEventListener(FileServerEvent.ON_NEW_DATA,this.handleData,false,0,true);
FeedbackFileServer.instance.requestFile(this._id);
}
public function destroy() : void
{
FeedbackFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
this._callback = null;
}
private function handleData(fse:FileServerEvent) : void
{
var fseDataCopy:* = undefined;
var copyBuffer:ByteArray = null;
if(fse.id == this._id && fse.success)
{
FeedbackFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
copyBuffer = new ByteArray();
copyBuffer.writeObject(fse.data);
copyBuffer.position = 0;
fseDataCopy = copyBuffer.readObject();
fseDataCopy.uncompress("deflate");
this._def = fseDataCopy.readObject();
if(this._callback != null)
{
this._callback(this);
this._callback = null;
}
}
}
}
}
@@ -0,0 +1,39 @@
package loader
{
import com.sbi.loader.BaseFileServer;
public class FeedbackFileServer extends BaseFileServer
{
private static var _instance:FeedbackFileServer;
private static const CONTENT_PATH:String = "feedbackDefs/";
public function FeedbackFileServer(lock:Class)
{
super(CONTENT_PATH);
if(lock != SingletonLock)
{
throw new Error("Invalid Singleton access. Use FeedbackFileServer.instance.");
}
}
public static function get instance() : FeedbackFileServer
{
if(!_instance)
{
_instance = new FeedbackFileServer(SingletonLock);
}
return _instance;
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,133 @@
package loader
{
import com.sbi.loader.FileServerEvent;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.events.Event;
import localization.LocalizationManager;
public class JCDefHelper
{
private var _id:uint;
private var _def:Object;
private var _callback:Function;
private var _passback:Object;
private var _loadImage:Boolean;
private var _loader:Loader;
public function JCDefHelper()
{
super();
}
public function get id() : int
{
return this._id;
}
public function get def() : Object
{
return this._def;
}
public function init(id:uint, callback:Function = null, loadImage:Boolean = false, passback:Object = null) : void
{
this._id = id;
this._callback = callback;
this._passback = passback;
this._loadImage = loadImage;
this._loader = new Loader();
JCFileServer.instance.addEventListener(FileServerEvent.ON_NEW_DATA,this.handleData,false,0,true);
if(loadImage)
{
JCFileServer.instance.requestFileWithExtension(this._id,false,FileServerEvent.JSON_TYPE,"images/");
}
else if(id == LocalizationManager.currentLanguage)
{
JCFileServer.instance.requestFileWithExtension(this._id,false,FileServerEvent.AMF3_TYPE,"index/");
}
else
{
JCFileServer.instance.requestFileWithExtension(this._id,false,FileServerEvent.AMF3_TYPE,"amf/");
}
}
public function destroy() : void
{
JCFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
this._callback = null;
this._passback = null;
this._loader = null;
}
public function deleteIndexFileFromCache() : void
{
JCFileServer.instance.clearFromCache("index/",1);
}
private function handleData(fse:FileServerEvent) : void
{
if(fse.id == this._id && fse.success)
{
JCFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
if(!this._loadImage)
{
fse.data.position = 0;
this._def = fse.data.readObject();
this.onComplete();
}
else
{
this._loader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.onBytesLoaded);
this._loader.loadBytes(fse.data);
}
}
}
private function onBytesLoaded(evt:Event) : void
{
var l:LoaderInfo = evt.target as LoaderInfo;
this._def = new MovieClip();
this._def.addChild(l.content);
if(this._def.hasOwnProperty("__rslPreloader") && Boolean(this._def.__rslPreloader))
{
this._def.addEventListener(Event.ENTER_FRAME,this.onFrame);
}
else
{
this.onComplete();
}
}
private function onFrame(e:Event) : void
{
if(this._def.__rslPreloader == null)
{
this._def.removeEventListener(Event.ENTER_FRAME,this.onFrame);
this.onComplete();
}
}
private function onComplete() : void
{
if(this._passback != null)
{
this._def.defHelper = this;
this._def.passback = this._passback;
}
if(this._callback != null)
{
this._callback(this._def);
this._callback = null;
}
}
}
}
@@ -0,0 +1,50 @@
package loader
{
import com.sbi.loader.BaseFileServer;
public class JCFileServer extends BaseFileServer
{
private static var _instance:JCFileServer;
private static const CONTENT_PATH:String = "ABSU/";
public function JCFileServer(lock:Class)
{
super(CONTENT_PATH);
if(lock != SingletonLock)
{
throw new Error("Invalid Singleton access. Use JCFileServer.instance.");
}
}
public static function get instance() : JCFileServer
{
if(!_instance)
{
_instance = new JCFileServer(SingletonLock);
}
return _instance;
}
public function requestFileWithExtension(id:uint, noCache:Boolean = false, contentType:int = 0, pathExtension:String = "") : void
{
super.updatePath(CONTENT_PATH + pathExtension);
super.requestFile(id,noCache,contentType,false);
}
override public function clearFromCache(path:String, id:int) : void
{
super.clearFromCache(CONTENT_PATH + path,id);
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,39 @@
package loader
{
import com.sbi.loader.BaseFileServer;
public class MediaFileServer extends BaseFileServer
{
private static var _instance:MediaFileServer;
private static const CONTENT_PATH:String = "media/";
public function MediaFileServer(lock:Class)
{
super(CONTENT_PATH);
if(lock != SingletonLock)
{
throw new Error("Invalid Singleton access. Use MediaFileServer.instance.");
}
}
public static function get instance() : MediaFileServer
{
if(!_instance)
{
_instance = new MediaFileServer(SingletonLock);
}
return _instance;
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,109 @@
package loader
{
import com.sbi.loader.FileServerEvent;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.events.Event;
import localization.LocalizationManager;
public class MediaHelper
{
private var _id:uint;
private var _callback:Function;
private var _passback:Object;
private var _loader:Loader;
private var _mc:MovieClip;
public function MediaHelper()
{
super();
}
public function init(id:uint, callback:Function = null, passback:Object = null) : void
{
if(id == 0)
{
throw new Error("Media id is 0");
}
this._id = id;
this._callback = callback;
this._passback = passback;
this._loader = new Loader();
MediaFileServer.instance.addEventListener(FileServerEvent.ON_NEW_DATA,this.handleMediaData);
MediaFileServer.instance.requestFile(this._id);
}
public function destroy() : void
{
MediaFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleMediaData);
this._mc = null;
this._passback = null;
this._loader = null;
this._callback = null;
}
public function get id() : int
{
if(this._loader == null)
{
throw new Error("attempt to get id of an uninitialized MediaHelper instance!");
}
return this._id;
}
private function handleMediaData(fse:FileServerEvent) : void
{
if(fse.id != this._id)
{
return;
}
if(fse.success)
{
MediaFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleMediaData);
this._loader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.onBytesLoaded);
this._loader.loadBytes(fse.data);
}
}
private function onBytesLoaded(evt:Event) : void
{
var l:LoaderInfo = evt.target as LoaderInfo;
this._mc = MovieClip(l.content);
LocalizationManager.findAllTextfields(this._mc);
if(this._passback != null)
{
this._mc.mediaHelper = this;
this._mc.passback = this._passback;
}
if(this._mc.hasOwnProperty("__rslPreloader") && Boolean(this._mc.__rslPreloader))
{
this._mc.addEventListener(Event.ENTER_FRAME,this.onFrame);
}
else if(this._callback != null)
{
this._callback(this._mc);
this._callback = null;
}
}
private function onFrame(e:Event) : void
{
if(this._mc.__rslPreloader == null)
{
this._mc.removeEventListener(Event.ENTER_FRAME,this.onFrame);
if(this._callback != null)
{
this._callback(this._mc);
this._callback = null;
}
}
}
}
}
@@ -0,0 +1,74 @@
package loader
{
import com.sbi.loader.FileServerEvent;
import flash.utils.ByteArray;
public class NGFactDefHelper
{
private var _id:uint;
private var _def:Object;
private var _callback:Function;
private var _passback:Object;
public function NGFactDefHelper()
{
super();
}
public function get id() : int
{
return this._id;
}
public function get def() : Object
{
return this._def;
}
public function init(id:uint, callback:Function = null, passback:Object = null) : void
{
this._id = id;
this._callback = callback;
this._passback = passback;
NGFactFileServer.instance.addEventListener(FileServerEvent.ON_NEW_DATA,this.handleData,false,0,true);
NGFactFileServer.instance.requestFile(this._id);
}
public function destroy() : void
{
NGFactFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
this._callback = null;
}
private function handleData(fse:FileServerEvent) : void
{
var fseDataCopy:* = undefined;
var copyBuffer:ByteArray = null;
if(fse.id == this._id && fse.success)
{
NGFactFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
copyBuffer = new ByteArray();
copyBuffer.writeObject(fse.data);
copyBuffer.position = 0;
fseDataCopy = copyBuffer.readObject();
fseDataCopy.uncompress("deflate");
this._def = fseDataCopy.readObject();
if(this._passback != null)
{
this._def.passback = this._passback;
this._passback = null;
}
if(this._callback != null)
{
this._callback(this);
this._callback = null;
}
}
}
}
}
@@ -0,0 +1,39 @@
package loader
{
import com.sbi.loader.BaseFileServer;
public class NGFactFileServer extends BaseFileServer
{
private static var _instance:NGFactFileServer;
private static const CONTENT_PATH:String = "factDefs/";
public function NGFactFileServer(lock:Class)
{
super(CONTENT_PATH);
if(lock != SingletonLock)
{
throw new Error("Invalid Singleton access. Use NGFactFileServer.instance.");
}
}
public static function get instance() : NGFactFileServer
{
if(!_instance)
{
_instance = new NGFactFileServer(SingletonLock);
}
return _instance;
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}
@@ -0,0 +1,78 @@
package loader
{
import com.adobe.serialization.json.JSON;
import com.sbi.loader.FileServerEvent;
import flash.utils.ByteArray;
public class PollDefHelper
{
private var _id:uint;
private var _def:Object;
private var _callback:Function;
public function PollDefHelper()
{
super();
}
public function get id() : int
{
return this._id;
}
public function get def() : Object
{
return this._def;
}
public function init(id:uint, callback:Function = null) : void
{
this._id = id;
this._callback = callback;
PollFileServer.instance.addEventListener(FileServerEvent.ON_NEW_DATA,this.handleData,false,0,true);
PollFileServer.instance.requestFile(this._id,false,FileServerEvent.AMF3_TYPE);
}
public function destroy() : void
{
PollFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
this._callback = null;
}
private function handleData(fse:FileServerEvent) : void
{
var fseDataCopy:* = undefined;
var copyBuffer:ByteArray = null;
if(fse.id == this._id && fse.success)
{
PollFileServer.instance.removeEventListener(FileServerEvent.ON_NEW_DATA,this.handleData);
if(fse.contentType == FileServerEvent.JSON_TYPE)
{
this._def = com.adobe.serialization.json.JSON.decode(fse.data);
}
else if(fse.contentType == FileServerEvent.AMF3_TYPE)
{
copyBuffer = new ByteArray();
copyBuffer.writeObject(fse.data);
copyBuffer.position = 0;
fseDataCopy = copyBuffer.readObject();
fseDataCopy.uncompress("deflate");
this._def = fseDataCopy.readObject();
}
else
{
this._def = fse.data;
}
if(this._callback != null)
{
this._callback(this);
this._callback = null;
}
}
}
}
}
@@ -0,0 +1,39 @@
package loader
{
import com.sbi.loader.BaseFileServer;
public class PollFileServer extends BaseFileServer
{
private static var _instance:PollFileServer;
private static const CONTENT_PATH:String = "pollDefs/";
public function PollFileServer(lock:Class)
{
super(CONTENT_PATH);
if(lock != SingletonLock)
{
throw new Error("Invalid Singleton access. Use PollItemServer.instance.");
}
}
public static function get instance() : PollFileServer
{
if(!_instance)
{
_instance = new PollFileServer(SingletonLock);
}
return _instance;
}
}
}
class SingletonLock
{
public function SingletonLock()
{
super();
}
}