Flash AS2,XML不接受HTML里面?

时间:2010-09-26 23:41:03

标签: xml flash actionscript-2

一个简单的as2 flash应用。正在读取XML文件。

以下是Flash AS2:

function loadXML(loaded) {
    if (loaded) {
        _root.inventor = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
        _root.comments = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
        name_txt.text = _root.inventor;
        comment_txt.text = _root.comments;
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("inventors.xml");

这是我的XML:

<?xml version="1.0"?>
<y>
    <t>
        <name>Name Here</name>
        <description>Some Html or what not in here, <b>I'm BOLD</b></description>
    </t>
    <t>
        <name>Name 2 Here</name>
        <description>Some Html or what not in here</description>
    </t>
    <t>
        <name>Name 3 Here</name>
        <description>Some Html or what not in here</description>
    </t>
</y>

问题是Flash动态文本框不会将XML(HTML)读取为HTML - 因此<b>I'm BOLD</b>标记不会以我是BOLD 的形式出现闪??我错过了什么?感谢。

1 个答案:

答案 0 :(得分:1)

我找到了!!!它有效!!

在Flash中,我需要更改变量以识别HTML:

像这样:

        name_txt.htmlText  = _root.inventor;
        comment_txt.htmlText  = _root.comments;

然后在我的XML文件中,我需要使用CDATA,如下所示:

<description><![CDATA[This is <ul><li>bold</li><li>bold</li><li>bold</li><li>bold</li></ul>]]></description>