4

I'm building an Air app that uses an .app/.exe file as a bridge to hardware devices.

Ideally, I would like to include the executable with the Air app installer and launch the external program together with the Air app.

1) Is this possible?
2) How do decide which OS specific file to launch?

EDIT: OK, the above wasn't very difficult:

var file:File = File.applicationDirectory;
file = file.resolvePath("src/assets/NativeApps");

if (Capabilities.os.toLowerCase().indexOf("win") > -1) {
    file = file.resolvePath("Windows/echoTestWin.exe");
}
else if (Capabilities.os.toLowerCase().indexOf("mac") > -1) {
    file = file.resolvePath("Mac/echoTestMac.app");
}

var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = file;
var process = new NativeProcess();
process.start(nativeProcessStartupInfo)

But why do I get this error message?

ArgumentError: Error #3214: NativeProcessStartupInfo.executable does not specify a valid executable file.

Isn't the .app extension valid?

dani
  • 4,880
  • 8
  • 55
  • 95
  • 1
    Have you tried without the .app extension? Like file.resolvePath("Mac/echoTestMac")? I have never used the NativeProcess stuff in AIR myself, but in general it is common to leave out the extension for applications in Mac OS. – Lars Blåsjö Nov 25 '10 at 17:52
  • 1
    Lars, thanks for the input. It seems however that the app extension works: trace(file.exists) => true - so it obviously finds something ... – dani Nov 25 '10 at 19:18

2 Answers2

7

The .app is actually a folder. To access the executable inside you have to reference YourApp.app/Contents/MacOS/YourApp

Greg
  • 600
  • 2
  • 5
1

There's a thread about executing an external program: Adobe AIR to execute program

And you can of course detect the OS: http://www.uibuzz.com/?p=1330

It's also possible to create OS specific, native installers.

Community
  • 1
  • 1
dain
  • 6,475
  • 1
  • 38
  • 47