NetStream
969
this.createTextField("buffer_txt", this.getNextHighestDepth(), 10, 10, 300,
22);
buffer_txt.html = true;
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
stream_ns.setBufferTime(3);
my_video.attachVideo(stream_ns);
stream_ns.play("video1.flv");
var buffer_interval:Number = setInterval(checkBufferTime, 100, stream_ns);
function checkBufferTime(my_ns:NetStream):Void {
var bufferPct:Number = Math.min(Math.round(my_ns.bufferLength/
my_ns.bufferTime 100), 100);
var output_str:String = "<textformat tabStops='[100,200]'>";
outp= "Length: "+my_ns.buffe"\t"+"Time:
"+my_ns.buf"\t"+"Buffer:"+bu"%";
outp= "</textformat>";
buffer_txt.htmlText = output_str;
}
If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
MovieClip.getNextHighestDepth()
method, which is
used in this example.
See also
setBufferTime (NetStream.setBufferTime method)
,
time (NetStream.time
property)
,
bufferLength (NetStream.bufferLength property)
bytesLoaded (NetStream.bytesLoaded property)
public bytesLoaded : Number [read-only]
The number of bytes of data that have been loaded into the player. You can use this method in
conjunction with
NetStream.bytesTotal
to estimate how close the buffer is to being full--
for example, to display feedback to a user who is waiting for data to be loaded into the buffer.
Availability:
ActionScript 1.0; Flash Player 7
Example
The following example creates a progress bar using the Drawing API and the
bytesLoaded
and
bytesTotal
properties that displays the loading progress of video1.flv into the video
object instance called
my_video
. A text field called
loaded_txt
is dynamically created to
display information about the loading progress as well.
var connection_nc:NetConnection = new NetConnection();
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...