I need to convert a code like the following so that "infoLabel" will show a picture instead of text.
This code reads from an XML string that had a field id of 'posteruri' instead of 'description'
I have and example of the working script with the Label/description. And my attempt to convert to a poster, which does not work.
My attempt doesn't return an error, however nothing shows but a blank rectangle.
<?xml version="1.0" encoding="utf-8" ?>
<component name="categoryinfoPanel" extends="Panel" >
<interface>
<field id="description" type="string" onChange="showdescription" />
</interface>
<script type="text/brightscript" >
<![CDATA[
sub init()
m.top.panelSize = "medium"
m.top.focusable = true
m.top.hasNextPanel = true
m.infolabel = m.top.findNode("infoLabel")
end sub
sub showdescription()
m.infolabel.text = m.top.description
end sub
]]>
</script>
<children>
<Rectangle
id = "infoRectangle"
translation = "[0,40]"
height = "420"
width = "520"
color = "0x00000099" >
<Label
id = "infoLabel"
translation = "[15,15]"
height = "595"
width = "510"
wrap = "true"
font = "font:MediumBoldSystemFont" />
</Rectangle>
</children>
</component>
I have tried simply replacing the field id, and replacing Label with Poster at the bottom to no avail.
<?xml version="1.0" encoding="utf-8" ?>
<component name="categoryinfoPoster" extends="Panel" >
<interface>
<field id="posteruri" type="string" onChange="showdescription" />
</interface>
<script type="text/brightscript" >
<![CDATA[
sub init()
m.top.panelSize = "medium"
m.top.focusable = true
m.top.hasNextPanel = true
m.infoposter= m.top.findNode("infoPoster")
end sub
sub showdescription()
m.infoposter.uri = m.top.poster
end sub
]]>
</script>
<children>
<Rectangle
id = "infoRectangle"
translation = "[0,40]"
height = "420"
width = "520"
color = "0x00000099" >
<Label
id = "infoPoster"
translation = "[15,15]"
height = "400"
width = "510" />
</Rectangle>
</children>
</component>
Currently text shows up onChange. I would like for an image to show up onChange
.
<?xml version="1.0" encoding="utf-8" ?>
<component name="categoryinfoPoster" extends="Panel" >
<interface>
<field id="posteruri" type="string" onChange="showdescription" />
</interface>
<script type="text/brightscript" >
<![CDATA[
sub init()
m.top.panelSize = "medium"
m.top.focusable = true
m.top.hasNextPanel = true
m.infoposter= m.top.findNode("infoPoster")
end sub
sub showdescription()
m.infoposter.uri = m.top.poster
end sub
]]>
</script>
<children>
<Rectangle
id = "infoRectangle"
translation = "[0,40]"
height = "420"
width = "520"
color = "0x00000099" >
<Poster
id = "infoPoster"
translation = "[15,15]"
height = "400"
width = "510" />
</Rectangle>
</children>
</component>
You need to replace "Label" node with "poster" node in "rectangle" node. It looks like You did everything except that. So You are passing "uri" to a "label" node and that's why you did not see the image. I also assume that You got some error in the debugger because of it.
Below is the full code that worked for me. Thanks to U.Mitic for catching my error in the PosterNode. And remember if you use scenegraph templates. Only HDPosterUrl or SDPosterURL will work for poster in the field ID.
''''
<component name="categoryinfoPoster" extends="Panel" >
<interface>
<field id="hdposterurl" type="string" onChange="showdescription" />
</interface>
<script type="text/brightscript" >
<![CDATA[
sub init()
m.top.panelSize = "medium"
m.top.focusable = true
m.top.hasNextPanel = true
m.infoposter= m.top.findNode("infoPoster")
end sub
sub showdescription()
m.infoposter.uri = m.top.hdposterurl
end sub
]]>
</script>
<children>
<Rectangle
id = "infoRectangle"
translation = "[0,40]"
height = "420"
width = "520"
color = "0x00000099" >
<Poster
id = "infoPoster"
translation = "[15,15]"
height = "400"
width = "510" />
</Rectangle>
</children>
</component>
''''
User contributions licensed under CC BY-SA 3.0