Showing posts with label air. Show all posts
Showing posts with label air. Show all posts

Wednesday, September 14, 2011

Adobe Air: Problem while reading „ and “

Solution: use UTF-32 encoding
var fs:FileStream = new FileStream();
fs.open(,FileMode.READ);
var string:String = fs.readMultiByte(fs.bytesAvailable, "UTF-32");

Sunday, September 11, 2011

Air: change / specify runtime location of air application [way to run air application in machine with out runtime installation]

Only way is to use adl.exe while running your applicaiton. With normal installer you cannot do so. So idea is to 1)use a bat file to manually specify your applicaiton.xml location and adobe run time location.
2) If you do'nt like console then  wire a program for you own that does what bat file does but with out console visible. I have written such program in c++. If you need it just leave a comment .

Friday, September 9, 2011

adobe air :: File handling

  • The static properties included in File class :
File.applicationStorageDirectory  A unique storage directory unique for each installed AIR application
File.applicationDirectory  Directory where the application is installed and it is read only
File.desktopDirectory  Desktop directory of the User
File.documentsDirectory  Documents directory of the user
File.userDirectory  User Directory
  • saving file:
  1. var bytearray:ByteArray = new ByteArray();
  2. var fileToCopy:File = new File("url of file");
  3. var newFile:File = new File("url of file to be created");
  4. var fileStream:FileStream = new FileStream();
  5. fileStream.open(file,FileMode.READ);
  6. fileStream.readBytes(bytearray);//getting bytes
  7. var newFileStream :FileStream = new FileStream()
  8. newFileStream.openAsync( newFile, FileMode.WRITE );
  9. newFileStream.writeBytes(bytearray);//filling bytes
  10. newFileStream.close();
  • Updating file
public function update(value:String,url:String,startIndex:int = 0):void
{
   var file:File = new File(url);
   var fs:FileStream = new FileStream();
   fs.open(file,FileMode.UPDATE);
   fs.position = startIndex;
   fs.writeUTFBytes(value);
   fs.close();
}
  • Getting current directory in air:
  1. NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvokeEvent);
  2. public function onInvokeEvent(invocation:InvokeEvent):void {
  3.         var currentDir:File = invocation.currentDirectory;
  4. }


  • File systems's tutorial:
http://labs.adobe.com/wiki/index.php/Apollo:Articles:Apollo_Local_File_System
http://www.flex888.com/296/9-flex-file-upload-examples-visited.html