PreloadJS:6
PreloadJS provides a consistent way to preload content for use in HTML applications. Preloading can be done using HTML tags, as well as XHR.
By default, PreloadJS will try and load content using XHR, since it provides better support for progress and completion events, however due to cross-domain issues, it may still be preferable to use tag-based loading instead. Note that some content requires XHR to work (plain text, web audio), and some requires tags (HTML audio). Note this is handled automatically where possible.
PreloadJS currently supports all modern browsers, and we have done our best to include support for most older browsers. If you find an issue with any specific OS/browser combination, please visit http://community.createjs.com/ and report it.
var queue = new createjs.LoadQueue();
queue.installPlugin(createjs.Sound);
queue.on("complete", handleComplete, this);
queue.loadFile({id:"sound", src:"http://path/to/sound.mp3"});
queue.loadManifest([
{id: "myImage", src:"path/to/myImage.jpg"}
]);
function handleComplete() {
createjs.Sound.play("sound");
var image = queue.getResult("myImage");
document.body.appendChild(image);
}
Important note on plugins: Plugins must be installed before items are added to the queue, otherwise they will not be processed, even if the load has not actually kicked off yet. Plugin functionality is handled when the items are added to the LoadQueue.
crossOrigin argument on the LoadQueue
constructor. If set to a string value (such as "Anonymous"), the "crossOrigin" property of images generated by
PreloadJS is set to that value. Please note that setting a crossOrigin value on an image that is served from a
server without CORS will cause other errors. For more info on CORS, visit https://en.wikipedia.org/wiki/Cross-origin_resource_sharing.
This module provides the following classes: