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 toCloneArrayBuffer | string the source data to clone into the internal data
-
startload(overrideResponseTypeopt)
-
Start loading the data asynchronously. Make sure to set
onloadfailed,onloadprogressandonloadsuccessbefore calling this.Parameters:
Name Type Attributes Default Description overrideResponseTypestring <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 keystring as defined in constructor
srcURLstring as defined in constructor
bytesLoadednumber bytes loaded so far
bytesTotalnumber total bytes to load (if known)
-
callbackOnLoadFailed(key, srcURL, httpStatusCode)
-
Function signature for callbacks to use with
onloadfailed.Parameters:
Name Type Description keystring as defined in constructor
srcURLstring as defined in constructor
httpStatusCodenumber the http code describing the problem
-
callbackOnLoading(key, srcURL, bytesLoaded, bytesTotal)
-
Function signature for callbacks to use with
onloadprogressandonloadsuccessParameters:
Name Type Description keystring as defined in constructor
srcURLstring as defined in constructor
bytesLoadednumber bytes loaded so far
bytesTotalnumber total bytes to load (if known)