Freeing a button

I’m trying to “free” a button, or remove its displayGroup.
Looking at Ui, I see no code for that, nor any code that seems to show how to hide it.
I try the typical myBtn.isVisible, the button does not hide. I’ve tried to nil it, no luck.
Looking at the code in ui, I should delete the displaygroup, and maybe remove the listener, but see no code for that either.

You help would be appreceated. [import]uid: 4656 topic_id: 635 reply_id: 300635[/import]

Here is tested code for a button that disappears after clicking it:

local btn = display.newImage("button.png")  
local group = display.newGroup()  
group:insert(btn)  
function tap()  
 btn.isVisible = false  
end  
btn:addEventListener("tap", tap)  

Alternatively you can remove the button from the group which will also make it invisible:

group:remove(btn) -- instead of btn.isVibible = false 

Arjan [import]uid: 4824 topic_id: 635 reply_id: 1260[/import]

Ok, understood, the code you gave. Just wondering if your saying not to use the ui.lua supplied.
Our apps tend to have several screens, so I can create buttons on the fly, and remove them when we switch screens (Less running memory),
or I can create a display group for each screen. My concern is if you have a app with a lot of screens, seems like the overhead/memory footprint
kills you.

So my preference is something that will work with ui.lua
[import]uid: 4656 topic_id: 635 reply_id: 1264[/import]

No, please, do use ui.lua. I wasn’t saying not to use it. I was just trying to answer your question about hiding buttons.
[import]uid: 4824 topic_id: 635 reply_id: 1275[/import]