3 Replies Latest reply: Feb 5, 2010 2:01 PM by Jose Diego Diaz Cuellar RSS

    Preloader Stops at 100%

    Ron Colmen Community Member

      I'm trying to preload a swf in to my webpage. The swf stops after completing 100% (not moving on to the frame 2). What's wrong here?

       

      stop(); 

      import flash.display.*;
      this.stop();

      this.addEventListener (ProgressEvent.PROGRESS, loading);

      function loading(event:ProgressEvent):void {
      var pcent:Number=event.bytesLoaded/event.bytesTotal*100;

      lbar.scaleX=pcent/100;

      lpc.text=int(pcent)+"%";

      if(pcent==100){
      this.gotoAndPlay(2);
      }
      }

        • 1. Re: Preloader Stops at 100%
          Ron Colmen Community Member

          COuld someone tell me why am I getting this error and how the code should be adjusted?

          • 2. Re: Preloader Stops at 100%
            dmeN Community Member

            Did you try tracing your percent? You probably would've seen your problem if you did. You are using a Number... it's likely never going to equal 100. And you can get rid of the 'this'  - there is no reason for them.

            • 3. Re: Preloader Stops at 100%
              Jose Diego Diaz Cuellar Community Member

              Hi  There.

               

              I use this code at the first frame:

               

              stop();
              this.addEventListener(Event.ENTER_FRAME, loading);
              function loading(e:Event):void {
                  var total:Number = this.stage.loaderInfo.bytesTotal;
                  var loaded:Number = this.stage.loaderInfo.bytesLoaded;
                  bar_mc.scaleX = loaded/total;
                  loader_txt.text = Math.floor((loaded/total)*100)+ "%";
                  if(total == loaded) {
                      play();
                      this.removeEventListener(Event.ENTER_FRAME, loading);
                  }
              }

               

              In the first frame but in the stage I put the progress bar componet and i assing the " bar_mc" instance name and put a dynamic text and name it "loader_txt"