2010-09-26 63 views
0

简单的as2 Flash应用程序。那就是读取一个XML文件。Flash AS2,XML里面不接受HTML?

这里是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

我发现了!它的工作原理!

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