Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
azimuth
Reel Rookie

How to create/access a Label in a scene as a global variable? (Displaying messages with roInput)

Jump to solution

I have a label in a scene, and I want to access it from main.brs.  I've tried assigning it to a global variable:

    m.myLabel = m.top.findNode("myLabel")

    m.global.myLabel = m.myLabel

Tried this a few ways, but the debugger keeps complaining.  I can't assign the label to a global, and so I can't access it in my main function, and so I can't display messages.

The reason I need access to the label it in the main function, that's where the while loop is where messages are checked.

Thanks!

 

0 Kudos
1 Solution

Accepted Solutions
renojim
Community Streaming Expert

Re: How to create/access a Label in a scene as a global variable? (Displaying messages with roInput)

Jump to solution

I think I know what you're trying to do, but I'm not sure.  To access a label in a scene from main.brs, you have to get to it via the scene:

sg = createObject("roSGScreen")
scene = sg.createScene("myScene")
label = scene.findNode("myLabel")
print label.text ' prints current value
label.text = "New text" ' set label text

-JT

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.

View solution in original post

2 REPLIES 2
renojim
Community Streaming Expert

Re: How to create/access a Label in a scene as a global variable? (Displaying messages with roInput)

Jump to solution

I think I know what you're trying to do, but I'm not sure.  To access a label in a scene from main.brs, you have to get to it via the scene:

sg = createObject("roSGScreen")
scene = sg.createScene("myScene")
label = scene.findNode("myLabel")
print label.text ' prints current value
label.text = "New text" ' set label text

-JT

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
azimuth
Reel Rookie

Re: How to create/access a Label in a scene as a global variable? (Displaying messages with roInput)

Jump to solution

Yes that was exactly what I was trying to do... thanks!

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.