Passing parameters to an EventListener

Hi,
I have several different objects that are connected to the same EventListener for “tap”. How do I know which one was tapped? If their is now ways of finding out which was tapped, is their a way to pass parameters to the event?

Thank you in advance. [import]uid: 97768 topic_id: 17657 reply_id: 317657[/import]

you can make one function and make sure every object has theirs .name like this:

[lua]local obj1 = display.newRect(0,0,50,50)
obj1.name = “obj1”

local function foo(self,event)
if event.phase == “ended” then
print(self.name)
end

obj1.touch = foo
obj1:addEventListener(“touch”, obj)[/lua] [import]uid: 16142 topic_id: 17657 reply_id: 67179[/import]

Have a look at the DragMeMultitouch sample code. This clearly shows how multiple objects are handled by a single event listener.

-David
[import]uid: 96411 topic_id: 17657 reply_id: 67189[/import]

Thank you to both of you. What is the difference between “self” and “event.target” ? [import]uid: 97768 topic_id: 17657 reply_id: 67487[/import]

You can use either. I tend not to use self as a parameter and use event.what-ever-property

-David
[import]uid: 96411 topic_id: 17657 reply_id: 67814[/import]