Forum Discussion

azimuth's avatar
azimuth
Reel Rookie
6 years ago
Solved

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

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!

 

  • 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

2 Replies

  • renojim's avatar
    renojim
    Community Streaming Expert

    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

    • azimuth's avatar
      azimuth
      Reel Rookie

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