Skip to content

Commit 0d8d514

Browse files
authored
Merge pull request #3527 from pandamicro/develop
Use arraybuffer responseType in BinaryLoader
2 parents 2fe97d5 + 926dc6b commit 0d8d514

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: cocos2d/core/utils/BinaryLoader.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ cc.loader.loadBinary = function (url, cb) {
3737
var xhr = this.getXMLHttpRequest(),
3838
errInfo = "load " + url + " failed!";
3939
xhr.open("GET", url, true);
40+
xhr.responseType = 'arraybuffer';
4041
if (cc.loader.loadBinary._IEFilter) {
4142
// IE-specific logic here
4243
xhr.setRequestHeader("Accept-Charset", "x-user-defined");
@@ -49,7 +50,7 @@ cc.loader.loadBinary = function (url, cb) {
4950
} else {
5051
if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=x-user-defined");
5152
xhr.onload = function () {
52-
xhr.readyState === 4 && xhr.status === 200 ? cb(null, self._str2Uint8Array(xhr.responseText)) : cb(errInfo);
53+
xhr.readyState === 4 && xhr.status === 200 ? cb(null, xhr.response) : cb(errInfo);
5354
};
5455
}
5556
xhr.send(null);
@@ -80,6 +81,7 @@ cc.loader.loadBinarySync = function (url) {
8081
req.timeout = 0;
8182
var errInfo = "load " + url + " failed!";
8283
req.open('GET', url, false);
84+
req.responseType = 'arraybuffer';
8385
var arrayInfo = null;
8486
if (cc.loader.loadBinary._IEFilter) {
8587
req.setRequestHeader("Accept-Charset", "x-user-defined");
@@ -102,7 +104,7 @@ cc.loader.loadBinarySync = function (url) {
102104
return null;
103105
}
104106

105-
arrayInfo = this._str2Uint8Array(req.responseText);
107+
arrayInfo = req.response;
106108
}
107109
return arrayInfo;
108110
};
@@ -151,4 +153,4 @@ if (cc.loader.loadBinary._IEFilter) {
151153
return byteMapping[match];
152154
}) + lastChr;
153155
};
154-
}
156+
}

0 commit comments

Comments
 (0)