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: 
youssefsherif
Streaming Star

cant load data through a task node

how can i load data from my json file through task node here is the code for mainscene and taskreader Screenshot 2022-12-28 at 1.46.59 PM.pngScreenshot 2022-12-28 at 1.47.25 PM.pngScreenshot 2022-12-28 at 1.52.20 PM.png

0 Kudos
2 REPLIES 2
sjb64
Roku Guru

Re: cant load data through a task node

Several issues:

  • On the task you are doing everything in init(), this is render thread.  You dont define m.top.FunctionName to specify a sub to actually run on a thread.  Defeats the entire purpose of a task.
  • The task never observers or even looks at the datapath field.  You are specifying a field then hardcoding it where you would have used it.
  • The task never does anything with it's result.  You defined a dataarray field but again never used it, never assigned you result to it.  You may have intended to in line 23?
  • The mainscene never observes or references the dataarray field.

I get the impression you were trying to create onscreen objects in the task, but a task (had it been properly in a thread sub) would not be allowed to do this anyway.

If this is a one time load and render before the user sees it, you could just do it in mainscene. 

If this is a menu load system that you dont want the user to wait for, have a task with a field and update a content node array and you load "Tiles", assigning it to the field at whatever iteration group size you need.  Meanwhile observe it from render and update the tiles as the content node array as it changes.

You might be better off using a MarkupGrid if you are just trying to create a menu of custom tiles.

0 Kudos
sjb64
Roku Guru

Re: cant load data through a task node

You aren't addressing the defined fields in the task, observing the input or setting the output and observing it in the render thread, so they are accomplishing nothing being there.  You also aren't really using the task as a thread - everything is in Init (which is for a quick setup and runs on the render thread).  You never define a task level sub/function or trigger it via m.top.FunctionName in your tasks Init (which is the main purpose of the Init).

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.