error when executing storyboard.gotoScene

Hello,

I am getting this error:

File: bad argument #-2 to ‘insert’ (Proxy expected, got nil)

Bad argument #-2 to ‘insert’ (Proxy expected, got nil)

trying to execute this line

storyboard.gotoScene( “scripts.screen2”,“fade”,400 )

this is part of an event handler for the userInput event on a textfield

local function onPasscode(event)

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

        if pwdField.text == “…” then

            storyboard.gotoScene( “scripts.screen2”,“fade”,400 )

            return true

        else

            pwdField.text = “”

            native.setKeyboardFocus(pwdField)

            return false

        end

    end

end

for some reason this  doesn’t work although is a fairly simple code, if the user press enter on the keyboard and the code is correct send the user to screen2…

by the way the same code works on  a handler for a button, but not for the text field.

any help would be greatly appreciated.

You don’t seem to be passing in your fade effect and time correctly, see http://docs.coronalabs.com/daily/api/library/storyboard/gotoScene.html

 storyboard.gotoScene( “scripts.screen2”, {effect = “fade”, time = 400})

Most likely you have an error in screen2.lua.

The same line of code works when in called from another event (a button touch event), and the screen2.lua works as I tested it by setting it as the launch screen from main.lua. I have discarded this two options.

Thanks for the repies.

I think I found the error. In all my scenes I like to destroy the scene upon exit as so on the exitScene event I usually have a line of code like

storyboard.removeScene(storyboard.getCurrentSceneName())

for some reason on this particular screen this line of code is not working so I have moved the removal of screens to the enter event of the screen I am going to, so for example on screen2’s enterScene event I have

storyboard.removeScene(storyboard.getPrevious()) and that seems to work.

I do like to remove screens to clear up memory and to make sure I remove all natives (textfields, etc…)

I found I’m happier removing before I do a gotoScene().

You don’t seem to be passing in your fade effect and time correctly, see http://docs.coronalabs.com/daily/api/library/storyboard/gotoScene.html

 storyboard.gotoScene( “scripts.screen2”, {effect = “fade”, time = 400})

Most likely you have an error in screen2.lua.

The same line of code works when in called from another event (a button touch event), and the screen2.lua works as I tested it by setting it as the launch screen from main.lua. I have discarded this two options.

Thanks for the repies.

I think I found the error. In all my scenes I like to destroy the scene upon exit as so on the exitScene event I usually have a line of code like

storyboard.removeScene(storyboard.getCurrentSceneName())

for some reason on this particular screen this line of code is not working so I have moved the removal of screens to the enter event of the screen I am going to, so for example on screen2’s enterScene event I have

storyboard.removeScene(storyboard.getPrevious()) and that seems to work.

I do like to remove screens to clear up memory and to make sure I remove all natives (textfields, etc…)

I found I’m happier removing before I do a gotoScene().