# Preloader for FLV loading dynamically

**URL:** https://forum.kirupa.com/t/preloader-for-flv-loading-dynamically/201152
**Category:** flash
**Created:** [September 18, 2006, 11:54pm UTC](https://forum.kirupa.com/t/preloader-for-flv-loading-dynamically/201152 "2006-09-18T23:54:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nath\_y](https://avatars.discourse-cdn.com/v4/letter/n/b9e5f3/32.png) [@nath\_y](https://forum.kirupa.com/u/nath_y)
#### Post date: [September 18, 2006, 11:54pm UTC](https://forum.kirupa.com/t/preloader-for-flv-loading-dynamically/201152/1 "2006-09-18T23:54:04Z")

</div>

Macromedia has given a sample on how to create a preloader for flv loading dynamically in its help files.

All you have to do is open an empty file, drag a new video from library on the stage give it an instance name of “my\_video” and copy the code below in the first frame.

Great it works but the preloader does NOT get removed once the video has loaded? Can anyone suggest how to? Give this sample a go and you’ll know what I mean!

Thank you in advance.

//code//  
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(“malaga.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 ("+pctLoaded+"%)";  
progressBar\_mc.bar\_mc.\_xscale = pctLoaded;  
if (pctLoaded=100) {  
clearInterval(loaded\_interval);  
}  
}
