Client-Side ActionScript Language
Reference for Flash Media Server 2
Trademarks
1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central,
ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite,
FlashPaper, Flash Video Encoder, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder,
Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit,
Studio MX, UltraDev, and WebHelp are either registered trademarks or trademarks of Macromedia, Inc. and may be registered in
the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words, or phrases
mentioned within this publication may be trademarks, service marks, or trade names of Macromedia, Inc. or other entities and
may be registered in certain jurisdictions including internationally.
Third-Party Information
This guide contains links to third-party websites that are not under the control of Macromedia, and Macromedia is not
responsible for the content on any linked site. If you access a third-party website mentioned in this guide, then you do so at your
own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia
endorses or accepts any responsibility for the content on those third-party sites.
Sorenson™ Spark™ video compression and decompression technology licensed from
Sorenson Media, Inc.
Macromedia Flash Media Server provides two application program interfaces (APIs): a ClientSide Media ActionScript API and a Server-Side Media ActionScript API. This guide explains
the client-side API.
This document is designed to be used in combination with the ActionScript documentation
included with Macromedia Flash. Refer to the Flash documentation for general scripting
information. Use this document to add Flash Media Server functionality to your Flash
applications.
For additional information about developing applications for Flash Media Server and to
understand how objects created on the client-side are paired with those on the server-Rside,
see Developing Media Applications.
NOTE
Most sample code in this document uses ActionScript 2.0 syntax.
1
ActionScript classes
The following table lists all the classes in this guide, Client-Side ActionScript Language
Reference for Flash Media Server 2:
ActionScript classDescription
Camera classLets you capture video from a video camera attached to the
computer that is running Macromedia Flash Player.
Microphone classLets you capture audio from a microphone attached to the
computer that is running Flash Player.
MovieClip classLets you specify whether an audio source is to be played locally
(Microphone object) or streamed from Flash Media Server
(NetStream object).
5
ActionScript classDescription
NetConnection classManages a bidirectional connection between Flash Player and a
server, which lets you connect to Flash Remoting or to Flash
Media Server.
NetStream classOpens a one-way streaming connection between Flash Player
and Flash Media Server through a connection made available by
a NetConnection object.
SharedObject classAllows real-time data sharing between multiple client SWF files
and objects that are persistent on the local or remote location.
System classThe System class contains properties related to certain
operations that take place on the user's computer, such as
operations with shared objects, local settings for cameras and
microphones, and use of the Clipboard.
Video classLets you display live or recorded streaming video on the Stage
without embedding it in your SWF file.
ActionScript elements
Entries in this document are alphabetical by class name and then by method, property, or
event handler name. The following table lists all classes, methods, properties, and event
handlers individually in alphabetical order.
The Camera class lets you capture video from a video camera attached to the computer that is
running Macromedia Flash Player. When used with Flash Media Server, this class lets you
transmit, display, and optionally record the video being captured. With these capabilities, you
can develop media applications such as video conferencing, instant messaging with video, and
so on. Flash provides similar audio capabilities; for more information, see the Microphone
class entry.
You can also use a Camera object without a server—for example, to monitor a video feed from
a webcam attached to your local system.
NOTE
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 for the Camera
class examples; this is the minimum size Flash requires to display the dialog box.) End
users and administrative users may also disable camera access on a per-site or global
basis.
To create or reference a Camera object, use the
Camera.get() method.
Method summary for the Camera class
MethodDescription
Camera.get()Returns a reference to a Camera object for capturing
video.
Camera.setKeyFrameInterval()Specifies which video frames are transmitted in full
instead of being interpolated by the video compression
algorithm.
Camera.setLoopback()Specifies whether to use a compressed video stream for a
local view of what the camera is transmitting.
Camera.setMode()Sets aspects of the camera capture mode, including
height, width, and frames per second.
Camera.setMotionLevel()Specifies how much motion is required to invoke
Camera.onActivity(true).
Camera.setQuality()Sets the maximum amount of bandwidth per second or
the required picture quality of the current outgoing video
feed.
Camera class9
Property summary for the Camera class
Property (read-only)Description
Camera.activityLevelA numeric value from 0 to 100 that specifies the amount of
motion the camera is detecting.
Camera.bandwidthThe maximum amount of bandwidth the current outgoing
video feed can use, in bytes.
Camera.currentFpsThe rate at which the camera is capturing data, in frames per
second.
Camera.fpsThe rate at which you would like the camera to capture data, in
frames per second.
Camera.heightThe current capture height, in pixels.
Camera.indexThe index of the camera, as reflected in the array returned by
Camera.names.
Camera.keyFrameIntervalA number that specifies which video frames are transmitted in
full instead of being interpolated by the video compression
algorithm.
Camera.loopbackA Boolean value that specifies whether a local view of what
the camera is capturing is compressed or uncompressed.
Camera.motionLevelA numeric value from 0 to 100 that specifies the amount of
motion required to invoke
Camera.motionTimeOutThe number of milliseconds between the time the camera
Camera.onActivity(true).
stops detecting motion and the time
Camera.onActivity(false) is invoked.
Camera.mutedA Boolean value that specifies whether the user has allowed
or denied access to the camera.
Camera.nameThe name of the camera as specified by the camera hardware.
Camera.namesClass property; an array of strings containing the names of all
available video capture devices, including video capture cards
and cameras.
Camera.qualityA number that specifies the current level of picture quality
based on the amount of compression being applied to each
video frame.
Camera.widthThe current capture width, in pixels.
10Client-Side ActionScript Language Reference
Event handler summary for the Camera class
MethodDescription
Camera.onActivityInvoked when the camera starts or stops detecting motion.
Camera.onStatusInvoked when the user allows or denies access to the camera.
Constructor for the Camera class
See Camera.get().
Camera.activityLevel
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public activityLevel : Number [read-only]
Description
Property (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 detected). The value of this property can help you determine if you need to
pass a setting to
If the camera is available but is not yet being used because neither
NetStream.attachVideo() has been called, this property is set to -1.
Camera.setMotionLevel().
Video.attachVideo() nor
If you are streaming only uncompressed local video—that is, you are not streaming the video
within a NetStream object and you have not called
property is set only if you have assigned a function to the
Property (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().
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
component instance to the Stage and give it the instance name
my_video. Add a NumericStepper
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+"
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player
7 or later. If your SWF file includes a v2 component (version 2 of the Macromedia
Component Architecture), use the DepthManager class from the component framework
instead of the
See also
Camera.setQuality()
MovieClip.getNextHighestDepth() method.
Camera.currentFps
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public currentFps : Number [read-only]
Description
Property (read-only); the rate at which the camera is capturing data, in frames per second.
This property cannot be set; however, you can use
property—
Camera.fps—which specifies the maximum frame rate at which you would like
the camera to capture data.
Camera.setMode() to set a related
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
the instance name
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);
};
my_video. Add a ProgressBar component instance to the Stage and give it
fps_pb. Then add the following ActionScript to Frame 1 of the Timeline:
Camera class13
See also
Camera.fps, Camera.setMode()
Camera.fps
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public fps : Number [read-only]
Description
Property (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.
■To set a desired value for this property, use Camera.setMode().
■To determine the rate at which the camera is currently capturing data, use
Camera.currentFps.
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
the instance name
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);
};
The setMode() method does not guarantee the requested fps setting; it sets the fps you
requested or the fastest fps available.
my_video. Add a ProgressBar component instance to the Stage and give it
fps_pb. Then add the following ActionScript to Frame 1 of the Timeline:
14Client-Side ActionScript Language Reference
See also
Camera.currentFps, Camera.setMode()
Camera.get()
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public static get([index:Number]) : Camera
NOTE
To assign the Camera object to a variable, use the following syntax:
var active_cam:Camera = Camera.get().
Parameters
index An optional zero-based integer that specifies which camera driver to get, as
determined from the array returned by
(which is recommended for most applications), omit this parameter.
Camera.names. To get the default camera driver
Returns
■If index is not specified, this method returns a reference to the default camera driver or, if
it is in use by another application, to the first available camera driver. (If there is more
than one camera driver installed, the user may specify the default camera driver in the
Flash Player Camera Settings panel.) If no camera drivers are available or installed, the
method returns
■If index is specified, this method returns a reference to the requested camera driver, or
null if it is not available.
Description
null.
Method; returns a reference to a Camera object for capturing video. To actually begin
capturing the video, you must attach the Camera object either to a Video object (see
Video.attachVideo()) or to a NetStream object (see NetStream.attachVideo()). (The
NetStream object is available only with Flash Media Server.)
NOTE
The Camera.get() method returns a reference to a camera driver, not to a physical
camera.
Camera class15
Unlike objects that you create using the new constructor, multiple calls to Camera.get()
reference the same camera driver. Thus, if your script contains the lines
cam1 = Camera.get() and cam2 = Camera.get(), both cam1 and cam2 reference the same
(default) camera driver.
In general, you shouldn’t pass a value for
index; simply use Camera.get() to return a
reference to the default camera driver. By means of the Camera settings panel (discussed later
in this section), the user can specify the default camera driver Flash should use. If you pass a
value for
prefers. You might use
index, you might be trying to reference a camera driver other than the one the user
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
you issue
NetStream.attachVideo() or Video.attachVideo()—Flash Player displays a
Camera.get()—for example, when
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 by 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
Camera.muted.
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 and selecting
Settings. When the Privacy dialog box opens, the user selects Remember.
You can’t use ActionScript to set the Allow or Deny value for a user, but you can display the
Privacy dialog box 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 driver to be referenced by
System.showSettings(3).
16Client-Side ActionScript Language Reference
Camera.get(), use
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 Flash 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.
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
instance name
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);
my_video. Add a Label component instance to the Stage and give it the
camera_lbl, and a ComboBox component instance and give it the instance
Property (read-only); the current capture height, in pixels. To set a value for this property, use
Camera.setMode().
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
Camera.setMode(), Camera.width
Camera.index
Availability
■Flash Player 6.
■Flash Media Server (not required).
18Client-Side ActionScript Language Reference
Usage
active_cam.index
Description
Property (read-only); a zero-based integer that specifies the index of the camera, as reflected in
the array returned by
Example
Camera.names.
The following example displays an array of cameras in a text field that is created at runtime,
and tells you which camera you are currently using. 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
instance name
var camera_lbl:mx.controls.Label;
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
my_video. Add a Label component instance to the Stage and give it the
camera_lbl. Then add the following ActionScript to Frame 1 of the Timeline:
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player
7 or later. If your SWF file includes a v2 component (version 2 of the Macromedia
Component Architecture), use the DepthManager class from the component framework
instead of the
See also
Camera.get(), Camera.names
MovieClip.getNextHighestDepth() method.
Camera class19
Camera.keyFrameInterval
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public keyFrameInterval : Number [read-only]
Description
Property (read-only); a number that specifies which video frames are transmitted in full
(called keyframes) instead of being interpolated by the video compression algorithm. The
default value is 15 (every 15th frame is a keyframe).
See also
Camera.setKeyFrameInterval()
Camera.loopback
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public loopback : Boolean [read-only]
Description
Property (read-only); a Boolean value that specifies whether a local view of what the camera is
capturing is compressed and decompressed as it would be for live transmission using Flash
Media Server (
true) or uncompressed (false). The default value is false.
To set this value, use Camera.setLoopback(). To set the amount of compression used when
this property is
Example
true, use Camera.setQuality().
See the example for Camera.setLoopback().
See also
Camera.setLoopback(), Camera.setQuality()
20Client-Side ActionScript Language Reference
Camera.motionLevel
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public motionLevel : Number [read-only]
Description
Property (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
information, see
Camera.setMotionLevel().
motionLevel property. For more
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
and give it the instance name
motionLevel_nstep, and a ProgressBar with the instance name motion_pb. Then add the
my_video. Add a Label component instance to the Stage
motionLevel_lbl, a NumericStepper with the instance name
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. */
/* 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);
Property (read-only); the number of milliseconds between the time the camera stops detecting
motion and the time
(2 seconds).
To set this value, use
Camera.onActivity(false) is invoked. The default value is 2000
Camera.setMotionLevel().
22Client-Side ActionScript Language Reference
Example
In the following example, the ProgressBar instance changes its halo theme color when the
activity level falls below the motion level. You can set the number of seconds for the
motionTimeout property using a NumericStepper 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
instance name
motionTimeOut_nstep, and a ProgressBar with the instance name motion_pb. Then add the
my_video. Add a Label component instance to the Stage and give it the
motionLevel_lbl, a NumericStepper with the instance name
following ActionScript to Frame 1 of the Timeline:
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);
Property (read-only); a Boolean value that specifies whether the user has denied access to the
camera (
value changes,
Example
In the following example, an error message could be displayed if my_cam.muted evaluates to
true. 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
ActionScript to Frame 1 of the Timeline:
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) {
trace("User denied access to Camera");
System.showSettings(0);
}
};
true) or allowed access (false) in the Flash Player Privacy dialog box. When this
Camera.onStatus is invoked. For more information, see Camera.get().
my_video. Then add the following
/* 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).*/
See also
Camera.get(), Camera.onStatus
24Client-Side ActionScript Language Reference
Camera.name
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public name : String [read-only]
Description
Property (read-only); a string that specifies the name of the current camera, as returned by the
camera hardware.
Example
The following example displays the name of the default camera in a text field and writes the
name to the log file. In Windows, this name is the same as the device name listed in the
Camera Settings 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
ActionScript to Frame 1 of the Timeline:
my_video. Then add the following
var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player
7 or later. If your SWF file includes a v2 component (version 2 of the Macromedia
Component Architecture), use the DepthManager class from the component framework
instead of the
See also
Camera.get(), Camera.names
MovieClip.getNextHighestDepth() method.
Camera class25
Camera.names
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public static names : Array [read-only]
NOTE
The correct syntax is Camera.names. To assign the return value to a variable, use syntax
like
var cam_array:Array = Camera.names. To determine the name of the current camera,
active_cam.name, where active_cam is the variable to which you assigned the results
use
of
Camera.get().
Description
Class property (read-only); retrieves an array of strings reflecting the names of all available
video capture devices (including video capture cards and cameras) without displaying the
Flash Player Privacy dialog box. This array behaves the same as any other ActionScript array,
implicitly providing the zero-based index of each camera driver and the number of camera
drivers on the system (by means of
Array class entry in the ActionScript 2.0 Language Reference.
Camera.names.length). For more information, see the
Calling the
Camera.names property requires an extensive examination of the hardware, and it
may take several seconds to build the array. In most cases, you can just use the default camera.
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, 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
Camera.get(), Camera.index, Camera.names
26Client-Side ActionScript Language Reference
Camera.onActivity
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public onActivity = function(activity:Boolean) {}
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 displays true or false in the Output panel when the camera starts or
stops detecting motion:
// assumes a Video object named "my_video" is on the Stage
var active_cam:Camera = Camera.get();
my_video.attachVideo(active_cam);
active_cam.setMotionLevel(10, 500);
active_cam.onActivity = function(mode) {
trace(mode);
}
See also
Camera.setMotionLevel()
Camera class27
Camera.onStatus
Availability
■Flash Player 6.
■Flash Media Server.
Usage
public onStatus = function(infoObject:Object) {}
Parameters
infoObject A parameter defined according to the status message. For more information
about this parameter, see “Camera information objects” on page 151.
Returns
Nothing.
Description
Event handler; invoked when one of the following events occurs:
■The user allows access to the camera. The Camera.muted property is set to false, and
this handler is invoked with an information object whose
Camera.Unmuted.
code property is
■The user denies access to the camera. The Camera.muted property is set to true, and this
handler is invoked with an information object whose
code property is Camera.Muted.
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().
If you want to respond to this event handler, you must create a function to process the
information object generated by the camera. For more information, see Appendix A, “Client-
Side Information Objects,” on page 149.
28Client-Side ActionScript Language Reference
Example
The following event handler displays a message whenever the user allows or denies access to
the camera:
// assumes a Video object named "my_video" is on the Stage
var active_cam:Camera = Camera.get();
my_video.attachVideo(active_cam);
active_cam.onStatus = function(infoMsg) {
if(infoMsg.code == "Camera.Muted"){
trace("User denies access to the camera");
}
else
trace("User allows access to the camera");
}
// Change the Allow or Deny value to invoke the function.
System.showSettings(0);
See also
Camera.get(), Camera.muted, System.showSettings()
Camera.quality
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public quality : Number [read-only]
Description
Property (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 (lowest quality, maximum compression) to 100 (highest quality, no
compression). The default value is 0, which means that picture quality can vary as needed to
avoid exceeding available bandwidth.
Camera class29
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
Add a NumericStepper with the instance name
quality_nstep. Then add the following
my_video.
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);
function changeQuality() {
my_cam.setQuality(my_cam.bandwidth, quality_nstep.value);
}
quality_nstep.addEventListener("change", changeQuality);
See also
Camera.setQuality()
Camera.setKeyFrameInterval()
Availability
■Flash Player 6.
■Flash Media Server (not required).
Usage
public setKeyFrameInterval(keyframeInterval : Number) : Void
Parameters
keyframeInterval A numeric value that specifies which video frames are transmitted in
full (called keyframes) instead of being interpolated by the video compression algorithm. A
value of 1 means that every frame is a keyframe, a value of 3 means that every third frame is a
keyframe, and so on. Acceptable values are 1 through 48. The default value is 15.
Returns
Nothing.
30Client-Side ActionScript Language Reference
Loading...
+ 126 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.