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

Required Task node Function calls only once

I created one task node. and use the below code To execute the Task node. Here, My updateFunction() calls Average 10 times. and I required a task node calls only a single time.

function on updateFunction()
     m.Tasknode = CreateObject("roSGNode", "Tasknode")
     m.Tasknode.control = "RUN"
end function

I tried to call using a flag. like below. The first time It's successfully handled. But when I moved that component again that component calls Average 3-4 times. I tried to call using a flag. like below. The first time It's successfully handled. But when I moved that component again that component calls Average 3-4 times. So Second Times It's not working. I should run in init() is true but I get data in this function. how many times the function is called. It's doesn't matter. But, the task node should be called only once. Is it possible?

sub init()
     m.flag = 0
end sub

function on updateFunction()
     if m.flag = 0 then
          m.Tasknode = CreateObject("roSGNode", "Tasknode")
          m.Tasknode.control = "RUN"
          m.flag = 1
     end if
end function
0 Kudos