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