Except for adding event listeners (i.e. onComplete’s for transition.to’s, the function for timers, etc.) you can use an anonymous function sometimes called a Closure to do so:
timer.performWithDelay(1000, function() printK( event, k ); end)
But because you may want to remove the event listener later, you have to pass the same function address to removeEventListener that you do to addEventListener so this concept of anonymous function won’t work.
Instead you have to pre-define a wrapper function:
local function SendK( event )
printK( event, k )
end
myImage:addEventListener( “touch”, SendK )
But ask yourself when someone touches an object, where is the value “k” coming from? A touch normally doesn’t generate this sort of thing. The usual way of doing this is to make sure myImage knows about k by adding it as an attribute:
myImage.k = k
Then in your touch handler, event.target.k will have the value of k.
Rob