Adobe Flash Camera Motion Detection

This is an experiment that utilizes the ActionScript Camera.motionLevel property of macromedia flash player. Requires Macromedia Flash player to be installed and a webcam to be connected to your computer.

ActionScript (AS2)
1.   // Assumes a Video object named "myVideoObject" is on the Stage
2.   c = Camera.get();
3.   x = 0;
4.   
5.   function motion(mode)
6.   {
7.       trace(x + ": " + mode);
8.       x++;
9.       if (c.activityLevel > 7) {
10.          msg = "Sensing Movement.."; 
11.      } else { msg = ""; }     
12.     
13.  
14.  }
15.  c.onActivity = function(mode) { motion(mode);   };     
16.  c.setMotionLevel(8, 500);
17.  myVideoObject.attachVideo(c);

Technorati Tags:
Comments