I’m trying to explore the features of Flash 8, which I just got. This is my first little experiment with it.
For those of you without a webcam, it basically just displays two images, one positive, one negative (inverted) of what your webcam is seeing.
import flash.display.*;
import flash.geom.*;
cam = Camera.get();
pos.attachVideo(cam);
var drawPos = new BitmapData(cam.width, cam.height);
var drawNeg = new BitmapData(cam.width, cam.height);
_root.createEmptyMovieClip("neg", 1);
neg._x = 320;
rect = new Rectangle(0, 0, cam.width, cam.height)
point = new Point(0, 0);
onEnterFrame = function() {
drawNeg.copyPixels(drawPos, rect, point);
for(var i=0; i<cam.height; i++) {
for(var j=0; j<cam.width; j++) {
drawNeg.setPixel(j, i, 255-drawNeg.getPixel(j, i));
}
}
drawPos.draw(pos);
neg.attachBitmap(drawNeg, 0);
neg._xscale = 200;
neg._yscale = 200;
}
It’s very simple, but it’s my first experiment with Flash 8. I used a couple of tutorials online as a starting point for figuring out the whole Bitmap manipulation and webcam thing, plus a lot of reading through the docs.
Edit: I think I might have a go at creating a Photobooth style app in Flash.