Browse files

Added support to SpriteSheetLoader for preferXHR, crossOrigin, and ba…

…sePath to all be passed through to the sub-LoadQueue that loads its images.
  • Loading branch information...
lannymcnie committed Oct 14, 2015
1 parent 632f1f8 commit a51bfc6e0caaba86d59f3cf0811f83d8b2379db4
Showing with 19 additions and 9 deletions.
  1. +6 −6 examples/SpriteSheet.html
  2. +13 −3 src/preloadjs/loaders/SpriteSheetLoader.js
@@ -56,14 +56,14 @@ <h1>Sprite Sheets</h1>
assets = [];
manifest = [
{src: "../_assets/art/sky.png", id: "sky"},
{src: "../_assets/art/ground.png", id: "ground"},
{src: "../_assets/art/hill2.png", id: "hill2"},
{src: "../_assets/art/hill1.png", id: "hill"},
{src: "../_assets/static/grant.json", id:"grant", type:"spritesheet"}
{src: "art/sky.png", id: "sky"},
{src: "art/ground.png", id: "ground"},
{src: "art/hill2.png", id: "hill2"},
{src: "art/hill1.png", id: "hill"},
{src: "static/grant.json", id:"grant", type:"spritesheet", crossOrigin:true}
var loader = new createjs.LoadQueue();
var loader = new createjs.LoadQueue(true, "../_assets/");
loader.on("fileload", handleFileLoad);
loader.on("complete", handleComplete);
@@ -45,13 +45,23 @@ this.createjs = this.createjs || {};
* and {{#crossLink "JSONPLoader"}}{{/crossLink}} are higher priority loaders, so SpriteSheets <strong>must</strong>
* set the {{#crossLink "LoadItem"}}{{/crossLink}} {{#crossLink "LoadItem/type:property"}}{{/crossLink}} property
* to {{#crossLink "AbstractLoader/SPRITESHEET:property"}}{{/crossLink}}.
* The {{#crossLink "LoadItem"}}{{/crossLink}} {{#crossLink "LoadItem/crossOrigin:property"}}{{/crossLink}} as well
* as the {{#crossLink "LoadQueue's"}}{{/crossLink}} `basePath` argument and {{#crossLink "LoadQueue/_preferXHR"}}{{/crossLink}}
* property supplied to the {{#crossLink "LoadQueue"}}{{/crossLink}} are passed on to the sub-manifest that loads
* the SpriteSheet images.
* Note that the SpriteSheet JSON does not respect the {{#crossLink "LoadQueue/_preferXHR:property"}}{{/crossLink}}
* property, which should instead be determined by the presence of a {{#crossLink "LoadItem/callback:property"}}{{/crossLink}}
* property on the SpriteSheet load item. This is because the JSON loaded will have a different format depending on
* if it is loaded as JSON, so just changing `preferXHR` is not enough to change how it is loaded.
* @class SpriteSheetLoader
* @param {LoadItem|Object} loadItem
* @extends AbstractLoader
* @constructor
function SpriteSheetLoader(loadItem) {
this.AbstractLoader_constructor(loadItem, null, createjs.AbstractLoader.SPRITESHEET);
function SpriteSheetLoader(loadItem, preferXHR) {
this.AbstractLoader_constructor(loadItem, preferXHR, createjs.AbstractLoader.SPRITESHEET);
// protected properties
@@ -132,7 +142,7 @@ this.createjs = this.createjs || {};
p._loadManifest = function (json) {
if (json && json.images) {
var queue = this._manifestQueue = new createjs.LoadQueue();
var queue = this._manifestQueue = new createjs.LoadQueue(this._preferXHR, this._item.path, this._item.crossOrigin);
queue.on("complete", this._handleManifestComplete, this, true);
queue.on("fileload", this._handleManifestFileLoad, this);
queue.on("progress", this._handleManifestProgress, this);

0 comments on commit a51bfc6

Please sign in to comment.