PackageTop Level
Classpublic class Video
InheritanceVideo Inheritance Object

Player version: Flash Player 6 — The ability to play Flash Video (FLV) files was added in Flash Player 7. The ability to use the On2 VP6 codec and to use an alpha channel was added in Flash Player 8.

The Video class enables you to display live streaming video on the Stage without embedding it in your SWF file. You capture the video by using Camera.get(). In files published for Flash Player 7 and later, you can also use the Video class to play back Flash Video (FLV) files over HTTP or from the local file system. For more information, see the NetConnection class and NetStream class entries.

Flash Player 7 supports Flash video (FLV) encoded with the Sorenson Spark video codec. Flash Player 8 supports Flash video (FLV) encoded with either the Sorenson or the On2 VP6 codec and also supports an alpha channel. The On2 VP6 video codec uses less bandwidth than older technologies, and offers additional deblocking and deringing filters.

If your Flash content dynamically loads Flash video (using either progressive download or Flash Media Server), you can use On2 VP6 video without having to republish your SWF for Flash Player 8, as long as users view your content through Flash Player 8 and later. By streaming or downloading On2 VP6 video into Flash SWF version 6 or 7, and playing the content using Flash Player 8, you avoid having to recreate your SWF files for use with Flash Player 8.

Flash Player 9.0.115.0 and later versions support files derived from the standard MPEG-4 container format including F4V, MP4, M4A, MOV, MP4V, 3GP, and 3G2 if they contain H.264 video and/or HEAAC v2 encoded audio. H.264 delivers higher quality video at lower bitrates when compared to the same encoding profile in Sorenson or On2. HE-AAC v2 is an extension of AAC (a standard audio format defined in the MPEG-4 video standard) that uses Spectral Band Replication (SBR) and Parametric Stereo (PS) techniques to increase coding efficiency at low bitrates. To learn more about H.264 encoding, see Exploring Flash Player support for high-definition H.264 video and AAC audio.

Codec Content (SWF) Version
(publish version)
Flash Player Version
(version required for playback)
Sorenson Spark 6 6, 7, 8
  7 7, 8
On2 VP6 6 8*
  7 8
  8 8
H.264 9.0.115.0 9.0.115.0

* If your Flash content dynamically loads Flash video (FLV), you can use On2 VP6 video without having to republish your SWF for Flash Player 8, as long as users use Flash Player 8 or later to view your content. Only Flash Player 8 and later versions support both publish and playback of On2 VP6 video.

A Video object can be used like a movie clip. As with other objects you place on the Stage, you can control various properties of Video objects. For example, you can move the Video object around on the Stage by using its _x and _y properties, you can change its size using its _height and _width properties, and so on.

To display the video stream, first place a Video object on the Stage. Then use Video.attachVideo() to attach the video stream to the Video object.

  1. If the Library panel isn't visible, select Window > Library to display it.
  2. Add an embedded Video object to the library by clicking the Options menu on the right side of the Library panel title bar and selecting New Video.
  3. Drag the Video object to the Stage and use the Property inspector to give it a unique instance name, such as my_video. (Do not name it Video.)

See also

NetConnection
NetStream


Public Properties
 Property
  _alpha : Number
Indicates the alpha transparency value of the Video object specified.
  deblocking : Number
Indicates the type of deblocking filter applied to decoded video as part of postprocessing.
  _height : Number
Indicates the height of the Video object, in pixels.
  height : Number
[read-only]An integer specifying the height of the video stream, in pixels.
  _name : String
Indicates the instance name of the Video object specified.
  _parent : MovieClip
Indicates the movie clip or object that contains the current Video object.
  _rotation : Number
Indicates the rotation of the Video object, in degrees, from its original orientation.
  smoothing : Boolean
Specifies whether the video should be smoothed (interpolated) when it is scaled.
  _visible : Boolean
Indicates whether the Video object specified by my_video is visible.
  _width : Number
Indicates the width of the Video object, in pixels.
  width : Number
[read-only]An integer specifying the width of the video stream, in pixels.
  _x : Number
Indicates the x coordinate of a Video object relative to the local coordinates of the parent movie clip.
  _xmouse : Number
[read-only]Indicates the x coordinate of the mouse position.
  _xscale : Number
Indicates the horizontal scale (percentage) of the Video object as applied from the registration point of the Video object.
  _y : Number
Indicates the y coordinate of a Video object relative to the local coordinates of the parent movie clip.
  _ymouse : Number
[read-only]Indicates the y coordinate of the mouse position.
  _yscale : Number
Indicates the vertical scale (percentage) of the Video object as applied from the registration point of the Video object.
 Properties inherited from class Object
 __proto__, __resolve, constructor, prototype
Public Methods
 Method
  
attachVideo(source:Object):Void
Specifies a video stream (source) to be displayed within the boundaries of the Video object on the Stage.
  
clear():Void
Clears the image currently displayed in the Video object.
 Methods inherited from class Object
 addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch
Property detail
_alphaproperty
public var _alpha:Number

Player version: Flash Player 8

Indicates the alpha transparency value of the Video object specified. Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Objects in a movie clip with _alpha set to 0 are active, even though they are invisible.

See also

deblockingproperty 
public var deblocking:Number

Player version: Flash Player 6

Indicates the type of deblocking filter applied to decoded video as part of postprocessing. Two deblocking filters are available: one in the Sorenson codec and one in the On2 VP6 codec. The following values are acceptable:

If a mode greater than 2 is selected for video when you are using the Sorenson codec, the Sorenson decoder defaults to mode 2 internally.

Use of a deblocking filter has an effect on overall playback performance, and it is usually not necessary for high-bandwidth video. If your system is not powerful enough, you may experience difficulties playing back video with this filter enabled.


Example
The following example plays video1.flv in the my_video video object, and lets the user change the deblocking filter behavior on video1.flv. Add a video object called my_video and a ComboBox instance called deblocking_cb to your file, and then add the following ActionScript to your FLA or AS file.
var deblocking_cb:mx.controls.ComboBox;
var my_video:Video; // my_video is a Video object on the Stage
var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play("video1.flv");

deblocking_cb.addItem({data:0, label:'Auto'});
deblocking_cb.addItem({data:1, label:'No'});
deblocking_cb.addItem({data:2, label:'Yes'});

var cbListener:Object = new Object();
cbListener.change = function(evt:Object) {
    my_video.deblocking = evt.target.selectedItem.data;
};
deblocking_cb.addEventListener("change", cbListener);

Use the ComboBox instance to change the deblocking filter behavior on video1.flv.

_heightproperty 
public var _height:Number

Player version: Flash Player 8

Indicates the height of the Video object, in pixels.

See also

heightproperty 
height:Number  [read-only]

Player version: Flash Player 6

An integer specifying the height of the video stream, in pixels. For live streams, this value is the same as the Camera.height property of the Camera object that is capturing the video stream. For FLV files, this value is the height of the file that was exported as FLV.

You may want to use this property, for example, to ensure that the user is seeing the video at the same size at which it was captured, regardless of the actual size of the Video object on the Stage.

Implementation
    public function get height():Number

See also


Example
The following example sets the _height and _width properties of the Video Symbol instance equal to the height and width of the loaded FLV file.

To use this example, first create a new Video symbol with an instance name of "myVideo" and place it in the same context as this script. The height and width properties will be zero when the NetStream.Play.Start status code is triggered. By resizing the video when the status of NetStream.Buffer.Full is received you make sure that its size is correct before the first frame of video is shown.

var netConn:NetConnection = new NetConnection();
netConn.connect(null);
var netStrm:NetStream = new NetStream(netConn);

myVideo.attachVideo(netStrm);
netStrm.play("Video.flv");

netStrm.onStatus = function(infoObject:Object) {
    switch (infoObject.code) {
        case 'NetStream.Play.Start' :
        case 'NetStream.Buffer.Full' :
            myVideo._width = myVideo.width;
            myVideo._height = myVideo.height;
            break;
    }
}

_nameproperty 
public var _name:String

Player version: Flash Player 8

Indicates the instance name of the Video object specified.

_parentproperty 
public var _parent:MovieClip

Player version: Flash Player 8

Indicates the movie clip or object that contains the current Video object. The current object is the object containing the ActionScript code that references _parent. Use the _parent property to specify a relative path to movie clips or objects that are above the current object.

You can use _parent to move up multiple levels in the display list as in the following:

this._parent._parent._alpha = 20;

See also

_rotationproperty 
public var _rotation:Number

Player version: Flash Player 8

Indicates the rotation of the Video object, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement my_video._rotation = 450 is the same as my_video._rotation = 90.

smoothingproperty 
public var smoothing:Boolean

Player version: Flash Player 6

Specifies whether the video should be smoothed (interpolated) when it is scaled. For smoothing to work, the player must be in high-quality mode. The default value is false (no smoothing).


Example
The following example uses a button (called smoothing_btn) to toggle the smoothing property that is applied to the video my_video when it plays in a SWF file. Create a button called smoothing_btn and add the following ActionScript to your FLA or AS file:
this.createTextField("smoothing_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
smoothing_txt.autoSize = true;

var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play("video1.flv");
my_ns.onStatus = function(infoObject:Object) {
    updateSmoothing();
};
smoothing_btn.onRelease = function() {
    my_video.smoothing = !my_video.smoothing;
    updateSmoothing();
};
function updateSmoothing():Void {
    smoothing_txt.text = "smoothing = "+my_video.smoothing;
}

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.

_visibleproperty 
public var _visible:Boolean

Player version: Flash Player 8

Indicates whether the Video object specified by my_video is visible.

_widthproperty 
public var _width:Number

Player version: Flash Player 8 — as a read-only property.

Indicates the width of the Video object, in pixels.

See also

widthproperty 
width:Number  [read-only]

Player version: Flash Player 6

An integer specifying the width of the video stream, in pixels. For live streams, this value is the same as the Camera.width property of the Camera object that is capturing the video stream. For FLV files, this value is the width of the file that was exported as an FLV file.

You may want to use this property, for example, to ensure that the user is seeing the video at the same size at which it was captured, regardless of the actual size of the Video object on the Stage.

Implementation
    public function get width():Number

Example
See the examples for Video.height.

_xproperty 
public var _x:Number

Player version: Flash Player 8

Indicates the x coordinate of a Video object relative to the local coordinates of the parent movie clip. If a Video object is in the main Timeline, then its coordinate system refers to the upper left corner of the Stage as (0, 0). If the Video object is inside a movie clip that has transformations, the Video object is in the local coordinate system of the enclosing movie clip. Thus, for a movie clip rotated 90° counterclockwise, the movie clip's children inherit a coordinate system that is rotated 90° counterclockwise. The Video object's coordinates refer to the registration point position.

See also

_xmouseproperty 
_xmouse:Number  [read-only]

Player version: Flash Player 8

Indicates the x coordinate of the mouse position.

Implementation
    public function get _xmouse():Number

See also

_xscaleproperty 
public var _xscale:Number

Player version: Flash Player 8

Indicates the horizontal scale (percentage) of the Video object as applied from the registration point of the Video object. The default registration point is (0,0).

Scaling the local coordinate system affects the _x and _y property settings, which are defined in whole pixels.

See also

_yproperty 
public var _y:Number

Player version: Flash Player 8

Indicates the y coordinate of a Video object relative to the local coordinates of the parent movie clip. If a Video object is in the main Timeline, then its coordinate system refers to the upper left corner of the Stage as (0, 0). If the Video object is inside a movie clip that has transformations, the Video object is in the local coordinate system of the enclosing movie clip. Thus, for a movie clip rotated 90° counterclockwise, the movie clip's children inherit a coordinate system that is rotated 90° counterclockwise. The Video object's coordinates refer to the registration point position.

See also

_ymouseproperty 
_ymouse:Number  [read-only]

Player version: Flash Player 8

Indicates the y coordinate of the mouse position.

Implementation
    public function get _ymouse():Number

See also

_yscaleproperty 
public var _yscale:Number

Player version: Flash Player 8

Indicates the vertical scale (percentage) of the Video object as applied from the registration point of the Video object. The default registration point is (0,0).

Scaling the local coordinate system affects the _x and _y property settings, which are defined in whole pixels.

See also

Method detail
attachVideo()method
public function attachVideo(source:Object):Void

Player version: Flash Player 6 — The ability to work with Flash Video (FLV) files was added in Flash Player 7.

Specifies a video stream (source) to be displayed within the boundaries of the Video object on the Stage. The video stream is either an FLV file being displayed by means of the NetStream.play() command, a Camera object, or null. If source is null, video is no longer played within the Video object.

You don't have to use this method if the FLV file contains only audio; the audio portion of an FLV files is played automatically when the NetStream.play() command is issued.

If you want to control the audio associated with an FLV file, you can use MovieClip.attachAudio() to route the audio to a movie clip; you can then create a Sound object to control some aspects of the audio. For more information, see MovieClip.attachAudio().

Parameters
source:Object — A Camera object that is capturing video data or a NetStream object. To drop the connection to the Video object, pass null for source.

See also


Example
The following example plays live video locally:
var my_video:Video; //my_video is a Video object on the Stage
var active_cam:Camera = Camera.get();
my_video.attachVideo(active_cam);

The following example plays a previously recorded file named video1.flv that is stored in the same directory as the SWF file.

var my_video:Video; // my_video is a Video object on the Stage
var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play("video1.flv");

clear()method 
public function clear():Void

Player version: Flash Player 6

Clears the image currently displayed in the Video object. This is useful when, for example, you want to display standby information without having to hide the Video object.

See also


Example
The following example pauses and clears video1.flv that is playing in a Video object (called my_video) when the user clicks the pause_btn instance.
var pause_btn:Button;
var my_video:Video; // my_video is a Video object on the Stage
var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play("video1.flv");
pause_btn.onRelease = function() {
    my_ns.pause();
    my_video.clear();
};