Hello. Is there way, how to close webcam connection in actionscript. I am opening stream through Camera.getCamera(). Problem is, that after freeing webcam instance (i tried many ways) LIGHT on webcam is still beam (tried on macbook pro).
+3
A:
You can simply call video.attachCamera(null)
to free the camera.
The below example demonstrates the code. When you click on the stage, Camera is toggled on/off.
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.media.Camera;
import flash.media.Video;
public class testAS3 extends Sprite
{
public var cam:Camera;
public var video:Video;
public var camOn:Boolean = false;
public function testAS3()
{
cam = Camera.getCamera();
video = new Video();
addChild(video);
stage.addEventListener(MouseEvent.CLICK,toggleCamera);
}
public function toggleCamera(evt:Event):void {
if (camOn){
video.attachCamera(null);
} else {
video.attachCamera(cam);
}
camOn = !camOn;
}
}
}
Andy Li
2009-09-27 15:23:58
Oh. Thank you! That's it, my incaution..
mczerkawski
2009-09-27 16:05:19
A:
Hi anybody how to access flash settings to allow webcam dyncamically? is it possible?
sankar
2010-10-19 14:11:59