Video


Object   |   +-Video public class Video extends Object

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 Communication 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. 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.

Codec

Content (SWF)Version(publish version)

Flash PlayerVersion(version required for playback)

Sorenson Spark

6

6, 7, 8

7

7, 8

On2 VP6

6

8[*]

7

8

8

8


[*] 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 to view your content. Only Flash Player 8 supports 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.

  • If the Library panel isn't visible, select Window > Library to display it.

  • 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.

  • 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.)

Availability: ActionScript 1.0; 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.

See also

NetConnection, NetStream

Property summary

Modifiers

Property

Description

 

_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

constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property)


Method summary

Modifiers

Signature

Description

 

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 (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method)


_alpha (Video._alpha property)

public _alpha : Number

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.

Availability: ActionScript 1.0; Flash Player 8

See also

_visible (Video._visible property)

attachVideo (Video.attachVideo method)

public attachVideo(source:Object) : Void

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().

Availability: ActionScript 1.0; Flash Player 6 - The ability to work with Flash Video (FLV) files was added in Flash Player 7.

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.

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 myVideo.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");

See also

Camera, NetStream

clear (Video.clear method)

public clear() : Void

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.

Availability: ActionScript 1.0; Flash Player 6

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(); };

See also

attachVideo (Video.attachVideo method)

deblocking (Video.deblocking property)

public deblocking : Number

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:

  • 0 (the default) Let the video compressor apply the deblocking filter as needed.

  • 1 Do not use any deblocking filter.

  • 2 Use the Sorenson deblocking filter.

  • 3 Use the On2 deblocking filter and no deringing filter.

  • 4 Use the On2 deblocking and the fast On2 deringing filter.

  • 5 Use the On2 deblocking and the better On2 deringing filter.

  • 6 Same as 5.

  • 7 Same as 5.

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.

Availability: ActionScript 1.0; Flash Player 6

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.

_height (Video._height property)

public _height : Number

Indicates the height of the Video object, in pixels.

Availability: ActionScript 1.0; Flash Player 8

See also

_width (Video._width property)

height (Video.height property)

public height : Number [read-only]

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.

Availability: ActionScript 1.0; Flash Player 6

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;   } }

See also

_height (MovieClip._height property),width (Video.width property)

_name (Video._name property)

public _name : String

Indicates the instance name of the Video object specified.

Availability: ActionScript 1.0; Flash Player 8

_parent (Video._parent property)

public _parent : MovieClip

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;

Availability: ActionScript 1.0; Flash Player 8

See also

_root property, _target (MovieClip._target property)

_rotation (Video._rotation property)

public _rotation : Number

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.

Availability: ActionScript 1.0; Flash Player 8

smoothing (Video.smoothing property)

public smoothing : Boolean

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).

Availability: ActionScript 1.0; Flash Player 6

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.

_visible (Video._visible property)

public _visible : Boolean

Indicates whether the Video object specified by my_video is visible.

Availability: ActionScript 1.0; Flash Player 8

_width (Video._width property)

public _width : Number

Indicates the width of the Video object, in pixels.

Availability: ActionScript 1.0; Flash Player 8 - as a read-only property.

See also

_height (Video._height property)

width (Video.width property)

public width : Number [read-only]

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.

Availability: ActionScript 1.0; Flash Player 6

Example

See the examples for Video.height.

_x (Video._x property)

public _x : Number

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.

Availability: ActionScript 1.0; Flash Player 8

See also

_xscale (Video._xscale property), _y (Video._y property), _yscale (Video._yscale property)

_xmouse (Video._xmouse property)

public _xmouse : Number [read-only]

Indicates the x coordinate of the mouse position.

Availability: ActionScript 1.0; Flash Player 8

See also

Mouse, _ymouse (Video._ymouse property)

_xscale (Video._xscale property)

public _xscale : Number

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.

Availability: ActionScript 1.0; Flash Player 8

See also

_x (Video._x property), _y (Video._y property), _yscale (Video._yscale property), _width (Video._width property)

_y (Video._y property)

public _y : Number

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.

Availability: ActionScript 1.0; Flash Player 8

See also

_x (Video._x property), _xscale (Video._xscale property), _yscale (Video._yscale property)

_ymouse (Video._ymouse property)

public _ymouse : Number [read-only]

Indicates the y coordinate of the mouse position.

Availability: ActionScript 1.0; Flash Player 8

See also

Mouse, _xmouse (Video._xmouse property)

_yscale (Video._yscale property)

public _yscale : Number

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.

Availability: ActionScript 1.0; Flash Player 8

See also

_x (Video._x property), _xscale (Video._xscale property), _y (Video._y property), _height (Video._height property)



ActionScript 2.0 Language Reference for Macromedia Flash 8
ActionScript 2.0 Language Reference for Macromedia Flash 8
ISBN: 0321384040
EAN: 2147483647
Year: 2004
Pages: 113

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net