storyboard.gotoScene error!

Hi All,

Below Code is working:

[lua]display.setStatusBar( display.HiddenStatusBar )

– include the Corona “storyboard” module
local storyboard = require “storyboard”

– load menu screen

storyboard.gotoScene( “menu” )
[/lua]

but below code doesnt working (error: attemp to call global ‘kkk’ (a nill value)   )  :

[lua]display.setStatusBar( display.HiddenStatusBar )

– include the Corona “storyboard” module
local storyboard = require “storyboard”

kkk()
– load menu screen

local function kkk()
storyboard.gotoScene( “menu” )
return true
end [/lua]

what is this error??

cant i use gotoScene in function?

please inform me about this

Thank you  :slight_smile:

You’re attempting to call the function before you declare it.  In Lua, you have to declare your functions before you call them.  The error has nothing to do with storyboard specifically, just the fact that your calling a function before you declared it.

  • Andrew

Hi Andrew,

thanks for replies. it has been solved  :) 

one more question please  :slight_smile:

code is below:

[lua]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

local function onTouch ( event )

if event.phase == “began” then
storyboard.gotoscene( “items”)
return true
end
end

local ball2 = display.newCircle( 0, 0, 40)
ball2:setFillColor(0, 255, 0, 166)
ball2.x = 200
ball2.y = 200

ball2:addEventListener(“touch”, onTouch)[/lua]

When i cliced my ball i get same error  :frowning:

what is my declaration wrong or another wrong? :rolleyes:

It should be storyboard.gotoScene (capital S), not storyboard.gotoscene.

  • Andrew

Adrew,

You are my hero  :slight_smile:

thank you again  :)  :slight_smile:

You’re attempting to call the function before you declare it.  In Lua, you have to declare your functions before you call them.  The error has nothing to do with storyboard specifically, just the fact that your calling a function before you declared it.

  • Andrew

Hi Andrew,

thanks for replies. it has been solved  :) 

one more question please  :slight_smile:

code is below:

[lua]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

local function onTouch ( event )

if event.phase == “began” then
storyboard.gotoscene( “items”)
return true
end
end

local ball2 = display.newCircle( 0, 0, 40)
ball2:setFillColor(0, 255, 0, 166)
ball2.x = 200
ball2.y = 200

ball2:addEventListener(“touch”, onTouch)[/lua]

When i cliced my ball i get same error  :frowning:

what is my declaration wrong or another wrong? :rolleyes:

It should be storyboard.gotoScene (capital S), not storyboard.gotoscene.

  • Andrew

Adrew,

You are my hero  :slight_smile:

thank you again  :)  :slight_smile: