Button gotoScene not working

The storyboard.gotoScene(“facebook”, “fade”, 400) is not working if i tap the button, and i dont get any error messages in the terminal. What am i doing wrong ?

-- requires   
display.setStatusBar( display.HiddenStatusBar )   
\_W = display.contentWidth; --Returns Screen Width  
\_H = display.contentHeight; --Returns Screen Height  
local storyboard = require ("storyboard")  
local scene = storyboard.newScene()  
  
-- background  
  
function scene:createScene(event)  
  
 local screenGroup = self.view  
 background = display.newImage("restart.png")  
 screenGroup:insert(background)  
  
 button = display.newImage("share2.png")   
 button.x = display.contentWidth / 2  
 button.y = display.contentHeight -400  
end  
  
 function listener(event)   
 if event.phase == "began" then  
 print(event.name.." occurred")   
 storyboard.gotoScene("facebook", "fade", 400)  
 end  
end   
  
function scene:enterScene(event)  
 storyboard.purgeScene("game")  
 button:addEventListener( "tap", listener )   
end  
  
function scene:exitScene(event)  
 button:removeEventListener( "tap", listener )   
end  
  
function scene:destroyScene(event)  
end  
  
scene:addEventListener("createScene", scene)  
scene:addEventListener("enterScene", scene)  
scene:addEventListener("exitScene", scene)  
scene:addEventListener("destroyScene", scene)  
  
return scene  

i have trite :

 function listener(event)   
 if event.phase == "began" then  
 print(event.name.." occurred")   
 storyboard.gotoScene("facebook", "fade", 400)  
 end  
end   
button:addEventListener( "touch", listener )   
button:removeEventListener( "touch", listener )   

and

function listener(event)   
 print(event.name.." occurred")   
 storyboard.gotoScene("facebook", "fade", 400)  
end  
button:addEventListener( "tap", listener )   
button:removeEventListener( "tap", listener )   

i get : Runtime error ?:0: attempt to call method ‘dispatchEvent’ –
[import]uid: 225288 topic_id: 36286 reply_id: 336286[/import]

the code is supposed to be Storyboard.gotoScene( “facebook”, {effect=“fade”})
if that doesnt work use a lowercase S and I don’t know if you can put a timer there, just put this in a function, and then use the code timer.preformWithDelay() [import]uid: 226740 topic_id: 36286 reply_id: 144199[/import]

I think you may have misread my advice. I think you posted this in another thread.

If you are executing that code its probably not going to work because of scoping issues. Try this:

[code]
– requires
display.setStatusBar( display.HiddenStatusBar )
_W = display.contentWidth; --Returns Screen Width
_H = display.contentHeight; --Returns Screen Height

local storyboard = require (“storyboard”)
local scene = storyboard.newScene()

– background

function scene:createScene(event)

local screenGroup = self.view
background = display.newImage(“restart.png”)
screenGroup:insert(background)

button = display.newImage(“share2.png”)
button.x = display.contentWidth / 2
button.y = display.contentHeight -400
end

function listener(event)
if event.phase == “began” then
print(event.name…" occurred")
storyboard.gotoScene(“facebook”, “fade”, 400)
end
button:addEventListener( “touch”, listener )
end

function scene:enterScene(event)
storyboard.purgeScene(“game”)
end

function scene:exitScene(event)
– button:removeEventListener( “touch”, listener )
– you really don’t need to do this. It will be removed when the scene is disposed of for you.
end

function scene:destroyScene(event)
end

scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)

return scene
[/code] [import]uid: 199310 topic_id: 36286 reply_id: 144214[/import]

the code is supposed to be Storyboard.gotoScene( “facebook”, {effect=“fade”})
if that doesnt work use a lowercase S and I don’t know if you can put a timer there, just put this in a function, and then use the code timer.preformWithDelay() [import]uid: 226740 topic_id: 36286 reply_id: 144199[/import]

I think you may have misread my advice. I think you posted this in another thread.

If you are executing that code its probably not going to work because of scoping issues. Try this:

[code]
– requires
display.setStatusBar( display.HiddenStatusBar )
_W = display.contentWidth; --Returns Screen Width
_H = display.contentHeight; --Returns Screen Height

local storyboard = require (“storyboard”)
local scene = storyboard.newScene()

– background

function scene:createScene(event)

local screenGroup = self.view
background = display.newImage(“restart.png”)
screenGroup:insert(background)

button = display.newImage(“share2.png”)
button.x = display.contentWidth / 2
button.y = display.contentHeight -400
end

function listener(event)
if event.phase == “began” then
print(event.name…" occurred")
storyboard.gotoScene(“facebook”, “fade”, 400)
end
button:addEventListener( “touch”, listener )
end

function scene:enterScene(event)
storyboard.purgeScene(“game”)
end

function scene:exitScene(event)
– button:removeEventListener( “touch”, listener )
– you really don’t need to do this. It will be removed when the scene is disposed of for you.
end

function scene:destroyScene(event)
end

scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)

return scene
[/code] [import]uid: 199310 topic_id: 36286 reply_id: 144214[/import]

the code is supposed to be Storyboard.gotoScene( “facebook”, {effect=“fade”})
if that doesnt work use a lowercase S and I don’t know if you can put a timer there, just put this in a function, and then use the code timer.preformWithDelay() [import]uid: 226740 topic_id: 36286 reply_id: 144199[/import]

I think you may have misread my advice. I think you posted this in another thread.

If you are executing that code its probably not going to work because of scoping issues. Try this:

[code]
– requires
display.setStatusBar( display.HiddenStatusBar )
_W = display.contentWidth; --Returns Screen Width
_H = display.contentHeight; --Returns Screen Height

local storyboard = require (“storyboard”)
local scene = storyboard.newScene()

– background

function scene:createScene(event)

local screenGroup = self.view
background = display.newImage(“restart.png”)
screenGroup:insert(background)

button = display.newImage(“share2.png”)
button.x = display.contentWidth / 2
button.y = display.contentHeight -400
end

function listener(event)
if event.phase == “began” then
print(event.name…" occurred")
storyboard.gotoScene(“facebook”, “fade”, 400)
end
button:addEventListener( “touch”, listener )
end

function scene:enterScene(event)
storyboard.purgeScene(“game”)
end

function scene:exitScene(event)
– button:removeEventListener( “touch”, listener )
– you really don’t need to do this. It will be removed when the scene is disposed of for you.
end

function scene:destroyScene(event)
end

scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)

return scene
[/code] [import]uid: 199310 topic_id: 36286 reply_id: 144214[/import]

the code is supposed to be Storyboard.gotoScene( “facebook”, {effect=“fade”})
if that doesnt work use a lowercase S and I don’t know if you can put a timer there, just put this in a function, and then use the code timer.preformWithDelay() [import]uid: 226740 topic_id: 36286 reply_id: 144199[/import]

I think you may have misread my advice. I think you posted this in another thread.

If you are executing that code its probably not going to work because of scoping issues. Try this:

[code]
– requires
display.setStatusBar( display.HiddenStatusBar )
_W = display.contentWidth; --Returns Screen Width
_H = display.contentHeight; --Returns Screen Height

local storyboard = require (“storyboard”)
local scene = storyboard.newScene()

– background

function scene:createScene(event)

local screenGroup = self.view
background = display.newImage(“restart.png”)
screenGroup:insert(background)

button = display.newImage(“share2.png”)
button.x = display.contentWidth / 2
button.y = display.contentHeight -400
end

function listener(event)
if event.phase == “began” then
print(event.name…" occurred")
storyboard.gotoScene(“facebook”, “fade”, 400)
end
button:addEventListener( “touch”, listener )
end

function scene:enterScene(event)
storyboard.purgeScene(“game”)
end

function scene:exitScene(event)
– button:removeEventListener( “touch”, listener )
– you really don’t need to do this. It will be removed when the scene is disposed of for you.
end

function scene:destroyScene(event)
end

scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)

return scene
[/code] [import]uid: 199310 topic_id: 36286 reply_id: 144214[/import]