# Removing Dynamic FLVPlayback Component

**URL:** <https://forum.kirupa.com/t/removing-dynamic-flvplayback-component/246034>\
**Category:** flash\
**Created:** [December 6, 2007, 2:31pm UTC](https://forum.kirupa.com/t/removing-dynamic-flvplayback-component/246034 "2007-12-06T14:31:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![loydmav](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/32.png) [@loydmav](https://forum.kirupa.com/u/loydmav)\
**Post date:** [December 6, 2007, 2:31pm UTC](https://forum.kirupa.com/t/removing-dynamic-flvplayback-component/246034/1 "2007-12-06T14:31:25Z")

</div>

I have a streaming video which streams and I have managed to detect when it stops playing so that I can mak the buttons appear again. But how do I tell the video instance to dissapear once it has finished playing?

Here is my code below:

Thanks

```auto
 
import flash.events.MouseEvent;
import fl.video.*;
// Class that handles video events
import fl.video.VideoEvent;
stop();
var my_FLVPlybk = new FLVPlayback();
// A variable to track if the video has begun playback
var playbackBegun:Boolean = false; 
var sObject:Object = new Object(); // create a new empty object 
// A function to handle the video events sent by the listener
function videoHandler(evt:VideoEvent) {
     // Detect state of theVideo
     switch(evt.state) {
          case "playing":
               playbackBegun = true;
               break;
          case "stopped":
               // Only process if playback occurred
               if(playbackBegun == true) {
                    // Reset the tracking variable
                    playbackBegun = false;
                    // ***THE VIDEO HAS COMPLETED***
                    // ***DO SOMETHING HERE***
     gotoAndPlay("start");
    
               }
               break;
          default:
               // Optional handler for other playback states
     }     
}
// Listen for "STATE_CHANGE" video events generated by theVideo
// and call the videoHandler function when they occur.
my_FLVPlybk.addEventListener(VideoEvent.STATE_CHANGE, videoHandler);

button_small_vid.addEventListener(MouseEvent.CLICK, onBtnSmallVidMouseClick);
function onBtnSmallVidMouseClick(event:MouseEvent):void{
 my_FLVPlybk.x = 100;
 my_FLVPlybk.y = 100;
 addChild(my_FLVPlybk);
 my_FLVPlybk.skin = "file:///C|/Program Files/Adobe/Adobe Flash CS3/en/Configuration/FLVPlayback Skins/ActionScript 3.0/SkinOverPlaySeekMute.swf"
 my_FLVPlybk.source = "url";
 gotoAndPlay("video_playing");
}
button_medium_vid.addEventListener(MouseEvent.CLICK, onBtnMediumVidMouseClick);
function onBtnMediumVidMouseClick(event:MouseEvent):void{
 my_FLVPlybk.x = 100;
 my_FLVPlybk.y = 100;
 addChild(my_FLVPlybk);
 my_FLVPlybk.skin = "file:///C|/Program Files/Adobe/Adobe Flash CS3/en/Configuration/FLVPlayback Skins/ActionScript 3.0/SkinOverPlaySeekMute.swf"
 my_FLVPlybk.source = "url";
 gotoAndPlay("video_playing");
}
button_large_vid.addEventListener(MouseEvent.CLICK, onBtnLargeVidMouseClick);
function onBtnLargeVidMouseClick(event:MouseEvent):void{
 my_FLVPlybk.x = 100;
 my_FLVPlybk.y = 100;
 addChild(my_FLVPlybk);
 my_FLVPlybk.skin = "file:///C|/Program Files/Adobe/Adobe Flash CS3/en/Configuration/FLVPlayback Skins/ActionScript 3.0/SkinOverPlaySeekMute.swf"
 my_FLVPlybk.source = "url";
 gotoAndPlay("video_playing");
}

```
