Monday, July 18, 2011

You want to load and playback progressive download Flash video.

The following code constructs a NetConnection object and initializes it for use with progressive download video.This code comes under the flash.net.Netconnection.

var videoConnection:NetConnection = new NetConnection( );
videoConnection.connect(null);
This code constructs a NetStream object
var videoStream:NetStream = new NetStream(videoConnection);
This code constructs a new Video object and then adds it to the display list:
var video:Video = new Video( );
addChild(video);
You can associate a NetStream object with a Video object by using the Video object's attachNetStream( ) method, passing a reference to the NetStream object as a parameter to the method:
video.attachNetStream(videoStream);
The NetStream class defines a play( ) method that loads and starts the Flash video playback. The parameter can be a relative or absolute URL.
videoStream.play("example.flv");
or
videoStream.play("http://www.mysite.com/example.flv");
The full code is :
var videoConnection:NetConnection = new NetConnection( );
videoConnection.connect(null);
var videoStream:NetStream = new NetStream(videoConnection);
var video:Video = new Video( );
addChild(video);
video.attachNetStream(videoStream);
videoStream.play("example.flv");

0 comments: