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?
The .app is actually a folder. To access the executable inside you have to reference YourApp.app/Contents/MacOS/YourApp
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With