Class: rlData

rlData

new rlData(key, srcURL)

Instantiate an object for loading any file from the provided URL into a binary data buffer. (primarily for use by rlDataManager but can be used directly well)

Parameters:
Name Type Description
key string

a key meant for internally referencing the loaded data

srcURL string

a relative or full URL to the file to load

Members

onloadfailed :rlData~callbackOnLoadFailed

Type:

onloadprogress :rlData~callbackOnLoading

Type:

onloadsuccess :rlData~callbackOnLoading

Type:

Methods

getData() → {ArrayBuffer}

Returns:

the data if it successfully loaded already, otherwise null

Type
ArrayBuffer

getKey() → {string}

Returns:

the key as defined in constructor

Type
string

getLoadState() → {rlData.loadState}

Returns:

an object containing load state info

Type
rlData.loadState

getLoadStateCompactString() → {string}

Returns:

a compact string representation of the loading state, e.g. "myKey : myImage.png : 42 / 666"

Type
string

setData(toClone)

Directly set the data to keep inside (will be cloned from the given data).

Parameters:
Name Type Description
toClone ArrayBuffer | string

the source data to clone into the internal data

startload(overrideResponseTypeopt)

Start loading the data asynchronously. Make sure to set onloadfailed, onloadprogress and onloadsuccess before calling this.

Parameters:
Name Type Attributes Default Description
overrideResponseType string <optional>
arraybuffer

explicitly set the response type for the asynchronous XMLHttpRequest

Type Definitions

loadState

(not an actual type, use object literals with these properties)

Properties:
Name Type Description
key string

as defined in constructor

srcURL string

as defined in constructor

bytesLoaded number

bytes loaded so far

bytesTotal number

total bytes to load (if known)

callbackOnLoadFailed(key, srcURL, httpStatusCode)

Function signature for callbacks to use with onloadfailed.

Parameters:
Name Type Description
key string

as defined in constructor

srcURL string

as defined in constructor

httpStatusCode number

the http code describing the problem

callbackOnLoading(key, srcURL, bytesLoaded, bytesTotal)

Function signature for callbacks to use with onloadprogress and onloadsuccess

Parameters:
Name Type Description
key string

as defined in constructor

srcURL string

as defined in constructor

bytesLoaded number

bytes loaded so far

bytesTotal number

total bytes to load (if known)