Hello everyone,
I am unable to remove the checkboxes created on one scene while changing to the next.
I have isolated the area where the problem is occurring and am unable to figure out the problem.
Here is my code (my apologies for the length):
main.lua
display.setStatusBar( display.HiddenStatusBar ) local storyboard = require "storyboard" storyboard.gotoScene( "page1", "fade", 400)
page1.lua
local storyboard = require "storyboard" local scene = storyboard.newScene() local widget = require( "widget" ) local screen = display.newGroup() local checks = display.newGroup() --forcheckboxes local function menuClick( event ) if event.phase == "ended" then storyboard.gotoScene( "page2", "fade", 800 ) return true end end for i = 1 ,5,1 do checks[i] = widget.newSwitch { left = 60, -- coordinates of top left corner top = 100\*i, style = "checkbox", initialSwitchState = false } end screen:insert(checks) menu = widget.newButton{ label = "Page 2", onEvent = menuClick } screen:insert(menu) function scene:enterScene( event ) storyboard.removeAll() end function scene:exitScene( event ) screen:removeSelf() end scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) return scene
page2.lua
local storyboard = require "storyboard" local scene = storyboard.newScene() local widget = require( "widget" ) local screen = display.newGroup() local checks = display.newGroup() local function menuClick( event ) if event.phase == "ended" then storyboard.gotoScene( "page1", "fade", 800 ) return true end end menu = widget.newButton{ label = "Page 1", onEvent = menuClick } function scene:enterScene( event ) storyboard.removeScene( storyboard.getPrevious()) end function scene:exitScene( event ) screen:removeSelf() end scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) return scene
The checkboxes created in the loop are present only in page1. They are not removed when going to page2. I am new to Corona and my apologies if i am missing something obvious.
Thanks in advance.