views:

1278

answers:

4

I'm working in Flash CS3, targeting Actionscript 2, and I'm writing an image preloader. When I test the movie with the download simulation turned on everything works just fine, and my preloader successfully updates the download progress bar I've made. When I upload the movie to my web server though, it almost behaves as though the MovieClipLoader.onLoadProgress event isn't firing until the very end of the upload, because the movie sits there for several seconds downloading with no notification and then there is a sudden burst of activity and my preloader goes from 0 to 100% very rapidly. Has anyone encountered this behavior before, and if so what am I doing wrong? Thanks!

+1  A: 

I'd suggest using a debugging proxy like Charles (http://www.charlesproxy.com/) to see how the file is being downloaded from your server (e.g. is there a high latency before the download begins, how many seconds does it actually take to transfer the data). That way you can better see if the preloader is accurately reflecting the data transfer from the server.

Matt
A: 

Thank you for the quick reply Matt. I had never heard of Charles before, but it seems like an incredibly powerful tool. For my purposes I can also see the file get requests and progress using Firebug's Net tool in Firefox. Both Charles and Firebug show that the images are being requested and downloaded successfully, and all images are completed several seconds before the flash movie appears to respond and update the loading bar/fire onLoadProgress.

The Brawny Man
+1  A: 

Have you tried it in different browsers? I believe Flash will, at least in some cases, use the browser to download the file. It's possible Firefox is downloading the file w/o notifying Flash, and then sending it all to flash in one big burst. I haven't seen FF do this myself, but it's possible an extension is intercepting the download.

The only time I believe I've seen the progress happen in an burst like that before is when I was getting a cached copy instead of it redownloading. But since you're seeing an actual download happen I'm guessing that's not what you're getting.

Try it in IE and see if you get the same behavior.

Herms
As far as I know Flash always uses the browser to download content (unless it's a over a socket). The standalone browser on windows even shares a cache with Internet Explorer.
grapefrukt
A: 

After much testing, I ended up completely restructuring/rewriting how the preloader works, and this fixed my issue. What I thought was some lag between the loading of the final image and the firing of the event was actually (for reasons that I still don't fully understand) the code that updated my preloader clip wasn't being run as the events were being fired, but instead was waiting until the last image in the series began loading to start working. I moved the code that updates the loading progress from inside the preloader movie clip (which was looking at some _root level progress variables and updating itself on enter frame) into the onLoadProgress event itself. Everyone who commented thank you very much for the quick responses, and as soon as I reach my 15, I'll vote up both of your answers as they were helpful, if not exactly the answer I was looking for.

The Brawny Man