pixi.loaders.ResourceLoader

type
class
extends
pixi.interaction.EventEmitter
subclasses
pixi.loaders.Loader

Constructor

new(?baseUrl : String, ?concurrency : Int)
parameters
[baseUrl=''] {string} The base url for all resources loaded by this loader.
[concurrency=10] {number} The number of resources to load concurrently.
Manages the state and loading of multiple resources to load.

Instance Variables hide inherited show inherited

baseUrl : String

The base url for all resources loaded by this loader.

loading : Bool

Loading state of the loader, true if it is currently loading resources.

progress : Float

The progress percent of the loader going through the queue.

resources : Dynamic

All the resources for this loader keyed by name.

Instance Methods hide inherited show inherited

add(name : String, url : String, ?options : LoaderOptions, ?callback : Resource -> Void) : ResourceLoader

parameters
[name] {string} The name of the resource to load, if not passed the url is used.
url {string} The url for this resource, relative to the baseUrl of this loader.
[options] {object} The options for the load.
[options.crossOrigin] {boolean} Is this request cross-origin? Default is to determine automatically.
[options.loadType=Resource.LOAD_TYPE.XHR] {Resource.XHR_LOAD_TYPE} How should this resource be loaded?
[options.xhrType=Resource.XHR_RESPONSE_TYPE.DEFAULT] {Resource.XHR_RESPONSE_TYPE} How should the data being loaded be interpreted when using XHR?
[callback] {function} function to call when this specific resource completes loading.
returns
{Loader}
Adds a resource (or multiple resources) to the loader queue. This function can take a wide variety of different parameters. The only thing that is always required the url to load. All the following will work: ```js loader // normal param syntax .add('key', 'http://...', function () {}) .add('http://...', function () {}) .add('http://...') // object syntax .add({ name: 'key2', url: 'http://...' }, function () {}) .add({ url: 'http://...' }, function () {}) .add({ name: 'key3', url: 'http://...' onComplete: function () {} }) .add({ url: 'https://...', onComplete: function () {}, crossOrigin: true }) // you can also pass an array of objects or urls or both .add(
              { name: 'key4', url: 'http://...', onComplete: function () {} },
              { url: 'http://...', onComplete: function () {} },
              'http://...'
          
); ```

addListener(event : String, fn : EventTarget -> Void, ?context : Dynamic) : Void

parameters
{String} event Name of the event.
{function} fn Callback function.
{Mixed} context The context of the function.
Register a new EventListener for the given event.

after(fn : Resource -> Dynamic -> Void) : ResourceLoader

parameters
middleware {function} The middleware function to register.
returns
{Loader}
Sets up a middleware function that will run *after* the resource is loaded.

before(fn : Resource -> Dynamic -> Void) : ResourceLoader

parameters
middleware {function} The middleware function to register.
returns
{Loader}
Sets up a middleware function that will run *before* the resource is loaded.

emit(event : String, ?a1 : Dynamic, ?a2 : Dynamic, ?a3 : Dynamic, ?a4 : Dynamic, ?a5 : Dynamic) : Bool

parameters
eventName {String} The name of the event.
returns
{Bool} Indication if we've emitted an event.
Emit an event to all registered event listeners.

listeners(event : String) : Array<Dynamic>

parameters
{String} eventName
returns
{Array}
Return a list of assigned event listeners.

load(?cb : Void -> Void) : ResourceLoader

parameters
[callback] {function} Optional callback that will be bound to the `complete` event.
returns
{Loader}
Starts loading the queued resources.

loadResource(resource : String, ?cb : Void -> Void) : ResourceLoader

Loads a single resource.

off(event : String, fn : EventTarget -> Void, ?once : Bool) : Void

parameters
{String} event The event we want to remove.
{function} fn The listener that we need to find.
{Bool} once Only remove once listeners.
Remove event listeners.

on(event : String, fn : EventTarget -> Void, ?context : Dynamic) : Void

parameters
{String} event Name of the event.
{function} fn Callback function.
{Mixed} context The context of the function.
Register a new EventListener for the given event.

once(event : String, fn : EventTarget -> Void, ?context : Dynamic) : Void

parameters
{String} event Name of the event.
{function} fn Callback function.
{Mixed} context The context of the function.
Add an EventListener that's only called once.

pre(fn : Resource -> Dynamic -> Void) : ResourceLoader

parameters
{function} function to call
Middleware function

removeAllListeners(?event : String) : Void

parameters
{String} event The event want to remove all listeners for.
Remove all listeners or only the listeners for the specified event.

removeListener(event : String, fn : EventTarget -> Void, ?once : Bool) : Void

parameters
{String} event The event we want to remove.
{function} fn The listener that we need to find.
{Bool} once Only remove once listeners.
Remove event listeners.

reset() : Void

Resets the queue of the loader to prepare for a new load.

use(fn : Resource -> Dynamic -> Void) : Void

parameters
{function} function to call
Middleware function to use