diff --git a/src/loaders/ImageLoader.js b/src/loaders/ImageLoader.js index 8c121a8..040517d 100644 --- a/src/loaders/ImageLoader.js +++ b/src/loaders/ImageLoader.js @@ -42,6 +42,7 @@ ImageLoader.prototype.load = function () { if (!this.texture.baseTexture.hasLoaded) { this.texture.baseTexture.on('loaded', this.onLoaded.bind(this)); + this.texture.baseTexture.on('error', this.onError.bind(this)); } else { this.onLoaded(); @@ -58,6 +59,16 @@ }; /** + * Invoked when image file failed loading + * + * @method onError + * @private + */ +ImageLoader.prototype.onError = function () { + this.emit('error', { content: this }); +}; + +/** * Loads image and split it to uniform sized frames * * @param frameWidth {number} width of each frame diff --git a/src/loaders/ImageLoader.js b/src/loaders/ImageLoader.js index 8c121a8..040517d 100644 --- a/src/loaders/ImageLoader.js +++ b/src/loaders/ImageLoader.js @@ -42,6 +42,7 @@ ImageLoader.prototype.load = function () { if (!this.texture.baseTexture.hasLoaded) { this.texture.baseTexture.on('loaded', this.onLoaded.bind(this)); + this.texture.baseTexture.on('error', this.onError.bind(this)); } else { this.onLoaded(); @@ -58,6 +59,16 @@ }; /** + * Invoked when image file failed loading + * + * @method onError + * @private + */ +ImageLoader.prototype.onError = function () { + this.emit('error', { content: this }); +}; + +/** * Loads image and split it to uniform sized frames * * @param frameWidth {number} width of each frame diff --git a/src/loaders/JsonLoader.js b/src/loaders/JsonLoader.js index 06cff13..6464946 100644 --- a/src/loaders/JsonLoader.js +++ b/src/loaders/JsonLoader.js @@ -120,6 +120,7 @@ this.texture = image.texture.baseTexture; image.addEventListener('loaded', this.onLoaded.bind(this)); + image.addEventListener('error', this.onError.bind(this)); for (var i in frameData) { var rect = frameData[i].frame;