Hi, I am new to attempting to get data from an xml file load in flash. I
followed a tutorial in a new fla and it seemed to work fine, I then tried to
adapt it to my own needs which worked fine. But then when trying to implement
this into my news section it doesn't seem to work.
I am trying to make a news section, that displays the date and news article.
This is in within a movie clip, I even tried putting it in the timeline of the
scene but still nothing.
- I have 2 dynamic text boxes, date_txt and news_txt
- The xml file is named news.xml,
- both the fla and the xml are in the same folder
This is the actionscript I am using:
function loadXML(loaded) {
if (loaded) {
_root.thedate =
this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.thenews =
this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
date_txt.text = _root.thedate;
news_txt.text = _root.thenews;
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("news.xml");
This is what I have in the xml document:
<?xml version="1.0"?>
<news>
<article>
<date>date</date>
<news>newentry.</news>
</article>
<article>
<date>Doug Engelbart</date>
<news>Invented the mouse at the Stanford Research Institute</news>
</article>
</news>
Does anyone perhaps have any ideas of what the problem could be?
Help much appreciated.
The Feldkircher - 28 Jan 2008 14:08 GMT
Hi
_root refers to the Main Timeline, if your date_txt and news_txt are in a
movieclip ie: news_mc
then your path should read _root.news_mc.date_txt.text and
_root.news_mc.news_txt.text
You will also need to embed the characters you wish to use inside your dymanic
text for it to show.
Hope it helps