Skip to main content
November 27, 2012
Answered

Preloader displays "Infinity%" on actual web url?

  • November 27, 2012
  • 1 reply
  • 6065 views

My preloader works fine in "simulated download" in the "test movie" window in Flash AS3, but when I upload it onto my server, all I get is the preloader screen with an "infinity%."

Here is my code:

stop();

var preLoaderPercent: Number
this.loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);

function loadComplete(e:Event) {
    // load complete - remove listeners and move on
    this.loaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
    this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
    play();
}

function loadProgress(e:ProgressEvent):void {
    preLoaderPercent = e.bytesLoaded / e.bytesTotal;
    // Put code here to update your display
var total_bytes:Number = this.stage.loaderInfo.bytesTotal;
var loaded_bytes:Number = this.stage.loaderInfo.bytesLoaded;
preLoader.preLoaderFill.scaleY = loaded_bytes/total_bytes;
preLoader.bytesPercent.text = Math.floor((loaded_bytes/total_bytes)*100) + "%";

}

This topic has been closed for replies.
Correct answer Ned Murphy

Ned, that preloader video/code you showed me works! I just don't know how to input my progress bar in it. What do you mean by, "Just change the "perc" variable in that function to define the scaleY value?" Can you please post a code for me? I'm sort of new to coding. I would really appreciate it! I'll show you the code for the preloader I had, which previously did not work on my site, but had the progress bar I want to use. Can you help me insert it into my current preloader code? The one from that video website you recommended to me? Here is the entire code with my progress bar that did not work on my site before:  

stop();

this.addEventListener(Event.ENTER_FRAME, preLoad)

function preLoad(e:Event):void{

          var total_bytes:Number = this.stage.loaderInfo.bytesTotal;

          var loaded_bytes:Number = this.stage.loaderInfo.bytesLoaded;

          preLoader.preLoaderFill.scaleY = loaded_bytes/total_bytes;

          preLoader.bytesPercent.text = Math.floor((loaded_bytes/total_bytes)*100) + "%";

          if (total_bytes==loaded_bytes){

                    gotoAndStop(2);

                    removeEventListener(Event.ENTER_FRAME, preLoad);

          }

 

}

Please disregard the "preLoader.bytesPercent.text = Math.floor((loaded_bytes/total_bytes)*100) + "%";." I'm not using that because the preloader that I am using already has a text field, but just not the progress bar.

If you need the code for the current preloader that I'm using (the one w/o the progressbar), please refer to post no.11.

Thanks again!


As I said, in the loop function of the code from the tutorial is where you want to have your loader bar code, making use of the perc variable that is already there....

function loop(e:ProgressEvent):void

{

          var perc:Number = e.bytesLoaded / e.bytesTotal;

          percent.text = Math.ceil(perc*100).toString();

          preLoader.preLoaderFill.scaleY = perc;

}

1 reply

Ned Murphy
Legend
November 27, 2012

If I test your code both locally and on a server I get the desired result.  The only way I know of getting an infinite result for division is to have a 0 (zero) value in the denominator.  Maybe what you should do is add another textfield for test purposes and see if the total_bytes value is coming up as a 0.

November 27, 2012

Do you think it's because of gzip. compression? I mean, you said you tested the code on a server, and it worked for you. I'm going to assume that the code is fine and that this is the problem. The only thing I need to figure out now is how to disable the gzip. compression on my server. Do you think I can do this in Dreamweaver, or do I need to contact my hosting site? I need to access my server's .htaccess file in order to disable this feature. Thanks for any information you can provide!

Ned Murphy
Legend
November 27, 2012

You should contact your server host to see if your suspiscions are possible.  I have never delat with a host involving gzip... I just load my files as they are and nothing else intrudes upon them.