I've got a few projects lined up which involve using a webcam so I though what better way to start than to give a quick example of how a webcam can be set up in flash. Here is a complete program - check it out. This can be copied into the first frame of the timeline.
var CAM:Camera = Camera.getCamera();
CAM.setQuality(0, 100);
CAM.setMode(550, 400, stage.frameRate );
var VIDEO:Video = new Video(550, 400);
VIDEO.attachCamera(CAM);
addChild(VIDEO);
So lets go through this one line at a time.
First the Camera class is initiated and a camera object is created using
var CAM:Camera = Camera.getCamera();
Some properties of the camera are then set, the size, quality and frame rate.
CAM.setQuality(0, 100);
CAM.setMode(550, 400, stage.frameRate );
Finally an object needs to be created to make the camera appear on the screen so lets attach the camera to the VIDEO object, and then add the VIDEO object to the stage.
var VIDEO:Video = new Video(550, 400);
VIDEO.attachCamera(CAM);
addChild(VIDEO);
Just click below for an example of how this works.
In my next few blogs I'll show you some cool stuff you can do with the webcam!
Enjoy guys!
No comments:
Post a Comment