remote listeners & groups/objects from a parent - is there a function?

Has someone a function that reliably would remove all groups/display objects/listeners from a parent object/display object?

I had been using this to clean groups. I’ve had some funny behaviour that looks like listeners being left around, so looking at this method I assume it is flawed in that it does not remove listeners (I don’t think the removeSelf() function removes listeners does it?)

function cleanGroups ( objectOrGroup )  
 if objectOrGroup.numChildren then  
 while objectOrGroup.numChildren \> 0 do  
 cleanGroups ( objectOrGroup[objectOrGroup.numChildren])  
 end  
 end  
  
 objectOrGroup:removeSelf()  
 objectOrGroup = nil  
  
 return  
end  

EDIT: After reading the following link I’m still a little confused re whether removeSelf() should remove listeners also. It seems yes. I guess my question still would be, does the code I posted above reliably have the effect of removing all objects & listeners? (e.g. touch listeners attached to display objects that are children under the parent - the parent would have groups and display objects under it therefore)

http://developer.anscamobile.com/forum/2011/03/06/remove-all-objects?page=1&destination= [import]uid: 140210 topic_id: 26894 reply_id: 326894[/import]

Unless it’s changed, you have to manually remove the listeners. Syntax is same but replace “add” with “remove”.
Ex.

add --> Runtime:addEventListener( “system”, onSystemEvent )

remove --> Runtime:removeEventListener( “system”, onSystemEvent )

[import]uid: 40033 topic_id: 26894 reply_id: 109157[/import]

thanks - understand how to manually do it, but was keen for the automated approach

I note a Corona Staff member at this point http://developer.anscamobile.com/forum/2011/03/06/remove-all-objects#comment-29108 did actually state:


Also, based on the underlining “removeSelf” code, any object listeners associated with the objects in the group, should be removed by the Lua garbage collection since the objects themselves are removed. This means there should be no need to object:removeEventListener for objects in the group. Any global event listeners (Runtime:AddEventListener) will still need to be removed manually.

So I’m assuming the code I posted in the original post should be sound?

For my case I have display object listeners in mind (not Runtime ones), but I didn’t point this out sorry. So want’ed something to remove all the objects/groups and the listeners associated with them.
[import]uid: 140210 topic_id: 26894 reply_id: 109159[/import]