03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

this.createTextField("buffer_txt", this.getNextHighestDepth(), 10, 10, 300,<br />

22);<br />

buffer_txt.html = true;<br />

var connection_nc:NetConnection = new NetConnection();<br />

connection_nc.connect(null);<br />

var stream_ns:NetStream = new NetStream(connection_nc);<br />

stream_ns.setBufferTime(3);<br />

my_video.attachVideo(stream_ns);<br />

stream_ns.play("video1.flv");<br />

var buffer_interval:Number = setInterval(checkBufferTime, 100, stream_ns);<br />

function checkBufferTime(my_ns:NetStream):Void {<br />

var bufferPct:Number = Math.min(Math.round(my_ns.bufferLength<br />

my_ns.bufferTime*100), 100);<br />

var output_str:String = "";<br />

output_str += "Length: "+my_ns.bufferLength+"\t"+"Time:<br />

"+my_ns.bufferTime+"\t"+"Buffer:"+bufferPct+"%";<br />

output_str += "";<br />

buffer_txt.htmlText = output_str;<br />

}<br />

bytesLoaded (NetStream.bytesLoaded property)<br />

public bytesLoaded : Number [read-only]<br />

The number of bytes of data that have been loaded into the player. You can use this method in<br />

conjunction with NetStream.bytesTotal to estimate how close the buffer is to being full-for<br />

example, to display feedback to a user who is waiting for data to be loaded into the buffer.<br />

Availability<br />

ActionScript 1.0; Flash Player 7<br />

Example<br />

The following example creates a progress bar using the Drawing API <strong>and</strong> the bytesLoaded<br />

<strong>and</strong> bytesTotal properties. The bar displays the progress of the operation as video1.flv is<br />

loaded into the video object instance called my_video. A text field called loaded_txt is<br />

dynamically created to display information about the loading progress as well.<br />

var connection_nc:NetConnection = new NetConnection();<br />

connection_nc.connect(null);<br />

var stream_ns:NetStream = new NetStream(connection_nc);<br />

my_video.attachVideo(stream_ns);<br />

stream_ns.play("video1.flv");<br />

this.createTextField("loaded_txt", this.getNextHighestDepth(), 10, 10, 160,<br />

22);<br />

500 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!