我需要使用NativeProcess進行一些非常簡單的操作,我需要通過cmd行啓動一個.exe文件並將其傳遞給一個參數。我發現了NativeProcess示例,但它們都是用於更復雜的事情,並沒有顯示完整的實現。我在flash as3方面有很多經驗,但在這個特定領域沒有......如果有人能告訴我這是從開始到結束如何實現的,我將不勝感激。如何在Air應用程序中實現NativeProcess
0
A
回答
2
下面是代碼從Adobe網站對究竟在做什麼你問:
package
{
public class Main extends Sprite
{
public var process:NativeProcess;
public function Main()
{
if(NativeProcess.isSupported)
setupAndLaunch();
else
trace("NativeProcess not supported.");
}
public function setupAndLaunch():void
{
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = File.applicationDirectory.resolvePath("yourapp.exe");
nativeProcessStartupInfo.executable = file;
var processArgs:Vector.<String> = new Vector.<String>();
processArgs[0] = "the parameter you are passing";
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());
}
}
}
和重要信息The NativeProcess class and its capabilities are only available to AIR applications installed with a native installer (extended desktop profile applications). When debugging, you can pass the -profile extendedDesktop argument to ADL to enable the NativeProcess functionality. At runtime, you can check the NativeProcess.isSupported property to to determine whether native process communication is supported.
我測試在Flash上面通過設置應用程序配置文件制定到Extended Desktop
和它的工作原理。
更多信息here。
相關問題
- 1. 如何在Adobe AIR桌面應用程序中重新啓動NativeProcess?
- 2. 如何在Linux中的Adobe AIR的NativeProcess
- 3. AIR NativeProcess API
- 4. Air NativeProcess java
- 5. Flex - Air「nativeprocess not supported」
- 6. 錯誤#3219 AIR中的NativeProcess
- 7. 在Air 2.0應用程序中啓動Air 2.0應用程序
- 8. 如何在Java中使用AIR 2.0 NativeProcess API?
- 9. AIR - 使用Sytem Profiler的NativeProcess在Mac上
- 10. 調試使用NativeProcess API調用可執行文件的Adobe AIR應用程序
- 11. Adobe Air NativeProcess與C++ Windows(非控制檯)應用程序通信
- 12. AIR應用程序
- 13. 我們是否可以通過AIR應用程序實現SSO
- 14. AuthenticationManager實現如何在SpringBoot應用程序中實例化
- 15. 如何停止AIR應用程序?
- 16. 如何部署Adobe AIR應用程序
- 17. 如何實現應用程序協議
- 18. 如何實現SQLite到應用程序?
- 19. 如何實現應用程序更新?
- 20. 如何實現提醒應用程序?
- 21. 裝載並運行現有AIR的AIR應用程序swf
- 22. 在AIR應用程序中執行POST
- 23. 在iphone應用程序中實現應用程序細化
- 24. 在Java應用程序中實現Growl
- 25. 在Android應用程序中實現Leadbolt
- 26. 在ASP.Net應用程序中實現HPKP
- 27. 在應用程序中實現聊天?
- 28. 如何在android中使用senchatouch實現phonegap應用程序2
- 29. 如何使用MVC在iOS應用程序中實現設置
- 30. 如何在iOS中使用Braintree實現支付應用程序
http://gotoandlearn.com/play.php?id=125 - 這是一個很好的起點。 – Tox 2015-05-18 16:45:37