detecting a touch event from inside an object

Hello everyone, i’m kinda new to corona and i’m checking the api but couldn’t find a way to add an event listener dynamically to a recently spawned object.

The problem is that i want to spawn a random number of rectangles and attach each of them and event that let me know which one was touched and register that in a table where i’ll have a reference to all the objects.

Maybe i’m looking this at the wrong way and should keep a reference of each coordinate of the rectangles and catch all the touches and depending of the startX and startY determine which one was interacted with, but i want to know if there’s a way to do it the first way. [import]uid: 118356 topic_id: 20823 reply_id: 320823[/import]

http://www.youtube.com/watch?v=6TsDdLY7VXk [import]uid: 33608 topic_id: 20823 reply_id: 81937[/import]

thanks, this seems what i was looking for. [import]uid: 118356 topic_id: 20823 reply_id: 81942[/import]