flvpayback preloader percent with VideoEvent.READY
Hello,
I'm trying to get a dynamic tex box to go from 0 to100%, 100% would be when videoEvent is ready. I cant think of a way to do this. Any suggestions? I guess I need to know how many bytes it takes for VideoEvent.READY to happen.
heres my code as of right now..
import fl.video.*;
import fl.controls.ProgressBarMode;
// Set Variables
var flvControl = display;
var flvSource = "main_vid.flv";
// Create event handler functions to control the progressbar
function progressHandler(event:VideoProgressEvent):void
{
var bl = Math.round(event.bytesLoaded/1000);
var bt = Math.round(event.bytesTotal/1000);
// Update progress...
pb.setProgress(bl,bt);
loader_txt.text = Math.floor((loaded/total)*100)+ "%";
}
function readyHandler(event:VideoEvent):void
{
// Remove progressbar when we start playing...
removeChild(pb);
removeChild(loader_txt);
}
// Set progress bar state
pb.mode = ProgressBarMode.MANUAL;
pb.indeterminate = false;
// Add listeners and load the video
flvControl.addEventListener(VideoProgressEvent.PROGRESS, progressHandler);
flvControl.addEventListener(VideoEvent.READY, readyHandler);
flvControl.source = flvSource;
Thanks,
Mark