谢谢。
使用AIR 2.0,现在您可以:
if(NativeProcess.isSupported)
{
var file:File = File.desktopDirectory;
file = file.resolvePath("StyleLookupold.exe");
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = file;
var process:NativeProcess = new NativeProcess();
process.start(nativeProcessStartupInfo);
}
你还需要将此添加到你的描述文件中。
<supportedProfiles>extendedDesktop</supportedProfiles>
创建一个 CommandProxy
对象,添加一些事件侦听器,用于连接检测和 Command
的响应和错误。
通过 connect
调用连接到本地exe
在 connect
的事件处理程序中,创建一个新的 Command
,例如ScreenshotCommand
,并执行它(通过 CommandProxy.execute
方法)
var request : URLRequest = new URLRequest('C:\\playlists\\test.m3u');
另一种方法是在本地计算机上启动简单的Web服务器(在后台),并使用HTTPService调用它的方法。
后台Web服务器可以使用Python,例如: http://fragments.turtlemeat.com/pythonwebserver.php
它可以启动可执行文件并提供AIR无法实现的功能。
这样可以保持Flex代码干净,因为它只实现了REST接口,而Python(或其他语言)则完成了其余工作。您还可以从使用Python作为与SQLite数据库的接口或将整个Django作为Web服务器中获益。
唯一的缺点是服务器必须已在本地主机上运行并侦听某个端口(即81)。您可能可以通过在系统启动时启动服务器来完成此操作。
虽然不是最佳方法,但在某些情况下,它可能有助于您的项目,就像我一样。
if(NativeProcess.isSupported)
{
//not correct
//file = file.resolvePath("/Applications/xxx.app");
//correct
file = file.resolvePath("/Applications/xxx.app/Contents/MacOS/xxx");
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = file;
var process:NativeProcess = new NativeProcess();
process.start(nativeProcessStartupInfo);
}
或者简单地说,我的网站可以创建定制的安装程序来安装新应用程序。了解更多信息。
奖励提示:我们建议您使用Enigma Virtual Box,因为它是免费的,并且非常适合应用程序虚拟化或Exe-Packer,例如BoxedApp Packer,但它的成本要比Enigma Virtual Box高得多。谢谢!