ActionScript3 : Get WebCam to use in Flash CS3

by toy

If you want to use camera or webcam in Flash CS3 or Flash CS4 for actionscript3. You can use actionScript3 to get camera and display in video symbol. I will just show the script, because it will be too easy for some expert Flash Developers :)

1
2
import flash.display.*;
import flash.geom.*;
1
 
1
2
3
4
5
var cam:Camera = Camera.getCamera();
var sizeX = cam.width;
var sizeY = cam.height;

cam.setMode( 544, 396, 25);
1
2
3
vid.attachCamera(cam); // attach the camera to video
vid.width = cam.width;
vid.height = cam.height;

While vid is your instance name of Video.

Note: For iSight for Mac users like me :) . You have to change a little bit in setting of camera in Flash Player. You have to choose USB Video Class Video.

iSight setting for Adobe Flash Player