Search code examples
flashactionscriptprogress-barloader

AS3 "Loader" progress immediately goes to 100%


If you go to http://moederdagontbijtplacemat.nl/ you will see a progress bar. The application is loading a fairly large SWF from the server using the Loader class. Strangely enough, the progress bar immediately goes to 100% (but the loading still takes a while after that). The code is below, but you'll see it's basically too simple to break.

---It has worked when the application was on a different server, so I though maybe the new server wasn't sending the size of the large SWF in the http headers. Firebug does show a progress bar though, so that is not the case, the information should be available.---

Update: That's actually incorrect, Apache does in fact not send the Content-Length the header. Going to look into that. :EndUpdate

It also works when I run the loader swf locally and change the URL (new URLRequest("Placemat.swf")) to the absolute URL of Placemat.swf on the server.

        var l:Loader = new Loader();
        addChild(l);
        l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, function(e:ProgressEvent) {
            s.setProgress(e.bytesLoaded/e.bytesTotal);
            trace(Math.round(100 * e.bytesLoaded/e.bytesTotal), "%");
        });
        l.contentLoaderInfo.addEventListener(Event.COMPLETE, function() {
            removeChild(s);
        });

        l.load(new URLRequest("Placemat.swf"));

Solution

  • Fixed, Apache was gzipping and not sending the Content-Length header.

    .htaccess:

    SetEnv no-gzip dont-vary