Accessing RowList component item element

Hello,

In the RowList I am trying to access the itemComponentName specific focused item. I am creating Poster elements inside. I need to access to Poster and do something like this:

m.videoElm = m.Poster.createChild(“Video”)
m.videoElm.width = “400”
m.VideoElm.height = “280”

The problem I can’t do onFocus inside itemComponent xml file, I need to access the Poster element from outside. How would I do that?

Thank You!

This is one way;

Poster_element_from_outside = m.top.findNode("PosterElementID")

https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeDict#ifSGNodeDict-findNode(nameasString)asObject

Obviously you need to switch in the actual ID of your poster element (and assign an ID if it doesn’t have one yet), and probably make a better (shorter) var name for the left side of the equation.

I am guessing the id of that Poster id element needs to be unique. How would I assign a unique value inside the custom.xml file?

I need to some how to declare a variable outside then pass it over so it could increment…

Thanks

You can set it in the component definition in the XML;
https://sdkdocs.roku.com/display/sdkdoc/XML+Components

Or after the fact in your brightscript code;

mything = CreateObject(“roSGNode”, “Poster”)
mything.id = “mything_id”

I need to some how to declare a variable outside then pass it over so it could increment…

That sounds like something you’d want to use a field and an observer for.
https://sdkdocs.roku.com/display/sdkdoc … lueChanges

It sounds like I need to create the RowList component dynamically (using script) instead of using an XML file. Is there an example how this be done?

This way I have access everything within the same function without jumping around…?

Thank You

“joetesta” wrote:
This is one way;

Poster_element_from_outside = m.top.findNode("PosterElementID")

https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeDict#ifSGNodeDict-findNode(nameasString)asObject

Obviously you need to switch in the actual ID of your poster element (and assign an ID if it doesn’t have one yet), and probably make a better (shorter) var name for the left side of the equation.
This didn’t work. I assigned the Poster a unique id value. I verified its assigned within component xml file.
But when I try to access it onFocus event
Poster = m.top.findNode(“Poster1”)
gives me “invalid”, any other solutions.

“slingxshot” wrote:
Poster = m.top.findNode(“Poster1”)
gives me “invalid”
Sounds like the element with id “Poster1” is just not attached to the current hierarchy? Check what’s m and m.top in that context, see if the poster is hanging where it should be in the tree. Also case-sensitivity (i don’t think it is) of ID?

“EnTerr” wrote:

“slingxshot” wrote:
Poster = m.top.findNode(“Poster1”)
gives me “invalid”
Sounds like the element with id “Poster1” is just not attached to the current hierarchy? Check what’s m and m.top in that context, see if the poster is hanging where it should be in the tree. Also case-sensitivity (i don’t think it is) of ID?
i am using this example as a guide
https://github.com/rokudev/hero-grid-channel
Everything displays and functions correctly thought.

I believe m.top is HeroScreen … is that wrong.. how else would I access RowList Poster… from HeroScreen component

So I was doing some experiments…

So basically the component for the RowList is just a loop. So when I create the Post Element with a specific id, doesn’t it just get overwritten over and over… it seems like it is a temporary item…

correct me if I am wrong