Flash 动态文本无法处理 HTML 标签

Flash Dynamic Text can't Handle HTML Tags

我有一个 flash 电影,它使用一个简单的函数从 XML 文档中读取其源代码:

nav_text.text = navText;

将 nav_text 作为动态文本实例(选择 HTML 呈现文本),将 navText 作为定义的变量。

在XML文档中,如果我写

    <navigation
         text="Please use the arrows either side of the picture to navigate through this slide show."
        />

然后 SWF 影片会完全按照所写的显示文本。但是,如果XML文档写成:

 <navigation
         text="<i>Please use the arrows either side of the picture to navigate through this slide show.</i>"
        />

然后 SWF 只在文本框中显示 'undefined'。

知道我可能做错了什么吗?

奇怪的是它显示为未定义,但或许可以尝试使用 htmlText 属性 而不是文本?

http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001601.html

您的问题是因为您在 XML 属性中使用了 HTML 标签( navigation.text 中的 <i></i> ),它们被解释为 XML 标记,这就是为什么你什么也得不到的原因,因为 XML 数据解析被破坏了。因此,为避免该问题,您必须使用 HTML entities(名称或编号)转义这些标签:

  • <i> => &lt;i&gt;&#60;i&#62;.
  • </i> => &lt;/i&gt;&#60;/i&#62;.

这对于XML属性,对于XML元素,可以使用CDATA.

然后,加载 xml 数据后,您可以:

text_field.html = true;
text_field.htmlText = your_xml_data;

希望能帮到你。