-
Notifications
You must be signed in to change notification settings - Fork 22
Loader Class
Matt Karl edited this page Sep 25, 2015
·
9 revisions
Loader is a singleton for interacting with CreateJS's PreloadJS. Some of the features of Loader include, browser cache control, priority queuing and setting simultaneous maximum downloads. Loader is included in the Core Module and accessible from the namespace springroll.Loader
.
var app = new springroll.Application();
app.on('init', function()
{
this.loader.load("assets/config.json", function(result)
{
// Result returned as a LoaderResult
var json = result.content; // the load contents
});
});
###load(url, callback, [updateCallback[, priority=0]])
Parameters
- url string The relative (recommended), root-relative or absolute path to an asset to load.
- callback function The callback function when the load completes.
- updateCallback function (optional) The callback function on load progress updates. Passes 0-1 as the only parameter.
- priority int (optional) The load priority, generally low is -1, normal is 0 (default) and 1 is high.
- Type: int
- Default: 2
The maximum number of simultaneous loads that can happen at the same time.
- Type: springroll.CacheManager
- Default: instance of springroll.CacheManager
The CacheManager is responsible for managing the formatting of URLs and managing the browser cache. If you are attempting to load a file outside of Loader, it would be important to call the prepare()
method on the CacheManager.
var app = new springroll.Application({
basePath : 'http://cdn.example.com/',
cacheBust : true,
});
app.on('init', function()
{
// The prepare method has two parameters, the first is the url, the second
// a boolean if the basePath should be applied.
var url = this.loader.cacheManager.prepare("assets/example.txt", true);
console.log(url); // returns "http://cdn.example.com/assets/example.txt?v=1230912380"
});
To see the full list of methods available to springroll.Loader
please see the full documentation.
- Core Module (required)
- Container Client Module
- Captions Module
- Debug Module
- EaselJS Animation Module
- EaselJS Cutscene Module
- EaselJS Display Module
- EaselJS Learning Module
- EaselJS States Module
- EaselJS UI Module
- Hints Module
- Languages Module
- Learning Module
- Learning Media Module
- Native Display Module
- Pixi.js Animation Module
- Pixi.js Display Module
- Pixi.js Spine Module
- Pixi.js UI Module
- Sound Module
- States Module
- UI Module