PDA

View Full Version : xml load problem



patrickjv
October 21st, 2009, 04:57 PM
I’m stumbling upon a strang phenomena. Locally my file works ok every time, only from server it behaves completely weird.

I have a xml mp3 player which loads xml data from file. But from server it get’s stuck not loading the xml file properly. And I’ve noticed that many times if I first view the xml file in browser then after that when viewing the html/swf file it DOES load properly.


code of the xml part;


public var myXML:XML
public var mySongs:XMLList;
public var loader = new URLLoader();
public var urlreq:URLRequest;

then it should load the xml file name from variable xmlmusicdatafile into a loader


urlreq = new URLRequest(xmlmusicdatafile);
loader.load(urlreq);
loader.addEventListener(Event.COMPLETE, setinit);
loader.addEventListener(ProgressEvent.PROGRESS, showxmlloadprogress);

If I trace(loader) right after .load it does trace [object URLLoader] but neither function setinit() nor function showxmlloadprogress() is being executed. It hangs on loading the xml file.


The xml code by the way is simple
<?xml version="1.0" encoding="utf-8"?>
<musiclist>
<musicitem>
<itemname>life-is-creative-patrick-jansen.mp3</itemname>
<title>life is creative</title>
<artist>Patrick Jansen</artist>
<album />
<link>http://marketplace.envato.com/user/patrickjansen/portfolio</link>
</musicitem>
</musiclist>
If anybody has any clue or idea i’d appreciate it.

I’m stuck in a black hole of knowing the xml load action has been triggered but the xml file never really started loading (showxmlloadprogress never starts tracing anything)


Any suggestions?
P.

patrickjv
October 21st, 2009, 05:40 PM
For those interested in testing it on server... check test file (http://www.patrickjansen.net/test/player2.zip)

final_end
October 21st, 2009, 05:52 PM
i see this function in your class, public function createmyXML(), that is what parses your xml, and its not getting called. you will want to run that once the xml is loaded, so something like this,


public function createmyXML(){

myXML.ignoreWhitespace = true;
mySongs = myXML.musicitem;
totalitems = mySongs.length();
//tst2.aaa.text = "checkpoint 5"
}
//---------------------------------

public function setinit(event:Event):void {
tst2.aaa.text = "checkpoint 5"
xmlisloaded = true;
// create the loaded XML
myXML = new XML(loader.data);
createmyXML(myXML);
}


it looked like your loader.data call was in the wrong place, i mean as far as how i usually set things up. that should fire when the xml is loaded, which is your setinit() function

final_end
October 21st, 2009, 05:56 PM
sorry your createXML function needs to stated like this

public function createmyXML(data:XML):void {

micken
October 21st, 2009, 06:00 PM
Maybe you're getting an IO error? Try adding a listener for IOErrorEvent.IO_ERROR to your loader


loader.addEventListener(IOErrorEvent.IO_ERROR, myErrorCallback);

patrickjv
October 21st, 2009, 08:45 PM
@ final_end: createXML doesn't require any arguments, that's why it's blank. And yes, it's included in the setinit() function... i merely stripped it since it's not even getting triggered. That's because Event.COMPLETE and ProgressEvent.PROGRESS don't initiate.

@micken: I tried adding that, see new zip I uploaded, don't get any error.

Everything works fine locally on disk, but the problem is on a server. Could anybody try that? Will be much appreciated.

P.