Link to home
Start Free TrialLog in
Avatar of eelcol
eelcolFlag for Netherlands

asked on

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

Avatar of eelcol
eelcol
Flag of Netherlands image

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of NiklasMoller
NiklasMoller

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eelcol

ASKER

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.