198
Chapter 11: Working with External Media
To play back an external FLV file in a Flash document:
1
With the document open in the Flash authoring tool, in the Library panel (Window > Library)
select New Video from the Library options menu to create a video object.
2
Drag a video object from the Library panel onto the Stage. This creates a video object instance.
3
With the video object selected on the Stage, in the Property inspector (Window > Properties)
enter
my_video
in the Instance Name text box.
4
Open the Components panel (Window > Development Panels > Components) and drag a
TextArea component to the Stage.
5
With the TextArea object selected on the Stage, enter
status
in the Instance Name text box in
the Property inspector.
6
Select Frame 1 in the Timeline, and open the Actions panel (Window > Development
Panels > Actions).
7
Add the following code to the Actions panel:
// 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.text += "Status (NetStream)" + newline;
status.text += "Level: "+infoObject.level + newline;
status.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);
// Being 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
“Preloading SWF and JPEG files” on page 199
.
To track the download progress of MP3 files, use the
Sound.getBytesLoaded()
and
Sound.getBytesTotal()
methods; to track the download progress of FLV files, use the
NetStream.bytesLoaded
and
NetStream.bytesTotal
properties. For more information, see
“Preloading MP3 and FLV files” on page 201
.
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...