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: 
VikR0001
Visitor

Assignment Not Working?

My app has the following function:


Function Opendetailsscreen_one_time_purchase()
    print "detailsscreen_one_time_purchase"
    
    print "m.gridScreen.focusedContent:"
    print m.gridScreen.focusedContent '<==PRINTS AS EXPECTED
    
    print "m.detailsscreen_one_time_purchase.content:"
    print m.detailsscreen_one_time_purchase.content '<==PRINTS 'invalid'
    
    'show DetailsScreen Node with description, Video Player
    m.detailsscreen_one_time_purchase.content = m.gridScreen.focusedContent
    
    print "m.detailsscreen_one_time_purchase.content:"
    print m.detailsscreen_one_time_purchase.content [size=85][font=monospace]'<==PRINTS 'invalid'[/font][/size]
    
    ShowScreen(m.detailsscreen_one_time_purchase)
End Function


Here is the print output:



m.gridScreen.focusedContent:
<Component: roSGNode> =
{
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: ""
    DESCRIPTION: "my description"
    GUID: "decbe34b64ea4ca281dc09997d0f23fd"
    HDBACKGROUNDIMAGEURL: "http://www.myURL.com/myImage.jpeg"
    HDPOSTERURL: "http://www.myURL.com/myImage2.jpeg"
    RELEASEDATE: ""
    STREAMFORMAT: "mp4"
    TITLE: "My Video- ONE-TIME PURCHASE"
    URL: "http://www.myURL.com/myVideo.mp4"
}

m.detailsscreen_one_time_purchase.content:
invalid

m.detailsscreen_one_time_purchase.content:
invalid

`m.gridScreen.focusedContent` is valid. It's assigned to `m.detailsscreen_one_time_purchase.content`. Why is `m.detailsscreen_one_time_purchase.content` invalid after the assignment?

Thanks very much in advance to all for any info!
0 Kudos
5 REPLIES 5
joetesta
Roku Guru

Re: Assignment Not Working?

what kind of object is "m.detailsscreen_one_time_purchase" ?
My guess is it does not have a field "content" and you'd need to add that field one way or the other.
aspiring
0 Kudos
VikR0001
Visitor

Re: Assignment Not Working?

detailsscreen_one_time_purchase is a <Component: roSGNode>. You are quite right -- it doesn't have field 'content'.  In looking at other Brightscript code, it seemed like you create a variable by assigning a value to it. I'm a Brightscript newbie. What is the correct way to add the field `content` to a  <Component: roSGNode>?
0 Kudos
joetesta
Roku Guru

Re: Assignment Not Working?

https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeField#ifSGNodeField-addField(fieldNameasString,typea...
addField(fieldName as String, type as String, alwayNotify as Boolean) as Boolean


So I think you can do this as soon as m.detailsscreen_one_time_purchase gets created:
m.detailsscreen_one_time_purchase.addField("content","Node",true)


then it will have content field available, via m.top.content from internally and via m.detailsscreen_one_time_purchase.content externally.
hope it helps,
Joe
aspiring
0 Kudos
joetesta
Roku Guru

Re: Assignment Not Working?

PS: many pre-defined components have a "content" field built in (rowlist is one example) so perhaps you'd rather consider changing the type of your node to one that has content already.  Also take a look at generic "contentNode" as that comes with a bunch of pre-defined fields you can use (although afaik "content" is not one) - generally "content" fields are made up of a Node with a bunch of child contentNodes.
aspiring
0 Kudos
VikR0001
Visitor

Re: Assignment Not Working?

Thanks very much for this great info, @joetesta!
0 Kudos