Forum Discussion

strattonbrazil's avatar
strattonbrazil
Binge Watcher
10 years ago

scene graph componet -- passing variables

Is there a way to pass variables to a component at initialization? Or after? If I want some part of the component to be dynamic, is there a way to pass this information in? Can I use init() or do I have to make an aux function? Or something else like a message port?

3 Replies

  • "strattonbrazil" wrote:
    Is there a way to pass variables to a component at initialization? Or after? If I want some part of the component to be dynamic, is there a way to pass this information in? Can I use init() or do I have to make an aux function? Or something else like a message port?

    You can create a custom interface field and set its value. Make sure you add an onChange function to it, so you can detect when the value is changed.
  • Thanks, this makes sense. How do I pass information/events back like if I want the component to close the current screen?
  • "strattonbrazil" wrote:
    Thanks, this makes sense. How do I pass information/events back like if I want the component to close the current screen?

    You'd use the same method of adding an interface field. The difference is that you'd set the value from within the component, and listen for changes from the main BrightScript thread (via roSGNodeEvent).

    Having said that, Roku engineers don't seem to recommend using multiple scenes/screens, per viewtopic.php?f=34&t=88621#p513504