mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-10 00:58:43 +08:00
[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:
parent
b70da6f000
commit
f05174fcb8
@ -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
@ -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
@ -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
@ -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
@ -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
@ -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
@ -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}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user