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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Roku Guru

call component function only possible via interface?

When a component defines some function via <source> tag or inline. How can I call a function of the script in the context of the component?

Seems I can only do that by changing an interface fiel and register an onChange callback, correct?
0 Kudos
Roku Guru

Re: call component function only possible via interface?

0 Kudos
Binge Watcher

Re: call component function only possible via interface?

I think you mean the <script> tag, and you should be able to call any of the functions in an included .brs file in your init, and while an observed field is, I think, necessary to initially call a function within an included file, I believe that called function should be able to call anything else within files included via the script tag. So if your onChange callback is a function named "DoSomething" -

function DoSomething()
print "something"
end function

function DoSomethingElse() as integer
print "something else"
return -1
end function

0 Kudos
Roku Guru

Re: call component function only possible via interface?

Hi Joel,
thanks for your answer, but that was not, what I meant:

Let's take this example script of a Vd


<script type="text/brightscript" >

sub init()
end sub

function setVideo() as void
videoContent = createObject("RoSGNode", "ContentNode")
videoContent.url = ""
videoContent.title = "Test Video"
videoContent.streamformat = "hls" ="musicvideos") = videoContent = "play"
end function


My question is, whether I can call setVideo() from somewhere else then the init() or an onChange-Callback which changes, when the intefacefield changes.

So instead of this:

node.myInterfaceField = {url: ....} ' // trigger setVideo

do this:

node.setVideo({url: ....}) ' //

I am probably talking about having "interface functions".
at the moment it seams I have to have interface fields in order to trigger functions..
0 Kudos