Camera.getCamera (name) doesn't work in Adobe Flash Player 9 beta
14 Jun 2006I 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.
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.media.Camera;
import flash.media.Video;
import flash.events.*;
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);
video1.attachCamera(camera1);
addChild(video1);
}
else
{
trace("Camera1 not working");
}
if(camera2 != null)
{
video2 = new Video(cameraWidth, cameraHeight);
video2.x = cameraWidth + 20;
video2.attachCamera (camera2)
addChild(video2);
}
else
{
trace("Camera2 not working");
}
}
private function activityHandler(event:ActivityEvent):void
{
trace("activityHandler: " + event);
}
}
}