PDA

View Full Version : Preloading of a .flv



x-itin
July 23rd, 2009, 05:11 AM
Hi there,

I'm trying to make a custom preloader for a .flv. But it won't work for me!

This is the code:

var flvControl:FLVPlayback = display;
var flvSource:String = "video.flv";

display.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
function onLoadProgress(event:ProgressEvent):void{
var loadedPct:uint = Math.round(100 * (event.bytesLoaded / event.bytesTotal));
loading_text.text = loadedPct.toString();
trace(event.bytesLoaded);
if (loadedPct == 100){
//do something
}
}

flvControl.source = flvSource;What am I doing wrong?

Everin
July 23rd, 2009, 08:00 AM
I sugesting you to use this preloader http://www.stevensacks.net/2008/10/01/as3-apple-style-preloader/

The implementation is very simple:


import net.stevensacks.preloaders.CircleSlicePreloader;
var loader:Loader = new Loader();
var preloader:CircleSlicePreloader = new CircleSlicePreloader();

now, only what you need is to show the preloader on CLICK function:

addChild(preloader);

and to remove the preloader on onComplete function:

removeChild(preloader);

I hope to make sense for you...

x-itin
July 23rd, 2009, 08:12 AM
Hi Everin,

Thanks for your answer.

I want to have a preloader that's a simple line that grows bigger when the .flv is loaded.

How can I check how much bytes there's loaded and then make something like this?
loadingBar.width = (((ns.bytesLoaded * 100) / ns.bytesTotal) * 100) / 230;
230 = the total width of loadingBar.

I remember that it was possible in AS2 - isn't it possible in AS3?