A Listener to many buttons

Hi Guys,

Just a quick logical question.

I have a listener object, and I have around 4 buttons on the stage. I add this same listener object to each of the 4 buttons.

Now when I get an onRelease event, how do I know which button it came from?

Thanks!

If you mean Button components, then use the event object passed to the function:

b0.addEventListener("click", this);
b1.addEventListener("click", this);
b2.addEventListener("click", this);
b3.addEventListener("click", this);
this.click = function(evtObj:Object):Void  {
 trace(evtObj.target);
};

:disco:

wow , thanks !!

If I use a button symbol, I can’t do this , right? It must be a button component?

By default you can’t but if you wanted to you could rig something up - although it really isn’t necessary :beam: