Preloading External Media - MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

To play back an external FLV file in a Flash document:
With the document open in the Flash authoring tool, in the Library panel (Window > Library)
1.
select New Video from the Library options menu to create a video object.
Drag a video object from the Library panel onto the Stage; this creates a video object instance.
2.
With the video object selected on the Stage, in the Property inspector (Window > Properties)
3.
enter
my_video
Open the Components panel (Window > Development Panels > Components), and drag a
4.
TextArea component to the Stage.
With the TextArea object selected on the Stage, enter
5.
the Property inspector.
Select Frame 1 in the Timeline, and open the Actions panel (Window > Development
6.
Panels > Actions).
Add the following code to the Actions panel:
7.
// 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");

Preloading external media

ActionScript provides several ways to preload or track the download progress of external media.
To preload SWF and JPEG files, use the MovieClipLoader class, which provides an event listener
mechanism for checking download progress. This class is new in Flash Player 7. For more
information, see
To track the download progress of MP3 files, use the
Sound.getBytesTotal()
NetStream.bytesLoaded
"Preloading MP3 and FLV files" on page
300
Chapter 12: Working with External Media
in the Instance Name text box.
"Preloading SWF and JPEG files" on page
methods; to track the download progress of FLV files, use the
and
NetStream.bytesTotal
status
301.
Sound.getBytesLoaded()
properties. For more information, see
302.
in the Instance Name text box in
and

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents