Hi,
I would like to know how is the display object removed when its parent group is removed.
Are there any calls made to it?
I would like to inject some of my code into the process, so that I can call some additional stuff when object is removed.
I’ve tried using metatables to hijack function calls, but it seems nothing is called on the object 
Here’s my sample code:
[lua]local function proxy(object)
local proxy = { }
proxy._class = object._class
proxy._proxy = object._proxy
proxy.raw = object
– Define metatable
local metatable = {
__index = function ( t, key )
print(“call to” … tostring(key))
if key == “raw” then
return object
end
if type(object[key]) == ‘function’ then
if key == “removeSelf” and object.__removeMe then
object.__removeMe()
end
return function(…) arg[1] = object; objectkey end
else
return object[key]
end
end,
__newindex = function ( t, key, value )
object[key] = value
end
}
setmetatable ( proxy, metatable )
return proxy
end
local function tst()
print(“test”)
end
local grp = display.newGroup()
local secondGrp = display.newGroup()
secondGrp = proxy(secondGrp)
secondGrp.__removeMe = tst
grp:insert(secondGrp)
print(“second group”)
secondGrp:removeSelf()
local thirdGroup = display.newGroup()
thirdGroup = proxy(thirdGroup)
thirdGroup.__removeMe = tst
print(“third group”)
grp:removeSelf()[/lua]
when you run it, you’ll see that when :removeSelf() is called my custom function will be called, but when I remove the parent group, nothing happens on the object [__index is not called]. [import]uid: 109453 topic_id: 34611 reply_id: 334611[/import]