Various types of content material can be downloaded from your server to a Scene Graph application. Many of the renderable nodes include a
uri field that allows you specify the URI of a graphical image file or other content on your server. Setting this field causes the node to automatically download the content to the Scene Graph node, and for graphical images, be rendered on the display screen according the configuration of the node.
For many nodes that require more complex data, a
content field is provided. This special field is designed to be assigned the value of a ContentNode node that you configure to contain the data required for the node. The ContentNode node can be configured in a Task node when you want to download the data in the ContentNode node from your server.
In a Task node, you can use the BrightScript roUrlTransfer component to read the content data from your server. If the data is contained in JSON or XML formats, you can then use the corresponding BrightScript parsing functions and components to configure a ContentNode node with the content data. The BrightScript JSON/XML parsing loop should be set up to terminate when the Task node <interface> field for the target ContentNode node is fully configured with new data, to allow an
observeField() function set in the component that requires the data to trigger a callback function to assign the data to the target node.
For example, the following Task node downloads a list of strings to be used as text for a LabelList node. The Task node includes two <interface> fields, one for the URI of the content data (
uri), and another for the ContentNode node that will be configured with the data (
content). When an XML component requires a list of strings for a LabelList node, the component can set the
control field of the Task node object to
RUN. This sends the specified <interface> field values to the Task node, one the ContentNode node object reference, the other the URI of the content data, and starts the Task node. The Task node then downloads an XML file with the content data from the specified URI, parses the XML data, and creates a parent ContentNode node and child ContentNode nodes for each string. When the ContentNode node is configured with all the strings in the XML file, it is assigned to the ContentNode object reference set in the component file as the content <interface> field. This triggers the
observeField() callback function to add the strings to the LabelList node