bytesTotal for Flash preloader AS3

Hello,

I am trying to build a Flash preloader. From this Flash file, I am dynamicly loading another Flash file. This is an SWF file of 30MB. I made it this big to test the progressbar.

While loading this SWF file, I want to show the progress of the loading in percentage. I have attached the used code.
I am showing the event.bytesTotal to the screen. But the strange thing is, that this bytesTotal is changing all the time, and it is always the same as bytesLoaded. How can I return the total file size so I can calculate the progress of the loading ?
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, Dcomplete);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
loader.load(new URLRequest("movie.swf"));

function showProgress(event:ProgressEvent):void {
	var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
	percentLoaded = Math.round(percentLoaded * 100);
	textf.text = String(event.bytesTotal);
}

Open in new window

eelcolAsked:
Who is Participating?
 
NiklasMollerCommented:
hello!

I googled around for this and there seems to be a problem with this happening to more people than you :)

It might be a problem/quirk with how your server provides the flv file to the client. Seemingly it does not provide correct values.

I am not providing a solution here, but pointing you to some more links where people have had the same problem:

http://stackoverflow.com/questions/1269875/why-loaderinfo-bytestotal-is-zero
http://www.bigresource.com/Tracker/Track-flash-InVLAke3S7/
http://www.bigresource.com/Tracker/Track-flash-mtyV9Gkm5/

hope you can solve it!
cheers
0
 
eelcolAuthor Commented:
It does seem to work if I debug it locally. But when using the swf file online, it doesn't return the right bytesTotal value.
0
 
eelcolAuthor Commented:
Hi

Thanks, I also found an article like that:

http://patrickmcd.com/2009/04/20/flash-preloading-errors-turn-off-gzip/

I have forwarded it to my hosting provider, I hope they can help me with this. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.