Displaying camera content on-screen

Connecting to a camera can require less code than using the NetConnection and NetStream classes to load an FLV. The camera class can also quickly become tricky since you need a user's permission to have Flash Player connect to their camera before you can access it.

The following code demonstrates how you can use the Camera class to connect to a user's local camera:

var cam:Camera = Camera.getCamera();
var vid:Video = new Video();
vid.attachCamera(cam);
addChild(vid);

NOTE

The Camera class does not have a constructor method. In order to create a new Camera instance you use the static Camera.getCamera() method.