Camera
Object
+-Camera
public class
Camera
extends Object
The Camera class is primarily for use with Macromedia Flash Communication Server, but can be used in a limited way without the server. The Camera class lets you capture video from a video camera attached to the computer that is running Macromedia Flash Player -for example, to monitor a video feed from a web camera attached to your local system. (Flash provides similar audio capabilities; for more information, see the Microphone class entry.)
Warning:
When a SWF file
To create or reference a Camera object, use the Camera.get() method. Availability: ActionScript 1.0; Flash Player 6 Property summary
Properties inherited from class Object
Event summary
{% if main.adsdop %}{% include 'adsenceinline.tpl' %}{% endif %} Method summary
activityLevel (Camera.activityLevel property)public activityLevel : Number [read-only]
A numeric value that specifies the amount of motion the camera is detecting. Values range from 0 (no motion is being detected) to 100 (a large amount of motion is being
If the camera is available but is not yet being used because Video.attachVideo() has not been called, this property is set to -1. If you are streaming only uncompressed local video, this property is set only if you have assigned a function to the Camera.onActivity event handler. Otherwise, it is undefined. Availability: ActionScript 1.0; Flash Player 6 Example This example detects the amount of motion the camera detects using the activityLevel property and a ProgressBar instance. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a ProgressBar component instance to the Stage and give it the instance name activity_pb . Then add the following ActionScript to Frame 1 of the Timeline:
// video instance on the Stage.
var my_video:Video;
var activity_pb:mx.controls.ProgressBar;
var my_cam:Camera = Camera.get();
my_video.attachVideo(my_cam);
activity_pb.mode = "manual";
activity_pb.label = "Activity %3%%";
this.onEnterFrame = function() {
activity_pb.setProgress(my_cam.activityLevel, 100);
};
my_cam.onActivity = function(isActive:Boolean) {
var themeColor:String = (isActive) ? "haloGreen" : "haloOrange";
activity_pb.setStyle("themeColor", themeColor);
};
See also motionLevel (Camera.motionLevel property), setMotionLevel (Camera.setMotionLevel method) bandwidth (Camera.bandwidth property)public bandwidth : Number [read-only] An integer that specifies the maximum amount of bandwidth the current outgoing video feed can use, in bytes. A value of 0 means that Flash video can use as much bandwidth as needed to maintain the desired frame quality. To set this property, use Camera.setQuality() . Availability: ActionScript 1.0; Flash Player 6 Example The following example changes the maximum amount of bandwidth used by the camera feed. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a NumericStepper component instance to the Stage and give it the instance name bandwidth_nstep . Then add the following ActionScript to Frame 1 of the Timeline:
var bandwidth_nstep:mx.controls.NumericStepper;
var my_video:Video;
var my_cam:Camera = Camera.get();
my_video.attachVideo(my_cam);
this.createTextField("bandwidth_txt", this.getNextHighestDepth(), 0, 0,
100, 22);
bandwidth_txt.autoSize = true;
this.onEnterFrame = function() {
bandwidth_txt.text = "Camera is currently using "+my_cam.bandwidth+"
bytes ("+Math.round(my_cam.bandwidth/1024)+" KB) bandwidth.";
};
//
bandwidth_nstep.minimum = 0;
bandwidth_nstep.maximum = 128;
bandwidth_nstep.stepSize = 16;
bandwidth_nstep.value = my_cam.bandwidth/1024;
function changeBandwidth(evt:Object) {
my_cam.setQuality(evt.target.value 1024, 0);
}
bandwidth_nstep.addEventListener("change", changeBandwidth);
The
MovieClip.getNextHighestDepth()
method used in this example requires Flash Player 7 or later. If your SWF file includes a version 2 component, use the version 2
See also setQuality (Camera.setQuality method) currentFps (Camera.currentFps property)public currentFps : Number [read-only]
The rate at which the camera is capturing data, in frames per second. This property cannot be set; however, you can use the
Camera.setMode()
method to set a
Availability: ActionScript 1.0; Flash Player 6 Example The following example detects the rate in frames per second that the camera captures data, using the currentFps property and a ProgressBar instance. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a ProgressBar component instance to the Stage and give it the instance name fps_pb. Then add the following ActionScript to Frame 1 of the Timeline:
var my_video:Video;
var fps_pb:mx.controls.ProgressBar;
var my_cam:Camera = Camera.get();
my_video.attachVideo(my_cam);
this.onEnterFrame = function() {
fps_pb.setProgress(my_cam.fps-my_cam.currentFps, my_cam.fps);
};
fps_pb.setStyle("fontSize", 10);
fps_pb.setStyle("themeColor", "haloOrange");
fps_pb.labelPlacement = "top";
fps_pb.mode = "manual";
fps_pb.label = "FPS: %2 (%3%% dropped)";
See also setMode (Camera.setMode method), fps (Camera.fps property) fps (Camera.fps property)public fps : Number [read-only] The maximum rate at which you want the camera to capture data, in frames per second. The maximum rate possible depends on the capabilities of the camera; that is, if the camera doesn't support the value you set here, this frame rate will not be achieved.
Availability: ActionScript 1.0; Flash Player 6 Example The following example detects the rate in frames per second that the camera captures data, using the currentFps property and a ProgressBar instance. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a ProgressBar component instance to the Stage and give it the instance name fps_pb. Then add the following ActionScript to Frame 1 of the Timeline:
var my_video:Video;
var fps_pb:mx.controls.ProgressBar;
var my_cam:Camera = Camera.get();
my_video.attachVideo(my_cam);
this.onEnterFrame = function() {
fps_pb.setProgress(my_cam.fps-my_cam.currentFps, my_cam.fps);
};
fps_pb.setStyle("fontSize", 10);
fps_pb.setStyle("themeColor", "haloOrange");
fps_pb.labelPlacement = "top";
fps_pb.mode = "manual";
fps_pb.label = "FPS: %2 (%3%% dropped)";
Note
This
setMode()
function does not guarentee the requested fps setting; it sets the fps you
See also currentFps (Camera.currentFps property), setMode (Camera.setMode method) get (Camera.get method)public static get([index:Number]) : Camera Returns a reference to a Camera object for capturing video. To actually begin capturing the video, you must attach the Camera object to a Video object (see Video.attachVideo() ). Unlike objects that you create using the new constructor, multiple calls to Camera.get() reference the same camera. Thus, if your script contains the lines first_cam = Camera.get() and second_cam = Camera.get() , both first_cam and second_cam reference the same (default) camera. In general, you shouldn't pass a value for index ; simply use Camera.get() to return a reference to the default camera. By means of the Camera settings panel (discussed later in this section), the user can specify the default camera Flash should use. If you pass a value for index , you might be trying to reference a camera other than the one the user prefers. You might use index in rare cases--for example, if your application is capturing video from two cameras at the same time. When a SWF file tries to access the camera returned by Camera.get() , Flash Player displays a Privacy dialog box that lets the user choose whether to allow or deny access to the camera. (Make sure your Stage size is at least 215 x 138 pixels; this is the minimum size Flash requires to display the dialog box.) When the user responds to this dialog box, the Camera.onStatus event handler returns an information object that indicates the user's response. To determine whether the user has denied or allowed access to the camera without processing this event handler, use the Camera.muted property. The user can also specify permanent privacy settings for a particular domain by right-clicking (Windows) or Control-clicking (Macintosh) while a SWF file is playing, selecting Settings, opening the Privacy panel, and selecting Remember. You can't use ActionScript to set the Allow or Deny value for a user, but you can display the Privacy panel for the user by using System.showSettings(0) . If the user selects Remember, Flash Player no longer displays the Privacy dialog box for SWF files from this domain. If Camera.get returns null , either the camera is in use by another application, or there are no cameras installed on the system. To determine whether any cameras are installed, use Camera.names.length . To display the Flash Player Camera Settings panel, which lets the user choose the camera to be referenced by Camera.get() , use System.showSettings(3) . Scanning the hardware for cameras takes time. When Flash finds at least one camera, the hardware is not scanned again for the lifetime of the player instance. However, if Flash doesn't find any cameras, it will scan each time Camera.get is called. This is helpful if a user has forgotten to connect the camera; if your SWF file provides a Try Again button that calls Camera.get , Flash can find the camera without the user having to restart the SWF file.
Note The correct syntax is Camera.get() . To assign the Camera object to a variable, use syntax like active_cam - Camera.get() . Availability: ActionScript 1.0; Flash Player 6 Parameters index :Number [optional] - A zero-based integer that specifies which camera to get, as determined from the array returned by the Camera.names property. To get the default camera (which is recommended for most applications), omit this parameter. Returns Camera - If index is not specified, this method returns a reference to the default camera or, if it is in use by another application, to the first available camera. (If there is more than one camera installed, the user may specify the default camera in the Flash Player Camera Settings panel.) If no cameras are available or installed, the method returns null . If index is specified, this method returns a reference to the requested camera, or null if it is not available. Example The following example lets you select an active camera to use from a ComboBox instance. The current active camera is displayed in a Label instance. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a Label component instance to the Stage and give it the instance name camera_lbl, and a ComboBox component instance and give it the instance name cameras_cb . Then add the following ActionScript to Frame 1 of the Timeline:
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
var camera_lbl:mx.controls.Label;
var cameras_cb:mx.controls.ComboBox;
camera_lbl.text = my_cam.name;
cameras_cb.dataProvider = Camera.names;
function changeCamera():Void {
my_cam = Camera.get(cameras_cb.selectedIndex);
my_video.attachVideo(my_cam);
camera_lbl.text = my_cam.name;
}
cameras_cb.addEventListener("change", changeCamera);
camera_lbl.setStyle("fontSize", 9);
cameras_cb.setStyle("fontSize", 9);
See also index (Camera.index property), muted (Camera.muted property), names (Camera.names property), onStatus (Camera.onStatus handler), setMode (Camera.setMode method), showSettings (System.showSettings method), attachVideo (Video.attachVideo method) height (Camera.height property)public height : Number [read-only] The current capture height, in pixels. To set a value for this property, use Camera.setMode() . Availability: ActionScript 1.0; Flash Player 6 Example The following code displays the current width, height and FPS of a video instance in a Label component instance on the Stage. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a Label component instance to the Stage and give it the instance name dimensions_lbl. Then add the following ActionScript to Frame 1 of the Timeline:
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
var dimensions_lbl:mx.controls.Label;
dimensions_lbl.setStyle("fontSize", 9);
dimensions_lbl.setStyle("fontWeight", "bold");
dimensions_lbl.setStyle("textAlign", "center");
dimensions_lbl.text = "width: "+my_cam.width+", height: "+my_cam.height+",
FPS: "+my_cam.fps;
See also the example for Camera.setMode() . See also width (Camera.width property), setMode (Camera.setMode method) index (Camera.index property)public index : Number [read-only] A zero-based integer that specifies the index of the camera, as reflected in the array returned by Camera.names . Availability: ActionScript 1.0; Flash Player 6 Example
The following example displays an array of cameras in a text field that is created at runtime, and
var camera_lbl:mx.controls.Label;
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
camera_lbl.text = my_cam.index+". "+my_cam.name;
this.createTextField("cameras_txt", this.getNextHighestDepth(), 25, 160,
160, 80);
cameras_txt.html = true;
cameras_txt.border = true;
cameras_txt.wordWrap = true;
cameras_txt.multiline = true;
for (var i = 0; i<Camera.names.length; i++) {
cameras_txt.htmlText += "<li><u><a
href=\"asfunction:changeCamera,"+i+"\">"+Camera.names[i]+"</a></u></
li>";
}
function changeCamera(index:Number) {
my_cam = Camera.get(index);
my_video.attachVideo(my_cam);
camera_lbl.text = my_cam.index+". "+my_cam.name;
}
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the MovieClip.getNextHighestDepth() method. See also names (Camera.names property), get (Camera.get method) motionLevel (Camera.motionLevel property)public motionLevel : Number [read-only] 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. Video can be displayed regardless of the value of the motionLevel property. For more information, see Camera.setMotionLevel() . Availability: ActionScript 1.0; Flash Player 6 Example The following example continually detects the motion level of a camera feed. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a Label component instance to the Stage and give it the instance name motionLevel_lbl, a NumericStepper with the instance name motionLevel_nstep , and a ProgressBar with the instance name motion_pb. Then add the following ActionScript to Frame 1 of the Timeline:
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
// configure the ProgressBar component instance
var motion_pb:mx.controls.ProgressBar;
motion_pb.mode = "manual";
motion_pb.label = "Motion: %3%%";
var motionLevel_lbl:mx.controls.Label;
// configure the NumericStepper component instance
var motionLevel_nstep:mx.controls.NumericStepper;
motionLevel_nstep.minimum = 0;
motionLevel_nstep.maximum = 100;
motionLevel_nstep.stepSize = 5;
motionLevel_nstep.value = my_cam.motionLevel;
// Continuously update the progress of the ProgressBar component instance to
the activityLevel
// of the current Camera instance, which is defined in my_cam
this.onEnterFrame = function() {
motion_pb.setProgress(my_cam.activityLevel, 100);
};
// When the level of activity goes above or below the number defined in
Camera.motionLevel,
// trigger the onActivity event handler.
my_cam.onActivity = function(isActive:Boolean) {
// If isActive equals true, set the themeColor variable to "haloGreen".
// Otherwise set the themeColor to "haloOrange".
var themeColor:String = (isActive) ? "haloGreen" : "haloOrange";
motion_pb.setStyle("themeColor", themeColor);
};
function changeMotionLevel() {
// Set the motionLevel property for my_cam Camera instance to the value
of the NumericStepper
// component instance. Maintain the current motionTimeOut value of the
my_cam Camera instance.
my_cam.setMotionLevel(motionLevel_nstep.value, my_cam.motionTimeOut);
}
motionLevel_nstep.addEventListener("change", changeMotionLevel);
See also onActivity (Camera.onActivity handler), onStatus (Camera.onStatus handler), setMotionLevel (Camera.setMotionLevel method), activityLevel (Camera.activityLevel property) motionTimeOut (Camera.motionTimeOut property)public motionTimeOut : Number [read-only] The number of milliseconds between the time the camera stops detecting motion and the time Camera.onActivity (false) is invoked. The default value is 2000 (2 seconds). To set this value, use Camera.setMotionLevel() . Availability: ActionScript 1.0; Flash Player 6 Example
In the following example, the ProgressBar instance changes its halo theme
var motionLevel_lbl:mx.controls.Label;
var motion_pb:mx.controls.ProgressBar;
var motionTimeOut_nstep:mx.controls.NumericStepper;
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
this.onEnterFrame = function() {
motionLevel_lbl.text = "activityLevel: "+my_cam.activityLevel;
};
motion_pb.indeterminate = true;
my_cam.onActivity = function(isActive:Boolean) {
if (isActive) {
motion_pb.setStyle("themeColor", "haloGreen");
motion_pb.label = "Motion is above "+my_cam.motionLevel;
} else {
motion_pb.setStyle("themeColor", "haloOrange");
motion_pb.label = "Motion is below "+my_cam.motionLevel;
}
};
function changeMotionTimeOut() {
my_cam.setMotionLevel(my_cam.motionLevel, motionTimeOut_nstep.value
1000);
}
motionTimeOut_nstep.addEventListener("change", changeMotionTimeOut);
motionTimeOut_nstep.value = my_cam.motionTimeOut/1000;
See also setMotionLevel (Camera.setMotionLevel method), onActivity (Camera.onActivity handler) muted (Camera.muted property)public muted : Boolean [read-only] A Boolean value that specifies whether the user has denied access to the camera ( true ) or allowed access ( false ) in the Flash Player Privacy Settings panel. When this value changes, Camera.onStatus is invoked. For more information, see Camera.get() . Availability: ActionScript 1.0; Flash Player 6 Example
In the following example, an error message could be displayed if
my_cam.muted
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
my_cam.onStatus = function(infoObj:Object) {
if (my_cam.muted) {
// If user is denied access to their Camera, you can display an error
message here. You can display the user's Camera/Privacy settings again
using System.showSettings(0);
trace("User denied access to Camera");
System.showSettings(0);
}
};
See also get (Camera.get method), onStatus (Camera.onStatus handler) name (Camera.name property)public name : String [read-only] A string that specifies the name of the current camera, as returned by the camera hardware. Availability: ActionScript 1.0; Flash Player 6 Example The following example displays the name of the default camera in a text field. In Windows, this name is the same as the device name listed in the Scanners and Cameras Control Panel. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Then add the following ActionScript to Frame 1 of the Timeline:
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
this.createTextField("name_txt", this.getNextHighestDepth(), 0, 0, 100,
22);
name_txt.autoSize = true;
name_txt.text = my_cam.name;
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the MovieClip.getNextHighestDepth() method. See also get (Camera.get method), names (Camera.names property) names (Camera.names property)public static names : Array [read-only] Retrieves an array of strings reflecting the names of all available cameras without displaying the Flash Player Privacy Settings panel. This array behaves in the same way as any other ActionScript array, implicitly providing the zero-based index of each camera and the number of cameras on the system (by means of Camera.names.length ). For more information, see the Camera.names Array class entry.
Calling the
Camera.names
property requires an
Note The correct syntax is Camera.names . To assign the return value to a variable, use syntax like cam_array = Camera.names . To determine the name of the current camera, use active_cam.name . Availability: ActionScript 1.0; Flash Player 6 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. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Then add the following ActionScript to Frame 1 of the Timeline:
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 get (Camera.get method), index (Camera.index property), name (Camera.name property) onActivity (Camera.onActivity handler)
onActivity = function(active:Boolean) {}
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.on Activity(false) , use Camera.setMotionLevel() . Availability: ActionScript 1.0; Flash Player 6 Parameters active :Boolean - A Boolean value set to true when the camera starts detecting motion, false when the motion stops. Example The following example displays true or false in the Output panel 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)
{
trace(mode);
}
See also setMotionLevel (Camera.setMotionLevel method) onStatus (Camera.onStatus handler)
onStatus = function(infoObject:Object) {}
Invoked when the user allows or denies access to the camera. If you want to respond to this event handler, you must create a function to process the information object generated by the camera. When a SWF file tries to access the camera, Flash Player displays a Privacy dialog box that lets the user choose whether to allow or deny access.
To determine whether the user has denied or allowed access to the camera without processing this event handler, use the Camera.muted property. Note: If the user chooses to permanently allow or deny access for all SWF files from a specified domain, this handler is not invoked for SWF files from that domain unless the user later changes the privacy setting. For more information, see Camera.get() . Availability: ActionScript 1.0; Flash Player 6 Parameters infoObject :Object - A parameter defined according to the status message. Example The following ActionScript is used to display a message whenever the user allows or denies access to the camera:
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
my_cam.onStatus = function(infoObj:Object) {
switch (infoObj.code) {
case 'Camera.Muted' :
trace("Camera access is denied");
break;
case 'Camera.Unmuted' :
trace("Camera access granted");
break;
}
}
See also get (Camera.get method), muted (Camera.muted property), showSettings (System.showSettings method), onStatus (System.onStatus handler) quality (Camera.quality property)public quality : Number [read-only]
An integer specifying the required level of picture quality, as determined by the amount of compression being applied to each video frame. Acceptable quality values range from 1 (
Availability: ActionScript 1.0; Flash Player 6 Example The following example uses a NumericStepper instance to specify the amount of compression applied to the camera feed. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a NumericStepper with the instance name quality_nstep. Then add the following ActionScript to Frame 1 of the Timeline:
var quality_nstep:mx.controls.NumericStepper;
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
quality_nstep.minimum = 0;
quality_nstep.maximum = 100;
quality_nstep.stepSize = 5;
quality_nstep.value = my_cam.quality;
function changeQuality() {
my_cam.setQuality(my_cam.bandwidth, quality_nstep.value);
}
quality_nstep.addEventListener("change", changeQuality);
See also setQuality (Camera.setQuality method) setMode (Camera.setMode method)public setMode([width:Number], [height:Number], [fps:Number], [favorArea:Boolean]) : Void Sets the camera capture mode to the native mode that best meets the specified requirements. If the camera does not have a native mode that matches all the parameters you pass, Flash selects a capture mode that most closely synthesizes the requested mode. This manipulation may involve cropping the image and dropping frames.
By default, Flash
When choosing a native mode, Flash tries to maintain the requested aspect ratio whenever possible. For example, if you issue the command active_cam . setMode ( 400, 400, 30 ), and the maximum width and height values available on the camera are 320 and 288, Flash sets both the width and height at 288; by setting these properties to the same value, Flash maintains the 1:1 aspect ratio you requested. To determine the values assigned to these properties after Flash selects the mode that most closely matches your requested values, use Camera.width , Camera.height , and Camera.fps . Availability: ActionScript 1.0; Flash Player 6 Parameters width :Number [optional] - The requested capture width, in pixels. The default value is 160. height :Number [optional] - The requested capture height, in pixels. The default value is 120. fps :Number [optional] - The requested rate at which the camera should capture data, in frames per second. The default value is 15. favorArea :Boolean [optional] - A Boolean value that specifies how to manipulate the width, height, and frame rate if the camera does not have a native mode that meets the specified requirements. The default value is true , which means that maintaining capture size is favored; using this parameter selects the mode that most closely matches width and height values, even if doing so adversely affects performance by reducing the frame rate. To maximize frame rate at the expense of camera height and width, pass false for the favorArea parameter. Example The following example sets the camera capture mode. You can type a frame rate into a TextInput instance and press Enter or Return to apply the frame rate. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a TextInput component instance with the instance name fps_ti. Then add the following ActionScript to Frame 1 of the Timeline:
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
fps_ti.maxChars = 2;
fps_ti.restrict = [0-9];
fps_lbl.text = "Current: "+my_cam.fps+" fps";
function changeFps():Void {
my_cam.setMode(my_cam.width, my_cam.height, fps_ti.text);
fps_lbl.text = "Current: "+my_cam.fps+" fps";
fps_ti.text = my_cam.fps;
Selection.setSelection(0,2);
}
fps_ti.addEventListener("enter", changeFps);
See also fps (Camera.fps property), height (Camera.height property), width (Camera.width property), currentFps (Camera.currentFps property) 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
Note Video can be displayed regardless of the value of the sensitivity parameter. This parameter determines only when and under waht 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) setQuality (Camera.setQuality method)public setQuality([bandwidth:Number], [quality:Number]) : Void
Sets the maximum amount of bandwidth per second or the required picture quality of the current outgoing video feed. This method is
Use this method to specify which element of the outgoing video feed is more important to your application--bandwidth use or picture quality.
Availability: ActionScript 1.0; Flash Player 6 Parameters bandwidth :Number [optional] - An integer that specifies the maximum amount of bandwidth that the current outgoing video feed can use, in bytes per second. To specify that Flash video can use as much bandwidth as needed to maintain the value of frameQuality , pass 0 for bandwidth . The default value is 16384. quality :Number [optional] - An integer that specifies the required level of picture quality, as determined by the amount of compression being applied to each video frame. Acceptable values range from 1 (lowest quality, maximum compression) to 100 (highest quality, no compression). To specify that picture quality can vary as needed to avoid exceeding bandwidth, pass 0 for quality . The default value is 0. Example
The following examples
// Ensure that no more than 8192 (8K/second) is used to send video active_cam.setQuality(8192,0); // Ensure that no more than 8192 (8K/second) is used to send video // with a minimum quality of 50 active_cam.setQuality(8192,50); // Ensure a minimum quality of 50, no matter how much bandwidth it takes active_cam.setQuality(0,50); See also get (Camera.get method), quality (Camera.quality property), bandwidth (Camera.bandwidth property) width (Camera.width property)public width : Number [read-only] The current capture width, in pixels. To set a desired value for this property, use Camera.setMode() . Availability: ActionScript 1.0; Flash Player 6 Example The following code displays the current width, height and FPS of a video instance in a Label component instance on the Stage. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name my_video . Add a Label component instance to the Stage and give it the instance name dimensions_lbl. Then add the following ActionScript to Frame 1 of the Timeline:
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
var dimensions_lbl:mx.controls.Label;
dimensions_lbl.setStyle("fontSize", 9);
dimensions_lbl.setStyle("fontWeight", "bold");
dimensions_lbl.setStyle("textAlign", "center");
dimensions_lbl.text = "width: "+my_cam.width+", height: "+my_cam.height+",
FPS: "+my_cam.fps;
See also the example for Camera.setMode() . See also height (Camera.height property), setMode (Camera.setMode method) |