[ts] Fixed order of registering asset loads/errors and callbacks. Fixed setting crossOrigin policy and setting source on newly created images

This commit is contained in:
badlogic 2016-11-14 13:16:06 +01:00
parent b70da6f000
commit f05174fcb8
13 changed files with 53 additions and 53 deletions

View File

@ -20,14 +20,14 @@ var spine;
request.onreadystatechange = function () {
if (request.readyState == XMLHttpRequest.DONE) {
if (request.status >= 200 && request.status < 300) {
_this.assets[path] = request.responseText;
if (success)
success(path, request.responseText);
_this.assets[path] = request.responseText;
}
else {
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
if (error)
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
}
_this.toLoad--;
_this.loaded++;
@ -43,22 +43,22 @@ var spine;
path = this.pathPrefix + path;
this.toLoad++;
var img = new Image();
img.src = path;
img.crossOrigin = "anonymous";
img.src = path;
img.onload = function (ev) {
if (success)
success(path, img);
var texture = _this.textureLoader(img);
_this.assets[path] = texture;
_this.toLoad--;
_this.loaded++;
if (success)
success(path, img);
};
img.onerror = function (ev) {
if (error)
error(path, "Couldn't load image " + path);
_this.errors[path] = "Couldn't load image " + path;
_this.toLoad--;
_this.loaded++;
if (error)
error(path, "Couldn't load image " + path);
};
};
AssetManager.prototype.get = function (path) {

File diff suppressed because one or more lines are too long

View File

@ -20,14 +20,14 @@ var spine;
request.onreadystatechange = function () {
if (request.readyState == XMLHttpRequest.DONE) {
if (request.status >= 200 && request.status < 300) {
_this.assets[path] = request.responseText;
if (success)
success(path, request.responseText);
_this.assets[path] = request.responseText;
}
else {
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
if (error)
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
}
_this.toLoad--;
_this.loaded++;
@ -43,22 +43,22 @@ var spine;
path = this.pathPrefix + path;
this.toLoad++;
var img = new Image();
img.src = path;
img.crossOrigin = "anonymous";
img.src = path;
img.onload = function (ev) {
if (success)
success(path, img);
var texture = _this.textureLoader(img);
_this.assets[path] = texture;
_this.toLoad--;
_this.loaded++;
if (success)
success(path, img);
};
img.onerror = function (ev) {
if (error)
error(path, "Couldn't load image " + path);
_this.errors[path] = "Couldn't load image " + path;
_this.toLoad--;
_this.loaded++;
if (error)
error(path, "Couldn't load image " + path);
};
};
AssetManager.prototype.get = function (path) {

File diff suppressed because one or more lines are too long

View File

@ -1643,14 +1643,14 @@ var spine;
request.onreadystatechange = function () {
if (request.readyState == XMLHttpRequest.DONE) {
if (request.status >= 200 && request.status < 300) {
_this.assets[path] = request.responseText;
if (success)
success(path, request.responseText);
_this.assets[path] = request.responseText;
}
else {
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
if (error)
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
}
_this.toLoad--;
_this.loaded++;
@ -1666,22 +1666,22 @@ var spine;
path = this.pathPrefix + path;
this.toLoad++;
var img = new Image();
img.src = path;
img.crossOrigin = "anonymous";
img.src = path;
img.onload = function (ev) {
if (success)
success(path, img);
var texture = _this.textureLoader(img);
_this.assets[path] = texture;
_this.toLoad--;
_this.loaded++;
if (success)
success(path, img);
};
img.onerror = function (ev) {
if (error)
error(path, "Couldn't load image " + path);
_this.errors[path] = "Couldn't load image " + path;
_this.toLoad--;
_this.loaded++;
if (error)
error(path, "Couldn't load image " + path);
};
};
AssetManager.prototype.get = function (path) {

File diff suppressed because one or more lines are too long

View File

@ -1643,14 +1643,14 @@ var spine;
request.onreadystatechange = function () {
if (request.readyState == XMLHttpRequest.DONE) {
if (request.status >= 200 && request.status < 300) {
_this.assets[path] = request.responseText;
if (success)
success(path, request.responseText);
_this.assets[path] = request.responseText;
}
else {
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
if (error)
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
}
_this.toLoad--;
_this.loaded++;
@ -1666,22 +1666,22 @@ var spine;
path = this.pathPrefix + path;
this.toLoad++;
var img = new Image();
img.src = path;
img.crossOrigin = "anonymous";
img.src = path;
img.onload = function (ev) {
if (success)
success(path, img);
var texture = _this.textureLoader(img);
_this.assets[path] = texture;
_this.toLoad--;
_this.loaded++;
if (success)
success(path, img);
};
img.onerror = function (ev) {
if (error)
error(path, "Couldn't load image " + path);
_this.errors[path] = "Couldn't load image " + path;
_this.toLoad--;
_this.loaded++;
if (error)
error(path, "Couldn't load image " + path);
};
};
AssetManager.prototype.get = function (path) {

File diff suppressed because one or more lines are too long

View File

@ -1643,14 +1643,14 @@ var spine;
request.onreadystatechange = function () {
if (request.readyState == XMLHttpRequest.DONE) {
if (request.status >= 200 && request.status < 300) {
_this.assets[path] = request.responseText;
if (success)
success(path, request.responseText);
_this.assets[path] = request.responseText;
}
else {
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
if (error)
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
}
_this.toLoad--;
_this.loaded++;
@ -1666,22 +1666,22 @@ var spine;
path = this.pathPrefix + path;
this.toLoad++;
var img = new Image();
img.src = path;
img.crossOrigin = "anonymous";
img.src = path;
img.onload = function (ev) {
if (success)
success(path, img);
var texture = _this.textureLoader(img);
_this.assets[path] = texture;
_this.toLoad--;
_this.loaded++;
if (success)
success(path, img);
};
img.onerror = function (ev) {
if (error)
error(path, "Couldn't load image " + path);
_this.errors[path] = "Couldn't load image " + path;
_this.toLoad--;
_this.loaded++;
if (error)
error(path, "Couldn't load image " + path);
};
};
AssetManager.prototype.get = function (path) {

File diff suppressed because one or more lines are too long

View File

@ -1643,14 +1643,14 @@ var spine;
request.onreadystatechange = function () {
if (request.readyState == XMLHttpRequest.DONE) {
if (request.status >= 200 && request.status < 300) {
_this.assets[path] = request.responseText;
if (success)
success(path, request.responseText);
_this.assets[path] = request.responseText;
}
else {
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
if (error)
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
}
_this.toLoad--;
_this.loaded++;
@ -1666,22 +1666,22 @@ var spine;
path = this.pathPrefix + path;
this.toLoad++;
var img = new Image();
img.src = path;
img.crossOrigin = "anonymous";
img.src = path;
img.onload = function (ev) {
if (success)
success(path, img);
var texture = _this.textureLoader(img);
_this.assets[path] = texture;
_this.toLoad--;
_this.loaded++;
if (success)
success(path, img);
};
img.onerror = function (ev) {
if (error)
error(path, "Couldn't load image " + path);
_this.errors[path] = "Couldn't load image " + path;
_this.toLoad--;
_this.loaded++;
if (error)
error(path, "Couldn't load image " + path);
};
};
AssetManager.prototype.get = function (path) {

File diff suppressed because one or more lines are too long

View File

@ -52,11 +52,11 @@ module spine {
request.onreadystatechange = () => {
if (request.readyState == XMLHttpRequest.DONE) {
if (request.status >= 200 && request.status < 300) {
if (success) success(path, request.responseText);
this.assets[path] = request.responseText;
if (success) success(path, request.responseText);
} else {
if (error) error(path, `Couldn't load text ${path}: status ${request.status}, ${request.responseText}`);
this.errors[path] = `Couldn't load text ${path}: status ${request.status}, ${request.responseText}`;
if (error) error(path, `Couldn't load text ${path}: status ${request.status}, ${request.responseText}`);
}
this.toLoad--;
this.loaded++;
@ -73,20 +73,20 @@ module spine {
path = this.pathPrefix + path;
this.toLoad++;
let img = new Image();
img.src = path;
img.crossOrigin = "anonymous";
img.src = path;
img.onload = (ev) => {
if (success) success(path, img);
let texture = this.textureLoader(img);
this.assets[path] = texture;
this.toLoad--;
this.loaded++;
if (success) success(path, img);
}
img.onerror = (ev) => {
if (error) error(path, `Couldn't load image ${path}`);
this.errors[path] = `Couldn't load image ${path}`;
this.toLoad--;
this.loaded++;
if (error) error(path, `Couldn't load image ${path}`);
}
}