simple addEventListener not working (display nil value) think you can help?

This is the error:

restart.lua:36: attempt to call method ‘addEventListener’ (a nil value)

This is the code:


function scene:enterScene(event)

        

        storyboard.purgeScene(“game”)

        bkg:addEventListener(“touch”, start)

    end


he second time my storyboard goes to the restart screen… hmm, any ideas?

There isn’t enough code to really know what’s going on, but just speculating…

The only reason that addEventListener would give that error is if your object has been destroyed or written over.  Is this “game.lua” we are looking at?  If so you’re removing it before  you try to access it.  Where is bkg defined?  Is it scoped only in createScene() or do you forward declare it at the top of the module?

Rob

There isn’t enough code to really know what’s going on, but just speculating…

The only reason that addEventListener would give that error is if your object has been destroyed or written over.  Is this “game.lua” we are looking at?  If so you’re removing it before  you try to access it.  Where is bkg defined?  Is it scoped only in createScene() or do you forward declare it at the top of the module?

Rob