Hello all,
I am having an odd problem can’t figure out what is going on. Basically, it’s a news ticker pulling news from an XML. Some items have a URL, some don’t. Obviously, I’d like the getURL to be invoked only when there is a URL present. What I’ve done is set up an If… Else to see if the URL node is “missing”. The problem is, even though it works fine, the getURL is still active and goes to the last URL present. I’m not sure what’s going on. Here is the truncated code:
[AS]
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
caption = [];
url = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
caption* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
url* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
test_txt.text = "XML loaded";
}
first_item();
} else {
content = "file not loaded!";
test_txt.text = "XML not loaded";
}
}
//chopped various XML stuff
function display(pos) {
newsMC.newsText.text = caption[pos];
var tester:String = url[pos];
if (tester == "missing")
{
trace("URL Missing"); //let's me know that the URL is missing
} else {
trace("URL exists"); //this is working
newsMC.onRelease = function() {
getURL(url[pos], "_new"); //here's the getURL
}
}
}
[/AS]
Here’s what the XML looks like.
<newsItems>
<item>
<news>Item #1</news>
<url>http://www.google.com</url>
</item>
<item>
<news>Item#2 </news>
<url>missing</url>
</item>
</newsItems>