bytesTotal for Flash preloader AS3


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

Who is Participating?

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:

hope you can solve it!
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.
eelcolAuthor Commented:

Thanks, I also found an article like that:

I have forwarded it to my hosting provider, I hope they can help me with this. Thanks.
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.