Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / January 2008



Tip: Looking for answers? Try searching our database.

Loading data from xml file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sammyfb - 27 Jan 2008 03:11 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.