flex - Opening sound recorder upon clicking on a button -
i'm developing flex air application(using windows 7 os). want open windows sound recorder software(in accessories section) upon clicking on button.i have tried lot.but not getting.is there way make possible?
you need use nativeprocess
. have @ http://help.adobe.com/en_us/flashplatform/reference/actionscript/3/flash/desktop/nativeprocess.html , check out example code.
modifying linked example code suit needs, complete code check if nativeprocess
supported , run sound recorder like:
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 ", event.exitcode); } public function onioerror(event:ioerrorevent):void { trace(event.tostring()); } } }
hope helps.
Comments
Post a Comment