User Guide

504 Chapter 7: ActionScript for Flash
Example
The following example uses the default camera unless more than one camera is available, in which
case the user can choose which camera to set as the default camera. If only one camera is present,
then the default camera is used.
var my_video:Video;
var cam_array:Array = Camera.names;
if (cam_array.length>1) {
System.showSettings(3);
}
var my_cam:Camera = Camera.get();
my_video.attachVideo(my_cam);
See also
Camera.get()
, Camera.index, Camera.name
Camera.onActivity
Availability
Flash Player 6.
Usage
active_cam.onActivity = function(activity:Boolean) : Void {
// your statements here
}
Parameters
activity
A Boolean value set to true when the camera starts detecting motion, false when
it stops.
Returns
Nothing.
Description
Event handler; invoked when the camera starts or stops detecting motion. If you want to respond
to this event handler, you must create a function to process its
activity value.
To specify the amount of motion required to invoke
Camera.onActivity(true) and the
amount of time that must elapse without activity before invoking
Camera.onActivity(false),
use
Camera.setMotionLevel().
Example
The following example writes to the log file when the camera starts or stops detecting motion:
// Assumes a Video object named "myVideoObject" is on the Stage
active_cam = Camera.get();
myVideoObject.attachVideo(active_cam);
active_cam.setMotionLevel(10, 500);
active_cam.onActivity = function(mode)
{