can't hide main scene for second scene to appear

You have to manually remove them in scene:hide()

Agree with Rob , as text field are native component , we need to handle them manually.

You can use removeSelf( ) , to do so .

-Assif

local composer = require( "composer" ) local scene = composer.newScene() local widget = require ("widget") -- ----------------------------------------------------------------------------------- -- Code outside of the scene event functions below will only be executed ONCE unless -- the scene is removed entirely (not recycled) via "composer.removeScene()" -- ----------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------- -- Scene event functions -- ----------------------------------------------------------------------------------- -- create() function scene:create( event ) local sceneGroup = self.view -- Code here runs when the scene is first created but has not yet appeared on screen local firstname = display.newText("FIRST NAME:",50,50,native.systemFont,14) firstname:setFillColor(1,1,1) sceneGroup:insert(firstname) local firstnamebox = native.newTextField(240,50,170,20) firstnamebox.size = 14 local lastname = display.newText("LAST NAME:",50,85,native.systemFont,14) lastname:setFillColor(1,1,1) sceneGroup:insert(lastname) local lastnamebox = native.newTextField(240,85,170,20) lastnamebox.sie= 14 local username1 = display.newText("USERNAME:",50,120, native.systemFont,14) username1:setFillColor(1,1,1) sceneGroup:insert(username1) local usernamebox1 = native.newTextField(240,120,170,20) usernamebox1.size = 14 local password1 = display.newText("PASSWORD:",50,155,native.systemFont,14) password1:setFillColor(1,1,1) sceneGroup:insert(password1) local passwordbox1 = native.newTextField(240,155,170,20) passwordbox1.size = 14 local repassword = display.newText("RETYPE PASSWORD:",80,190,native.systemFont,14) repassword:setFillColor(1,1,1) sceneGroup:insert(repassword) local repasswordbox = native.newTextField(240,190,170,20) repasswordbox.size = 14 local email = display.newText("E-MAIL:",30,225,native.systemFont,14) email:setFillColor(1,1,1) sceneGroup:insert(email) local emailbox = native.newTextField(240,225,170,20) emailbox.size = 14 local dob = display.newText("DATE OF BIRTH:",60,260,native.systemFont,14) dob:setFillColor(1,1,1) sceneGroup:insert(dob) local dobbox = native.newTextField(240,260,170,20) dobbox.size = 14 local gender = display.newText("GENDER:",40,310,native.systemFont,14) gender:setFillColor(1,1,1) sceneGroup:insert(gender) local male = display.newText("MALE:",120,310,native.systemFont,14) male:setFillColor(1,1,1) sceneGroup:insert(male) local female = display.newText("FEMALE:",230,310,native.systemFont,14) female:setFillColor(1,1,1) sceneGroup:insert(female) local function onSwitchPress(event) local switch = event.target print("switch with ID'"..switch.id.."'is on: " ..tostring(switch.isOn)) end local male = widget.newSwitch( { left = 150, top = 295, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) sceneGroup:insert(male) local female = widget.newSwitch( { left = 270, top = 295, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) sceneGroup:insert(female) end local nextpag = widget.newButton( { left = -20, top = 450, id = "nextpag", label = "NEXT", onEvent = handleButtonEvent } ) function nextpag:touch(event) if (event.phase == "ended") then composer.removeScene("regform1",true) composer.gotoScene("regform2",{effect = "fade",time = 200}) end return true; end local cancel = widget.newButton( { left = 150, top = 450, id = "cancel", label = "CANCEL", onEvent = handleButtonEvent } ) function cancel:touch(event) if (event.phase == "ended") then composer.removeScene("regform1",true) composer.gotoScene("mpage",{effect = "fade",time = 200}) end return true; end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) firstnamebox:removeSelf() firstnamebox = nil lastnamebox:removeSelfF() lastnamebox = nil usernamebox1:removeSelf() usernamebox1 = nil passwordbox1:removeSelf() passwordbox1 = nil repasswordbox:removeSelf() repasswordbox = nil emailbox:removeSelf() emailbox = nil dobbox:removeSelf() dobbox = nil elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene

this is what i tried doing but it’s giving me error now which says "regform1.lua:171:attempt to index global ‘firstnamebox’(a nil value)

You have a “scope” issue. You declared them “local” inside of scene:create(). They are only visible to that function and it’s children. You need to take the “local” off in scene:create() and at the top of the scene just declare them:

local firstnamebox

local repasswordbox

etc.

Then they will be visible module wide.

Rob

local widget = require ("widget") local composer = require( "composer" ) local scene = composer.newScene() -- ----------------------------------------------------------------------------------- -- Code outside of the scene event functions below will only be executed ONCE unless -- the scene is removed entirely (not recycled) via "composer.removeScene()" -- ----------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------- -- Scene event functions -- ----------------------------------------------------------------------------------- -- create() function scene:create( event ) local sceneGroup = self.view -- Code here runs when the scene is first created but has not yet appeared on screen local mnumber = display.newText("MOBILE NUMBER:",80,100,native.systemFont,16) mnumber:setFillColor(1,1,1) sceneGroup:insert(mnumber) mnumberbox1 = native.newTextField(240,100,170,30) mnumberbox1.size = 16 local function onSwitchPress(event) local switch = event.target print("switch with ID'"..switch.id.."'is on: " ..tostring(switch.isOn)) end local mtn = widget.newSwitch( { left = 130, top = 170, style = "checkbox", id = "mtn", onPress = onSwitchPress } ) sceneGroup:insert(mtn) local voda = widget.newSwitch( { left = 285, top = 170, style = "checkbox", id = "voda", onPress = onSwitchPress } ) sceneGroup:insert(voda) local tigo = widget.newSwitch( { left = 130, top = 225, style = "checkbox", id = "tigo", onPress = onSwitchPress } ) sceneGroup:insert(tigo) local airtel = widget.newSwitch( { left = 285, top = 225, style = "checkbox", id = "airtel", onPress = onSwitchPress } ) sceneGroup:insert(airtel) local mtn = display.newText("MTN:", 100,190,native.systemFont,16) sceneGroup:insert(mtn) local vodafone = display.newText("VODAFONE:", 235,190,native.systemFont,16) sceneGroup:insert(vodafone) local tigo = display.newText("TIGO:", 100,245,native.systemFont,16) sceneGroup:insert(tigo) local airtel = display.newText("AIRTEL:",235,245) sceneGroup:insert(airtel) local pincode = display.newText("PINCODE:",65,320,native.systemFont,16) sceneGroup:insert(pincode) pincodebox = native.newTextField(240,320,100,30) pincodebox.size = 14 local nextreg = widget.newButton( { left = -20, top = 450, id = "nextreg", label = "NEXT", onEvent = handleButtonEvent } ) sceneGroup:insert(nextreg) function nextreg:touch(event) if (event.phase == "ended") then composer.removeScene("regform2",true) composer.gotoScene("regform3",{effect = "fade",time = 200}) end return true; end nextreg:addEventListener("touch",nextreg); local cancelform = widget.newButton( { left = 150, top = 450, id = "cancelform", label = "CANCEL", onEvent = handleButtonEvent } ) sceneGroup:insert(cancelform) function cancelform:touch(event) if (event.phase == "ended") then composer.removeScene("regform2",true) composer.gotoScene("login",{effect = "fade",time = 200}) end return true; end end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen mnumberbox1:removeSelf() mnumberbox1 = nil pincodebox:removeSelf() pincodebox = nil end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene

local widget = require ("widget") local composer = require( "composer" ) local scene = composer.newScene() -- ----------------------------------------------------------------------------------- -- Code outside of the scene event functions below will only be executed ONCE unless -- the scene is removed entirely (not recycled) via "composer.removeScene()" -- ----------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------- -- Scene event functions -- ---------------------------------------------------------------------------------- -- create() function scene:create( event ) local sceneGroup = self.view -- Code here runs when the scene is first created but has not yet appeared on screen local acctname = display.newText("ACCOUNT NAME:",75,30,native.systemFont,16) sceneGroup:insert(acctname) acctnamebox = native.newTextField(250,30,130,30) acctnamebox.size = 14 local accntnum = display.newText("ACCOUNT NUMBER:",85,90,native.systemFont,16) sceneGroup:insert(accntnum) accntnumbox = native.newTextField(250,90,130,30) accntnumbox.size = 14 local bname = display.newText("BANK NAME:",55,140,native.systemFont,16) sceneGroup:insert(bname) bnamebox = native.newTextField(250,140,130,30) bnamebox.size = 14 local branch = display.newText("BRACH:",35,190,native.systemFont,16) sceneGroup:insert(branch) branchbox = native.newTextField(250,190,130,30) branchbox.size = 16 local signupform = widget.newButton( { left = -20, top = 450, id = "sigupform", label = "SIGNUP", onEvent = handleButtonEvent } ) sceneGroup:insert(signupform) function signupform:touch(event) if (event.phase == "ended") then composer.removeScene("regform3",true) composer.gotoScene("mpage",{effect = "fade",time = 200}) end return true; end local cancelreg = widget.newButton( { left = 150, top = 450, id = "cancelreg", label = "CANCEL", onEvent = handleButtonEvent } ) function cancelreg:touch(event) if (event.phase == "ended") then composer.removeScene("regform3",true) composer.gotoScene("login",{effect = "fade",time = 200}) end return true; end sceneGroup:insert(cancelreg) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) acctnamebox:removeSelf() acctnamebox = nil accntnumbox:removeSelf() accntnumbox = nil bnamebox:removeSelf() bnamebox = nil branchbox:removeSelf() branchbox = nil elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene

moving from scene 1 to 2 is smooth but cant sems to find why from scene 3 to scene 4 isnt the textboxes are cleared but the remaining won’t and if i start the scene from scene 3 to scene 4 it runs smooth without a hitch it sometimes give error when next is pressed 2 times pointing to scene.hide() but if i modified it in anyway the textboxes remain. have looked through the codes for days but dnt know why it is so