[webcam] Replace mouse with lightsource

While experimenting with motion detection late at night with the lights out and using an OLD webcam, I found I could track a light source pretty easily in a dark room. I was wondering if this works with better webcams, or if they see too much light for it to work? You may have to adjust the brightness and/or contrast of your webcam to get it to work well (my webcam is so old it doesn’t have those adjustment options). Does anyone know if there are examples of this technique already in use.

my_cam = Camera.get();
webcam_video.attachVideo(my_cam); // webcam_video is a video object

now = new BitmapData(webcam_video._width, webcam_video._height);

createEmptyMovieClip('holder', getNextHighestDepth());
holder.attachBitmap(now, holder.getNextHighestDepth());
with(holder){
  _x=webcam_video._width;
  _y=webcam_video._height+10;
  _xscale=-100;
}

createEmptyMovieClip('crossHairs', getNextHighestDepth());
with(crossHairs){
  lineStyle(1,0xFFFFFF);
  moveTo(0,-6);
  lineTo(0,6);
  moveTo(-6,0);
  lineTo(6,0);
  moveTo(0,-4);
  lineTo(4,0);
  lineTo(0,4);
  lineTo(-4,0);
  lineTo(0,-4);
}

crossHairs.onEnterFrame=function(){
  now.draw(webcam_video);
  now.threshold(now, now.rectangle, new flashGeomPoint(0, 0), '<=', 0xFF666666, 0xFF000000, 0xFF0000FF, false);
  lightBox = now.getColorBoundsRect(0x00FF0000, 0x00FFFFFF, false);
  if(lightBox.width > 0){
    this._x = Stage.width - (lightBox.x / webcam_video._width) * Stage.width;
    this._y = (lightBox.y / webcam_video._height) * Stage.height;
  }
};

It seems to work with any light source that is not bright enough to light your hand. I’ve used my cellphone screen, a penlight, even my mouse’s laser, though you have to make sure the mouse’s laser is pointed at the webcam, which is a bit akward, but works great for shooting. Oh yeah, make sure your computer screen doesn’t illuminate anything enough for the webcam to see it!
(Sample attached)