Skip to content

Two Cameras, Two Videos (Actionscript)

November 17, 2009

Yes, it is possible to use two cameras at once in Flash. I’ve tried this successfully with two different varieties of webcams, but also using the same model. I did run into a little issue at first when trying this out with two of the same model cameras, but after a little fiddling around, it worked out. I found that if I changed a value such as brightness or contrast in the camera’s software, it would somehow realize there were two cameras and sort any little glitches out. There is the assumption that using two of the same model device will not work because they are both reliant on the same driver, but in Windows, I went into the device management area and discovered that both cameras were being recognized. The second camera to be connected was just labeled as “#2” after it’s name.

I set up a video for each of the cameras, both beside each other on the stage. When first tested, the second camera produced a video that was black with a couple dead pixels on it. I thought this was that driver issue, but in the end I think I am concluding that it was more likely the software for the camera. I went into the software and altered the brightness and other setting for each camera and I believe it was after this point that the both camera were able to work at the same time. I assume that the software wasn’t designed to run to cameras at once because it would from time to time have trouble changing the setting for each camera separately and would instead change the setting for both (or the wrong camera). Nevertheless, in the end, both cameras were able to operate at the same time.

The key step to using more that one camera is probably specifying which camera you are using at the attachCamera step. Notice, I have a camera “0” and a camera “1”. This is how you call a specific camera (by number). You may need to try a few numbers out to sort out which camera is which. If you plan to distribute a .swf using a code like this, i might suggest using an if statement or a loop to retrieve the active camera. Using a camera number that doesn’t retrieve a specific camera will not return a video (blank, not even a black video).

The code is here below, you can use Autoformat to do proper indentation in Flash.

package twoCamCode{
import flash.display.MovieClip;

public class TwoCameras extends MovieClip {

private var camL:Camera; //for me (cam 1) is on the left (its perspective)
private var camR:Camera; //for me cam 0) is on the right (its perspective)
private var vidL:Video; //
private var vidR:Video; //

public function TwoCameras() {

//Left eye
vidL=new Video(320,240);
vidL.scaleX= -1;

vidR =new Video(320,240);
vidR.scaleX= -1;

if(!camL){ trace("Left Camera not found") }
if(!camR){ trace("Right Camera not found") }



No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: