This content has been marked as final.
Show 4 replies
-
1. Re: Urgent help wanted to construct IF statement
Damon Edwards Feb 8, 2008 7:38 AM (in response to OrlandoJetset)add a second request url with the relative path to the xml file. add another listener to your urlloader that listens for ioerrors, and in that listener have your urlloader load the second request. -
2. Re: Urgent help wanted to construct IF statement
OrlandoJetset Feb 8, 2008 7:52 AM (in response to OrlandoJetset)So if I understand correctly I need 2 distinct URL request variables (ie. myURLRequestOnline, myURLRequestLocal). Do I need 2 distinct URL loader variables too (ie. myURLLoaderOnline, myURLLoaderLocal), or only one that will handle both? Finally, how do you listen for i/o errors?
Thanks dzedward :-) -
3. Re: Urgent help wanted to construct IF statement
Damon Edwards Feb 8, 2008 8:02 AM (in response to OrlandoJetset)var myURLLoader:URLLoader = new URLLoader();
var myURLRequest:URLRequest = new URLRequest(" http://myserver.com/data.xml");
var myURLRequestLocal:URLRequest = new URLRequest("data.xml");
myURLLoader.addEventListener(Event.COMPLETE, dataOK);
myURLLoader.addEventListener(IOErrorEvent.IO_ERROR, ioHandler);
myURLLoader.load(myURLRequest);
function ioHandler(e:IOErrorEvent):void{
myURLLoader.load(myURLRequestLocal);
}
function dataOK(myevent:Event):void{
var myXML:XML = new XML(myURLLoader.data);
textfield1.text = myXML.mycaption[0];
textfield2.text = myXML.mycaption[1];
} -
4. Re: Urgent help wanted to construct IF statement
OrlandoJetset Feb 8, 2008 8:49 AM (in response to OrlandoJetset)OK, after reading the code a few times, i understand the flow and its very logical. (Gosh, it would have taken me a while to figure that out so thank you!)
Few questions:
1. Should one always put an eventListener for IO errors along with the COMPLETE listener?
2. Does it "listen" for both events at the same time, or is it following an order?
3. I'm assuming if it cant find the local xml either, than it will be stuck in a loop right?

