Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Level 7

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
Highlighted
Level 19

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

View solution in original post

2 Replies
Highlighted
Level 19

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

View solution in original post

Highlighted
Level 7

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