我正在开发一个 flex air 应用程序(使用 windows 7 操作系统)。我想在单击按钮时打开我的 Windows 录音机软件(在附件部分)。我尝试了很多。但没有得到。有什么办法可以做到这一点?
问问题
42 次
1 回答
0
您将需要使用NativeProcess
. 查看http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/NativeProcess.html并查看示例代码。
修改链接的示例代码以满足您的需要,检查是否NativeProcess
支持并运行录音机的完整代码将类似于:
package
{
import flash.display.Sprite;
import flash.desktop.NativeProcess;
import flash.desktop.NativeProcessStartupInfo;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.IOErrorEvent;
import flash.events.NativeProcessExitEvent;
import flash.filesystem.File;
public class NativeProcessExample extends Sprite
{
public var process:NativeProcess;
public function NativeProcessExample()
{
if(NativeProcess.isSupported)
{
setupAndLaunch();
}
else
{
trace("NativeProcess not supported.");
}
}
public function setupAndLaunch():void
{
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = File.applicationDirectory.resolvePath("%SystemRoot%\system32\SoundRecorder.exe");
nativeProcessStartupInfo.executable = file;
var processArgs:Vector.<String> = new Vector.<String>();
processArgs[0] = "foo";
nativeProcessStartupInfo.arguments = processArgs;
process = new NativeProcess();
process.start(nativeProcessStartupInfo);
process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
process.addEventListener(NativeProcessExitEvent.EXIT, onExit);
process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);
process.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, onIOError);
}
public function onOutputData(event:ProgressEvent):void
{
trace("Got: ", process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable));
}
public function onErrorData(event:ProgressEvent):void
{
trace("ERROR -", process.standardError.readUTFBytes(process.standardError.bytesAvailable));
}
public function onExit(event:NativeProcessExitEvent):void
{
trace("Process exited with ", event.exitCode);
}
public function onIOError(event:IOErrorEvent):void
{
trace(event.toString());
}
}
}
希望有帮助。
于 2013-05-21T06:42:02.253 回答