Chris,
Have you found an answer? I am trying to do the same thing, and so far what I have read about events and dispatchEvent does not make sense to me.
For example, the below code is how I understand you should dispatch events between objects, but in this way the one that is dispatching the event (last line) must know the object it dispatches to, which makes it pointless.
I also prefer to avoid contaminating global space.
[lua]-- main.lua
display.setStatusBar(display.HiddenStatusBar)
print “\n\n\n\n\n\n\n------------------”
local Smurf = {}
Smurf.new = function()
local self = display.newRect( 0,0,100,100 )
self:addEventListener( “tickle”, self )
function self:tickle(e) print “I was tickled” end
return self
end
smurf = Smurf.new()
smurf:dispatchEvent( {name=“tickle”} )
– smurf:dispatchEvent( {name=“tickle”, target=smurf} ) – this is the full syntax, not sure why we have this target here[/lua]
Edit:
Also there is this piece of code that I intend to try, maybe it will be of help
http://developer.anscamobile.com/code/easy-event-handling-your-classes-tables [import]uid: 145050 topic_id: 18572 reply_id: 109172[/import]