parameter passing through scene.

Hi I have two scene. I want to pass variable from one page to another.
Here is the code block.

In scene1.lua :
local options =
{
effect = “fade”,
time = 400,
params =
{
myVar= “Hi”
}
}
local storyboard = require( “storyboard” )
storyboard.gotoScene( “scene2”, options )

In scene2.lua :
function scene:enterScene( event )
local scene1Data = event.params.myVar
print( scene1Data )
end

Now when I run my app and tries to go from scene1 to scene2, the page transition “fade” was not working and also I am not able to get params in scene2 page.

Please suggest… [import]uid: 154400 topic_id: 35194 reply_id: 335194[/import]

Hi rajumahato, I find that if you’re only sending one number or string the easiest way to do this is to use:

storyboard.cat = “Hi” ( cat is is just a variable name)

And in your next scene print(storyboard.cat)

Sending params is a bit trickier to get working. But here is an example of were I use it
scene1.lua

local options = { effect = "slideLeft", time = 1000, params = {t[num]} } storyboard.cat = "Animals" storyboard.gotoScene( "scene2", options)
scene2.lua

local words = event.params print(words[1])
In scene1 the params = t[num] is a randomly selected word from a table that I want to pass to the next scene.
Hope this helps you [import]uid: 208811 topic_id: 35194 reply_id: 139941[/import]

Thanks philjk19875, for your quick reply. I have used the both process that you have mentioned.
I have still unable to run my code using second process. The page transition was not working using the option parameter and also the values are not reaching to second scene. [import]uid: 154400 topic_id: 35194 reply_id: 140036[/import]

Hi, rajumahato.

We are using parameter passing heavily in a large project. To my knowledge it has never failed for us.

I modified you code a bit, and this seems to work:
scene1.lua

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
function scene:createScene( event )  
 local group = self.view  
   
 local options = {  
 effect = "fade",  
 time = 400,  
 params = { myVar= "Hi" }  
 }  
  
 storyboard.gotoScene( "scene2", options )  
  
end  
  
scene:addEventListener( "createScene", scene )  
  
return scene   

scene2.lua

  
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
function scene:createScene( event )  
 local group = self.view  
   
 local scene1Data = event.params  
 print( scene1Data.myVar )  
  
end  
  
scene:addEventListener( "createScene", scene )  
  
return scene  

I do not know if this effects your other code, but I was not able to put the parameter fetching in enterScene. Though the API documentation seems to tell it should… [import]uid: 25729 topic_id: 35194 reply_id: 140045[/import]

Hi rajumahato, I find that if you’re only sending one number or string the easiest way to do this is to use:

storyboard.cat = “Hi” ( cat is is just a variable name)

And in your next scene print(storyboard.cat)

Sending params is a bit trickier to get working. But here is an example of were I use it
scene1.lua

local options = { effect = "slideLeft", time = 1000, params = {t[num]} } storyboard.cat = "Animals" storyboard.gotoScene( "scene2", options)
scene2.lua

local words = event.params print(words[1])
In scene1 the params = t[num] is a randomly selected word from a table that I want to pass to the next scene.
Hope this helps you [import]uid: 208811 topic_id: 35194 reply_id: 139941[/import]

Thanks philjk19875, for your quick reply. I have used the both process that you have mentioned.
I have still unable to run my code using second process. The page transition was not working using the option parameter and also the values are not reaching to second scene. [import]uid: 154400 topic_id: 35194 reply_id: 140036[/import]

Hi, rajumahato.

We are using parameter passing heavily in a large project. To my knowledge it has never failed for us.

I modified you code a bit, and this seems to work:
scene1.lua

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
function scene:createScene( event )  
 local group = self.view  
   
 local options = {  
 effect = "fade",  
 time = 400,  
 params = { myVar= "Hi" }  
 }  
  
 storyboard.gotoScene( "scene2", options )  
  
end  
  
scene:addEventListener( "createScene", scene )  
  
return scene   

scene2.lua

  
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
function scene:createScene( event )  
 local group = self.view  
   
 local scene1Data = event.params  
 print( scene1Data.myVar )  
  
end  
  
scene:addEventListener( "createScene", scene )  
  
return scene  

I do not know if this effects your other code, but I was not able to put the parameter fetching in enterScene. Though the API documentation seems to tell it should… [import]uid: 25729 topic_id: 35194 reply_id: 140045[/import]