mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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 () {
|
request.onreadystatechange = function () {
|
||||||
if (request.readyState == XMLHttpRequest.DONE) {
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
if (request.status >= 200 && request.status < 300) {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
|
_this.assets[path] = request.responseText;
|
||||||
if (success)
|
if (success)
|
||||||
success(path, request.responseText);
|
success(path, request.responseText);
|
||||||
_this.assets[path] = request.responseText;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
|
||||||
if (error)
|
if (error)
|
||||||
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
|
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.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
@ -43,22 +43,22 @@ var spine;
|
|||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
this.toLoad++;
|
this.toLoad++;
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = path;
|
|
||||||
img.crossOrigin = "anonymous";
|
img.crossOrigin = "anonymous";
|
||||||
|
img.src = path;
|
||||||
img.onload = function (ev) {
|
img.onload = function (ev) {
|
||||||
if (success)
|
|
||||||
success(path, img);
|
|
||||||
var texture = _this.textureLoader(img);
|
var texture = _this.textureLoader(img);
|
||||||
_this.assets[path] = texture;
|
_this.assets[path] = texture;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (success)
|
||||||
|
success(path, img);
|
||||||
};
|
};
|
||||||
img.onerror = function (ev) {
|
img.onerror = function (ev) {
|
||||||
if (error)
|
|
||||||
error(path, "Couldn't load image " + path);
|
|
||||||
_this.errors[path] = "Couldn't load image " + path;
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (error)
|
||||||
|
error(path, "Couldn't load image " + path);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
AssetManager.prototype.get = function (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 () {
|
request.onreadystatechange = function () {
|
||||||
if (request.readyState == XMLHttpRequest.DONE) {
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
if (request.status >= 200 && request.status < 300) {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
|
_this.assets[path] = request.responseText;
|
||||||
if (success)
|
if (success)
|
||||||
success(path, request.responseText);
|
success(path, request.responseText);
|
||||||
_this.assets[path] = request.responseText;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
|
||||||
if (error)
|
if (error)
|
||||||
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
|
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.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
@ -43,22 +43,22 @@ var spine;
|
|||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
this.toLoad++;
|
this.toLoad++;
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = path;
|
|
||||||
img.crossOrigin = "anonymous";
|
img.crossOrigin = "anonymous";
|
||||||
|
img.src = path;
|
||||||
img.onload = function (ev) {
|
img.onload = function (ev) {
|
||||||
if (success)
|
|
||||||
success(path, img);
|
|
||||||
var texture = _this.textureLoader(img);
|
var texture = _this.textureLoader(img);
|
||||||
_this.assets[path] = texture;
|
_this.assets[path] = texture;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (success)
|
||||||
|
success(path, img);
|
||||||
};
|
};
|
||||||
img.onerror = function (ev) {
|
img.onerror = function (ev) {
|
||||||
if (error)
|
|
||||||
error(path, "Couldn't load image " + path);
|
|
||||||
_this.errors[path] = "Couldn't load image " + path;
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (error)
|
||||||
|
error(path, "Couldn't load image " + path);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
AssetManager.prototype.get = function (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 () {
|
request.onreadystatechange = function () {
|
||||||
if (request.readyState == XMLHttpRequest.DONE) {
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
if (request.status >= 200 && request.status < 300) {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
|
_this.assets[path] = request.responseText;
|
||||||
if (success)
|
if (success)
|
||||||
success(path, request.responseText);
|
success(path, request.responseText);
|
||||||
_this.assets[path] = request.responseText;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
|
||||||
if (error)
|
if (error)
|
||||||
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
|
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.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
@ -1666,22 +1666,22 @@ var spine;
|
|||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
this.toLoad++;
|
this.toLoad++;
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = path;
|
|
||||||
img.crossOrigin = "anonymous";
|
img.crossOrigin = "anonymous";
|
||||||
|
img.src = path;
|
||||||
img.onload = function (ev) {
|
img.onload = function (ev) {
|
||||||
if (success)
|
|
||||||
success(path, img);
|
|
||||||
var texture = _this.textureLoader(img);
|
var texture = _this.textureLoader(img);
|
||||||
_this.assets[path] = texture;
|
_this.assets[path] = texture;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (success)
|
||||||
|
success(path, img);
|
||||||
};
|
};
|
||||||
img.onerror = function (ev) {
|
img.onerror = function (ev) {
|
||||||
if (error)
|
|
||||||
error(path, "Couldn't load image " + path);
|
|
||||||
_this.errors[path] = "Couldn't load image " + path;
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (error)
|
||||||
|
error(path, "Couldn't load image " + path);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
AssetManager.prototype.get = function (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 () {
|
request.onreadystatechange = function () {
|
||||||
if (request.readyState == XMLHttpRequest.DONE) {
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
if (request.status >= 200 && request.status < 300) {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
|
_this.assets[path] = request.responseText;
|
||||||
if (success)
|
if (success)
|
||||||
success(path, request.responseText);
|
success(path, request.responseText);
|
||||||
_this.assets[path] = request.responseText;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
|
||||||
if (error)
|
if (error)
|
||||||
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
|
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.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
@ -1666,22 +1666,22 @@ var spine;
|
|||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
this.toLoad++;
|
this.toLoad++;
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = path;
|
|
||||||
img.crossOrigin = "anonymous";
|
img.crossOrigin = "anonymous";
|
||||||
|
img.src = path;
|
||||||
img.onload = function (ev) {
|
img.onload = function (ev) {
|
||||||
if (success)
|
|
||||||
success(path, img);
|
|
||||||
var texture = _this.textureLoader(img);
|
var texture = _this.textureLoader(img);
|
||||||
_this.assets[path] = texture;
|
_this.assets[path] = texture;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (success)
|
||||||
|
success(path, img);
|
||||||
};
|
};
|
||||||
img.onerror = function (ev) {
|
img.onerror = function (ev) {
|
||||||
if (error)
|
|
||||||
error(path, "Couldn't load image " + path);
|
|
||||||
_this.errors[path] = "Couldn't load image " + path;
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (error)
|
||||||
|
error(path, "Couldn't load image " + path);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
AssetManager.prototype.get = function (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 () {
|
request.onreadystatechange = function () {
|
||||||
if (request.readyState == XMLHttpRequest.DONE) {
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
if (request.status >= 200 && request.status < 300) {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
|
_this.assets[path] = request.responseText;
|
||||||
if (success)
|
if (success)
|
||||||
success(path, request.responseText);
|
success(path, request.responseText);
|
||||||
_this.assets[path] = request.responseText;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
|
||||||
if (error)
|
if (error)
|
||||||
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
|
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.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
@ -1666,22 +1666,22 @@ var spine;
|
|||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
this.toLoad++;
|
this.toLoad++;
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = path;
|
|
||||||
img.crossOrigin = "anonymous";
|
img.crossOrigin = "anonymous";
|
||||||
|
img.src = path;
|
||||||
img.onload = function (ev) {
|
img.onload = function (ev) {
|
||||||
if (success)
|
|
||||||
success(path, img);
|
|
||||||
var texture = _this.textureLoader(img);
|
var texture = _this.textureLoader(img);
|
||||||
_this.assets[path] = texture;
|
_this.assets[path] = texture;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (success)
|
||||||
|
success(path, img);
|
||||||
};
|
};
|
||||||
img.onerror = function (ev) {
|
img.onerror = function (ev) {
|
||||||
if (error)
|
|
||||||
error(path, "Couldn't load image " + path);
|
|
||||||
_this.errors[path] = "Couldn't load image " + path;
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (error)
|
||||||
|
error(path, "Couldn't load image " + path);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
AssetManager.prototype.get = function (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 () {
|
request.onreadystatechange = function () {
|
||||||
if (request.readyState == XMLHttpRequest.DONE) {
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
if (request.status >= 200 && request.status < 300) {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
|
_this.assets[path] = request.responseText;
|
||||||
if (success)
|
if (success)
|
||||||
success(path, request.responseText);
|
success(path, request.responseText);
|
||||||
_this.assets[path] = request.responseText;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
|
||||||
if (error)
|
if (error)
|
||||||
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
|
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.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
@ -1666,22 +1666,22 @@ var spine;
|
|||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
this.toLoad++;
|
this.toLoad++;
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = path;
|
|
||||||
img.crossOrigin = "anonymous";
|
img.crossOrigin = "anonymous";
|
||||||
|
img.src = path;
|
||||||
img.onload = function (ev) {
|
img.onload = function (ev) {
|
||||||
if (success)
|
|
||||||
success(path, img);
|
|
||||||
var texture = _this.textureLoader(img);
|
var texture = _this.textureLoader(img);
|
||||||
_this.assets[path] = texture;
|
_this.assets[path] = texture;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (success)
|
||||||
|
success(path, img);
|
||||||
};
|
};
|
||||||
img.onerror = function (ev) {
|
img.onerror = function (ev) {
|
||||||
if (error)
|
|
||||||
error(path, "Couldn't load image " + path);
|
|
||||||
_this.errors[path] = "Couldn't load image " + path;
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
_this.toLoad--;
|
_this.toLoad--;
|
||||||
_this.loaded++;
|
_this.loaded++;
|
||||||
|
if (error)
|
||||||
|
error(path, "Couldn't load image " + path);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
AssetManager.prototype.get = function (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 = () => {
|
request.onreadystatechange = () => {
|
||||||
if (request.readyState == XMLHttpRequest.DONE) {
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
if (request.status >= 200 && request.status < 300) {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
if (success) success(path, request.responseText);
|
|
||||||
this.assets[path] = request.responseText;
|
this.assets[path] = request.responseText;
|
||||||
|
if (success) success(path, request.responseText);
|
||||||
} else {
|
} 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}`;
|
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.toLoad--;
|
||||||
this.loaded++;
|
this.loaded++;
|
||||||
@ -73,20 +73,20 @@ module spine {
|
|||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
this.toLoad++;
|
this.toLoad++;
|
||||||
let img = new Image();
|
let img = new Image();
|
||||||
img.src = path;
|
|
||||||
img.crossOrigin = "anonymous";
|
img.crossOrigin = "anonymous";
|
||||||
|
img.src = path;
|
||||||
img.onload = (ev) => {
|
img.onload = (ev) => {
|
||||||
if (success) success(path, img);
|
|
||||||
let texture = this.textureLoader(img);
|
let texture = this.textureLoader(img);
|
||||||
this.assets[path] = texture;
|
this.assets[path] = texture;
|
||||||
this.toLoad--;
|
this.toLoad--;
|
||||||
this.loaded++;
|
this.loaded++;
|
||||||
|
if (success) success(path, img);
|
||||||
}
|
}
|
||||||
img.onerror = (ev) => {
|
img.onerror = (ev) => {
|
||||||
if (error) error(path, `Couldn't load image ${path}`);
|
|
||||||
this.errors[path] = `Couldn't load image ${path}`;
|
this.errors[path] = `Couldn't load image ${path}`;
|
||||||
this.toLoad--;
|
this.toLoad--;
|
||||||
this.loaded++;
|
this.loaded++;
|
||||||
|
if (error) error(path, `Couldn't load image ${path}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user