`

Sunday, September 26, 2010

Webcam in AS3

When using the Camera, you cannot always expect the default camera object to work when using.

var myCam:Camera = Camera.getCamera();

Sometimes you need to access a different camera object in your hardware setup.  This is true when using my MBP, the default DV Camera object just doesn’t work.  Now the API suggests that you can access a camera object name from the array in”
var names:Array = Camera.names;
However trying to access a camera object via this API yields null.

var names:Array = Camera.names;
var myCam:Camera = Camera.getCamera(names[i] as String);

instead you must use this syntax:

var names:Array = Camera.names;
//where i is the index, not the array index value
var myCam:Camera = Camera.getCamera(String(i));

No comments: