actionscript 3 - How to implement NativeProcess in Air app -
i need simple nativeprocess, need launch .exe file via cmd line , pass 1 parameter. have found nativeprocess examples far more complex things , not showing complete implementation. have lot of experience flash as3 not in particular area... if show me how accomplished begining end appreciate it.
here code adobe's website doing ask :
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 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 ", event.exitcode); } public function onioerror(event:ioerrorevent):void { trace(event.tostring()); } } }
and important information the nativeprocess class , capabilities available air applications installed native installer (extended desktop profile applications). when debugging, can pass -profile extendeddesktop argument adl enable nativeprocess functionality. @ runtime, can check nativeprocess.issupported property to determine whether native process communication supported.
i tested above in flash develop setting application profile extended desktop
, works.
more info here.
Comments
Post a Comment