A-C > Camera.get |
![]() ![]() ![]() |
Camera.get
Camera, video, constructor, Camera.get, get
Communications/Camera/Methods/get
Availability
Flash Player 6.
Usage
Camera.get([index
])
Note: The correct syntax is Camera.get()
. To assign the Camera object to a variable, use syntax like activeCamera = Camera.get()
.
Parameters
index
An optional 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
![]() |
If |
![]() |
If |
Description
Method; 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 or.
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 cam1 = Camera.get()
and cam2 = Camera.get()
, both cam1
and cam2
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 casesfor example, if your application is capturing video from two cameras at the same time.
When a movie tries to access the camera returned by Camera.get
, the 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 movie is playing, choosing Settings, opening the Privacy panel, and selecting Remember.
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
.
Note that scanning the hardware for cameras takes time. Once 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 movie provides a Try Again button that calls Camera.get
, Flash can find the camera without the user having to restart the movie.
Example
The following example captures and displays video locally within a Video object named myVid on the Stage.
myCam = Camera.get(); myVid.attachVideo(myCam);
See also
Camera.index
, Camera.muted
, Camera.names
, Camera.onStatus
, Camera.setMode
![]() ![]() ![]() |