setMotionLevel (Camera.setMotionLevel method)

public setMotionLevel([motionLevel:Number], [timeOut:Number]) : Void

Specifies how much motion is required to invoke Camera.onActivity(true). Optionally sets the number of milliseconds that must elapse without activity before Flash considers motion to have stopped and invokes Camera.onActivity(false).

Note: Video can be displayed regardless of the value of the sensitivity parameter. This parameter determines only when and under what circumstances Camera.onActivity is invoked--not whether video is actually being captured or displayed.

Availability: ActionScript 1.0; Flash Player 6

Parameters

motionLevel:Number [optional] - A numeric value that specifies the amount of motion required to invoke Camera.onActivity(true). Acceptable values range from 0 to 100. The default value is 50.

timeOut:Number [optional] - A numeric parameter that specifies how many milliseconds must elapse without activity before Flash considers activity to have stopped and invokes the Camera.onActivity(false) event handler. The default value is 2000 (2 seconds).

Example

The following example sends messages to the Output panel when video activity starts or stops. Change the motion sensitivity value of 30 to a higher or lower number to see how different values affect motion detection.

// Assumes a Video object named "myVideoObject" is on the Stage
active_cam = Camera.get();
x = 0;
function motion(mode) {
    trace(x + ": " + mode);
    x++;
}
active_cam.onActivity = function(mode) {
    motion(mode);
}
active_cam.setMotionLevel(30, 500);
myVideoObject.attachVideo(active_cam);

See also

motionLevel (Camera.motionLevel property), motionTimeOut (Camera.motionTimeOut property), onActivity (Camera.onActivity handler), activityLevel (Camera.activityLevel property)


Flash CS3