Cannot Remove Button Widget

Hello,

 

I have started a new project using the storyboard and added the code below. It adds a button to the screen and I have an event that fires when clicked. But the button shows on the next scene. I have tried to remove it all kinds of ways. Does anyone see what I am doing wrong?

 

Thanks!!!

 

---------------------------------------------------------------------------------- -- -- sceneHome.lua -- ---------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) storyboard.removeAll() local scene = storyboard.newScene() local widget = require( "widget" ) ---------------------------------------------------------------------------------- -- -- NOTE: -- -- Code outside of listener functions (below) will only be executed once, -- unless storyboard.removeScene() is called. -- --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- local function onButtonEvent( event ) local phase = event.phase if "ended" == phase then display.remove( myButton ) display.remove( imgBack ) storyboard.gotoScene( "sceneLogin" ) --print( "You pressed and released a button!" ) end return true end -- Called when the scene's view does not exist: function scene:createScene( event ) display.setDefault( "background", 255, 255, 255 ) local group = display.newGroup() local screenGroup = self.view imgBack = display.newImage( "backhome1.png" ,0,0) group:insert( imgBack ) imgHome = display.newImage( "logo\_wub.jpg") group:insert( imgHome ) local myButton = widget.newButton{ id = "btn001", left = 100, top = 200, label = "Widget Button", width = 150, height = 28, cornerRadius = 8, onEvent = onButtonEvent } group:insert( myButton ) -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view end end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.) ----------------------------------------------------------------------------- end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene

 

Nevermind, I looked at the demo for the new button and followed it in the sample code and it works now.

 

Thanks!!!

Nevermind, I looked at the demo for the new button and followed it in the sample code and it works now.

 

Thanks!!!