MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 610

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

9.
Type the following code in the Actions panel:
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
my_video.attachVideo(stream_ns);
stream_ns.play("http://www.helpexamples.com/flash/video/
lights_short.flv");
this.createTextField("loaded_txt", this.getNextHighestDepth(), 10, 10,
160, 22);
var loaded_interval:Number = setInterval(checkBytesLoaded, 500,
stream_ns);
function checkBytesLoaded(my_ns:NetStream) {
var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal
* 100);
loaded_txt.text = Math.round(my_ns.bytesLoaded / 1000) + " of " +
Math.round(my_ns.bytesTotal / 1000) + " KB loaded (" + pctLoaded +
"%)";
progressBar_mc.bar_mc._xscale = pctLoaded;
if (pctLoaded >= 100) {
clearInterval(loaded_interval);
}
}
10.
Select Control > Test Movie to test your code.
If your progress bar loads instantly, the video has cached on your hard disk (either
from testing this example or loading it in a different procedure). If this occurs, upload
a FLV file to your server and load it instead.
Another way to preload FLV files is to use the
method takes a single parameter that indicates the number of seconds of the FLV stream to
buffer before playback begins. For more information, see
(NetStream.setBufferTime method), getBytesLoaded
(MovieClip.getBytesLoaded method)
(MovieClip.getBytesTotal method)
,
property)
bytesTotal (NetStream.bytesTotal property)
setInterval function
610
Working with Images, Sound, and Video
,
getBytesTotal
,
bytesLoaded (NetStream.bytesLoaded
in the ActionScript 2.0 Language Reference
NetStream.setBufferTime()
setBufferTime
, and
method. This

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents