views:

10

answers:

1

A simple as2 flash app. that is reading an XML file.

Here is the 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");

And here is my 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>

The problem is that the flash dynamic text box will not read the XML (HTML) as HTML -- so the <b>I'm BOLD</b> tag doesn't come through as I'm BOLD in flash?? What I'm I missing?? Thanks.

+1  A: 

I found it!!! And it works!!

In Flash I need to change the variables to recognize HTML:

Like so:

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

Then in my XML file, I needed to use CDATA, like so:

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