API Documentation for: 0.3.0
Show:

PreloadJS Module

Defined in: PreloadJS:3

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.

Getting Started

To get started, check out the LoadQueue class, which includes a quick overview of how to load files and process results.

Example

 var queue = new createjs.LoadQueue();
 queue.installPlugin(createjs.Sound);
 queue.addEventListener("complete", handleComplete);
 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.