Hey, I’m trying to get my news to pull through an xml file into a textbox. But for some reason its not loading. This script was originally used for an external page, which it then loaded into another .swf. But not I want to just use it by itself.
Any thoughts?
var scrollbar;
// set stylesheet to the text box
textbox.styleSheet = _root.stylesheet;
// get xml file name
var xmlFile = _root.xml_news;
if (xmlFile == undefined) { xmlFile = "news.xml"; }
// create array to hold news data
var a_news = new Array();
var s_news = "";
// create an xml object
var xmlNews = new XML();
xmlNews.ignoreWhite = true;
xmlNews.load();
xmlNews.onLoad = function (success) {
if (success) { loadData(xmlNews.firstChild);
} else {
_root.alert("Failed to load XML file");
}
}
function loadData (xml) {
// trace(xml_object);
// loop thru the tourdates in the xml
var xml_post = xml.firstChild; //trace(xml);
var newsString = '';
//trace(xml_object.childNodes.length);
// load data into array of xml data
for (var x = 0; x < xml.childNodes.length - 1; x++) {
date = xml_post.attributes.date;//childNodes[0].firstChild.nodeValue;
heading = xml_post.attributes.title;//childNodes[1].firstChild.nodeValue;
body = xml_post.firstChild.nodeValue;
a_news[x] = {Date: date, Heading: heading, Body: body};
// construct textbox string
newsString = newsString + '<p class="news_heading">' + heading.toUpperCase() + '</p>';
newsString = newsString + '<p class="news_date">' + date + '</p><br>';
newsString = newsString + '<p class="news_body">' + body + '</p><br>';
//trace( date + ' | ' + place + ' | ' + info + '
');
//trace (xml_show);
xml_post = xml_post.nextSibling;
}
// this.scrollbar = this.attachMovie("scrollbar", "scrollbar", this.getNextHighestDepth());
// create and assign the scrollbar
// scrollbar._x = 460;
// scrollbar._y = 12;
trace(scrollbar.setTarget);
scrollbar.setTarget(textbox);
textbox.html = true;
textbox.htmlText = newsString;
}