removeEventListener problems

Hi there,

My RPG game has lot of menus during combat and while at the beginning I didn’t have problems, now the game has become more complex, and I’m having lots of trouble managing button listeners.

It seems that attempting to remove a listener from a object that has no listener attached will cause an error. Also, it seems it’s possible to add a identical listener to an object several times (I had a few errors that were caused by functions being triggered twice or more, took me a lot of time to figure that it was the listener’s fault).

So basically my questions are:

is there a way to ask if a object has listeners attached?
is there a way to clear all listeners from a object? (without destroying the object)

any help or suggestions are welcome. [import]uid: 136402 topic_id: 36298 reply_id: 336298[/import]

If you have alot of buttons on screen have you thought of using a single touch listener (on Runtime) and having a .id handle for each button.

[code]
button1.id = “button1”
button2.id = “button2”

local function touchIt(e)
if e.phase == “began” then
local button = e.target.id
if button == “button1” then
–touched button 1
elseif button == “button2” then
–touched button 2
end
end
end

Runtime:addEventListener(“touch”, touchIt)
[/code] [import]uid: 40731 topic_id: 36298 reply_id: 144207[/import]

If you have alot of buttons on screen have you thought of using a single touch listener (on Runtime) and having a .id handle for each button.

[code]
button1.id = “button1”
button2.id = “button2”

local function touchIt(e)
if e.phase == “began” then
local button = e.target.id
if button == “button1” then
–touched button 1
elseif button == “button2” then
–touched button 2
end
end
end

Runtime:addEventListener(“touch”, touchIt)
[/code] [import]uid: 40731 topic_id: 36298 reply_id: 144207[/import]

If you have alot of buttons on screen have you thought of using a single touch listener (on Runtime) and having a .id handle for each button.

[code]
button1.id = “button1”
button2.id = “button2”

local function touchIt(e)
if e.phase == “began” then
local button = e.target.id
if button == “button1” then
–touched button 1
elseif button == “button2” then
–touched button 2
end
end
end

Runtime:addEventListener(“touch”, touchIt)
[/code] [import]uid: 40731 topic_id: 36298 reply_id: 144207[/import]

If you have alot of buttons on screen have you thought of using a single touch listener (on Runtime) and having a .id handle for each button.

[code]
button1.id = “button1”
button2.id = “button2”

local function touchIt(e)
if e.phase == “began” then
local button = e.target.id
if button == “button1” then
–touched button 1
elseif button == “button2” then
–touched button 2
end
end
end

Runtime:addEventListener(“touch”, touchIt)
[/code] [import]uid: 40731 topic_id: 36298 reply_id: 144207[/import]