I’m using widget to make my buttons like this:
local backButton = widget.newButton { options }
but in the destroy function i can’t reach the backbutton variable, how can i reach it so i can remove it from the screen?
function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Called when the scene is still off screen (but is about to come on screen). local background = display.newRect( display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight ) background:setFillColor( 1, 0.65, 0.5) sceneGroup:insert( background ) local myText = display.newText("PictureIT", display.contentCenterX,100, native.systemFont, 48) myText:setFillColor( 1, 1,1) sceneGroup:insert( myText ) local mainButton = widget.newButton { left = 240-150, top = 510, width = 300, height = 70, label = "TelaMain", onEvent = nextTela, fillColor = { default={ 0.4, 0.4, 0.9, 1 }, over={ 0.4, 0.4, 0.9, 0.7 } }, labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 0, 0.5 } }, shape="roundedRect", } elseif ( phase == "did" ) then -- Called when the scene is now on screen. -- Insert code here to make the scene come alive. -- Example: start timers, begin animation, play audio, etc. end end
function scene:destroy( event ) local sceneGroup = self.view -- Called prior to the removal of scene's view ("sceneGroup"). -- Insert code here to clean up the scene. -- Example: remove display objects, save state, etc. facebookButton:removeSelf() end