FLVPlayback FLV Preloader
Here’s a way to Preload flv files before you play them in FLVPlayback component.
import mx.video.*;
var listenerObject:Object = new Object();
my_FLVPlybk.progressInterval = 001;
my_FLVPlybk.autoPlay = false;
listenerObject.progress = function(eventObject:Object) :Void {
var perc = Math.floor(eventObject.bytesLoaded * 100 / eventObject.bytesTotal);
//implement you loading visual representation here
if(perc == 100)
my_FLVPlybk.play();
}
my_FLVPlybk.addEventListener("progress", listenerObject);
my_FLVPlybk.load("yourflv.flv");
You can hide the player while its getting downloaded and show it when its fully downloaded. Make sure to set the autoplay option to false.
Happy coding ![]()
May 27th, 2008 at 7:47 pm
Would that work with action script 3 flash cs3…if it supposed to, this is the error I’m getting when I use the code.
1046: Type was not found or was not a compile-time constant: Void.
May 28th, 2008 at 5:48 am
Not sure regarding AS3. The code provided above is for AS2. Probably you can remove the Void return type for AS3.
June 25th, 2008 at 3:55 pm
Thank’s a lot. I applied your code successfully to my project ! I tried before on my own to figure out somethink like your code .. but i fuc.. up
July 25th, 2008 at 2:01 am
I try your code on my project but not successful. I have cue point in my flv like this:
stop();
var nextAniIndex:Number = 0;
var Ani:Array = [ ani1, ani2];
//
// Listen for cuePoint events on the FLVPlayback component
//
flv_overview.addEventListener( “cuePoint”, this );
//
// Event handler: cuePoint
//
function cuePoint ( eventObj:Object )
{
var nextAni:MovieClip = Ani [ nextAniIndex ];
nextAni.play();
nextAniIndex++;
}
//when video finish, go to next scene
var vidList : Object = new Object();
vidList.complete = function() {
_root.loader_mc.loadMovie(”startup.swf”);
}
flv_overview.addEventListener (”complete”,vidList);
I got an output like this when testing the movie:
Statement must appear within on/onClipEvent handler
flv_overview.addEventListener (”complete”,vidList);
Total ActionScript Errors: 8 Reported Errors: 8
The movie continue to play but all cue point won’t show up.
Do you have any idea how to fix it?
August 27th, 2008 at 2:35 am
Hi-
Came to this post a little late. Is this script going on an AS layer on the same frame as the Flash Playback component?
Also, is this assuming we should be creating visual representations of the progress (progress bar) itself?
(this.loading_mc.load_txt.text)
October 3rd, 2008 at 3:20 am
Thanks for the code, works like a charm!
October 14th, 2008 at 4:56 am
this looks like what i need, but i’m not quite sure how to implement it. would you mind giving me a little more detail as to where exactly i’d put this code?
October 16th, 2008 at 8:49 am
Yueming,
You are trying to put the ActionScript code on the FLVPlayer and hence the error. You will need to put the code on a separate key frame or an as file.
MP,
Yes it will need to be at the frame where you have your flv player or an external AS file. I have removed the loading code, but yes you will need to implement your own.
sky,
my_FLVPlybk is the instance name of you flv player component. You will then need to place the above code in the frame that contains the player or an external AS file.