Turn off application temporarily from flash
I have been asked to figure out a way to turn off a running application on a host computer when i certain flash application is running in the browser, a seemingly difficult task but i have thought of a few possible ways to achieve this and i would like to ask which approach would be the best.
The way i see it these are my possibilities
- Have the flash application create a cookie which another program checks for and if detected, this program running on the computer will then turn off the other application.
- Have a program running on the host computer listening on a specific port and when the proper string is sent fx. through the use of actionscript sockets, the program will turn off the application temporarily.
- Create a program sniffing network traffic and if the swf in question is being downloaded, turn off the other application temporarily (This seems to me to be the least viable approach, not even sure it would be possible to do effectively)
The reason i need to do this, is because the flash application will need to access the webcamera of the host computer, which doubles as a motion detecting camera which means the camera will be locked while the motion detection software is running. So i need to turn off the motion detection software, grab a picture in flash, save the picture and start up the motion detection again.
Am i missing some super simple approach? how would you achieve this? Thanks in advance for your answers.
TBH I don't think you'll succeed in this, unless you create it as an Air app (granted, I didn't spend too much brain power on thinking up solutions). The flash player is very restricting on what you can and cannot do. ExternalInterface is the replacement of FSCommand, which is considered obsolete, BTW. It allows you to communicate from AS with the swf container. JS (and maybe VBScript?) only though.
However, if it turns out you need to create an Air app, you can use NativeProcess which allows you to run an application on the host. For instance, if you'd want to run a java .jar you could do this:
var javaExecutable : File = new File(); javaExecutable.nativePath = '/path/to/java/'; var processArguments : Vector.<String> = Vector.<String>([ '-jar', '/path/to/jar/', 'foo' ]); var process : NativeProcessStartupInfo = new NativeProcessStartupInfo(); process.executable = javaExecutable; process.arguments = processArguments; var shell : NativeProcess = new NativeProcess(); shell.addEventListener(NativeProcessExitEvent.EXIT, onExitEvent); shell.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onStdOutputDataEvent); shell.start(process);
Very important to note: (emphasis mine)
The NativeProcess class and its capabilities are only available to AIR applications installed with a native installer (extended desktop profile applications).
You can also use the fscommand() function to pass messages to Director or to Visual Basic, Visual C++, and other programs that can host ActiveX controls.