# Clearing an NS Buffer

**URL:** <https://forum.kirupa.com/t/clearing-an-ns-buffer/154524>\
**Category:** flash\
**Created:** [July 10, 2005, 8:24pm UTC](https://forum.kirupa.com/t/clearing-an-ns-buffer/154524 "2005-07-10T20:24:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiziano](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@Tiziano](https://forum.kirupa.com/u/Tiziano)\
**Post date:** [July 10, 2005, 8:24pm UTC](https://forum.kirupa.com/t/clearing-an-ns-buffer/154524/1 "2005-07-10T20:24:15Z")

</div>

I’ve got the below code on 3 frames in my movie (with the requisite changes relative to the appropriate FLV’s I’m loading).

The buffer clip works when the first FLV starts to load. But, when I select one of my buttons (thereby taking the playhead to another frame where it loads another FLV) the buffer clip doesn’t play.

Not sure why. Do I need to clear the buffer within an onRelease?

Here’s the site:[http://www.thevisualgospel.org/](http://www.thevisualgospel.org/)  
(click on ‘here’ with in the intro text block) or follow the menus:  
The Project \> Videos

var nc:NetConnection = new NetConnection();  
nc.connect(null);

var ns:NetStream = new NetStream(nc);

theVideo.attachVideo(ns);

ns.play(“vid1.flv”);

playBtn.onRelease = function() {  
ns.pause();  
}

pauseBtn.onRelease = function() {  
ns.pause();  
}

ns.setBufferTime(10);

ns.onStatus = function(info) {  
trace(info.code);  
if(info.code == “NetStream.Buffer.Full”) {  
bufferClip.\_visible = false;  
}  
if(info.code == “NetStream.Buffer.Empty”) {  
bufferClip.\_visible = true;  
}  
if(info.code == “NetStream.Play.Stop”) {  
ns.seek(0);  
}  
}

var videoInterval = setInterval(videoStatus,100);  
var amountLoaded:Number;  
var duration:Number;

ns[“onMetaData”] = function(obj) {  
duration = obj.duration;  
}

function videoStatus() {  
amountLoaded = ns.bytesLoaded / ns.bytesTotal;  
loader.loadbar.\_width = amountLoaded \* 180;  
loader.scrub.\_x = ns.time / duration \* 180;  
}

var scrubInterval;

loader.scrub.onPress = function() {  
clearInterval(videoInterval);  
scrubInterval = setInterval(scrubit,10);  
this.startDrag(false,0,this.\_y,180,this.\_y);  
}

loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {  
clearInterval(scrubInterval);  
videoInterval = setInterval(videoStatus,100);  
this.stopDrag();  
}

function scrubit() {  
ns.seek(Math.floor((loader.scrub.\_x/180)\*duration));  
}

project\_btn.onRelease = function() {  
ns.pause();  
gotoAndPlay(2);  
}

our\_btn.onRelease = function() {  
ns.pause();  
gotoAndPlay(3);  
}

stop();
