Not sure if there is a way to stop propagation inside an event handler.
In the code below I create a box and add a event listener. Then inside the listener
I create another box at the same position add an event listener to it.
What is crazy is that after the first box is deleted it event gets propagated to
an object that did not even exist when the event began.
function makeBox(name)
local box = display.newRect(50,50,50,50)
box.name=name
boxCount = boxCount + 1
return box
end
local box1 = makeBox(“box1”)
local box2
function box1EventFunc(event)
print(event.target.name, event.phase)
box1:removeEventListener(“touch”, box1EventFunc)
box1:removeSelf()
box2 = makeBox(“box2”)
box2:addEventListener(“touch”, function(event) print(“box2”, event.phase) end)
return true
end
box1:addEventListener(“touch”, box1EventFunc)