PIXI.LoaderResource
class LoaderResource
Manages the state and loading of a resource and all child resources.
Can be extended in GlobalMixins.LoaderResource
.
Constructor
new PIXI.LoaderResource(name: string, url: string | Array<string>, options: object) → {}
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name | string |
The name of the resource to load. |
||
url | string | Array<string> |
The url for this resource, for audio/video loads you can pass an array of sources. |
||
options | object |
<optional> |
The options for the load. |
|
options.crossOrigin | string | boolean |
<optional> |
Is this request cross-origin? Default is to determine automatically. |
|
options.timeout | number |
<optional> |
0 |
A timeout in milliseconds for the load. If the load takes
longer than this time it is cancelled and the load is considered a failure. If this value is
set to |
options.loadType | PIXI.LoaderResource.LOAD_TYPE |
<optional> |
LOAD_TYPE.XHR |
How should this resource be loaded? |
options.xhrType | PIXI.LoaderResource.XHR_RESPONSE_TYPE |
<optional> |
XHR_RESPONSE_TYPE.DEFAULT |
How should the data being loaded be interpreted when using XHR? |
options.metadata | PIXI.LoaderResource.IMetadata |
<optional> |
Extra configuration for middleware and the Resource object. |
Summary
Properties from LoaderResource
Blob |
used by parsing middleware |
Array<PIXI.LoaderResource> |
|
string | boolean |
Is this request cross-origin? If unset, determined automatically. |
any |
The data that was loaded by the resource. |
Error |
|
string |
|
boolean |
|
boolean |
|
boolean |
|
PIXI.LoaderResource.LOAD_TYPE |
|
PIXI.IResourceMetadata |
Extra info for middleware, and controlling specifics about how the resource loads. |
string |
|
PIXI.Signal |
Dispatched after this resource has had all the after middleware run on it. |
PIXI.Signal |
|
PIXI.Signal |
|
PIXI.Signal |
Dispatched when the resource beings to load. |
number |
|
PIXI.Spritesheet |
|
PIXI.Texture |
|
Object<string, PIXI.Texture> |
|
number |
|
PIXI.LoaderResource.TYPE |
|
string |
|
XMLHttpRequest |
|
string |
|
Methods from LoaderResource
void |
|
void |
|
void |
|
void |
Marks the resource as complete. |
void |
|
Public Properties
children: Array<PIXI.LoaderResource>
The child resources this resource owns.
crossOrigin: string | boolean
Is this request cross-origin? If unset, determined automatically.
isComplete: boolean
Describes if this resource has finished loading. Is true when the resource has completely loaded.
isLoading: boolean
Describes if this resource is currently loading. Is true when the resource starts loading, and is false again when complete.
loadType: PIXI.LoaderResource.LOAD_TYPE
The method of loading to use for this resource.
metadata: PIXI.IResourceMetadata
Extra info for middleware, and controlling specifics about how the resource loads.
Note that if you pass in a loadElement
, the Resource class takes ownership of it.
Meaning it will modify it as it sees fit.
onAfterMiddleware: PIXI.Signal
Dispatched after this resource has had all the after middleware run on it.
The callback looks like LoaderResource.OnCompleteSignal.
onComplete: PIXI.Signal
Dispatched once this resource has loaded, if there was an error it will
be in the error
property.
The callback looks like LoaderResource.OnCompleteSignal.
onProgress: PIXI.Signal
Dispatched each time progress of this resource load updates. Not all resources types and loader systems can support this event so sometimes it may not be available. If the resource is being loaded on a modern browser, using XHR, and the remote server properly sets Content-Length headers, then this will be available.
The callback looks like LoaderResource.OnProgressSignal.
onStart: PIXI.Signal
Dispatched when the resource beings to load.
The callback looks like LoaderResource.OnStartSignal.
progressChunk: number
The progress chunk owned by this resource.
spritesheet: PIXI.Spritesheet
Reference to Spritesheet object created.
texture: PIXI.Texture
Texture reference for loading images and other textures.
textures: Object<string, PIXI.Texture>
Dictionary of textures from Spritesheet.
timeout: number
A timeout in milliseconds for the load. If the load takes longer than this time
it is cancelled and the load is considered a failure. If this value is set to 0
then there is no explicit timeout.
xhr: XMLHttpRequest
The XHR object that was used to load this resource. This is only set
when loadType
is LoaderResource.LOAD_TYPE.XHR
.
xhrType: string
The type used to load the resource via XHR. If unset, determined automatically.
Public Methods
static setExtensionLoadType(extname: string, loadType: PIXI.LoaderResource.LOAD_TYPE) → {void}
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 | PIXI.LoaderResource.LOAD_TYPE |
The load type to set it to. |
Type | Description |
---|---|
void |
static setExtensionXhrType(extname: string, xhrType: PIXI.LoaderResource.XHR_RESPONSE_TYPE) → {void}
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 | PIXI.LoaderResource.XHR_RESPONSE_TYPE |
The xhr type to set it to. |
Type | Description |
---|---|
void |
abort(message: string) → {void}
Aborts the loading of this resource, with an optional message.
Name | Type | Description |
---|---|---|
message | string |
The message to use for the error |
Type | Description |
---|---|
void |
complete() → {void}
Marks the resource as complete.
Type | Description |
---|---|
void |
load(cb: PIXI.LoaderResource.OnCompleteSignal) → {void}
Kicks off loading of this resource. This method is asynchronous.
Name | Type | Attributes | Description |
---|---|---|---|
cb | PIXI.LoaderResource.OnCompleteSignal |
<optional> |
Optional callback to call once the resource is loaded. |
Type | Description |
---|---|
void |