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

Thursday, 28 April 2011

flex, air, How to write a file where the application is located


problem

adobe flex4 AS3.0, filestraem (air)
How to write a file where the application is located | the mystery "fileWriteResource" hidden error | how to write files in applicationDirectory (where is not allowed) [tested in windows only]
---
> page by dennis
solution

How to write a file where the application is located
in the follow example, the variable "filename" is String and has as value the the file name without path, i.e.: "sample.txt"
the follow code doesn't work, produces an error "fileWriteResource" that is not even thrown!
    var newFile:File=File.applicationDirectory.resolvePath(filename);
use the follow code:
    var newFile:File=File(File.getRootDirectories()[0]).resolvePath(File.applicationDirectory.nativePath+File.separator+filename);  //I am not kidding... it is working

Thursday, 21 April 2011

flex error message: If the program is already running, close it before attempting to run.


problem
adobe flex4 AS3.0 air
Launching an air application from Flex 4 IDE, it crashes because of a bug, but the widow of the application is not created so…
Trying to launch the application again you get the error
If the program is already running, close it before attempting to run.
You cannot close the application… how to kill this invisible application?
---
> dn
solution
kill the process adl.exe

how to get the command line arguments of the flex air application


problem
adobe flex4 AS3.0 air
how to get the command line arguments of the air application
---
> dn
solution
You have to listen to invoke event of the air application.
Then, this event gives an InvokeEvent object.
This object has the arguments array, in this arrays are the command line arguments stored... see the follow Listener as example:
   protected function Handler_InvoceEvent(event:InvokeEvent):void
   {
    lb_test.text= event.arguments[0]+' '+ event.arguments[1];
    loadConfigFile();
   }