fireas.library.net
public class LoaderTool
继承LoaderTool Inheritance Object

加载工具类.

对于不是很复杂的加载,都建议使用该类.该工具类非常稳定,对可能出错的地方都做了容错处理. 如果是开发环境,会直接将错误trace出来;而发布后用户在使用的过程中,即使出错也不会报任何错误,包括debug版播放器. 这样可以做到较好的用户体验,不会因为网站编辑传错一次图片,编辑错一次XML,而引起较大的用户体验问题.



公共方法
 方法定义方
  
loadApplicationDomain(url:*, callBack:Function):IEventDispatcher
[静态] 加载应用程序域.
LoaderTool
  
loadAVM1(url:*, callBack:Function):IEventDispatcher
[静态] 加载AVM1Movie(AS1,AS2).
LoaderTool
  
loadBytes(url:String, callBack:Function = null, arg:Object = null):IEventDispatcher
[静态] 加载二进制数据以ByteArray输出.
LoaderTool
  
loadData(url:String, callBack:Function = null, arg:Object = null):IEventDispatcher
[静态] 加载数据以字符串输出.
LoaderTool
  
loadDisplay(url:*, callBack:Function):IEventDispatcher
[静态] 加载显示对象.
LoaderTool
  
loadImage(url:*, callBack:Function):IEventDispatcher
[静态] 加载图像(jpg,png或gif)文件.
LoaderTool
  
loadMovie(url:*, callBack:Function):IEventDispatcher
[静态] 加载MovieClip(AVM2).
LoaderTool
  
loadSWF(url:*, callBack:Function):IEventDispatcher
[静态] 加载swf文件.
LoaderTool
  
loadVars(url:String, callBack:Function = null, arg:Object = null):IEventDispatcher
[静态] 加载URL编码变量以URLVariables输出.
LoaderTool
  
loadXML(url:String, callBack:Function = null, arg:Object = null):IEventDispatcher
[静态] 加载XML文件.
LoaderTool
方法详细信息
loadApplicationDomain()方法
public static function loadApplicationDomain(url:*, callBack:Function):IEventDispatcher

加载应用程序域.

参数

url:* — 需要加载的URL地址.也可以是ByteArray.
 
callBack:Function — 加载成功时的回调函数.回调时将用加载成功的ApplicationDomain作为参数.

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.
loadAVM1()方法 
public static function loadAVM1(url:*, callBack:Function):IEventDispatcher

加载AVM1Movie(AS1,AS2).

参数

url:* — 需要加载的URL地址.也可以是ByteArray.
 
callBack:Function — 加载成功时的回调函数.回调时将用加载成功的AVM1Movie作为参数.

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.
loadBytes()方法 
public static function loadBytes(url:String, callBack:Function = null, arg:Object = null):IEventDispatcher

加载二进制数据以ByteArray输出.

与URLLoader的dataFormat属性等于URLLoaderDataFormat.BINARY时一样.

参数

url:String — 需要加载的URL地址.
 
callBack:Function (default = null) — 加载成功时的回调函数.回调时将用加载成功的ByteArray作为参数.
 
arg:Object (default = null) — 随URL请求一起传输的数据.当arg为null时,HTTP提交方法为"GET";反之为"POST".

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.
loadData()方法 
public static function loadData(url:String, callBack:Function = null, arg:Object = null):IEventDispatcher

加载数据以字符串输出.

与URLLoader的dataFormat属性等于URLLoaderDataFormat.TEXT时一样.

参数

url:String — 需要加载的URL地址.
 
callBack:Function (default = null) — 加载成功时的回调函数.回调时将用加载成功的String作为参数.
 
arg:Object (default = null) — 随URL请求一起传输的数据.当arg为null时,HTTP提交方法为"GET";反之为"POST".

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.
loadDisplay()方法 
public static function loadDisplay(url:*, callBack:Function):IEventDispatcher

加载显示对象.

当不知道该路径是图片还是swf,或者只是需要加载一个显示对象(无论类型)放在某地,那么使用该方法就行了.

参数

url:* — 需要加载的URL地址.也可以是ByteArray.
 
callBack:Function — 加载成功时的回调函数.回调时将用加载成功的DisplayObject作为参数.

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.
loadImage()方法 
public static function loadImage(url:*, callBack:Function):IEventDispatcher

加载图像(jpg,png或gif)文件.

参数

url:* — 需要加载的URL地址.也可以是ByteArray.
 
callBack:Function — 加载成功时的回调函数.回调时将用加载成功的Bitmap作为参数.

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.
loadMovie()方法 
public static function loadMovie(url:*, callBack:Function):IEventDispatcher

加载MovieClip(AVM2).

参数

url:* — 需要加载的URL地址.也可以是ByteArray.
 
callBack:Function — 加载成功时的回调函数.回调时将用加载成功的MovieClip作为参数.

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.
loadSWF()方法 
public static function loadSWF(url:*, callBack:Function):IEventDispatcher

加载swf文件.

参数

url:* — 需要加载的URL地址.也可以是ByteArray.
 
callBack:Function — 加载成功时的回调函数.回调时将用加载成功的Sprite作为参数.

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.
loadVars()方法 
public static function loadVars(url:String, callBack:Function = null, arg:Object = null):IEventDispatcher

加载URL编码变量以URLVariables输出.

与URLLoader的dataFormat属性等于URLLoaderDataFormat.VARIABLES时一样.

参数

url:String — 需要加载的URL地址.
 
callBack:Function (default = null) — 加载成功时的回调函数.回调时将用加载成功的URLVariables作为参数.
 
arg:Object (default = null) — 随URL请求一起传输的数据.当arg为null时,HTTP提交方法为"GET";反之为"POST".

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.
loadXML()方法 
public static function loadXML(url:String, callBack:Function = null, arg:Object = null):IEventDispatcher

加载XML文件.

参数

url:String — 需要加载的URL地址.
 
callBack:Function (default = null) — 加载成功时的回调函数.回调时将用加载成功的XML作为参数.
 
arg:Object (default = null) — 随URL请求一起传输的数据.当arg为null时,HTTP提交方法为"GET";反之为"POST".

返回
IEventDispatcher — 事件调度器,侦听该事件调度器可以得到ProgressEvent.PROGRESS事件.