Skip to content

Video From Webcam in Actionscript

November 17, 2009

I’m working my way up to more advanced applications of the Video and Camera Classes in Actionscript 3.0 so I will be posting up the code each step of the way. The code below shown below is the most basic level of using a camera in Flash. The Camera used needs to be retrieved and attached to video. Additional parameters may be entered here, but if they are not specified, the default settings will be used.

package basicCamCode{
import flash.display.MovieClip;

public class BasicCamera extends MovieClip {

private var cam:Camera;
private var vid:Video;

public function BasicCamera() {
cam=Camera.getCamera(); //
vid=new Video(); //default dimensions are 320 x 240
vid.x=(stage.stageWidth/2)+(vid.width/2); //the scaling causes registation point to  switch to top right corner

//trace("cam width = "+cam.width); //if you don't know what dimensions your camera returns
//trace("cam height = "+cam.height);



No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: