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
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");
}