I've been testing the new capabilities of AIR 2.0 lately, and I can say it's becoming more powerful than ever. I created a small application that uses a Mac OS X native process, the same used for the speech feature in Leopard. Basically, you can let your mac say something by writing the following command on Terminal:
$ say hello world!
When you execute this line on terminal you are actually using the "say" binary file that comes with your Mac OS X (/usr/bin/say) and you are passing to it the text you want it to say.
What you need to to do in AIR, is to actually start the native process and pass the arguments to it.
In this case we will not use STDOUT or STDIN (Standard Input and Standard Output) to communicate to the process.
Here you go:
private var nativeProcessStartup:NativeProcessStartup;
private var nativeProcess:NativeProcess;
public function Main() {
nativeProcessStartup = new NativeProcessStartupInfo();
nativeProcess = new NativeProcess();
var args:Vector = new Vector.<string>;
nativeProcessStartup.executable = new File("/usr/bin/say");
args.push("I'm an AIR application that can talk!");
nativeProcessStartup.arguments = args;
nativeProcess.start(nativeProcessStartup);
}
Actually, I'm creating two instances here, a NativeProcessStartupInfo instance and a NativeProcess instance, then I'm passing the path of the "say" file to the executable property of NativeProcessStartupInfo class. After that I'm passing to it a vector containing the command arguments to be executed (I've pushed some text in the vector).
Finally, I start the native process passing the NativeProcessStartupInfo instance to it.
Now, before testing your application you should tell the compiler that you are going to use an "Extended Desktop" profile, as your app is going to use the some OS resources. All you need to do is to add the following tag to the application descriptor xml file:
<supportedprofiles>extendedDesktop</supportedprofiles>
Of course you must install the AIR 2.0 runtime and its SDK (download from here).
In order to distribute an application that uses extended profiles, you have to package it inside a native installer, so in this case you have to package this application into a DMG file and you can do it only on a Mac computer. To package an AIR application into an EXE file you will need a Windows computer. In this case, this application will work only on a mac, because it is using a Native Process that it is currently available only on the Mac Operating System (the "say" file). To do that, there are many ways, but the easier way is to package the app into an AIR file as you normally would then open Terminal and write:
$ adt -package -target native myApp.dmg myApp.air
where myApp.dmg is the final installer file. To save it to the desktop write ~/Desktop/myApp.dmg instead.
Download the final installer here
Good luck!