API Documentation for: 0.3.1
Show:

LoadQueue Class

Extends AbstractLoader
Defined in: LoadQueue:97
Module: PreloadJS

The LoadQueue class is the main API for preloading content. LoadQueue is a load manager, which maintains a single file, or a queue of files.

Creating a Queue
To use LoadQueue, create a LoadQueue instance. If you want to force tag loading where possible, set the useXHR argument to false.

 var queue = new createjs.LoadQueue(true);

Listening for Events
Add any listeners you want to the queue. Since PreloadJS 0.3.0, the EventDispatcher lets you add as many listeners as you want for events. You can subscribe to complete, error, fileload, progress, and fileprogress.

 queue.addEventListener("fileload", handleFileLoad);
 queue.addEventListener("complete", handleComplete);

Adding files and manifests
Add files you want to load using loadFile or add multiple files at a time using loadManifest. Files are appended to the queue, so you can use these methods as many times as you like, whenever you like.

 queue.loadFile("filePath/file.jpg");
 queue.loadFile({id:"image", src:"filePath/file.jpg"});
 queue.loadManifest(["filePath/file.jpg", {id:"image", src:"filePath/file.jpg"}];

If you pass false as the second parameter, the queue will not immediately load the files (unless it has already been started). Call the load method to begin a paused queue. Note that a paused queue will automatically resume when new files are added to it.

 queue.load();

Handling Results
When a file is finished downloading, a "fileload" event is dispatched. In an example above, there is an event listener snippet for fileload. Loaded files are always an object that can be used immediately, including:

  • Image: An <img /> tag
  • Audio: An <audio /> tag
  • JavaScript: A <script /> tag
  • CSS: A <link /> tag
  • XML: An XML DOM node
  • SVG: An <object /> tag
  • JSON: A formatted JavaScript Object
  • Text: Raw text
  • Binary: The binary loaded result
 function handleFileLoad(event) {
     var item = event.item; // A reference to the item that was passed in
     var type = item.type;

     // Add any images to the page body.
     if (type == createjs.LoadQueue.IMAGE) {
         document.body.appendChild(event.result);
     }
 }

At any time after the file has been loaded (usually after the queue has completed), any result can be looked up via its "id" using getResult. If no id was provided, then the "src" or file path can be used instead. It is recommended to always pass an id.

 var image = queue.getResult("image");
 document.body.appendChild(image);

Raw loaded content can be accessed using the rawResult property of the fileload event, or can be looked up using getResult, and true as the 2nd parameter. This is only applicable for content that has been parsed for the browser, specifically, JavaScript, CSS, XML, SVG, and JSON objects.

 var image = queue.getResult("image", true);

Plugins
LoadQueue has a simple plugin architecture to help process and preload content. For example, to preload audio, make sure to install the SoundJS Sound class, which will help preload HTML audio, Flash audio, and WebAudio files. This should be installed before loading any audio files.

 queue.installPlugin(createjs.Sound);

Known Browser Issues

  • Browsers without audio support can not load audio files.
  • Audio tags will only download until their canPlayThrough event is fired. Browsers other than Chrome will continue to download in the background.
  • When loading scripts using tags, they are automatically added to the document.
  • Scripts loaded via XHR may not be properly inspectable with browser tools.
  • IE6 and IE7 (and some other browsers) may not be able to load XML, Text, or JSON, since they require XHR to work.
  • Content loaded via tags will not show progress, and although they can be canceled, they will continue to download in the background.

Constructor

LoadQueue

(
  • [useXHR=true]
  • basePath
)

Defined in LoadQueue:97

Parameters:

  • [useXHR=true] Boolean optional

    Determines whether the preload instance will favor loading with XHR (XML HTTP Requests), or HTML tags. When this is false, LoadQueue will use tag loading when possible, and fall back on XHR when necessary.

  • basePath String

    A path that will be prepended on to the source parameter of all items in the queue before they are loaded. Note that a basePath provided to any loadFile or loadManifest call will override the basePath specified on the LoadQueue constructor.

Methods

_addItem

(
  • value
  • basePath
)
private

Defined in _addItem:970

Add an item to the queue. Items are formatted into a usable object containing all the properties necessary to load the content. The load queue is populated with the loader instance that handles preloading, and not the load item that was passed in by the user. To look up the load item by id or src, use the LoadQueue.getItem method.

Parameters:

  • value String | Object

    The item to add to the queue.

  • basePath String

    A path to prepend to the item's source.

_checkScriptLoadOrder

() private

Ensure the scripts load and dispatch in the correct order. When using XHR, scripts are stored in an array in the order they were added, but with a "null" value. When they are completed, the value is set to the load item, and then when they are processed and dispatched, the value is set to true. This method simply iterates the array, and ensures that any loaded items that are not preceded by a null value are dispatched.

_createLoader

(
  • item
)
AbstractLoader private

Defined in _createLoader:1099

Create a loader for a load item.

Parameters:

  • item Object

    A formatted load item that can be used to generate a loader.

Returns:

AbstractLoader: A loader that can be used to load content.

_createLoadItem

(
  • value
)
Object private

Create a refined load item, which contains all the required properties (src, type, extension, tag). The type of item is determined by browser support, requirements based on the file type, and developer settings. For example, XHR is only used for file types that support it in new browsers.

Before the item is returned, any plugins registered to handle the type or extension will be fired, which may alter the load item.

Parameters:

  • value String | Object | HTMLAudioElement | HTMLImageElement

    The item that needs to be preloaded.

Returns:

Object: The loader instance that will be used.

_createTag

(
  • type
)
HTMLImageElement | HTMLAudioElement | HTMLScriptElement | HTMLLinkElement | Object private

Defined in _createTag:1355

Create an HTML tag. This is in LoadQueue instead of TagLoader because no matter how we load the data, we may need to return it in a tag.

Parameters:

  • type String

    The item type. Items are passed in by the developer, or deteremined by the extension.

Returns:

HTMLImageElement | HTMLAudioElement | HTMLScriptElement | HTMLLinkElement | Object: The tag that is created. Note that tags are not appended to the HTML body.

_disposeItem

(
  • item
)
private

Defined in _disposeItem:1340

Clean out item results, to free them from memory. Mainly, the loaded item and results are cleared from internal hashes.

Parameters:

  • item Object

    The item that was passed in for preloading.

_formatQueryString

(
  • data
  • [query]
)
private

Formats an object into a query string for either a POST or GET request.

Parameters:

  • data Object

    The data to convert to a query string.

  • [query] Array optional

    Existing name/value pairs to append on to this query.

_handleFileComplete

(
  • event
)
private

An item has finished loading. We can assume that it is totally loaded, has been parsed for immediate use, and is available as the "result" property on the load item. The raw text result for a parsed item (such as JSON, XML, CSS, JavaScript, etc) is available as the "rawResult" event, and can also be looked up using getResult.

Parameters:

  • event Object

    The event object from the loader.

_handleFileError

(
  • event
)
private

The callback that is fired when a loader encounters an error. The queue will continue loading unless stopOnError is set to true.

Parameters:

  • event Object

    The error event, containing relevant error information.

_handleProgress

(
  • event
)
private

An item has dispatched progress. Propagate that progress, and update the LoadQueue overall progress.

Parameters:

  • event Object

    The progress event from the item.

_isCanceled

() Boolean protected

Determine if the load has been canceled. This is important to ensure that method calls or asynchronous events do not cause issues after the queue has been cleaned up.

Returns:

Boolean: If the loader has been canceled.

_loadItem

(
  • loader
)
private

Defined in _loadItem:1181

Begin loading an item. Events are not added to the loaders until the load starts.

Parameters:

  • loader AbstractLoader

    The loader instance to start. Currently, this will be an XHRLoader or TagLoader.

_loadNext

() private

Defined in _loadNext:1135

Load the next item in the queue. If the queue is empty (all items have been loaded), then the complete event is processed. The queue will "fill up" any empty slots, up to the max connection specified using LoadQueue.setMaxConnections method. The only exception is scripts that are loaded using tags, which have to be loaded one at a time to maintain load order.

_parseURI

(
  • path
)
Array protected

Inherited from AbstractLoader: _parseURI:326

Parse a file URI using the AbstractLoader.FILE_PATTERN RegExp pattern.

Parameters:

  • path String

    The file path to parse.

Returns:

Array: The matched file contents. Please see the AbstractLoader.FILE_PATTERN property for details on the return value. This will return null if it does not match.

_removeLoadItem

(
  • loader
)
private

A load item is completed or was canceled, and needs to be removed from the LoadQueue.

Parameters:

_sendComplete

() protected

Dispatch a complete event (and onComplete callback). Please see the AbstractLoader.complete event for details on the event payload.

_sendError

(
  • event
)
protected

Inherited from AbstractLoader: _sendError:296

Dispatch an error event (and onError callback). Please see the AbstractLoader.error event for details on the event payload.

Parameters:

  • event Object

    The event object containing specific error properties.

_sendFileComplete

(
  • item
  • loader
)
protected

Dispatch a fileload event (and onFileLoad callback). Please see the LoadQueue.fileload event for details on the event payload.

Parameters:

_sendFileProgress

(
  • item
  • progress
)
protected

Dispatch a fileprogress event (and onFileProgress callback). Please see the LoadQueue.fileprogress event for details on the event payload.

Parameters:

  • item Object

    The item that is being loaded.

  • progress Number

    The amount the item has been loaded (between 0 and 1).

_sendFileStart

(
  • loader
)
protected

Defined in _sendFileStart:1489

Dispatch a filestart event immediately before a file has started to load. Please see the LoadQueue.filestart event for details on the event payload.

Parameters:

_sendLoadStart

() protected

Dispatch a loadstart event (and onLoadStart callback). Please see the AbstractLoader.loadstart event for details on the event payload.

_sendProgress

(
  • value
)
protected

Dispatch a progress event (and onProgress callback). Please see the AbstractLoader.progress event for details on the event payload.

Parameters:

  • value Number | Object

    The progress of the loaded item, or an object containing loaded and total properties.

_updateProgress

() private

Overall progress has changed, so determine the new progress amount and dispatch it. This changes any time an item dispatches progress or completes. Note that since we don't know the actual filesize of items before they are loaded, and even then we can only get the size of items loaded with XHR. In this case, we define a "slot" for each item (1 item in 10 would get 10%), and then append loaded progress on top of the already-loaded items.

For example, if 5/10 items have loaded, and item 6 is 20% loaded, the total progress would be:

  • 5/10 of the items in the queue (50%)
  • plus 20% of item 6's slot (2%)
  • equals 52%

addEventListener

(
  • type
  • listener
)
Function | Object

Adds the specified event listener. Note that adding multiple listeners to the same function will result in multiple callbacks getting fired.

Example

 displayObject.addEventListener("click", handleClick);
 function handleClick(event) {
    // Click happened.
 }

Parameters:

  • type String

    The string type of the event.

  • listener Function | Object

    An object with a handleEvent method, or a function that will be called when the event is dispatched.

Returns:

Function | Object: Returns the listener for chaining or assignment.

buildPath

(
  • src
  • [basePath]
  • [data]
)
String

Inherited from AbstractLoader: buildPath:360

Available since 0.3.1

A utility method that builds a file path using a source, a basePath, and a data object, and formats it into a new path. All of the loaders in PreloadJS use this method to compile paths when loading.

Parameters:

  • src String

    The source path to add values to.

  • [basePath] String optional

    A string to prepend to the file path. Sources beginning with http:// or similar will not receive a base path.

  • [data] Object optional

    Object used to append values to this request as a query string. Existing parameters on the path will be preserved.

Returns:

String: A formatted string that contains the path and the supplied parameters.

close

()

Inherited from AbstractLoader: close:234

Close the active queue. Closing a queue completely empties the queue, and prevents any remaining items from starting to download. Note that currently any active loads will remain open, and events may be processed.

To stop and restart a queue, use the setPaused method instead.

dispatchEvent

(
  • eventObj
  • [target]
)
Boolean

Dispatches the specified event to all listeners.

Example

 // Use a string event
 this.dispatchEvent("complete");

 // Use an object
 var event = {
     type: "complete",
     foo: "bar"
 };
 this.dispatchEvent(event);

Parameters:

  • eventObj Object | String

    An object with a "type" property, or a string type. If a string is used, dispatchEvent will construct a generic event object with the specified type.

  • [target] Object optional

    The object to use as the target property of the event object. This will default to the dispatching object.

Returns:

Boolean: Returns true if any listener returned true.

getItem

(
  • value
)
Object

Defined in getItem:899

Look up a load item using either the "id" or "src" that was specified when loading it.

Parameters:

  • value String

    The id or src of the load item.

Returns:

Object: The load item that was initially requested using loadFile or loadManifest. This object is also returned via the "fileload" event as the "item" parameter.

getResult

(
  • value
  • [rawResult=false]
)
Object

Defined in getResult:911

Look up a loaded result using either the "id" or "src" that was specified when loading it.

Parameters:

  • value String

    The id or src of the load item.

  • [rawResult=false] Boolean optional

    Return a raw result instead of a formatted result. This applies to content loaded via XHR such as scripts, XML, CSS, and Images. If there is no raw result, the formatted result will be returned instead.

Returns:

Object: A result object containing the content that was loaded, such as:
  • An image tag (<image />) for images
  • A script tag for JavaScript (<script />). Note that scripts loaded with tags may be added to the HTML head.
  • A style tag for CSS (<style />)
  • Raw text for TEXT
  • A formatted JavaScript object defined by JSON
  • An XML document
  • An binary arraybuffer loaded by XHR
  • An audio tag (<audio >) for HTML audio. Note that it is recommended to use SoundJS APIs to play loaded audio. Specifically, audio loaded by Flash and WebAudio will return a loader object using this method which can not be used to play audio back.
This object is also returned via the "fileload" event as the "item" parameter. Note that if a raw result is requested, but not found, the result will be returned instead.

hasEventListener

(
  • type
)
Boolean

Indicates whether there is at least one listener for the specified event type.

Parameters:

  • type String

    The string type of the event.

Returns:

Boolean: Returns true if there is at least one listener for the specified event.

init

() private

Inherited from AbstractLoader: init:215

Initialize the loader. This is called by the constructor.

initialize

() protected

Inherited from EventDispatcher: initialize:98

Initialization method.

installPlugin

(
  • plugin
)

Defined in installPlugin:749

Register a plugin. Plugins can map to both load types (sound, image, etc), or can map to specific extensions (png, mp3, etc). Currently, only one plugin can exist per type/extension. Plugins must return an object containing:

  • callback: The function to call
  • types: An array of types to handle
  • extensions: An array of extensions to handle. This only fires if an applicable type handler has not fired.
Note that even though a plugin might match both a type and extension handler, the type handler takes priority and is the only one that gets fired. For example if you have a handler for type=sound, and a handler for extension=mp3, only the type handler would fire when an mp3 file is loaded.

Parameters:

isBinary

(
  • type
)
private

Defined in isBinary:729

Determine if a specific type should be loaded as a binary file. Currently, only images and items marked specifically as "binary" are loaded as binary. Note that audio is not a binary type, as we can not play back using an audio tag if it is loaded as binary. Plugins can change the item type to binary to ensure they get a binary result to work with. Binary files are loaded using XHR2.

Parameters:

Returns:

If the specified type is binary.

load

()

Inherited from AbstractLoader: load:222

Begin loading the queued items. This method can be called when a LoadQueue is set up but not started immediately.

Example:

 var queue = new createjs.LoadQueue();
 queue.addEventListener("complete", handleComplete);
 queue.loadManifest(fileArray, false); // Note the 2nd argument that tells the queue not to start loading yet
 queue.load();

loadFile

(
  • file
  • [loadNow=true]
  • [basePath]
)

Defined in loadFile:792

Load a single file. To add multiple files at once, use the loadManifest method.

Note that files are always appended to the current queue, so this method can be used multiple times to add files. To clear the queue first, use the close method.

Parameters:

  • file Object | String

    The file object or path to load. A file can be either

    1. a path to a resource (string). Note that this kind of load item will be converted to an object (see below) in the background.
    2. OR an object that contains:
      • src: The source of the file that is being loaded. This property is required. The source can either be a string (recommended), or an HTML tag.
      • type: The type of file that will be loaded (image, sound, json, etc). PreloadJS does auto-detection of types using the extension. Supported types are defined on LoadQueue, such as LoadQueue.IMAGE. It is recommended that a type is specified when a non-standard file URI (such as a php script) us used.
      • id: A string identifier which can be used to reference the loaded object.
      • callback: Optional, used for JSONP requests, to define what method to call when the JSONP is loaded.
      • data: An arbitrary data object, which is included with the loaded object
      • method: used to define if this request uses GET or POST when sending data to the server. Default; GET
      • values: Optional object of name/value pairs to send to the server.
  • [loadNow=true] Boolean optional

    Kick off an immediate load (true) or wait for a load call (false). The default value is true. If the queue is paused using setPaused, and the value is true, the queue will resume automatically.

  • [basePath] String optional

    An optional base path prepended to the file source when the file is loaded. The load item will not be modified.

loadManifest

(
  • manifest
  • [loadNow=true]
  • [basePath]
)

Defined in loadManifest:836

Load an array of items. To load a single file, use the loadFile method. The files in the manifest are requested in the same order, but may complete in a different order if the max connections are set above 1 using setMaxConnections. Scripts will load in the right order as long as loadQueue.maintainScriptOrder is true (which is default).

Note that files are always appended to the current queue, so this method can be used multiple times to add files. To clear the queue first, use the close method.

Parameters:

  • manifest Array

    The list of files to load. Each file can be either:

    1. a path to a resource (string). Note that this kind of load item will be converted to an object (see below) in the background.
    2. OR an object that contains:
      • src: The source of the file that is being loaded. This property is required. The source can either be a string (recommended), or an HTML tag.
      • type: The type of file that will be loaded (image, sound, json, etc). PreloadJS does auto-detection of types using the extension. Supported types are defined on LoadQueue, such as LoadQueue.IMAGE. It is recommended that a type is specified when a non-standard file URI (such as a php script) us used.
      • id: A string identifier which can be used to reference the loaded object.
      • data: An arbitrary data object, which is returned with the loaded object
  • [loadNow=true] Boolean optional

    Kick off an immediate load (true) or wait for a load call (false). The default value is true. If the queue is paused using setPaused and this value is true, the queue will resume automatically.

  • [basePath] String optional

    An optional base path prepended to each of the files' source when the file is loaded. The load items will not be modified.

proxy

(
  • method
  • scope
)
deprecated private static

Defined in proxy:1509

Deprecated: In favour of the createjs.proxy method (see LoadQueue source).

A function proxy for PreloadJS methods. By default, JavaScript methods do not maintain scope, so passing a method as a callback will result in the method getting called in the scope of the caller. Using a proxy ensures that the method gets called in the correct scope.

Parameters:

  • method Function

    The function to call

  • scope Object

    The scope to call the method name on

remove

(
  • idsOrUrls
)

Defined in remove:628

Available since 0.3.0

Stops an item from being loaded, and removes it from the queue. If nothing is passed, all items are removed. This also removes internal references to loaded item(s).

Parameters:

  • idsOrUrls String | Array

    The id or ids to remove from this queue. You can pass an item, an array of items, or multiple items as arguments.

removeAll

()

Defined in removeAll:617

Available since 0.3.0

Stops all queued and loading items, and clears the queue. This also removes all internal references to loaded content, and allows the queue to be used again. Items that have not yet started can be kicked off again using the load method.

removeAllEventListeners

(
  • [type]
)

Removes all listeners for the specified type, or all listeners of all types.

Example

 // Remove all listeners
 displayObject.removeAllEvenListeners();

 // Remove all click listeners
 displayObject.removeAllEventListeners("click");

Parameters:

  • [type] String optional

    The string type of the event. If omitted, all listeners for all types will be removed.

removeEventListener

(
  • type
  • listener
)

Removes the specified event listener.

Important Note: that you must pass the exact function reference used when the event was added. If a proxy function, or function closure is used as the callback, the proxy/closure reference must be used - a new proxy or closure will not work.

Example

 displayObject.removeEventListener("click", handleClick);

Parameters:

  • type String

    The string type of the event.

  • listener Function | Object

    The listener function or object.

reset

()

Defined in reset:706

Available since 0.3.0

Stops all open loads, destroys any loaded items, and resets the queue, so all items can be reloaded again by calling load. Items are not removed from the queue. To remove items use the remove or removeAll method.

setMaxConnections

(
  • value
)

Set the maximum number of concurrent connections. Note that browsers and servers may have a built-in maximum number of open connections, so any additional connections may remain in a pending state until the browser opens the connection. Note that when loading scripts using tags, with maintainScriptOrder=true, only one script is loaded at a time due to browser limitations.

Parameters:

  • value Number

    The number of concurrent loads to allow. By default, only a single connection per LoadQueue is open at any time.

setPaused

(
  • value
)

Defined in setPaused:945

Pause or resume the current load. Active loads will not be cancelled, but the next items in the queue will not be processed when active loads complete. LoadQueues are not paused by default.

Parameters:

  • value Boolean

    Whether the queue should be paused or not.

setUseXHR

(
  • value
)
Boolean

Defined in setUseXHR:602

Available since 0.3.0

Change the usXHR value. Note that if this is set to true, it may fail depending on the browser's capabilities.

Parameters:

  • value Boolean

    The new useXHR value to set.

Returns:

Boolean: The new useXHR value. If XHR is not supported by the browser, this will return false, even if the provided value argument was true.

toString

() String

Inherited from EventDispatcher but overwritten in toString:399

Returns:

String: a string representation of the instance.

Properties

_basePath

String private

Inherited from AbstractLoader: _basePath:99

Available since 0.3.1

A path that will be prepended on to the item's source parameter before it is loaded.

_currentLoads

Array private

Defined in _currentLoads:483

An array containing the currently downloading files.

_currentlyLoadingScript

Boolean private

Determines if there is currently a script loading. This helps ensure that only a single script loads at once when using a script tag to do preloading.

_extensionCallbacks

Null private

An object hash of callbacks that are fired for each file extension before the file is loaded, giving plugins the ability to override properties of the load. Please see the installPlugin method for more information.

_item

Object private

Inherited from AbstractLoader: _item:90

The item this loader represents. Note that this is null in a LoadQueue, but will be available on loaders such as XHRLoader and TagLoader.

_listeners

Object protected

Inherited from EventDispatcher: _listeners:90

_loadedRawResults

Object private

An object hash of un-parsed loaded items, indexed by the ID of the load item.

_loadedResults

Object private

Defined in _loadedResults:523

An object hash of loaded items, indexed by the ID of the load item.

_loadedScripts

Array private

Defined in _loadedScripts:568

A list of scripts that have been loaded. Items are added to this list as null when they are requested, contain the loaded item if it has completed, but not been dispatched to the user, and true once they are complete and have been dispatched.

_loadItemsById

Object private

Defined in _loadItemsById:507

An object hash of items that have finished downloading, indexed by item IDs.

_loadItemsBySrc

Object private

Defined in _loadItemsBySrc:515

An object hash of items that have finished downloading, indexed by item source.

_loadQueue

Array private

Defined in _loadQueue:491

An array containing the queued items that have not yet started downloading.

_loadQueueBackup

Array private

An array containing downloads that have not completed, so that the LoadQueue can be properly reset.

_loadStartWasDispatched

Boolean private

Determines if the loadStart event was dispatched already. This event is only fired one time, when the first file is requested.

Default: false

_maxConnections

Number private

Defined in _maxConnections:464

The number of maximum open connections that a loadQueue tries to maintain. Please see setMaxConnections for more information.

Default: 1

_numItems

Number private

Defined in _numItems:539

The number of items that have been requested. This helps manage an overall progress without knowing how large the files are before they are downloaded.

Default: 0

_numItemsLoaded

Number private

Defined in _numItemsLoaded:549

The number of items that have completed loaded. This helps manage an overall progress without knowing how large the files are before they are downloaded.

Default: 0

_scriptOrder

Array private

Defined in _scriptOrder:559

A list of scripts in the order they were requested. This helps ensure that scripts are "completed" in the right order.

_typeCallbacks

Object private

Defined in _typeCallbacks:434

An object hash of callbacks that are fired for each file type before the file is loaded, giving plugins the ability to override properties of the load. Please see the installPlugin method for more information.

BINARY

String static

Defined in BINARY:215

The preload type for generic binary types. Note that images and sound files are treated as binary.

Default: binary

canceled

Boolean

Inherited from AbstractLoader: canceled:72

Determine if the loader was canceled. Canceled loads will not fire complete events. Note that LoadQueue queues should be closed using close instead of canceled.

Default: false

CSS

String static

Defined in CSS:224

The preload type for css files. CSS files are loaded into a LINK or STYLE tag (depending on the load type)

Default: css

IMAGE

String static

Defined in IMAGE:233

The preload type for image files, usually png, gif, or jpg/jpeg. Images are loaded into an IMAGE tag.

Default: image

JAVASCRIPT

String static

Defined in JAVASCRIPT:242

The preload type for javascript files, usually with the "js" file extension. JavaScript files are loaded into a SCRIPT tag.

Default: javascript

JSON

String static

Defined in JSON:252

The preload type for json files, usually with the "json" file extension. JSON data is loaded and parsed into a JavaScript object.

Default: json

JSON

String static

Defined in JSON:262

The preload type for jsonp files, usually with the "json" file extension. You are required to pass a callback parameter when loading jsonp.

Default: json

LOAD_TIMEOUT

Number static

Defined in LOAD_TIMEOUT:205

Time in milliseconds to assume a load has failed.

Default: 8000

loaded

Boolean

Inherited from AbstractLoader: loaded:63

If the loader has completed loading. This provides a quick check, but also ensures that the different approaches used for loading do not pile up resulting in more than one complete event.

Default: false

maintainScriptOrder

Boolean

Ensure loaded scripts "complete" in the order they are specified. Note that scripts loaded via tags will only load one at a time, and will be added to the document when they are loaded.

Default: true

next

LoadQueue

Defined in next:367

The next preload queue to process when this one is complete. If an error is thrown in the current queue, and loadQueue.stopOnError is true, the next queue will not be processed.

Default: null

onComplete

Function deprecated

Inherited from AbstractLoader: onComplete:176

Deprecated: In favour of the "complete" event. Will be removed in a future version.

The callback that is fired when the loader's content has been entirely loaded.

onError

Function deprecated

Inherited from AbstractLoader: onError:184

Deprecated: In favour of the "error" event. Will be removed in a future version.

The callback that is fired when the loader encounters an error.

onFileLoad

Function deprecated

Defined in onFileLoad:416

Deprecated: In favour of the "fileload" event. Will be removed in a future version.

The callback that is fired when an individual file is loaded.

onFileProgress

Function deprecated

Defined in onFileProgress:424

Deprecated: In favour of the "fileprogress" event. Will be removed in a future version.

The callback that is fired when an individual files progress changes.

onLoadStart

Function deprecated

Inherited from AbstractLoader: onLoadStart:168

Deprecated: In favour of the "loadStart" event. Will be removed in a future version.

The callback that is fired when a load starts.

onProgress

Function deprecated

Inherited from AbstractLoader: onProgress:160

Deprecated: In favour of the "progress" event. Will be removed in a future version.

The callback that is fired when the overall progress changes.

progress

Number

Inherited from AbstractLoader: progress:82

The current load progress (percentage) for this item. This will be a number between 0 and 1.

Default: 0

SOUND

String static

Defined in SOUND:272

The preload type for sound files, usually mp3, ogg, or wav. Audio is loaded into an AUDIO tag.

Default: sound

stopOnError

Boolean

Defined in stopOnError:339

Does LoadQueue stop processing the current queue when an error is encountered.

Default: false

SVG

String static

Defined in SVG:281

The preload type for SVG files.

Default: svg

TEXT

String static

Defined in TEXT:290

The preload type for text files, which is also the default file type if the type can not be determined. Text is loaded as raw text.

Default: text

useXHR

Boolean

Defined in useXHR:325

Use XMLHttpRequest (XHR) when possible. Note that LoadQueue will default to tag loading or XHR loading depending on the requirements for a media type. For example, HTML audio can not be loaded with XHR, and WebAudio can not be loaded with tags, so it will default the the correct type instead of using the user-defined type.

Note: This property is read-only. To change it, please use the setUseXHR method.

Default: true

XML

String static

Defined in XML:300

The preload type for xml files. XML is loaded into an XML document.

Default: xml

Events

complete

Inherited from AbstractLoader: complete:137

Available since 0.3.0

The event that is fired when the entire queue has been loaded.

Event Payload:

  • target Object

    The object that dispatched the event.

  • type String

    The event type.

error

Inherited from AbstractLoader: error:145

Available since 0.3.0

The event that is fired when the loader encounters an error. If the error was encountered by a file, the event will contain the item that caused the error. There may be additional properties such as the error reason on event objects.

Event Payload:

  • target Object

    The object that dispatched the event.

  • type String

    The event type.

  • [item] Object optional

    The item that was being loaded that caused the error. The item was specified in the loadFile or loadManifest call. If only a string path or tag was specified, the object will contain that value as a property.

  • [error] String optional

    The error object or text.

fileload

Defined in fileload:377

Available since 0.3.0

This event is fired when an individual file has loaded, and been processed.

Event Payload:

  • target Object

    The object that dispatched the event.

  • type String

    The event type.

  • item Object

    The file item which was specified in the loadFile or loadManifest call. If only a string path or tag was specified, the object will contain that value as a property.

  • result Object

    The HTML tag or parsed result of the loaded item.

  • rawResult Object

    The unprocessed result, usually the raw text or binary data before it is converted to a usable object.

fileprogress

Defined in fileprogress:391

Available since 0.3.0

This event is fired when an an individual file progress changes.

Event Payload:

  • The Object

    object that dispatched the event.

  • type String

    The event type.

  • item Object

    The file item which was specified in the loadFile or loadManifest call. If only a string path or tag was specified, the object will contain that value as a property.

  • loaded Number

    The number of bytes that have been loaded. Note that this may just be a percentage of 1.

  • total Number

    The total number of bytes. If it is unknown, the value is 1.

  • progress Number

    The amount that has been loaded between 0 and 1.

filestart

Defined in filestart:405

This event is fired when an individual file starts to load.

Event Payload:

  • The Object

    object that dispatched the event.

  • type String

    The event type.

  • item Object

    The file item which was specified in the loadFile or loadManifest call. If only a string path or tag was specified, the object will contain that value as a property.

loadStart

deprecated

Inherited from AbstractLoader: loadStart:121

Deprecated: in favour of the "loadstart" event.

Available since 0.3.0

The event that is fired when a load starts. This event has been deprecated in favour of the "loadstart" event.

Event Payload:

  • target Object

    The object that dispatched the event.

  • type String

    The event type.

loadstart

Inherited from AbstractLoader: loadstart:129

Available since 0.3.1

The event that is fired when a load starts.

Event Payload:

  • target Object

    The object that dispatched the event.

  • type String

    The event type.

progress

Inherited from AbstractLoader: progress:109

Available since 0.3.0

The event that is fired when the overall progress changes.

Event Payload:

  • target Object

    The object that dispatched the event.

  • type String

    The event type.

  • loaded Number

    The amount that has been loaded so far. Note that this is may just be a percentage of 1, since file sizes can not be determined before a load is kicked off, if at all.

  • total Number

    The total number of bytes. Note that this may just be 1.

  • progress Number

    The ratio that has been loaded between 0 and 1.