Passing a parameter from an event listener to a function. HELP!

I needed the same and I came up with code like this:

[lua]

     local handleTouch = function(event,fragmentId)

         if(event.phase == “ended”) then

            print(fragmentId);

         end

     end

     –

     local handleTouchGenerator = function(fragmentId)

         return function(event)

             handleTouch(event,fragmentId)

         end

     end

     – add evetns

     piece.fragments[1]:addEventListener(“touch”,handleTouchGenerator(1))

     piece.fragments[2]:addEventListener(“touch”,handleTouchGenerator(2))

[/lua]

Thanks, you solved my problem here

http://forums.coronalabs.com/topic/56394-hundreds-of-dynamic-images-with-one-tap-listener-how-to-get-tagged-data/?p=291786

Thanks, you solved my problem here

http://forums.coronalabs.com/topic/56394-hundreds-of-dynamic-images-with-one-tap-listener-how-to-get-tagged-data/?p=291786