So what gives? Well, the staging environment was serving SWFs with gzip compression and this was messing up the bytesLoaded and bytesTotal properties that my preloader SWF was trying to read from the main SWF. Different browsers reacted differently too. Some saw bytesTotal as 0 (IE), which is what gave me the infinity percentage (dividing bytesLoaded / 0 will give you Infinity), while others reported bytesTotal as the same as bytesLoaded (Firefox). Hard coding a fake bytesTotal was my temporary fix.
To check to see how your server is sending your files, you can use Charles to inspect your web traffic. Here’s the one that was breaking because of gzip compression:

A SWF served with gzip compression will cause preloading errors.
And here’s what it should look like:

A SWF correctly served without gzip compression.
I originally thought the issue was with the SWF being served with the wrong MIME type of “text/plain” but changing that didn’t fix my problems. The moral of the story is to check these server settings before wasting a Saturday (Gasp? Working on a weekend?) trying different versions of a Flash preloader and waiting for staging to build the site after each try.

15 Comments
Hi Thanks very much for this info
I wasted alot of time trying to find out what was the problem with my code
Did you find anyway to bypass this problem without using external swf?
Thanks
Natan
I’m glad I could help, Natan. And thanks for being my first commenter.
I used two SWFs in this project because I used SWFAddress for deep linking in Flash. To achieve this, SWFAddress adds a # to the URL which will mess up your preloading if a user goes directly to a deep link. This is discussed in the SWFAddress forum (search for c.swf). Basically, the # forces SWFs in the page to fully load before displaying and adding a intermediary SWF is the fix.
That said, I don’t think the second SWF is necessary. Your main SWF should be able to display its own preloader if it’s set up correctly.
Thank you thank you thank you! I was having this exact problem on a client site and finally stumbled upon your blog. I used the program you mentioned (Charles), and sure enough…gzip compression! As soon as that was turned off, everything worked fine. You have saved me.
Thanks! I had a few people get this nagging issue as well. I had noticed it was returning fouled up file sizes, but how the heck you found it was encoding it differently is wonderful…
No problem, Josh.
Back in the day when they released the FLV file format, I had to configure IIS to serve these new videos with the video/x-flv MIME type. That’s why I used Charles to see what was up. And that showed the wrong MIME type along with the other discrepancy of the gzip in the Response Compression.
It seems like some people turn gzip on for everything thinking it will save bandwidth. But compiled SWF files are already about as compressed as they are going to get (the same goes for some image and video files I think). So you’re just wasting processing power/time to compress these files.
hello,
I don’t speak English very well, sorry.
I have this problem but not sure how to turn off gzip.
can you help me?
I’m a begginer.
thank you
Unfortunately, I’m not an Apache expert. I just asked the client to have their server admins fix it.
Try some searches for mod_deflate and mod_gzip. I think the gist of it is that when you configure one of these compression modules, you can add file types to an exclusion list, or you can specifically tell it what types to include in its compression.
The exclusion list will look something like this:
2
\.(?:gif|jpe?g|png|swf|flv)$ no-gzip dont-vary
If you can’t change it server wide, you can do it in a specific directory with an .htaccess file, but I’m not much more help there either.
You saved me dude !!!
i also found that you can disable server gzip compression using .htaccess file
http://www.flash-db.com/Board/index.php?topic=19252.0
Thanks bro for giving me clues on this issue ^^
Cheers from France !
Yep, same here – THANK YOU!
(But IE8 still shows the bytes instead of the % – I’m on it…)
awesome job figuring out this issue, debugging this on a project of mine was a pain. thanks!
Total n00b here! I have this problem but I am in a hosted enviornment (e.g. i don’t have the ability to turn off gzip). How do I fix this problem. Again total n00b here so if you can be detailed and I’d be forever in your debt!
Thanks in advance!
I would tell your host that they are serving their files incorrectly.
Otherwise, try following Darkoleptik’s link from above and see if you can figure it out by adding/editing an .htaccess file.
Thanks for saving me countless hours of troubleshooting!
-Asa
I had the same problem with safari and chrome. This is how my .htacces file look slike:
2
3
RewriteEngine on
RewriteRule . - [E=no-gzip:1]
This works. Thanx for this post. Saved me a lot of time!
Glad to help and thanks for the code.
One Trackback
[...] was fine however. Now I was really confused. So I did a bit of research…Apparently, I’m not alone. The issue seeming stems from files being served up with GZIP compression before being sent to the [...]