removing an event listener

I am trying to remove an event listener but it doesn’t appear to be removing.

I add it as follows:

  
Runtime:addEventListener( "enterFrame", moveBallObjects )  
  

And inside a local function if a conditional is met I remove it as follows:

  
Runtime:removeEventListener( "enterFrame", moveBallObjects )  
  

I have put a print statement in the moveBallObjects function to check if it is still being called after I remove the event listener and unfortunately it is.

Guess I am doing something wrong?

Any help appreciated.

Thanks

Paul

[import]uid: 7863 topic_id: 2539 reply_id: 302539[/import]

Is the function moveBallObjects located AFTER the remove line and is it declared there as local? If yes, then predeclare it before the remove line.

I am removing eventlistener without a problem in my game. [import]uid: 5712 topic_id: 2539 reply_id: 7318[/import]

Thanks Mike
When you say predeclare it do you mean just move it or is there a way to predeclare a function but leave it after?

Thanks
Paul [import]uid: 7863 topic_id: 2539 reply_id: 7320[/import]