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,54 @@
|
||||
package org.osmf.elements.loaderClasses
|
||||
{
|
||||
import flash.display.Loader;
|
||||
import flash.events.ProgressEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class LoaderLoadTrait extends LoadTrait
|
||||
{
|
||||
|
||||
private var _loader:Loader;
|
||||
|
||||
public function LoaderLoadTrait(param1:LoaderBase, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function get loader() : Loader
|
||||
{
|
||||
return _loader;
|
||||
}
|
||||
|
||||
public function set loader(param1:Loader) : void
|
||||
{
|
||||
_loader = param1;
|
||||
}
|
||||
|
||||
override protected function loadStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == "loading")
|
||||
{
|
||||
loader.contentLoaderInfo.addEventListener("progress",onContentLoadProgress,false,0,true);
|
||||
}
|
||||
else if(param1 == "ready")
|
||||
{
|
||||
setBytesTotal(loader.contentLoaderInfo.bytesTotal);
|
||||
setBytesLoaded(loader.contentLoaderInfo.bytesLoaded);
|
||||
loader.contentLoaderInfo.addEventListener("progress",onContentLoadProgress,false,0,true);
|
||||
}
|
||||
else if(param1 == "uninitialized")
|
||||
{
|
||||
setBytesLoaded(0);
|
||||
}
|
||||
}
|
||||
|
||||
private function onContentLoadProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
setBytesTotal(param1.bytesTotal);
|
||||
setBytesLoaded(param1.bytesLoaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
package org.osmf.elements.loaderClasses
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Loader;
|
||||
import flash.display.LoaderInfo;
|
||||
import flash.errors.IOError;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.net.URLRequest;
|
||||
import flash.system.ApplicationDomain;
|
||||
import flash.system.Capabilities;
|
||||
import flash.system.LoaderContext;
|
||||
import flash.system.SecurityDomain;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.DisplayObjectTrait;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
|
||||
public class LoaderUtils
|
||||
{
|
||||
|
||||
private static const SWF_MIME_TYPE:String = "application/x-shockwave-flash";
|
||||
|
||||
public function LoaderUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function createDisplayObjectTrait(param1:Loader, param2:MediaElement) : DisplayObjectTrait
|
||||
{
|
||||
var _loc3_:DisplayObject = null;
|
||||
var _loc5_:Number = 0;
|
||||
var _loc4_:Number = 0;
|
||||
var _loc6_:LoaderInfo = param1.contentLoaderInfo;
|
||||
_loc3_ = param1;
|
||||
_loc3_.scrollRect = new Rectangle(0,0,_loc6_.width,_loc6_.height);
|
||||
_loc5_ = _loc6_.width;
|
||||
_loc4_ = _loc6_.height;
|
||||
return new DisplayObjectTrait(_loc3_,_loc5_,_loc4_);
|
||||
}
|
||||
|
||||
public static function loadLoadTrait(param1:LoadTrait, param2:Function, param3:Boolean, param4:Boolean, param5:Function = null) : void
|
||||
{
|
||||
var context:LoaderContext;
|
||||
var urlReq:URLRequest;
|
||||
var loadTrait:LoadTrait = param1;
|
||||
var updateLoadTraitFunction:Function = param2;
|
||||
var useCurrentSecurityDomain:Boolean = param3;
|
||||
var checkPolicyFile:Boolean = param4;
|
||||
var validateLoadedContentFunction:Function = param5;
|
||||
var toggleLoaderListeners:* = function(param1:Loader, param2:Boolean):void
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
param1.contentLoaderInfo.addEventListener("complete",onLoadComplete);
|
||||
param1.contentLoaderInfo.addEventListener("ioError",onIOError);
|
||||
param1.contentLoaderInfo.addEventListener("securityError",onSecurityError);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.contentLoaderInfo.removeEventListener("complete",onLoadComplete);
|
||||
param1.contentLoaderInfo.removeEventListener("ioError",onIOError);
|
||||
param1.contentLoaderInfo.removeEventListener("securityError",onSecurityError);
|
||||
}
|
||||
};
|
||||
var onLoadComplete:* = function(param1:Event):void
|
||||
{
|
||||
var validated:Boolean;
|
||||
var timer:Timer;
|
||||
var onTimer:*;
|
||||
var event:Event = param1;
|
||||
toggleLoaderListeners(loader,false);
|
||||
if(loadTrait.loadState == "loading")
|
||||
{
|
||||
if(validateLoadedContentFunction != null)
|
||||
{
|
||||
validated = Boolean(validateLoadedContentFunction(loader.content));
|
||||
if(validated)
|
||||
{
|
||||
if(Capabilities.isDebugger)
|
||||
{
|
||||
onTimer = function(param1:TimerEvent):void
|
||||
{
|
||||
timer.removeEventListener("timerComplete",onTimer);
|
||||
timer = null;
|
||||
loader.unloadAndStop();
|
||||
loader = null;
|
||||
loadLoadTrait(loadTrait,updateLoadTraitFunction,useCurrentSecurityDomain,false,null);
|
||||
};
|
||||
timer = new Timer(250,1);
|
||||
timer.addEventListener("timerComplete",onTimer);
|
||||
timer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
loader.unloadAndStop();
|
||||
loader = null;
|
||||
loadLoadTrait(loadTrait,updateLoadTraitFunction,useCurrentSecurityDomain,false,null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loader.unloadAndStop();
|
||||
loader = null;
|
||||
updateLoadTraitFunction(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(1)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateLoadTraitFunction(loadTrait,"ready");
|
||||
}
|
||||
}
|
||||
};
|
||||
var onIOError:* = function(param1:IOErrorEvent, param2:String = null):void
|
||||
{
|
||||
toggleLoaderListeners(loader,false);
|
||||
loader = null;
|
||||
updateLoadTraitFunction(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(1,param1 ? param1.text : param2)));
|
||||
};
|
||||
var onSecurityError:* = function(param1:SecurityErrorEvent, param2:String = null):void
|
||||
{
|
||||
toggleLoaderListeners(loader,false);
|
||||
loader = null;
|
||||
updateLoadTraitFunction(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(2,param1 ? param1.text : param2)));
|
||||
};
|
||||
var loaderLoadTrait:LoaderLoadTrait = loadTrait as LoaderLoadTrait;
|
||||
var loader:Loader = new Loader();
|
||||
loaderLoadTrait.loader = loader;
|
||||
updateLoadTraitFunction(loadTrait,"loading");
|
||||
context = new LoaderContext();
|
||||
urlReq = new URLRequest((loadTrait.resource as URLResource).url.toString());
|
||||
context.checkPolicyFile = checkPolicyFile;
|
||||
if(useCurrentSecurityDomain && urlReq.url.search(/^file:\//i) == -1)
|
||||
{
|
||||
context.securityDomain = SecurityDomain.currentDomain;
|
||||
}
|
||||
if(validateLoadedContentFunction != null)
|
||||
{
|
||||
context.applicationDomain = new ApplicationDomain();
|
||||
}
|
||||
toggleLoaderListeners(loader,true);
|
||||
try
|
||||
{
|
||||
loader.load(urlReq,context);
|
||||
}
|
||||
catch(ioError:IOError)
|
||||
{
|
||||
onIOError(null,ioError.message);
|
||||
}
|
||||
catch(securityError:SecurityError)
|
||||
{
|
||||
onSecurityError(null,securityError.message);
|
||||
}
|
||||
}
|
||||
|
||||
public static function unloadLoadTrait(param1:LoadTrait, param2:Function) : void
|
||||
{
|
||||
var _loc3_:LoaderLoadTrait = param1 as LoaderLoadTrait;
|
||||
param2(param1,"unloading");
|
||||
_loc3_.loader.unloadAndStop();
|
||||
param2(param1,"uninitialized");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user