Core. Loader

Loader Class can be used to load text, JSON, XML, binary, images, and other resources.

Constructor

new Loader()

Extends

Member

(static) _imgCache :Object

(static) _loaders :Array

(static) _preLoadedAtlasMap :Object

(static) ATLAS :String

Default Value:
  • "atlas"

(static) atlasMap :Object

(static) BUFFER :String

Default Value:
  • "arraybuffer"

(static) FONT :String

Default Value:
  • "font"

(static) groupMap :Object

(static) IMAGE :String

Default Value:
  • "image"

(static) JSON :String

Default Value:
  • "json"

(static) loadedMap :Object

(static) maxTimeOut :int

The maximum timeout time, using callback per frame loaded if the timeout is under the frame to frame processing, prevent caton.
Default Value:
  • 100

(static) parserMap :Object

The resource resolution function corresponding table is used to extend more types of resource loading parsing.

(static) SOUND :String

Default Value:
  • "sound"

(static) TEXT :String

Default Value:
  • "text"

(static) typeMap :Object

File suffix and type corresponding table.

(static) XML :String

Default Value:
  • "xml"

cache :Boolean

Cache?.

data :Object

Returned data.

type :String

Load type.

url :String

Load address.

Methods

cacheRes(url, data)

Cache resources.
Parameters:
Name Type Description
url String Resource address.
data Object What you want to cache.

clearRes(url, forceDispose)

Cache that specifies the address of the specified resource.
Parameters:
Name Type Description
url String Resource address.
forceDispose Boolean If destruction is mandatory, some resources are destroyed by reference counting. If forceDispose=true, the reference count is ignored and destroyed directly, such as Texture, and defaults to false

clearResByGroup(group)

Clear resources according to groups.
Parameters:
Name Type Description
group String Grouping name.

complete(data)

Load complete.
Parameters:
Name Type Description
data Object Loaded data.

endLoad(contentopt)

End loading, processing, caching, and distributing completed events Event.COMPLETE .
Parameters:
Name Type Attributes Default Description
content Object <optional>
null content Loaded data

event(type, dataopt) → {Boolean}

Dispatch events.
Inherited From:
Parameters:
Name Type Attributes Default Description
type String Event type.
data Object <optional>
null data (optional) callback data. Be careful: If you need to pass multiple parameters, P1, P2, P3, you can use the array structure, such as: [p1,p2,p3,...] If you need to call a single parameter P, and P is an array, you need to use a structure such as: [p] Other single parameters, P, can be passed directly to the parameter P.
Returns:
Type:
Boolean
Is there a listener for this event type? If there is a listener, the value is true, otherwise the value is false.

getAtlas(url) → {Array}

Gets the atlas address list of the specified resource address.
Parameters:
Name Type Description
url String Atlas address.
Returns:
Type:
Array
Return address set.

getRes(url) → {Object}

Gets the resource of the specified resource address.
Parameters:
Name Type Description
url String Resource address.
Returns:
Type:
Object
Return resources.

getTypeFromUrl(url) → {String}

Gets the data type of the specified resource address.
Parameters:
Name Type Description
url String Resource address.
Returns:
Type:
String
Data type.

hasListener(type) → {Boolean}

inspect EventDispatcher Object registers any listeners for a particular event type.
Inherited From:
Parameters:
Name Type Description
type String Event type.
Returns:
Type:
Boolean
If the specified type of listener has been registered, the value is true; otherwise, the value is false.

isMouseEvent(type) → {Boolean}

Detects whether the specified event type is a mouse event.
Inherited From:
Parameters:
Name Type Description
type String Event type.
Returns:
Type:
Boolean
If it is a mouse event, the value is true; otherwise, the value is false.

load(url, typeopt, cache, groupopt, ignoreCache, useWorkerLoader(default)

Load resources. Loading errors will dispatch Event.ERROR events, and the parameters are error messages.
Parameters:
Name Type Attributes Default Description
url String Resource address.
type String <optional>
null type (default = null) resource type. The optional values are: Loader.TEXT, Loader.JSON, Loader.XML, Loader.BUFFER, Loader.IMAGE, Loader.SOUND, Loader.ATLAS, Loader.FONT. If NULL, the type is analyzed based on the file suffix.
cache Boolean (default = true) does the data cache?.
group String <optional>
null group (default = null) grouping name.
ignoreCache Boolean (default = false) do you want to ignore the cache and force the reload?.
useWorkerLoader(default Boolean = false) do you use worker to load (for IMAGE types and ATLAS types only and browser support)?

off(type, caller, listener, onceOnly) → {EventDispatcher}

from EventDispatcher Delete listeners in object.
Inherited From:
Parameters:
Name Type Description
type String Event type.
caller Object The domain of the event listener function.
listener function Event listener function.
onceOnly Boolean (optional) if the value is true, only the listeners added by the once method are removed.
Returns:
Type:
EventDispatcher
this EventDispatcher Object.

offAll(typeopt) → {EventDispatcher}

from EventDispatcher Removes all listeners that specify the type of event in the object.
Inherited From:
Parameters:
Name Type Attributes Default Description
type String <optional>
null type (optional) event type. If the value is null, all types of listeners for this object are removed.
Returns:
Type:
EventDispatcher
this EventDispatcher Object.

on(type, caller, listener, argsopt) → {EventDispatcher}

Use EventDispatcher Object registers the event listener object of the specified type so that listeners can receive event notifications.
Inherited From:
Parameters:
Name Type Attributes Default Description
type String Event type.
caller Object The domain of the event listener function.
listener function Event listener function.
args Array <optional>
null args Optional callback parameters for the event listener function.
Returns:
Type:
EventDispatcher
this EventDispatcher Object.

once(type, caller, listener, argsopt) → {EventDispatcher}

Use EventDispatcher Object registers the event listener object of the specified type so that the listener can receive the event notification, which is automatically removed after a response event.
Inherited From:
Parameters:
Name Type Attributes Default Description
type String Event type.
caller Object The domain of the event listener function.
listener function Event listener function.
args Array <optional>
null args Optional callback parameters for the event listener function.
Returns:
Type:
EventDispatcher
this EventDispatcher Object.

onLoaded(dataopt)

The processing function completed by the resource load.
Parameters:
Name Type Attributes Default Description
data Object <optional>
null data Data.

setAtlasConfigs(url, configO)

Sets the preloaded atlas profile
Parameters:
Name Type Description
url String Resource address.
configO Object Configuration data

setGroup(url, group)

Set resource groups.
Parameters:
Name Type Description
url String Resource address.
group String Grouping name.

Event

complete

See:
  • events.Event

error

See:
  • events.Event

progress

See:
  • events.Event