Verifying that cameras are installed

Before you attempt to use any methods or properties on a camera instance, you'll want to verify that the user has a camera installed. There are two ways to check whether the user has a camera installed:

Since the Camera class doesn't extend the DisplayObject class, it cannot be directly added to the display list using the addChild() method. In order to display the camera's captured video, you need to create a new Video object and call the attachCamera() method on the Video instance.

This snippet shows how you can attach the camera if one exists; if not, Flash Player simply displays nothing:

var cam:Camera = Camera.getCamera();
if (cam != null)
{
    var vid:Video = new Video();
    vid.attachCamera(cam);
    addChild(vid);
}