Class: Resource

Resource

new Resource ()

Manages the state and loading of a resource and all child resources.

Members

Resource.LOAD_TYPE number staticreadonly

The types of loading a resource can use.

Properties:
Name Type Default Description
XHR number 1

Uses XMLHttpRequest to load the resource.

IMAGE number 2

Uses an Image object to load the resource.

AUDIO number 3

Uses an Audio object to load the resource.

VIDEO number 4

Uses a Video object to load the resource.

Resource.STATUS_FLAGS number staticreadonly

The types of resources a resource could represent.

Properties:
Name Type Default Description
NONE number 0
DATA_URL number
COMPLETE number
LOADING number

Resource.TYPE number staticreadonly

The types of resources a resource could represent.

Properties:
Name Type Default Description
UNKNOWN number 0
JSON number 1
XML number 2
IMAGE number 3
AUDIO number 4
VIDEO number 5
TEXT number 6

Resource.XHR_RESPONSE_TYPE string staticreadonly

The XHR ready states, used internally.

Properties:
Name Type Default Description
DEFAULT string text

string

BUFFER string arraybuffer

ArrayBuffer

BLOB string blob

Blob

DOCUMENT string document

Document

JSON string json

Object

TEXT string text

String

Methods

Resource.setExtensionLoadType (extname, loadType) static

Sets the load type to be used for a specific extension.

Name Type Description
extname string

The extension to set the type for, e.g. "png" or "fnt"

loadType Resource.LOAD_TYPE

The load type to set it to.

Resource.setExtensionXhrType (extname, xhrType) static

Sets the load type to be used for a specific extension.

Name Type Description
extname string

The extension to set the type for, e.g. "png" or "fnt"

xhrType Resource.XHR_RESPONSE_TYPE

The xhr type to set it to.

Type Definitions

Resource.IMetadata object

Properties:
Name Type Argument Default Description
loadElement HTMLImageElement | HTMLAudioElement | HTMLVideoElement <optional>
null

The element to use for loading, instead of creating one.

skipSource boolean <optional>
false

Skips adding source(s) to the load element. This is useful if you want to pass in a loadElement that you already added load sources to.

mimeType string | Array.<string> <optional>

The mime type to use for the source element of a video/audio elment. If the urls are an array, you can pass this as an array as well where each index is the mime type to use for the corresponding url index.

Resource.OnCompleteSignal (resource)

When the resource finishes loading.

Name Type Description
resource Resource

The resource that the event happened on.

Resource.OnProgressSignal (resource, percentage)

When the resource reports loading progress.

Name Type Description
resource Resource

The resource that the event happened on.

percentage number

The progress of the load in the range [0, 1].

Resource.OnStartSignal (resource)

When the resource starts to load.

Name Type Description
resource Resource

The resource that the event happened on.