How to define a function in component interface on Roku(BrightScript/SceneGraph)

umitic

Uros Mitic

Posted on March 29, 2018

How to define a function in component interface on Roku(BrightScript/SceneGraph)

If you have custom component named "doWhateverScreen" and you would like to print a string passed down from a different component named "HomeScene" using function in "doWhateverScreen" component interface, this is how you would do it.

First in your doWhateverScreen.xml file add:

    <interface>
        <function name="doWhateverMan" />
    </interface>
Enter fullscreen mode Exit fullscreen mode

Now in doWhateverScreen.brs file add your "doWhateverMan" function:

    Function doWhateverMan(param as String)
        print param
    End Function
Enter fullscreen mode Exit fullscreen mode

Great, so far so good!Let us continue.
In your HomeScene.xml add this custom created "doWhateverScreen" screen/component and in HomeScene.brs init() function add:

    m.doWhateverScreen= m.top.findNode("doWhateverScreen")
Enter fullscreen mode Exit fullscreen mode

We can now call a function named "doWhateverMan" from HomeScene.brs with:

    param = "Do Androids Dream of Electric Sheep?"
    m.doWhateverScreen.callFunc("doWhateverMan",param)
Enter fullscreen mode Exit fullscreen mode

That's it! Have a great day. :-D

💖 💪 🙅 🚩
umitic
Uros Mitic

Posted on March 29, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related