From d4900493e2d133c6e53f34769d3b4db583fbe576 Mon Sep 17 00:00:00 2001 From: VisualSj Date: Wed, 22 Jul 2015 17:56:35 +0800 Subject: [PATCH] JS Studio parser (Modify callback method) --- .../studio/parsers/timelineParser-2.x.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index ff9d31ff1f..c8ab968f48 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -364,21 +364,16 @@ var bindCallback = function(widget, json){ var callBackType = json["CallBackType"]; var callBackName = json["CallBackName"]; + var callBack = function(e){ + if(typeof widget[callBackName] === "function") + widget[callBackName](e); + }; if(callBackType === "Click"){ - widget.addClickEventListener(function(){ - if(widget.onLocateClickCallback) - widget.onLocateClickCallback(callBackName); - }); + widget.addClickEventListener(callBack); }else if(callBackType === "Touch"){ - widget.addTouchEventListener(function(){ - if(widget.onLocateTouchCallback) - widget.onLocateTouchCallback(callBackName); - }); + widget.addTouchEventListener(callBack); }else if(callBackType === "Event"){ - widget.addCCSEventListener(function(){ - if(widget.onLocateEventCallback) - widget.onLocateEventCallback(callBackName); - }); + widget.addCCSEventListener(callBack); } };