Camera.getCamera (name) doesn’t work in Adobe Flash Player 9 beta

I just noticed that if you have multiple cameras attached to your machine, in that case Camera.getCamera (cameraName) doesn’t work Adobe Flash Player 9 beta 3. Camera.getCamera () works fine but that would return the default camera.
But if you want to use multiple cameras in your application, it seems you can’t. I have informed Adobe Flash Player team about it and I am sure, it would get fixed.
However, I wanted to see if I am doing any thing wrong in following code. This is the sample code to reproduce the problem. Please let me know (through comments), if there is some problem in code itself. Thanks.

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
public class CameraExample extends Sprite
private var video1:Video;
private var video2:Video;
private var cameraWidth:int = 640;
private var cameraHeight:int = 480;
public function CameraExample()
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var cameraNames:Array = Camera.names;
trace ("Available cameras: " + cameraNames);
var camera1:Camera = Camera.getCamera(cameraNames[0]);
var camera2:Camera = Camera.getCamera(cameraNames[1]);
if(camera1 != null)
camera1.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
video1 = new Video(cameraWidth, cameraHeight);
trace("Camera1 not working");
if(camera2 != null)
video2 = new Video(cameraWidth, cameraHeight);
video2.x = cameraWidth + 20;
video2.attachCamera (camera2)
trace("Camera2 not working");
private function activityHandler(event:ActivityEvent):void
trace("activityHandler: " + event);
  • Hi,
    you’re doing fine, i have noticed the same problem in my as3 projects, happy to hear that you informed Adobe 😉

  • WillSells

    I’m only a beginner with action script and i’m working on a project which intends on using up five cameras i’ve only written the script for the first one using the default .getCamera(), but isent there a difference between using the “names” property which is an array, and the “name” property whhich is a string. On lines 21 and 22 after tracing the camera names should you not use name (string) instead of names (array) to specify the camera. i haven’t got access to more than one camera so i can’t test this so please let me know if it works as i’ll probably need use some similar code.

  • Nolan Love

    I ran into this same bug. Please let me know if you find a workaround. I couldn’t find references to it as a “known issue” on the Flex Developers’ Site.

  • Hello,

    I ran into the same problem. It seems that you need to pass the index instead of the name to getCamera. So, the following code will work:

    var camera1:Camera = Camera.getCamera(“0”);
    var camera2:Camera = Camera.getCamera(“1”);

    The index corresponds to the Array index in Camera.names. To loop through the attached cameras:

    for (var i :String in Camera.names)
    var name :String = Camera.names[i];
    var cam :Camera = Camera.getCamera( i );

    Have a look at my recent article on cameras for more info.

  • Visco

    If you use ComboBox to let user select between cameras…

    var camCombo = new ComboBox()
    for (var i:uint = 0; i < Camera.names.length; i++)

    GetCamera depends on comboBox selection:

    var camnames:Array = Camera.names
    var camera:Camera = Camera.getCamera(camnames.indexOf(camCombo.selectedLabel).toString())