如何用海报图片替换 infoLabel 描述?

How do I replace infoLabel description with a Poster image?

我需要转换如下代码,以便 "infoLabel" 显示图片而不是文本。

此代码从字段 ID 为 'posteruri' 而不是 'description'

的 XML 字符串中读取

我有 Label/description 的工作脚本示例。我尝试转换为海报,但没有用。

我的尝试没有 return 错误,但是除了一个空白矩形之外什么也没有显示。

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

我试过简单的替换字段id,把底部的Label替换成Poster也没有用。

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

当前文本显示在 onChange 上。我想要一张图片显示 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>

您需要将 "Label" 节点替换为 "rectangle" 节点中的 "poster" 节点。 看起来你做了除此之外的所有事情。因此,您正在将 "uri" 传递给 "label" 节点,这就是您没有看到图像的原因。 我还假设您因此在调试器中遇到了一些错误。

下面是对我有用的完整代码。感谢 U.Mitic 发现了我在 PosterNode 中的错误。请记住,如果您使用场景图形模板。只有 HDPosterUrl 或 SDPosterURL 可用于字段 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> 

''''