I am currently using the news ticker displayed at this site
My question has to do with showing (or not showing) XML entries that have an expiration date set to them. For example here’s my XML file.
<?xml version="1.0" encoding="iso-8859-1"?>
<images>
<item>
<news>Join Super Oldies 105.5 for a special Indianapolis Colts...</news>
</item>
<item>
<news>...sports broadcast, Friday, September 2nd at 6:30PM!</news>
</item>
<item>
<news>Bloomington Speedway's Chuck Welsh (Click for more)</news>
<url>http://www.superoldies.net/news/</url>
<expire>08/31/2005</expire>
</item>
<item>
<news>Listen to Mitchell Bluejacket Sports all season long...</news>
<url>http://www.superoldies.net/sports/#mitchell</url>
</item>
<item>
<news>...on Super Oldies 102.5 WQRJ!</news>
<url>http://www.superoldies.net/sports/#mitchell</url>
</item>
<item>
<news>Join Super Oldies at D&D 37 One Stop...</news>
<url>http://www.superoldies.net/summertime/</url>
</item>
<item>
<news>...for the 6th Annual Super Oldies Cruise-In...</news>
<url>http://www.superoldies.net/summertime/</url>
</item>
<item>
<news>...Friday, September 9th from 4PM to 8PM</news>
<url>http://www.superoldies.net/summertime/</url>
</item>
<item>
<news>Listen to Mike Harvey's Super Gold...</news>
<url>http://www.superoldies.net/shows/#supergold</url>
</item>
<item>
<news>...every Saturday night on Super Oldies!</news>
<url>http://www.superoldies.net/shows/#supergold</url>
</item>
</images>
You can see that the third entry has an expiration date set for August 31st. Since it is September 1st the flash file would pull the XML data and not show this entry.
Here is the code as it stands in my flash file:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
caption = [];
url = [];
expire = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
caption* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
url* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
expire* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
}
first_item();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://www.superoldies.net/news.xml?blarg="+new Date().getTime());
//
function first_item() {
delay = 3000;
p = 0;
display(p);
p++;
}
function timer() {
myInterval = setInterval(ticker, delay);
function ticker() {
clearInterval(myInterval);
if (p == total) {
p = 0;
}
fadeout();
}
}
function display(pos) {
over = new TextFormat();
over.underline = true;
//
out = new TextFormat();
out.underline = false;
//
newsMC.newsText._alpha = 100;
newsMC.newsText.text = caption[pos];
newsMC.onRelease = function() {
getURL(url[pos], "_self");
};
newsMC.onRollOver = function() {
this.newsText.setTextFormat(over);
};
newsMC.onRollOut = function() {
this.newsText.setTextFormat(out);
};
timer();
}
function fadeout() {
this.onEnterFrame = function() {
if (newsMC.newsText._alpha>=0) {
newsMC.newsText._alpha -= 5;
} else {
display(p);
p++;
delete this.onEnterFrame;
}
};
}
What I’m needing is an IF statement that will look to see if anything is set in <expire>, compare it to todays date, and choose whether or not the entry is displayed.
Can someone help me out with this?