# Stop video from playing

**URL:** <https://forum.kirupa.com/t/stop-video-from-playing/318912>\
**Category:** flash\
**Created:** [February 3, 2011, 12:02pm UTC](https://forum.kirupa.com/t/stop-video-from-playing/318912 "2011-02-03T12:02:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gwh](https://avatars.discourse-cdn.com/v4/letter/g/bbe5ce/32.png) [@gwh](https://forum.kirupa.com/u/gwh)\
**Post date:** [February 3, 2011, 12:02pm UTC](https://forum.kirupa.com/t/stop-video-from-playing/318912/1 "2011-02-03T12:02:54Z")

</div>

Hi everyone,

The following code causes a video to play and then when complete it fades out.

```auto

import fl.video.FLVPlayback;
import fl.video.VideoEvent;
import flash.events.Event;
import flash.events.MouseEvent;

video.videoMC.addEventListener(VideoEvent.COMPLETE, vidEnd);

background_mc.uniformsLink_btn.visible = false;
background_mc.RetailLink_btn.visible = false;

function vidEnd(evt:VideoEvent):void
	{
		trace("FLV has ended");
		stage.addEventListener(Event.ENTER_FRAME, fadeVideo);
	}

function fadeVideo(e:Event):void
{	
	//Lowers alpha of video - normal value is 1.
	video.alpha -= .05;
	//Use this to fade your other MC.
	background_mc.alpha += .05; 
	//Checks to see if video is faded out.
	if(video.alpha <= 0)
	{
		//If so, stop listening for the event, remove the video, make ready for collection with the "null".
		stage.removeEventListener(Event.ENTER_FRAME, fadeVideo);
		trace("faded and gone");
		background_mc.uniformsLink_btn.visible = true;
		background_mc.RetailLink_btn.visible = true;
	}
}

function restartVideo(e:MouseEvent):void
{
	stage.addEventListener(Event.ENTER_FRAME, fadeVideoIn);
}

function fadeVideoIn(e:Event):void
{
	video.alpha += .05;
	background_mc.alpha -= .025;
	if(video.alpha >= 1)
		{
			stage.removeEventListener(Event.ENTER_FRAME, fadeVideoIn);
			video.videoMC.play();
		}
}

background_mc.firstURLLink_btn.addEventListener (MouseEvent.CLICK, mouseClickU);
function mouseClickU(event:MouseEvent):void
{
var requestBiz = new URLRequest("http://www.mysiteb.php");
navigateToURL(requestBiz);
}

background_mc.secondURLLink_btn.addEventListener (MouseEvent.CLICK, mouseClickR);
function mouseClickR(event:MouseEvent):void
{
var requestRet = new URLRequest("http://www.mysiteb.php");
navigateToURL(requestRet);
}

skip_btn.addEventListener (MouseEvent.CLICK, vidEndPurpose);
function vidEndPurpose(event:MouseEvent):void
{
		trace("FLV has ended");
		stage.addEventListener(Event.ENTER_FRAME, fadeVideo);
		
}

```

Since I want the viewer to have the option to skip the video, I put a button on top of the video so they can exit. The instance name is skip\_btn.

The following code is what I used to try and stop the video, however when the skip button is pressed the video only fades out but doesn’t actually stop, ie. you can still hear it playing.

```auto

skip_btn.addEventListener (MouseEvent.CLICK, vidEndPurpose);
function vidEndPurpose(event:MouseEvent):void
{
		trace("FLV has ended");
		stage.addEventListener(Event.ENTER_FRAME, fadeVideo);
		
}

```

I wondered if someone could help me with the code. Do I need to add further code to the abovementioned block?

Really appreciate any help.
