I've been working on an app running in a browser and I would like to try to convert it to an AIR one.
In my web app, after loading the document, I am loading a text file in a string with jquery.
var info;
$.get('media/info.txt',function(data) {
info=data;
alert("the info is "+info.length+" bytes long");
});
In my AIR app, after loading the document locally, I am loading the SAME text file (but here hosted locally with the AIR app) in a string with the AIR file API.
var info;
var file=air.File.applicationDirectory.resolvePath("media/info.txt");
var filestream=new air.FileStream();
filestream.addEventListener(air.Event.COMPLETE, function() {
info=filestream.readUTFBytes(filestream.bytesAvailable);
alert("the info is "+info.length+" bytes long");
});
filestream.openAsync(file, air.FileMode.READ);
The two alerts above give me two different values for the same file, whereas my app's working well in a browser, the AIR info is bigger and seems to introduce some untrackable characters that broke my app!
I guessed this may have to do with the reading method used in AIR (UTF shit) but I cannot find another reading that actually worked.
Can someone give me a hint to get the same data in both cases?