As an alternative to importing video into the Flash authoring environment, you can use ActionScript to dynamically play back external FLV files in Flash Player. You can play back FLV files from an HTTP address or from the local file system. To play back FLV files, you use the NetConnection and NetStream classes and the attachVideo() method of the Video class. (For more information, see "NetConnection class", "NetStream class", and Video.attachVideo() in Flash ActionScript Language Reference.)
You can create FLV files by importing video into the Flash authoring tool and exporting it as an FLV file. (See "Macromedia Flash Video (FLV)" in Using Flash.) If you have Flash Professional, you can use the FLV Export plug-in to export FLV files from supported video-editing applications. (See "Exporting FLV files from video-editing applications (Flash Professional only)" in Using Flash.)
Using external FLV files provides certain capabilities that are not available when you use imported video:
Tip: To load FLV files from a web server, you might need to register the file extension and MIME type with your web server; check your web server documentation. The MIME type for FLV files is video/x-flv.
The following procedure shows how to play back a file named videoFile.flv that is stored in the same location as your SWF file.
my_video in the Instance Name text box.
status in the Instance Name text box in the Property inspector.
// Create a NetConnection object
var netConn:NetConnection = new NetConnection();
// Create a local streaming connection
netConn.connect(null);
// Create a NetStream object and define an onStatus() function
var netStream:NetStream = new NetStream(netConn);
netStream.onStatus = function(infoObject) {
status_txt.text += "Status (NetStream)" + newline;
status_txt.text += "Level: "+infoObject.level + newline;
status_txt.text += "Code: "+infoObject.code + newline;
};
// Attach the NetStream video feed to the Video object
my_video.attachVideo(netStream);
// Set the buffer time
netStream.setBufferTime(5);
// Begin playing the FLV file
netStream.play("videoFile.flv");
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001107.html
Comments
recoveredfromflashMX2004 said on Jul 27, 2004 at 11:40 AM : glenn_mx6 said on Sep 13, 2004 at 10:38 AM : lenbradshaw said on Oct 26, 2004 at 12:38 PM :