Remove Event Listener From Table

Hello, i am having a problem with removing a event listenr.

This is the error

Runtime error  
 /Users/gzijlstra/Desktop/App/First Project/game.lua:94: attempt to call method 'removeEventListener' (a nil value)  
stack traceback:  
 [C]: in function 'removeEventListener'  
 /Users/gzijlstra/Desktop/App/First Project/game.lua:94: in function 'gameover'  
  

This is the code i have to remove it:
[lua]for g=1,n do
name = spawn[g]
name:removeEventListener(“touch”, delete)
end[/lua]

Whats wrong?

Thanks Gjosse [import]uid: 120506 topic_id: 24022 reply_id: 324022[/import]

Would need to see more code to advise on this. [import]uid: 52491 topic_id: 24022 reply_id: 97048[/import]

Ok
This is the code to make a enity spawn:
[lua] function newenemy()

local n = 1
local random = math.random(1,800)
if(pausenum==0) then
spawn[n] = display.newImage(“media/pos.png”)

spawn[n].x= random/2;spawn[n].y= 40;

localGroup:insert(spawn[n]);

spawn[n]:addEventListener(“touch”, delete);

amount[n] = transition.to( spawn[n], { time=levelamount, y=player.y, x=_W/2})

n=n+1;

end
if(pausenum==0) then
pausethings[n] = timer.performWithDelay(1000, newenemy)
else
print(“paused”)
end
end

timer1 = timer.performWithDelay(1000, newenemy)
[/lua]

What other thing would you need?

And, i have a other problem but should i do that here or make a new post?

Thanks
Gjosse [import]uid: 120506 topic_id: 24022 reply_id: 97060[/import]

Misschien is het handig als je de hele context laat zien! [import]uid: 10863 topic_id: 24022 reply_id: 97061[/import]

For another unrelated issue a new thread is best.

For this - I’m guessing it may be the order of your code, however I would want to see it all together.

Could you post a plug and play example showing your error? If so I should be able to fix it for you. [import]uid: 52491 topic_id: 24022 reply_id: 97250[/import]

I’m having the same trouble.

Did you come up with a solution for removing an Eventlistener from a table ?

edit: I also just read an article from corona where it says that it automatically removes the eventlistener as soon as the object gets removed. so problem solved? [import]uid: 140000 topic_id: 24022 reply_id: 130793[/import]

I’m having the same trouble.

Did you come up with a solution for removing an Eventlistener from a table ?

edit: I also just read an article from corona where it says that it automatically removes the eventlistener as soon as the object gets removed. so problem solved? [import]uid: 140000 topic_id: 24022 reply_id: 130793[/import]