Component.Event Handler question

Hi,

// Call Function
var eventHandler = new cc.Component.EventHandler();
eventHandler.target = newTarget;
eventHandler.component = “MainMenu”;
eventHandler.handler = “OnClick”
eventHandler.emit([“param1”, “param2”, …]);

If I have a node under canvas, example: hudgraphicnode, how can I target such node via the eventHandler.target = newTarget. I’m trying to target a node in the canvas, that has a component ( example.js ), which in turn has a handler / function ( examplefunction ).… Would appreciate any feedback / help…Thanks for your time and God Bless…

Sincerely,

Sunday

I’m not very sure about your requirement. In fact, the example.js you mentioned is a component. So, maybe what you want to do is like this:

// example.js

...
onLoad: function() {
    this.node.on(SOME_EVENT, callback);
    this.node.emit(SOME_EVENT, EVENT_DETAIL);
}
...

Hi @zhangbin

Thanks for the help…appreciated it…:slight_smile: God Bless…

Sincerely,

Sunday