Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
belltown
Level 7

Re: Copy of Brightscript object being created when using assignment operator.

"parag" wrote:
Can I replace an array or list with a node/ContentNode? I have got most of it working, except I am still copying the array and would like to use a reference instead.

That would be a good idea.

It may be worth noting that you can put anything you want in a ContentNode, by extending it and adding your own fields. That will give you access to all the content item properties of the ContentNode, in addition to any properties you want to add.

For example, I have a content list, which consists of a list of items that extend a ContentNode.

<?xml version="1.0" encoding="UTF-8"?>

<component name="ContentItem" extends="ContentNode">
 <interface>
   <field id="field1" type="string" />
   <field id="field2" type="string" />
 </interface>
</component>



<?xml version="1.0" encoding="UTF-8"?>

<component name="ContentList" extends="ContentItem">
 <children>
   <ContentItem field1="Item-1" field2="Field-2" TITLE="Title-1" URL="http://url.com/1" />
   <ContentItem field1="Item-2" field2="Field-2" TITLE="Title-2" URL="http://url.com/2" />
 </children>
</component>
https://github.com/belltown/
0 Kudos
parag
Level 7

Re: Copy of Brightscript object being created when using assignment operator.

Thanks again. I understand that I can put anything in the ContentNode, but it seems to work to replace an associative array rather than an array/list where you don't have key/value pairs. So, if I am dynamically creating an array using a contentNode, I would just create random keys and keep adding them using 'addField'? Do you see any issue?

Also, is you don't know the keys, is there a way to iterate through all the keys or simply get an array of all values like a map in java?
0 Kudos