function popupGroup:cleanUp() -- popupGroup is a displayGroup with two objects within (a rectangle and an image).
popupGroup[1]:removeSelf()
popupGroup[1] = nil
popupGroup[2]:removeSelf()
popupGroup[2] = nil
popupGroup = nil
That sounds like it should either outright delete or at least nil out popupGroup. But am I correct in thinking that if any other code references it, it’s still there? say:
someButton:addEventListener("tap", PressPop)
I ask because in this event listener, the variable can only be nil once. Even if it says nil, it’s still not.
local PressPop = function(event)
if event.phase == began then
if myPopup ~= nil then
print("Removing the popup!")
myPopup:cleanUp()
end
end
end
^^ In that example, the if statement only works once. Run the cleanUp code, and myPopup ~= nil is still true, even though I explicitly tell it that myPopup = nil in the cleanUp code. print reveals an 8 digit table code.
(I was hoping to just say if myPopup == nil or if myPopup ~= nil.)
Is there a more reliable way to delete objects? Or, if not, is there a better way to detect whether a variable exists (and how to delete it?) Or do I basically have to give up on existance detection and use a variable to store whether there should or shouldn’t be a popup? [import]uid: 41884 topic_id: 15229 reply_id: 315229[/import]