This is one of those cases when the Adobe documentation is rare, or doesn't help much.
I had a hard time figuring out how to place a bar that would grow along with the playback of a movie in the FLVPlayback component.
First make a custom MovieClip with a rectangle (it can be another shape, but usually rectangles are best for these) and give it a name: myPlayhead
You must have already the FLVPlayback component on stage, with a given name. I will name it: myFLVplayback
For the script we will need to import a class to do this: VideoEvent. This class has several events you can use to get info from the FLVplayback when playing video (http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/fl/video/VideoEvent.html)
import flash.video.VideoEvent;
//The movie doesn't start
myFLVPlayback.stop();
//Rewinds automatically if the video is stopped or it reaches the end.
//By default it's false
myFLVPlayback.autoRewind=true;
//Adds the listener for each time the playhead updates it's position
myFLVPlayback.addEventListener(VideoEvent.PLAYHEAD_UPDATE, videoHandler);
function videoHandler(evt:VideoEvent):void{
var totalSeconds:Number = myFLVPlayback.totalTime;
var elapsedSeconds:Number = myFLVPlayback.playheadTime;
var percent:Number=Math.round((elapsedSeconds/totalSeconds)*100);
//The custom seekBar will change it's size according the the percentage
//of the played movie
seekBt.progressMc.scaleX=percent;
}
Cheers
No comments:
Post a Comment