# Preloading a .flv into the .swf generated via Flash

**URL:** <https://forum.kirupa.com/t/preloading-a-flv-into-the-swf-generated-via-flash/271063>\
**Category:** flash\
**Created:** [September 17, 2008, 11:23pm UTC](https://forum.kirupa.com/t/preloading-a-flv-into-the-swf-generated-via-flash/271063 "2008-09-17T23:23:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![theycallmeuma](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@theycallmeuma](https://forum.kirupa.com/u/theycallmeuma)\
**Post date:** [September 17, 2008, 11:23pm UTC](https://forum.kirupa.com/t/preloading-a-flv-into-the-swf-generated-via-flash/271063/1 "2008-09-17T23:23:59Z")

</div>

Hi Guys,

Please excuse me if this has already been mentioned (although I’ve strugged to find anything to help me out).

Here’s the scenario:  
I have a .flv file which I am progressively downloading into a .swf file. The .swf file contains a control bar skin with the play, seek, volume features. All three elements (.flv, .swf and control bar) were generated from Flash 8.

I want to create a preloader so that when the buffer has reached 5 seconds, the video will start playing, and will continue from there on, regardless of the buffer state. It is only whilst the video is loading for 5 seconds worth of content to be in the buffer, that a preloader graphic should be displayed. After that, the video will play as normal.

I’ve obtained this code from the Adobe website:  
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(“videoDemo.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]’\>”;  
output\_str += "Length: “+my\_ns.bufferLength+” "+“Time: “+my\_ns.bufferTime+” “+“Buffer:”+bufferPct+”%”;  
output\_str += “\</textformat\>”;  
buffer\_txt.htmlText = output\_str;  
}

This particular code displays the buffer status all the way through the video in text form.

I know this may sound stupid, but if I have a visual called load.swf, and merely want to display that while the buffer is loading, then remove it completely, how is is called into the actionscript? Looking at the code above, I don’t think the checkBufferTime function is actually needed in this case.

Any help would REALLY be appreciated. Please be kind, I haven’t touched Actionscript for around 8 years, so am completely lost.
