Show:

annie.URLLoader Class

Defined in: libs/URLLoader.js:19
Module: annie

Available since 1.0.0

小游戏不支持 小程序不支持

资源加载类,后台请求,加载资源和后台交互都可以使用此类

Methods

addEventListener

(
  • type
  • listener
  • useCapture
)
Void public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:109

Available since 1.0.0

给对象添加一个侦听

Parameters:

  • type String

    侦听类型

  • listener Function

    侦听后的回调方法,如果这个方法是类实例的方法,为了this引用的正确性,请在方法参数后加上.bind(this);

  • useCapture Boolean

    true 捕获阶段 false 冒泡阶段 默认 true

Returns:

Void:

Example:

 this.addEventListener(annie.Event.ADD_TO_STAGE,function(e){console.log(this);}.bind(this));

addHeader

(
  • name
  • value
)

添加自定义头

Parameters:

destroy

() Void public

Inherited from annie.AObject: libs/EventDispatcher.js:63

Available since 2.0.0

销毁一个对象 销毁之前一定要做完其他善后工作,否则有可能会出错 特别注意不能在对象自身方法或事件里调用此方法。 比如,不要在显示对象自身的 annie.Event.ON_REMOVE_TO_STAGE 或者其他类似事件调用,一定会报错

Returns:

Void:

dispatchEvent

(
  • event
  • data
  • useCapture
)
Boolean public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:156

Available since 1.0.0

广播侦听

Parameters:

  • event annie.Event | String

    广播所带的事件对象,如果传的是字符串则自动生成一个annie.Event对象,事件类型就是传入进来的字符串的值

  • data Object

    广播后跟着事件一起传过去的其他任信息,默认值为null

  • useCapture Boolean

    true 捕获阶段 false 冒泡阶段 默认 true

Returns:

Boolean:

如果有收听者则返回true

Example:

 var mySprite=new annie.Sprite(),
 yourEvent=new annie.Event("yourCustomerEvent");
 yourEvent.data={a:1,b:2,c:"hello",d:{aa:1,bb:2}};
 mySprite.addEventListener("yourCustomerEvent",function(e){
     console.log(e.data);
 })
 mySprite.dispatchEvent(yourEvent);

hasEventListener

(
  • type
  • useCapture
)
Boolean public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:215

Available since 1.0.0

是否有添加过此类型的侦听

Parameters:

  • type String

    侦听类型

  • useCapture Boolean

    true 捕获阶段 false 冒泡阶段 默认 true

Returns:

Boolean:

如果有则返回true

load

(
  • url
  • contentType
)
public

Defined in libs/URLLoader.js:157

Available since 1.0.0

加载或请求数据

Parameters:

  • url String
  • contentType String

    如果请求类型需要设置主体类型,有form json binary jsonp等,请设置 默认为form

loadCancel

() public

Defined in libs/URLLoader.js:145

Available since 1.0.0

取消加载

removeAllEventListener

() Void public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:268

Available since 1.0.0

移除对象中所有的侦听

Returns:

Void:

removeEventListener

(
  • type
  • listener
  • useCapture
)
Void public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:239

Available since 1.0.0

移除对应类型的侦听

Parameters:

  • type String

    要移除的侦听类型

  • listener Function

    侦听时绑定的回调方法

  • useCapture Boolean

    true 捕获阶段 false 冒泡阶段 默认 true

Returns:

Void:

URLLoader

(
  • type
)

构造函数

Parameters:

  • type Object

    text json js xml image sound css svg video unKnow

Properties

data

Object public

Defined in libs/URLLoader.js:102

Available since 1.0.0

需要向后台传送的数据对象

Default: null

instanceId

Number public

Inherited from annie.AObject: libs/EventDispatcher.js:31

Available since 1.0.0

每一个annie引擎对象都会有一个唯一的id码。

Example:

 //获取 annie引擎类对象唯一码
 console.log(this.instanceId);

instanceType

String public

Inherited from annie.AObject: libs/EventDispatcher.js:49

Available since 1.0.3

每一个annie类都有一个实例类型字符串,通过这个字符串,你能知道这个实例是从哪个类实例而来

method

String public

Defined in libs/URLLoader.js:93

Available since 1.0.0

请求后台的类型 get post

Default: get

responseType

String public

Defined in libs/URLLoader.js:76

Available since 1.0.0

后台返回来的数据类型

Default: null

url

String public

Defined in libs/URLLoader.js:85

Available since 1.0.0

请求的url地址

Events

annie.Event.ABORT

Defined in libs/URLLoader.js:57

Available since 1.0.0

annie.URLLoader中断事件

annie.Event.COMPLETE

Defined in libs/URLLoader.js:42

Available since 1.0.0

完成事件

annie.Event.ERROR

Defined in libs/URLLoader.js:52

Available since 1.0.0

annie.URLLoader出错事件

annie.Event.PROGRESS

Defined in libs/URLLoader.js:47

Available since 1.0.0

annie.URLLoader加载过程事件

annie.Event.START

Defined in libs/URLLoader.js:62

Available since 1.0.0

annie.URLLoader开始事件