Goj*_*e87 3 apache-flex command-line actionscript-3
我想以编程方式从我的flex应用程序执行CMD命令.就像是
> mediaplayer.exe "mySong.mp3"
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用fscommand但没有成功.谷歌搜索时我了解到AIR不支持它.我想知道是否还有其他替代方法来执行命令.谢谢...
您需要使用NativeProcess仅在AIR 2.0+中可用的内容
这应该做的伎俩:
if(NativeProcess.isSupported)
{
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var mp:File = new File();
mp = mp.resolvePath('native\path\to\mediaplayer.exe');
nativeProcessStartupInfo.executable = mp;
var args:Vector.<String> = new Vector.<String>();
args.push('mySong.mp3');
nativeProcessStartupInfo.arguments = args;
var process:NativeProcess = new NativeProcess();
process.start(nativeProcessStartupInfo);
}
Run Code Online (Sandbox Code Playgroud)
还要确保您的app.xml文件包含以下内容:
<supportedProfiles>extendedDesktop</supportedProfiles>
Run Code Online (Sandbox Code Playgroud)