I have this problem where my .swf is working fine on one host but doesnt work at another. The problem is that it doesnt want to show the variable txt. And the only thing i can think of is that the Xpath databinding doesnt work. Anyone got an idea what to do?
import mx.xpath.XPathAPI;
var news_xml:XML = new XML();
news_xml.ignoreWhite = true;
news_xml.load("readwrite/news.xml");
news_xml.onLoad = function(success:Boolean) {
trace("onload...");
if (success) {
trace("success...");
// Retrieve all the entry nodes
var thePath:String = "/*/news/entry";
var entryArray:Array = XPathAPI.selectNodeList(this, thePath);
//Build an array for sorting the entry nodes
var entrySortArray:Array = new Array();
var sortObj:Object;
trace("This many nodes were found: " + entryArray.length);
for(var i:Number = 0; i < entryArray.length; i++){
sortObj = new Object();
sortObj.title = entryArray*.childNodes[0].firstChild.toString();
sortObj.tid = entryArray*.childNodes[4].firstChild.toString();
sortObj.tidSec = getTIDSeconds(sortObj.tid); //convert string so you can do a numeric sort
sortObj.dateTime = entryArray*.attributes.date;
entrySortArray.push(sortObj);
}
//sort the array
entrySortArray.sortOn("tidSec", Array.NUMERIC); //sorts ascending //
//build text for display
var txt:String = "";
for(var i:Number = 0; i < entrySortArray.length; i++){
if(txt != "") txt += "
";
txt += entrySortArray*.title + " " + entrySortArray*.tid; //+ " (" + entrySortArray*.dateTime + ")";
}
trace("txt is: " + txt);
//display text
content_txt.htmlText = "poƤng" + txt;
} else {
trace("error loading XML");
content_txt.htmlText = "Error i XMLladdningen";
}
};
function getTIDSeconds(tid:String):Number{
var rv:Number = 0;
var minutes:Number = 0;
var seconds:Number = 0;
var pos:Number = tid.indexOf(":");
if(pos < 0){
minutes = Number(tid);
}
else{
minutes = Number(tid.slice(0, pos));
seconds = Number(tid.substr(pos+1));
}
rv = minutes * 100 + seconds;
//trace("getTIDSeconds for " + tid + " is " + rv);
return(rv);
}