About creating progress animations for media files
631
8.
Select Frame 1 in the Timeline and 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/
typing_short.flv");
this.createTextField("loaded_txt", this.getNextHighestDepth(), 10, 10,
160, 22);
this.createEmptyMovieClip("progressBar_mc", this.getNextHighestDepth());
progressBar_mc.createEmptyMovieClip("bar_mc",
progressBar_mc.getNextHighestDepth());
with (progressBar_mc.bar_mc) {
beginFill(0xFF0000);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
endFill();
_xscale = 0;
}
progressBar_mc.createEmptyMovieClip("stroke_mc",
progressBar_mc.getNextHighestDepth());
with (progressBar_mc.stroke_mc) {
lineStyle(0, 0x000000);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
}
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 (" + pct
"%)";
progressBar_mc.bar_mc._xscale = pctLoaded;
if (pctLoaded>=100) {
clearInterval(loaded_interval);
}
}
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...