views:

43

answers:

1

Anyone out there can help me with this?

I am facing some problem on preloading swf in Chrome and IE. It only works in Firefox.

When i preload flash, Iam getting bytesTotal as 0. So when i bytesLoaded divide by bytesTotal will cause infinity.

I read this article on GZIP. http://patrickmcd.com/2009/04/20/flash-preloading-errors-turn-off-gzip/

But tested that the response compression was not gzipped.

Here's my preloading script:

 addEventListener(Event.ENTER_FRAME, preloadSelf);

 function preloadSelf(e:Event):void {
        var bytestotal:int = stage.loaderInfo.bytesTotal;
        var bytesloaded:int = stage.loaderInfo.bytesLoaded;
        var shellLoaded:int = bytesloaded / bytestotal * 100;
        trace("bytestotal : ", bytestotal);
        trace("bytesloaded : ", bytesloaded);
        trace("shellLoaded : ", shellLoaded);


        if (shellLoaded== 100) {
            removeEventListener(Event.ENTER_FRAME, preloadSelf);
            doSomethingElse();
        }

}

A: 
addEventListener(Event.ENTER_FRAME, preloadSelf);

 function preloadSelf(e:Event):void {

    if( stage.loaderInfo.bytesLoaded > 0 )
    {
        var bytestotal:int = stage.loaderInfo.bytesTotal;
        var bytesloaded:int = stage.loaderInfo.bytesLoaded;
        var shellLoaded:int = bytesloaded / bytestotal * 100;
        trace("bytestotal : ", bytestotal);
        trace("bytesloaded : ", bytesloaded);
        trace("shellLoaded : ", shellLoaded);


        if (shellLoaded== 100) {
            removeEventListener(Event.ENTER_FRAME, preloadSelf);
            doSomethingElse();
        }
     }
}

PatrickS
Why does wrapping his ENTER_FRAME logic in that if statement help?
Tegeril
Only really answering to paragraph 3, it doesn't solves any issue, it's a security switch. Since there is an EnterFrame Event , and not a ProgressEvent that kicks in when content starts to be loaded , it's in theory possible for the function to return a 0 value. On the other hand, there's no certainty that this is the same case scenario as what's referred to in the linked article.
PatrickS