I know I'm mostly talking to myself here, but here's the solution I came up with :D
'Create a row of content '
function createRow(list as object, num as Integer)
print "Parser.brs - [createRow]"
Parent = createObject("RoSGNode", "ContentNode")
row = createObject("RoSGNode", "ContentNode")
row.Title = list[num].Title
fullContentList = list[num].ContentList
' Clone the content list '
copyContentList = []
for each thingToClone in fullContentList
copyContentList.push(thingToClone)
end for
' Loop through the content list to create a single video node '
for each itemAA in fullContentList
Playlist = createObject("RoSGNode", "ContentNode")
Playlist.title = itemAA.title
Playlist.description = itemAA.description
Playlist.hdposterurl = itemAA.hdposterurl
Playlist.sdposterurl = itemAA.sdposterurl
Playlist.hdBackgroundImageUrl = itemAA.hdBackgroundImageUrl
' Loop through the cloned content list, to create the playlist of other vids in the category '
for each itemAA2 in copyContentList
item2 = createObject("RoSGNode","ContentNode")
item2.url = itemAA2.url
Playlist.appendChild(item2)
end for
' Remove the first item in the list and put it at the end. '
' This makes the 1st video in the playlist the one thats showing its title '
shiftedItem = copyContentList.shift()
copyContentList.push(shiftedItem)
row.appendChild(Playlist)
end for
Parent.appendChild(row)
return Parent
end function
The issue I had was the objects are passed by reference, as I suspected. So I cloned the object (is there a built-in function that does that?) and did a shift() and push() to reorder the playlist. This seems pretty clunky to me, so if anyone runs across this and has a better idea, please let me know!