• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How to pull XML into Flash

icklejez

Member
Okay, so I have a basic flash file with a button, when you hover over it, an object with dynamic text appears...

Now I want text from an XML file to be pulled from it into my dynamic text box...

this is what my code in my actionScript looks like so far...

function DisplayInfo()
{
var title = items.firstChild;
var items = channel_xml.firstChild.firstChild.childNodes;
box.text1.text = title.firstChild.firstChild.nodeValue;

menu_md._visible = false;
box._visible = true;
box.text1.text = this.location_text;
}

button1.onRollOver = DisplayInfo;

box.closeButton.onRelease = function()
{
menu_md._visible = true;
box._visible = false;
box.text1.text =

Its this part I cant figure out...

Code:
{
    var title = items[i].firstChild;
    var items = channel_xml.firstChild.firstChild.childNodes;
    box.text1.text = title.firstChild.firstChild.nodeValue;
   
    menu_md._visible = false;
    box._visible = true;
    box.text1.text = this.location_text;
}

My XML looks like this:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
    <title>
    Travel Warnings
    </title>
        <link>
        [url="http://travel.state.gov/travel/cis_pa_tw/tw/tw_1764.html"]http://travel.state.gov/travel..._pa_tw/tw/tw_1764.html[/url]
        </link>
            <description>
            TEXT HERE
            </description>
</channel>
</rss>

Anyone know how to simply grab the info in the description tags and whack it in my dynamic text field?
 
unfortunately because you have the xml and rss stating tags you have more than 1 firstChild to get through.
So going from your items XML var it looks like:

items.firstChild.firstChild.childNodes[2].firstChild.nodeValue

if your familiar with XPATH you might want to look into using the XPATH class for flash:
http://www.xfactorstudio.com/ (a very robust implementation)

http://www.flash-mx.com/faq/xp...pi.selectnodelist.html (the Flash embedded implementation if you are using MX 2004 pro+)
 
Hmmm, okay then, several different tags to penetrate...

Still confused as to what I must declare against what, would it be:?

function DisplayInfo()

{
var title = items.firstChild.firstChild.childNodes[2].firstChild.nodeValue

var items = channel_xml.firstChild.firstChild.childNodes;

box.text1.text = title

menu_md._visible = false;
box._visible = true;
box.text1.text = this.location_text;
}
 
well what is the variable the XML is being loaded into?
i.e.

var myXML:XML = new XML();
var link:String = "";
var title:String = "";
var description :String = "";
var channel:XMLNode;
myXML.onload = function(success) {
if(success) {
channel = myXML.firstChild.firstChild.childNodes;
description = myXML.firstChild.firstChild.childNodes[2].firstChild.nodeValue;
link = myXML.firstChild.firstChild.childNodes[1].firstChild.nodeValue;
title = myXML.firstChild.firstChild.childNodes[0].firstChild.nodeValue;
}
}
myXML.load('file.xml');
 
Back
Top