Using Screens

I realize that this is a pretty basic question, but could someone help me out. I have some code working that has multiple screens that are stacked on top of one another, but cannot seem to remove them on a button press. I would be happy if I could get a button to delete the group that it is in. From there I could make it take out the complete screen.

–Here is a piece of my current code that has been simplified to illustrate what I am doing

– The Buttons Function
local MainMenuReturnF = function()
Backbtn = OptionsGroup.Backbtn
Backbtn.parent:remove( Backbtn )
OptionsGroup.Backbtn = nil
end

– The Button
Backbtn = ui.newButton{default=“ButtonNormal.png”, rollover=“ButtonPressed.png”, onRelease=MainMenuReturnF , x = 300, y = 240}
[import]uid: 4871 topic_id: 522 reply_id: 300522[/import]

you want to remove the screen or just move it out of the stacking order?

you can always set its visibility to false.

c [import]uid: 24 topic_id: 522 reply_id: 1020[/import]

I currently have everything set up so that when I button is pressed the contents of the next screen are created and displayed above the current screen. I wanted to remove the previous screen so that I am not allowing the user to stack multiple screens on top of each other and was wanting to know what the most effective way of doing this would be. Simply hiding the unused screens seems like it would allow them to stack on top of one another and use up a great deal of memory if there where many graphical elements. Should I be creating everything at the beginning and use the buttons to hide and reveal these graphics or was my assumption about the need to remove them wrong? [import]uid: 4871 topic_id: 522 reply_id: 1040[/import]

i have created all groups at once but there is a hit on startup if there are a lot of items.

then i did them on demand, when a user hits a button load the images into a group, and delete the the previous group.

one way to do so is by calling or creating a function like such

function removeScreen(screen)
screen.parent:remove(screen);
end
Hope this works

Carlos

[import]uid: 24 topic_id: 522 reply_id: 1047[/import]