# Stop button for a video player

**URL:** https://forum.kirupa.com/t/stop-button-for-a-video-player/204323
**Category:** Uncategorized
**Created:** [October 18, 2006, 10:07pm UTC](https://forum.kirupa.com/t/stop-button-for-a-video-player/204323 "2006-10-18T22:07:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lilbit2600](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lilbit2600](https://forum.kirupa.com/u/lilbit2600)
#### Post date: [October 18, 2006, 10:07pm UTC](https://forum.kirupa.com/t/stop-button-for-a-video-player/204323/1 "2006-10-18T22:07:36Z")

</div>

I can’t seem to get a stop/ button to work… If anyone could lend a helping hand that would be great.

Here’s my code so far.

var myNetConn:NetConnection;  
var myNetStream:NetStream;  
var videoLV:LoadVars;

this.videoContainer.\_visible = false;

//-------------\<VideoActivate\>-----------------//  
function videoActivate() {

```
this.videoContainer._visible = true;

//REPLACE THE .FLV HERE!!!!!!!
myNetStream.play("chasing_cars_video.flv");

this.vidProgBar.onEnterFrame = function() {
var progPos:Number = Math.round((myNetStream.time/videoLV.totalTime) * 100);
this.vidProgBar.vidProg._x = progPos;
var vidD1Percent:Number = Math.round((myNetStream.bytesLoaded/myNetstream.bytesTotal)*100);
this.vidProgBar.progMaskContainer.progMask._width = vidD1Percent + 10;
}

```

}  
//-------------\</VideoActivate\>-----------------//

this.pause.onRelease = function () {  
myNetStream.pause();  
}

this.play.onRollOver = function () {

}  
this.play.onRollOut = function () {

}  
//back to scene 1//  
this.play.onRelease = function () {  
this.enabled = false;  
initializeVideo();  
videoActivate();  
[//play2.gotoAndPlay](https://play2.gotoAndPlay)(2);  
}

//-------------\<Video\>-----------------//

function initializeVideo() {  
myNetConn = new NetConnection();  
myNetConn.connect(null);  
myNetStream = new NetStream(myNetConn);  
this.videoContainer.myVideo.attachVideo(myNetStream);  
myNetStream.setBufferTime(5);

```
myNetStream.onStatus = function(info) {
    if (info.code == "NetStream.Play.Stop" && info.level == "status") {
        this.togglePlay.gotoAndStop(2);
        myNetStream.seek(0);
        myNetStream.pause(true);
    }
}

videoLV = new LoadVars();
videoLV.onLoad = function (success) {
    if (success) {
        videoActivate();
    }
    //videoLV.load("video_info.txt");
}

```

}  
//-------------\</Video\>-----------------//

//-------------\<ourVideoOption\>-----------------//

//-------------\</ourVideoOption\>-----------------//

//-------------\<VideoDeactivate\>-----------------//  
function videoDeactivate() {  
this.videoContainer.\_visible = false;  
delete \_root.vidProgBar.onEnterFrame;

}  
//-------------\</VideoDeactivate\>-----------------//

//-------------\<cancelVideo\>-----------------//  
//close//  
this.stop.onRollOver = function () {

}  
this.stop.onRollOut = function () {

}  
//back to scene 1//  
this.stop.onRelease = function () {  
[//togglePlay.gotoAndStop](https://togglePlay.gotoAndStop)(1);  
myNetStream.close();  
myNetStream.seek(0);  
videoContainer.myVideo.clear();  
delete videoContainer.myVideo.onEnterFrame;  
videoDeactivate();  
videoActivate();
