Hi ,
I am loading an external xml file i.e “file2.xml” which contains the names and places and i am retrieving the xml data into array. i have no problem for loading the file .But my problem is when loading the file i have given file wrong name as"file5.xml" ,i got an error as shown below
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: file:
what i need is instead of avoiding the error what i have to put in try catch block so that the below cases should be solved
1.when there is no xml file found and
2. when the file name was given wrong…
and i have to show a message saying “Unable to load game. Please try later”
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, XMLLoaded);
loader.load(new URLRequest(“file5.xml”));
function XMLLoaded(e:Event):void
{
var xml:XMLDocument = new XMLDocument();
xml.ignoreWhite = true;
xml.parseXML(loader.data);
for(var i:int = 0; i < xml.firstChild.childNodes.length;i++)
{
var names:Object = xml.firstChild.childNodes*.attributes;
nameArray.push(names.name);
}
}
please recorrect my code with appropriate code i.e try catch blocks where ever needed