From 8d0a688a22c531657dc68f22ef41df82a463cdce Mon Sep 17 00:00:00 2001 From: linkqjlin Date: Wed, 6 Sep 2017 21:14:19 +0800 Subject: [PATCH] =?UTF-8?q?BinaryLoader=20=E8=AE=BE=E7=BD=AE=20xhr.respons?= =?UTF-8?q?eType=3D"arraybuffer"=EF=BC=8C=E4=BD=BF=E7=94=A8=20xhr.response?= =?UTF-8?q?=20=E5=93=8D=E5=BA=94=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos2d/core/utils/BinaryLoader.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/utils/BinaryLoader.js b/cocos2d/core/utils/BinaryLoader.js index 7127b1279c..01e5c6194b 100644 --- a/cocos2d/core/utils/BinaryLoader.js +++ b/cocos2d/core/utils/BinaryLoader.js @@ -37,6 +37,7 @@ cc.loader.loadBinary = function (url, cb) { var xhr = this.getXMLHttpRequest(), errInfo = "load " + url + " failed!"; xhr.open("GET", url, true); + xhr.responseType = 'arraybuffer'; if (cc.loader.loadBinary._IEFilter) { // IE-specific logic here xhr.setRequestHeader("Accept-Charset", "x-user-defined"); @@ -49,7 +50,7 @@ cc.loader.loadBinary = function (url, cb) { } else { if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=x-user-defined"); xhr.onload = function () { - xhr.readyState === 4 && xhr.status === 200 ? cb(null, self._str2Uint8Array(xhr.responseText)) : cb(errInfo); + xhr.readyState === 4 && xhr.status === 200 ? cb(null, xhr.response) : cb(errInfo); }; } xhr.send(null); @@ -80,6 +81,7 @@ cc.loader.loadBinarySync = function (url) { req.timeout = 0; var errInfo = "load " + url + " failed!"; req.open('GET', url, false); + req.responseType = 'arraybuffer'; var arrayInfo = null; if (cc.loader.loadBinary._IEFilter) { req.setRequestHeader("Accept-Charset", "x-user-defined"); @@ -102,7 +104,7 @@ cc.loader.loadBinarySync = function (url) { return null; } - arrayInfo = this._str2Uint8Array(req.responseText); + arrayInfo = req.response; } return arrayInfo; }; @@ -151,4 +153,4 @@ if (cc.loader.loadBinary._IEFilter) { return byteMapping[match]; }) + lastChr; }; -} \ No newline at end of file +}