From 1e5cfcad9fc0f73007cf285165964aeeb90d84ae Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 9 May 2018 10:31:56 +0800 Subject: [PATCH] Fix Color fromHEX typo (#2651) --- cocos2d/core/value-types/color.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/value-types/color.js b/cocos2d/core/value-types/color.js index d8ce6b701b..7024aa4066 100644 --- a/cocos2d/core/value-types/color.js +++ b/cocos2d/core/value-types/color.js @@ -383,10 +383,10 @@ var Color = (function () { */ proto.fromHEX = function (hexString) { hexString = (hexString.indexOf('#') === 0) ? hexString.substring(1) : hexString; - let r = parseInt(str.substr(0, 2), 16) || 0; - let g = parseInt(str.substr(2, 2), 16) || 0; - let b = parseInt(str.substr(4, 2), 16) || 0; - let a = parseInt(str.substr(6, 2), 16) || 255; + let r = parseInt(hexString.substr(0, 2), 16) || 0; + let g = parseInt(hexString.substr(2, 2), 16) || 0; + let b = parseInt(hexString.substr(4, 2), 16) || 0; + let a = parseInt(hexString.substr(6, 2), 16) || 255; this._val = ((a<<24) >>> 0) + (b<<16) + (g<<8) + r; return this; };