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]