cleanGroups() method stopped working correctly in recent Corona builds

Hi guys,

I know cleanGroups has been removed in the most recent Director, but I still use it and find it very handy. The method not only removed objects from the group, but did some extra work, like removing any assigned touch listeners. I also extended it to look if display object has a clean() method and if so, call it first before removing the object.

But now all properties are nil , where they used to have assigned values.
Here is what I mean:

[lua]local isDisplayObject = function(aDisplayObject)
return (type(aDisplayObject) == “table” and getmetatable(aDisplayObject) == coronaMetaTable)
end

local function cleanGroups ( objectOrGroup, level )
if (not isDisplayObject(objectOrGroup)) then return end

if objectOrGroup.numChildren then
while objectOrGroup.numChildren > 0 do
cleanGroups ( objectOrGroup[objectOrGroup.numChildren], level + 1 )
end
end

if level > 0 then

– check if object/group has an attached touch listener
if objectOrGroup.touch then
objectOrGroup:removeEventListener( “touch”, objectOrGroup )
objectOrGroup.touch = nil
end

print(“OBJECT:”, objectOrGroup) – prints “table: xxxxxxxx”
print(“OBJECT TYPE:”, type(objectOrGroup[“clean”])) – prints “nil”, used to be “function”

if type(objectOrGroup[“clean”]) == “function” then
objectOrGroup:clean() – never gets called now
end

objectOrGroup:removeSelf()
end
end[/lua]

Any idea what happened and why this stopped working? [import]uid: 52103 topic_id: 16494 reply_id: 316494[/import]

Hmm… for some reason replacing

if level \> 0 then

with

if level \>= 0 then

worked! In older builds of Corona level \> 0 was enough. [import]uid: 52103 topic_id: 16494 reply_id: 61853[/import]