Bundle and execute .app/.exe file with Adobe Air App
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 开发者_如何学Gowith 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.
精彩评论