can't hide main scene for second scene to appear

local widget = require ("widget") local composer = require( "composer" ) local scene = composer.newScene() local background = display.newImage("") local login local signup --hide keyboard function background:tap(event) native.setKeyboardFocus(nil) end background:addEventListener("tap", background) local login = widget.newButton({left = 0,top = 450,id = "login",label = "LOGIN",onEvent = handleButtonEvent}) function login:touch(event) if (event.phase == "ended") then composer.removeScene("main",true) composer.gotoScene("mainpage",{effect = "crossfade",time = 200}) end end login:addEventListener("touch",scene) local signup = widget.newButton({left = 150,top = 450,id = "signup",label = "SIGN UP",onEvent = handleButtonEvent}) function signup:touch(event) if (event.phase == "ended") then composer.removeScene("main",true) composer.gotoScene("registration1",{effect = "crossfade",time = 200}) end end signup:addEventListener("touch",signup) local username = display.newText("USERNAME",110,70, native.systemFont,18) username:setFillColor(1,1,1) local password = display.newText("PASSWORD",110,210, native.systemFont,18) password:setFillColor(1,1,1) --Textboxes local usernamebox = native.newTextField(160,120,220,40) usernamebox.size = 16 username:addEventListener("userinput", username) local passwordbox = native.newTextField(160,260,220,40) passwordbox.size = 16 local feedback = display.newText("",130,140,native.systemFont,14) function username:userinput(event) if (event.phase == "began") then event.target.text = "" feedback.text = "PLEASE ENTER YOUR USERNAME OR EMAIL ADDRESS" elseif (event.phase == "editing") then feedback.text = event.startPosition end end --creating scenes

local widget = require ("widget") local composer = require( "composer" ) local scene = composer.newScene() local background = display.newImage("") --hide keyboard function background:tap(event) native.setKeyboardFocus(nil) end background:addEventListener("tap", background) local firstname = display.newText("FIRST NAME:",50,0,native.systemFont,14) firstname:setFillColor(1,1,1) local firstnamebox = native.newTextField(240,0,170,20) firstnamebox.size = 14 local lastname = display.newText("LAST NAME:",50,35,native.systemFont,14) lastname:setFillColor(1,1,1) local lastnamebox = native.newTextField(240,35,170,20) lastnamebox.sie= 14 local username = display.newText("USERNAME:",50,70, native.systemFont,14) username:setFillColor(1,1,1) local usernamebox = native.newTextField(240,70,170,20) usernamebox.size = 14 local password = display.newText("PASSWORD:",50,105,native.systemFont,14) password:setFillColor(1,1,1) local passwordbox = native.newTextField(240,105,170,20) passwordbox.size = 14 local repassword = display.newText("RETYPE PASSWORD:",80,140,native.systemFont,14) repassword:setFillColor(1,1,1) local repassword = native.newTextField(240,140,170,20) repassword.size = 14 local email = display.newText("E-MAIL:",30,175,native.systemFont,14) email:setFillColor(1,1,1) local emailbox = native.newTextField(240,175,170,20) emailbox.size = 14 local dob = display.newText("DATE OF BIRTH:",60,210,native.systemFont,14) dob:setFillColor(1,1,1) local dobbox = native.newTextField(240,210,170,20) dobbox.size = 14 local gender = display.newText("GENDER:",40,260,native.systemFont,14) gender:setFillColor(1,1,1) local male = display.newText("MALE:",120,260,native.systemFont,14) male:setFillColor(1,1,1) local female = display.newText("FEMALE:",230,260,native.systemFont,14) female:setFillColor(1,1,1) --checkboxes for Gneder 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 = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) local function onSwitchPress(event) local switch = event.target print("switch with ID'"..switch.id.."'is on: " ..tostring(switch.isOn)) end local FEMALE = widget.newSwitch( { left = 270, top = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) local nextpage= widget.newButton( { left = 0, top = 450, id = "SIGN UP", label = "NEXT", onEvent = handleButtonEvent } ) function nextpage:touch(event) if (event.phase == "ended") then composer.removeScene("registration1",true) composer.gotoScene("registration2",{effect = "crossfade",time = 200}) end return true; end login:addEventListener("touch",nextpage); 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("registration1",true) composer.gotoScene("main",{effect = "crossfade",time = 200}) end return true; end login:addEventListener("touch",cancel);

i want to change scene but whenever i press the button to do so i get attempted to index global ‘login’ (a nil value) dont know how to fix this issue. the first part is my main.lua and the second is registraioon1.lua, the scene i want to appear when i press the signup button

You are creating all the object in main.lua ,  & remember main.lua is not a scene.

Thus if you want to remove the first scene i.e objects of main.lua , you can go with the following solutions:

1- Remove all the objects before going on the next scene i.e registration.lua in your case

    To do so, you can take a table  & store all the ref of each object in that table & before going on next scene you can remove all using  a loop.

I have updated your main.lua , use this :

[lua]

local widget = require (“widget”)

local composer = require( “composer” )

local scene = composer.newScene() 

local background = display.newImage("")

–===========================================================

– Module added by Assif

local objGrp=display.newGroup()

local cleanObj=function()

        objGrp:removeSelf()

        objGrp=nil

end

–===========================================================

function background:tap(event)

    native.setKeyboardFocus(nil)

end

background:addEventListener(“tap”, background)   

objGrp:insert(background)

local login = widget.newButton({left = 0,top = 450,id = “login”,label = “LOGIN”,onEvent = handleButtonEvent}) 

function login:touch(event)

    if (event.phase == “ended”) then

        cleanObj()

        composer.gotoScene(“mainpage”,{effect = “crossfade”,time = 200})

    end

end    

login:addEventListener(“touch”,scene)

objGrp:insert(login)

local signup = widget.newButton({left = 150,top = 450,id = “signup”,label = “SIGN UP”,onEvent = handleButtonEvent})

function signup:touch(event)

    if (event.phase == “ended”) then

        cleanObj()

        composer.gotoScene(“registration1”,{effect = “crossfade”,time = 200})     

    end   

end   

signup:addEventListener(“touch”,signup)   

objGrp:insert(signup)

local username = display.newText(“USERNAME”,110,70, native.systemFont,18)

username:setFillColor(1,1,1)

objGrp:insert(username)

local password = display.newText(“PASSWORD”,110,210, native.systemFont,18)

password:setFillColor(1,1,1)

objGrp:insert(password)

local usernamebox = native.newTextField(160,120,220,40)

usernamebox.size = 16

username:addEventListener(“userinput”, username)

objGrp:insert(usernamebox)

local passwordbox = native.newTextField(160,260,220,40)

passwordbox.size = 16

objGrp:insert(passwordbox)

local feedback = display.newText("",130,140,native.systemFont,14)

function username:userinput(event)

    if (event.phase == “began”) then

        event.target.text = “”

        feedback.text = “PLEASE ENTER YOUR USERNAME OR EMAIL ADDRESS”

    elseif (event.phase == “editing”) then

        feedback.text = event.startPosition

    end

end    

objGrp:insert(feedback)    

[/lua]

2- The best way is , move all the objects of main.lua into a new scene file.

     Thus you can put all the objects in sceneGroup.

      Creating objects in main.lua is not a professional way .

-Assif

i have created a new scene for the login and just put few lines of codes in my main.lua which will direct me to my login scene but am still getting error reading ?:0: attempt to index field ‘from’ (a nil value)

stack traceback:

?:in function ‘gotoScene’

main.lua:2:in main chunck

share you code

--main.lua local composer = require("composer") composer.gotoScene ("loginform",{effect = "crossfade", time = 300})

--loginform.lua local widget = require ("widget") local composer = require( "composer" ) local scene = composer.newScene() local background = display.newImage("") --=========================================================== -- Module added by Assif local objGrp=display.newGroup() local cleanObj=function() objGrp:removeSelf() objGrp=nil end --=========================================================== function background:tap(event) native.setKeyboardFocus(nil) end background:addEventListener("tap", background) objGrp:insert(background) local login = widget.newButton({left = 0,top = 450,id = "login",label = "LOGIN",onEvent = handleButtonEvent}) function login:touch(event) if (event.phase == "ended") then cleanObj() composer.gotoScene("mainpage",{effect = "crossfade",time = 200}) end end login:addEventListener("touch",scene) objGrp:insert(login) local signup = widget.newButton({left = 150,top = 450,id = "signup",label = "SIGN UP",onEvent = handleButtonEvent}) function signup:touch(event) if (event.phase == "ended") then cleanObj() composer.gotoScene("registration1",{effect = "crossfade",time = 200}) end end signup:addEventListener("touch",signup) objGrp:insert(signup) local username = display.newText("USERNAME",110,70, native.systemFont,18) username:setFillColor(1,1,1) objGrp:insert(username) local password = display.newText("PASSWORD",110,210, native.systemFont,18) password:setFillColor(1,1,1) objGrp:insert(password) local usernamebox = native.newTextField(160,120,220,40) usernamebox.size = 16 username:addEventListener("userinput", username) objGrp:insert(usernamebox) local passwordbox = native.newTextField(160,260,220,40) passwordbox.size = 16 objGrp:insert(passwordbox) local feedback = display.newText("",130,140,native.systemFont,14) function username:userinput(event) if (event.phase == "began") then event.target.text = "" feedback.text = "PLEASE ENTER YOUR USERNAME OR EMAIL ADDRESS" elseif (event.phase == "editing") then feedback.text = event.startPosition end end objGrp:insert(feedback) function scene:create( event ) local sceneGroup = self.view -- Code here runs when the scene is first created but has not yet appeared on screen 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 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

--registration1.lua local widget = require ("widget") local composer = require( "composer" ) local scene = composer.newScene() local background = display.newImage("") --hide keyboard function background:tap(event) native.setKeyboardFocus(nil) end background:addEventListener("tap", background) local firstname = display.newText("FIRST NAME:",50,0,native.systemFont,14) firstname:setFillColor(1,1,1) local firstnamebox = native.newTextField(240,0,170,20) firstnamebox.size = 14 local lastname = display.newText("LAST NAME:",50,35,native.systemFont,14) lastname:setFillColor(1,1,1) local lastnamebox = native.newTextField(240,35,170,20) lastnamebox.sie= 14 local username = display.newText("USERNAME:",50,70, native.systemFont,14) username:setFillColor(1,1,1) local usernamebox = native.newTextField(240,70,170,20) usernamebox.size = 14 local password = display.newText("PASSWORD:",50,105,native.systemFont,14) password:setFillColor(1,1,1) local passwordbox = native.newTextField(240,105,170,20) passwordbox.size = 14 local repassword = display.newText("RETYPE PASSWORD:",80,140,native.systemFont,14) repassword:setFillColor(1,1,1) local repassword = native.newTextField(240,140,170,20) repassword.size = 14 local email = display.newText("E-MAIL:",30,175,native.systemFont,14) email:setFillColor(1,1,1) local emailbox = native.newTextField(240,175,170,20) emailbox.size = 14 local dob = display.newText("DATE OF BIRTH:",60,210,native.systemFont,14) dob:setFillColor(1,1,1) local dobbox = native.newTextField(240,210,170,20) dobbox.size = 14 local gender = display.newText("GENDER:",40,260,native.systemFont,14) gender:setFillColor(1,1,1) local male = display.newText("MALE:",120,260,native.systemFont,14) male:setFillColor(1,1,1) local female = display.newText("FEMALE:",230,260,native.systemFont,14) female:setFillColor(1,1,1) --checkboxes for Gneder 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 = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) local function onSwitchPress(event) local switch = event.target print("switch with ID'"..switch.id.."'is on: " ..tostring(switch.isOn)) end local FEMALE = widget.newSwitch( { left = 270, top = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) local nextpage= widget.newButton( { left = 0, top = 450, id = "SIGN UP", label = "NEXT", onEvent = handleButtonEvent } ) function nextpage:touch(event) if (event.phase == "ended") then composer.removeScene("registration1",true) composer.gotoScene("registration2",{effect = "crossfade",time = 200}) end return true; end nextpage:addEventListener("touch",nextpage); 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("registration1",true) composer.gotoScene("main",{effect = "crossfade",time = 200}) end return true; end cancel:addEventListener("touch",cancel);
--main.lua ----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local composer = require ("composer") composer.gotoScene("login", {effect = "fade", time = 200})

--login.lualocal composer = require("composer") local scene = composer.newScene() local widget =require ("widget") function scene:create( event ) local sceneGroup = self.view local username = display.newText("USERNAME",110,70, native.systemFont,18) username:setFillColor(1,1,1) local password = display.newText("PASSWORD",110,210, native.systemFont,18) password:setFillColor(1,1,1) local usernamebox = native.newTextField(160,120,220,40) usernamebox.size = 16 local passwordbox = native.newTextField(160,260,220,40) passwordbox.size = 16 local login = widget.newButton( { left = 0, top = 450, id = "login" ,label = "LOGIN", onEvent = handleButtonEvent } ) function login:touch(event) if (event.phase == "ended") then composer.removeScene("login",false) composer.gotoScene("mpage",{effect = "fade",time = 300}) end end login:addEventListener("touch",login) local signup = widget.newButton( { left = 150, top = 450, id = "signup", label = "SIGN UP", onEvent = handleButtonEvent } ) function signup:touch(event) if (event.phase == "ended") then composer.removeScene("login",true) composer.gotoScene("regform1",{effect = "fade",time = 300}) end end signup:addEventListener("touch",signup) 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 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

--regform1.lua 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,0,native.systemFont,14) firstname:setFillColor(1,1,1) local firstnamebox = native.newTextField(240,0,170,20) firstnamebox.size = 14 local lastname = display.newText("LAST NAME:",50,35,native.systemFont,14) lastname:setFillColor(1,1,1) local lastnamebox = native.newTextField(240,35,170,20) lastnamebox.sie= 14 local username = display.newText("USERNAME:",50,70, native.systemFont,14) username:setFillColor(1,1,1) local usernamebox = native.newTextField(240,70,170,20) usernamebox.size = 14 local password = display.newText("PASSWORD:",50,105,native.systemFont,14) password:setFillColor(1,1,1) local passwordbox = native.newTextField(240,105,170,20) passwordbox.size = 14 local repassword = display.newText("RETYPE PASSWORD:",80,140,native.systemFont,14) repassword:setFillColor(1,1,1) local repassword = native.newTextField(240,140,170,20) repassword.size = 14 local email = display.newText("E-MAIL:",30,175,native.systemFont,14) email:setFillColor(1,1,1) local emailbox = native.newTextField(240,175,170,20) emailbox.size = 14 local dob = display.newText("DATE OF BIRTH:",60,210,native.systemFont,14) dob:setFillColor(1,1,1) local dobbox = native.newTextField(240,210,170,20) dobbox.size = 14 local gender = display.newText("GENDER:",40,260,native.systemFont,14) gender:setFillColor(1,1,1) local male = display.newText("MALE:",120,260,native.systemFont,14) male:setFillColor(1,1,1) local female = display.newText("FEMALE:",230,260,native.systemFont,14) female:setFillColor(1,1,1) 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 = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) end local function onSwitchPress(event) local switch = event.target print("switch with ID'"..switch.id.."'is on: " ..tostring(switch.isOn)) end local FEMALE = widget.newSwitch( { left = 270, top = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) local nextpage= widget.newButton( { left = 0, top = 450, id = "SIGN UP", label = "NEXT", onEvent = handleButtonEvent } ) function nextpage:touch(event) if (event.phase == "ended") then composer.removeScene("regform1",true) composer.gotoScene("regform2",{effect = "fade",time = 200}) end return true; end nextpage:addEventListener("touch",nextpage); 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 cancel:addEventListener("touch",cancel); -- 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 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 my new code. there are no errors but i can’t seem to hide the scene for another to display but rather both scenes appear on the same time

I don’t see where you are inserting anything you’re creating into the scene’s “view” group. You need to do:

sceneGroup:insert( username )

for every object. If you don’t Composer can’t manage them. That means Composer can’t show and hide the scenes, it can’t clean up after itself.

This is why you don’t see the scenes hiding.

Secondly ever one of your native.newTextField() objects are not part of OppenGL system, so they can’t really be shown or hidden by composer any way. As a rule I personally prefer to actually create native.* objects in scene:show(). Everything else done in scene:create() that way you can create the native.* in scene:show() and remove them in scene:hide(). This is the best balance for doing text fields with Corona.

Finally your widget.newButtons already have a touch/tap handling function. You should not be adding your own event listeners for them. Just create a function above scene:create() named “handleButtonEvent”.

Rob

still my text fields are not clearing from the screen but all is

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

You are creating all the object in main.lua ,  & remember main.lua is not a scene.

Thus if you want to remove the first scene i.e objects of main.lua , you can go with the following solutions:

1- Remove all the objects before going on the next scene i.e registration.lua in your case

    To do so, you can take a table  & store all the ref of each object in that table & before going on next scene you can remove all using  a loop.

I have updated your main.lua , use this :

[lua]

local widget = require (“widget”)

local composer = require( “composer” )

local scene = composer.newScene() 

local background = display.newImage("")

–===========================================================

– Module added by Assif

local objGrp=display.newGroup()

local cleanObj=function()

        objGrp:removeSelf()

        objGrp=nil

end

–===========================================================

function background:tap(event)

    native.setKeyboardFocus(nil)

end

background:addEventListener(“tap”, background)   

objGrp:insert(background)

local login = widget.newButton({left = 0,top = 450,id = “login”,label = “LOGIN”,onEvent = handleButtonEvent}) 

function login:touch(event)

    if (event.phase == “ended”) then

        cleanObj()

        composer.gotoScene(“mainpage”,{effect = “crossfade”,time = 200})

    end

end    

login:addEventListener(“touch”,scene)

objGrp:insert(login)

local signup = widget.newButton({left = 150,top = 450,id = “signup”,label = “SIGN UP”,onEvent = handleButtonEvent})

function signup:touch(event)

    if (event.phase == “ended”) then

        cleanObj()

        composer.gotoScene(“registration1”,{effect = “crossfade”,time = 200})     

    end   

end   

signup:addEventListener(“touch”,signup)   

objGrp:insert(signup)

local username = display.newText(“USERNAME”,110,70, native.systemFont,18)

username:setFillColor(1,1,1)

objGrp:insert(username)

local password = display.newText(“PASSWORD”,110,210, native.systemFont,18)

password:setFillColor(1,1,1)

objGrp:insert(password)

local usernamebox = native.newTextField(160,120,220,40)

usernamebox.size = 16

username:addEventListener(“userinput”, username)

objGrp:insert(usernamebox)

local passwordbox = native.newTextField(160,260,220,40)

passwordbox.size = 16

objGrp:insert(passwordbox)

local feedback = display.newText("",130,140,native.systemFont,14)

function username:userinput(event)

    if (event.phase == “began”) then

        event.target.text = “”

        feedback.text = “PLEASE ENTER YOUR USERNAME OR EMAIL ADDRESS”

    elseif (event.phase == “editing”) then

        feedback.text = event.startPosition

    end

end    

objGrp:insert(feedback)    

[/lua]

2- The best way is , move all the objects of main.lua into a new scene file.

     Thus you can put all the objects in sceneGroup.

      Creating objects in main.lua is not a professional way .

-Assif

i have created a new scene for the login and just put few lines of codes in my main.lua which will direct me to my login scene but am still getting error reading ?:0: attempt to index field ‘from’ (a nil value)

stack traceback:

?:in function ‘gotoScene’

main.lua:2:in main chunck

share you code

--main.lua local composer = require("composer") composer.gotoScene ("loginform",{effect = "crossfade", time = 300})

--loginform.lua local widget = require ("widget") local composer = require( "composer" ) local scene = composer.newScene() local background = display.newImage("") --=========================================================== -- Module added by Assif local objGrp=display.newGroup() local cleanObj=function() objGrp:removeSelf() objGrp=nil end --=========================================================== function background:tap(event) native.setKeyboardFocus(nil) end background:addEventListener("tap", background) objGrp:insert(background) local login = widget.newButton({left = 0,top = 450,id = "login",label = "LOGIN",onEvent = handleButtonEvent}) function login:touch(event) if (event.phase == "ended") then cleanObj() composer.gotoScene("mainpage",{effect = "crossfade",time = 200}) end end login:addEventListener("touch",scene) objGrp:insert(login) local signup = widget.newButton({left = 150,top = 450,id = "signup",label = "SIGN UP",onEvent = handleButtonEvent}) function signup:touch(event) if (event.phase == "ended") then cleanObj() composer.gotoScene("registration1",{effect = "crossfade",time = 200}) end end signup:addEventListener("touch",signup) objGrp:insert(signup) local username = display.newText("USERNAME",110,70, native.systemFont,18) username:setFillColor(1,1,1) objGrp:insert(username) local password = display.newText("PASSWORD",110,210, native.systemFont,18) password:setFillColor(1,1,1) objGrp:insert(password) local usernamebox = native.newTextField(160,120,220,40) usernamebox.size = 16 username:addEventListener("userinput", username) objGrp:insert(usernamebox) local passwordbox = native.newTextField(160,260,220,40) passwordbox.size = 16 objGrp:insert(passwordbox) local feedback = display.newText("",130,140,native.systemFont,14) function username:userinput(event) if (event.phase == "began") then event.target.text = "" feedback.text = "PLEASE ENTER YOUR USERNAME OR EMAIL ADDRESS" elseif (event.phase == "editing") then feedback.text = event.startPosition end end objGrp:insert(feedback) function scene:create( event ) local sceneGroup = self.view -- Code here runs when the scene is first created but has not yet appeared on screen 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 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

--registration1.lua local widget = require ("widget") local composer = require( "composer" ) local scene = composer.newScene() local background = display.newImage("") --hide keyboard function background:tap(event) native.setKeyboardFocus(nil) end background:addEventListener("tap", background) local firstname = display.newText("FIRST NAME:",50,0,native.systemFont,14) firstname:setFillColor(1,1,1) local firstnamebox = native.newTextField(240,0,170,20) firstnamebox.size = 14 local lastname = display.newText("LAST NAME:",50,35,native.systemFont,14) lastname:setFillColor(1,1,1) local lastnamebox = native.newTextField(240,35,170,20) lastnamebox.sie= 14 local username = display.newText("USERNAME:",50,70, native.systemFont,14) username:setFillColor(1,1,1) local usernamebox = native.newTextField(240,70,170,20) usernamebox.size = 14 local password = display.newText("PASSWORD:",50,105,native.systemFont,14) password:setFillColor(1,1,1) local passwordbox = native.newTextField(240,105,170,20) passwordbox.size = 14 local repassword = display.newText("RETYPE PASSWORD:",80,140,native.systemFont,14) repassword:setFillColor(1,1,1) local repassword = native.newTextField(240,140,170,20) repassword.size = 14 local email = display.newText("E-MAIL:",30,175,native.systemFont,14) email:setFillColor(1,1,1) local emailbox = native.newTextField(240,175,170,20) emailbox.size = 14 local dob = display.newText("DATE OF BIRTH:",60,210,native.systemFont,14) dob:setFillColor(1,1,1) local dobbox = native.newTextField(240,210,170,20) dobbox.size = 14 local gender = display.newText("GENDER:",40,260,native.systemFont,14) gender:setFillColor(1,1,1) local male = display.newText("MALE:",120,260,native.systemFont,14) male:setFillColor(1,1,1) local female = display.newText("FEMALE:",230,260,native.systemFont,14) female:setFillColor(1,1,1) --checkboxes for Gneder 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 = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) local function onSwitchPress(event) local switch = event.target print("switch with ID'"..switch.id.."'is on: " ..tostring(switch.isOn)) end local FEMALE = widget.newSwitch( { left = 270, top = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) local nextpage= widget.newButton( { left = 0, top = 450, id = "SIGN UP", label = "NEXT", onEvent = handleButtonEvent } ) function nextpage:touch(event) if (event.phase == "ended") then composer.removeScene("registration1",true) composer.gotoScene("registration2",{effect = "crossfade",time = 200}) end return true; end nextpage:addEventListener("touch",nextpage); 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("registration1",true) composer.gotoScene("main",{effect = "crossfade",time = 200}) end return true; end cancel:addEventListener("touch",cancel);
--main.lua ----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local composer = require ("composer") composer.gotoScene("login", {effect = "fade", time = 200})

--login.lualocal composer = require("composer") local scene = composer.newScene() local widget =require ("widget") function scene:create( event ) local sceneGroup = self.view local username = display.newText("USERNAME",110,70, native.systemFont,18) username:setFillColor(1,1,1) local password = display.newText("PASSWORD",110,210, native.systemFont,18) password:setFillColor(1,1,1) local usernamebox = native.newTextField(160,120,220,40) usernamebox.size = 16 local passwordbox = native.newTextField(160,260,220,40) passwordbox.size = 16 local login = widget.newButton( { left = 0, top = 450, id = "login" ,label = "LOGIN", onEvent = handleButtonEvent } ) function login:touch(event) if (event.phase == "ended") then composer.removeScene("login",false) composer.gotoScene("mpage",{effect = "fade",time = 300}) end end login:addEventListener("touch",login) local signup = widget.newButton( { left = 150, top = 450, id = "signup", label = "SIGN UP", onEvent = handleButtonEvent } ) function signup:touch(event) if (event.phase == "ended") then composer.removeScene("login",true) composer.gotoScene("regform1",{effect = "fade",time = 300}) end end signup:addEventListener("touch",signup) 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 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

--regform1.lua 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,0,native.systemFont,14) firstname:setFillColor(1,1,1) local firstnamebox = native.newTextField(240,0,170,20) firstnamebox.size = 14 local lastname = display.newText("LAST NAME:",50,35,native.systemFont,14) lastname:setFillColor(1,1,1) local lastnamebox = native.newTextField(240,35,170,20) lastnamebox.sie= 14 local username = display.newText("USERNAME:",50,70, native.systemFont,14) username:setFillColor(1,1,1) local usernamebox = native.newTextField(240,70,170,20) usernamebox.size = 14 local password = display.newText("PASSWORD:",50,105,native.systemFont,14) password:setFillColor(1,1,1) local passwordbox = native.newTextField(240,105,170,20) passwordbox.size = 14 local repassword = display.newText("RETYPE PASSWORD:",80,140,native.systemFont,14) repassword:setFillColor(1,1,1) local repassword = native.newTextField(240,140,170,20) repassword.size = 14 local email = display.newText("E-MAIL:",30,175,native.systemFont,14) email:setFillColor(1,1,1) local emailbox = native.newTextField(240,175,170,20) emailbox.size = 14 local dob = display.newText("DATE OF BIRTH:",60,210,native.systemFont,14) dob:setFillColor(1,1,1) local dobbox = native.newTextField(240,210,170,20) dobbox.size = 14 local gender = display.newText("GENDER:",40,260,native.systemFont,14) gender:setFillColor(1,1,1) local male = display.newText("MALE:",120,260,native.systemFont,14) male:setFillColor(1,1,1) local female = display.newText("FEMALE:",230,260,native.systemFont,14) female:setFillColor(1,1,1) 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 = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) end local function onSwitchPress(event) local switch = event.target print("switch with ID'"..switch.id.."'is on: " ..tostring(switch.isOn)) end local FEMALE = widget.newSwitch( { left = 270, top = 245, style = "checkbox", id = "Checkbox", onPress = onSwitchPress } ) local nextpage= widget.newButton( { left = 0, top = 450, id = "SIGN UP", label = "NEXT", onEvent = handleButtonEvent } ) function nextpage:touch(event) if (event.phase == "ended") then composer.removeScene("regform1",true) composer.gotoScene("regform2",{effect = "fade",time = 200}) end return true; end nextpage:addEventListener("touch",nextpage); 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 cancel:addEventListener("touch",cancel); -- 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 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 my new code. there are no errors but i can’t seem to hide the scene for another to display but rather both scenes appear on the same time

I don’t see where you are inserting anything you’re creating into the scene’s “view” group. You need to do:

sceneGroup:insert( username )

for every object. If you don’t Composer can’t manage them. That means Composer can’t show and hide the scenes, it can’t clean up after itself.

This is why you don’t see the scenes hiding.

Secondly ever one of your native.newTextField() objects are not part of OppenGL system, so they can’t really be shown or hidden by composer any way. As a rule I personally prefer to actually create native.* objects in scene:show(). Everything else done in scene:create() that way you can create the native.* in scene:show() and remove them in scene:hide(). This is the best balance for doing text fields with Corona.

Finally your widget.newButtons already have a touch/tap handling function. You should not be adding your own event listeners for them. Just create a function above scene:create() named “handleButtonEvent”.

Rob

still my text fields are not clearing from the screen but all is