20Oct/091
Converting Binary String to ByteArray
While using HTML/JavaScript in air, I have found no way of getting the Air-Ajax functionalities to run in synchronous mode. For this reason we are forced to manage certain upload / download functionality using the XMLHTTPRequest object available via Javascript.
However, one quickly runs into problems trying to write binary strings requested in this fashion, to the local file system. Write operations for binary files need to be passed a flash ByteArray object that contains the data.
Here is how to convert a JavaScript binary string to a ByteArray, ready for use with file IO functionality in Adobe Air:
string2byteArray=function(str){
var ba=new air.ByteArray();
for(var i=0;i<str.length; i++){
ba.writeByte(str.charCodeAt(i));
}
return ba;
}
Hope this helps some.

June 15th, 2010 - 13:38
Thank you man.. this was exactly what I was looking for.