Hi,
I have searched everywhere and cannot find how to create a global variable that can be used in all of the screens of a storyboard app. Is this possible?
Thanks,
Warren
[import]uid: 184193 topic_id: 33328 reply_id: 333328[/import]
Hi,
I have searched everywhere and cannot find how to create a global variable that can be used in all of the screens of a storyboard app. Is this possible?
Thanks,
Warren
[import]uid: 184193 topic_id: 33328 reply_id: 333328[/import]
Hey Warren, Check out this link:
http://www.coronalabs.com/blog/2011/11/16/common-storyboard-api-questions/
and search for the section titled: How do you transfer data/variables between scenes? [import]uid: 135765 topic_id: 33328 reply_id: 132343[/import]
I think the best way is to declare them on top of main.lua. After that they are accessible/assignable anywhere. Theoretically you can make them anywhere though.
It’s best to avoid them and do what r.delia pointed out though. For some things they are useful though. [import]uid: 65415 topic_id: 33328 reply_id: 132369[/import]
So if I declare a variable in mail.lua called strName and assign the value “Hello” to it then I can use that variable just like that in other pages? I do not need to refer to main.lua to get the value? I only need one public variable so this sounds like the easiest way if that’s how it works.
Thanks,
Warren
[import]uid: 184193 topic_id: 33328 reply_id: 132424[/import]
[code]
local storyboard = require “storyboard”;
storyboard.myVariable = “my item”
[/code] [import]uid: 81188 topic_id: 33328 reply_id: 132428[/import]
Hey Warren, Check out this link:
http://www.coronalabs.com/blog/2011/11/16/common-storyboard-api-questions/
and search for the section titled: How do you transfer data/variables between scenes? [import]uid: 135765 topic_id: 33328 reply_id: 132343[/import]
I think the best way is to declare them on top of main.lua. After that they are accessible/assignable anywhere. Theoretically you can make them anywhere though.
It’s best to avoid them and do what r.delia pointed out though. For some things they are useful though. [import]uid: 65415 topic_id: 33328 reply_id: 132369[/import]
So if I declare a variable in mail.lua called strName and assign the value “Hello” to it then I can use that variable just like that in other pages? I do not need to refer to main.lua to get the value? I only need one public variable so this sounds like the easiest way if that’s how it works.
Thanks,
Warren
[import]uid: 184193 topic_id: 33328 reply_id: 132424[/import]
[code]
local storyboard = require “storyboard”;
storyboard.myVariable = “my item”
[/code] [import]uid: 81188 topic_id: 33328 reply_id: 132428[/import]