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: 
belltown
Roku Guru

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>
0 Kudos
parag
Visitor

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
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.