Copy link to clipboard
Copied
Hi,
I have an app (Android & IOS) that contains an XML file (embedded with Adobe Flash in settings) that my app uses for showing data to the user.
I've made a function that compares the xml file embedded in the app with an xml file on my server
var packagedFile:File = File.applicationDirectory.resolvePath( "soleil.xml" );
var destFile_soleilXML:File = File.
applicationStorageDirectory.
resolvePath( "soleil.xml" );var url_local_soleil:URLRequest = new URLRequest("soleil.xml");
loader_local.load(url_local_soleil);
var url_online_soleil:URLRequest = new URLRequest("http://mywebsite.com/soleil.xml");
loader_online.load(url_online_soleil);
function loader_local_Complete(e:Event):void{
size_of_horaires_local = URLLoader(e.target).bytesTotal;
}
function loader_local_soleil_Complete(e:Event):void{
size_of_soleil_local = URLLoader(e.target).bytesTotal;
}
function check_if_size_different():void{
if(size_of_horaires_local == size_of_horaires_online){
//if same size, copy the actual xml file into a specific folder
packagedFile.copyTo( destFile_soleilXML );
}else{
// copy the xml of my server into a specific folder (will do later)
}
I didn't do the part where the app copy and read the xml file that as been downloaded yet. I've tried, at first, to load the embedded xml file that I moved to a specific folder (see line 21) but when I want to load my xml file to show the data to the user :
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest(destFile_soleilXML));
myLoader.addEventListener(Event.COMPLETE, processSoleil);
function processSoleil(e:Event):void {
myXML = new XML(e.target.data);
var results:XMLList = myXML.row.(date == mySavedData.data.theDate);
if(results.length()){
for each(var row:XML in results){
//doingstuff
}
}
}
I've got an error :
Error #2032: Unhandled ioError:. text=Error #2032: Stream Error. URL: app:/data/user/0/air.nc.cocogeek.mareeNC/nc.cocogeek.mareeNC/Local%20Store/soleil.xml
Any idea why ?
Copy link to clipboard
Copied
The stream-error means that the file can't be found.
To access an embedded file, you have to look in the applicationDirectory instead of the applicationStorageDirectory.
More info here: File - Adobe ActionScript® 3 (AS3 ) API Reference