9 Replies Latest reply on Nov 11, 2010 6:18 AM by kglad

    how to find the Internet speed ?

    @flash Level 1

      hi,

       

      I need a meter that shows the current bandwidth rate as a percentage. For example: The maximum bandwidth rate is 4mbps, the current bandwidth is 3mbps, so the bar would be 75% full. This bar would change dynamically as the bandwidth rate changes.

       

      can any one tell me, how to detect the bandwidth.

       

      Thanks is advance

      ayathas

        • 1. Re: how to detect a current bandwidth.....
          kglad Adobe Community Professional & MVP

          you can pass the downloading movieclip and start time (in seconds) and start bytes to yourBarF().  for example, if the code below is attached to the main timeliine and you want to display bandwidth while downloading the main swf:

           

          var startTime:Number=getTimer()/1000;

          var startBytes:Number = this.getBytesLoaded();

          clearInterval(preloadI);

          var preloadI:Number = setInterval(yourBarF,1000,this,startTime,startBytes);

           

          function yourBarF(mc:MovieClip,startTime:Number,startBytes:Number):Void{

          var timeN:Number = getTimer()/1000 - startTime;

          // where yourBar is your display and it has a movieclip named, fill

          yourBar.fill._xscale = Math.min( 100,100*(this.getBytesLoaded()-startBytes)/(1024*1024*timeN) )

          }

          • 2. Re: how to detect a current bandwidth.....
            @flash Level 1

            thanks for your reply.

             

            actualy, i will have a menu button. when i click the check bandwidth button, it will reply the current internet speed of the user. based on the speed status, i need to show the bar.

             

            is there any built in function to do this?

             

            or

             

            any calculation v have to done.

            • 3. Re: how to detect a current bandwidth.....
              kglad Adobe Community Professional & MVP

              no, there's no built-in flash function to do that.  use the function i suggested.

              1 person found this helpful
              • 4. Re: how to detect a current bandwidth.....
                @flash Level 1

                i am getting undefined, when i trace the this.getBytesLoaded() inside the yourBarF function.

                 

                function yourBarF(mc:MovieClip, startTime:Number, startBytes:Number):Void {

                     .

                     .

                     trace(this.getBytesLoaded())
                     yourBar.fill._xscale = Math.min(100, 100*(this.getBytesLoaded()-startBytes)/(1024*1024*timeN));

                    

                }

                 

                 

                i am not sure how this will solve my problem. can u explain this code pls?

                • 5. Re: how to detect a current bandwidth.....
                  kglad Adobe Community Professional & MVP

                  use:

                   

                  var tl:MovieClip=this

                   

                  var startTime:Number=getTimer()/1000;

                  var startBytes:Number = this.getBytesLoaded();

                  clearInterval(preloadI);

                  var preloadI:Number = setInterval(yourBarF,1000,this,startTime,startBytes);

                   

                  function yourBarF(mc:MovieClip,startTime:Number,startBytes:Number):Void{

                  var timeN:Number = getTimer()/1000 - startTime;

                  // where yourBar is your display and it has a movieclip named, fill

                  yourBar.fill._xscale = Math.min( 100,100*(tl.getBytesLoaded()-startBytes)/(1024*1024*timeN) )

                  }

                  • 6. Re: how to detect a current bandwidth.....
                    @flash Level 1

                    i have executed the code. now i got some idea about it. Thanks

                     

                    yourBar.fill._xscale = Math.min( 100,100*(this.getBytesLoaded()-startBytes)/(1024*1024*timeN) )

                     

                    both the this.getBytesLoaded() and startBytes traced the same value. so the result gets zero.

                    i have tested this file in my local system only, so it may return zero( if i am wrong pls correct it .)

                    when i download the same files from  the sever. it will work fine. is am correct? .

                    • 7. Re: how to detect a current bandwidth.....
                      kglad Adobe Community Professional & MVP

                      the frame that contains that code should only execute once and it should be in the first frame of your swf.

                      • 8. Re: how to detect a current bandwidth.....
                        @flash Level 1

                        hi

                         

                        the above code gives the download speed of the user( is it right)

                        i have shown this. but they want to show the user internet speed(256 kpbs...)

                         

                        i think i have lacked basic knowledge about bandwidth. can u explain this pls...

                         

                         

                        and also i came to know the internet speed can be calculated using javascript or php. any suggestion pls

                        • 9. Re: how to detect a current bandwidth.....
                          kglad Adobe Community Professional & MVP

                          if you want the dl speed as a percentage of 256kbps, use:

                           

                           

                           

                          var tl:MovieClip=this

                           

                           

                          var startTime:Number=getTimer()/1000;

                          var startBytes:Number = this.getBytesLoaded();

                          clearInterval(preloadI);

                          var preloadI:Number = setInterval(yourBarF,1000,this,startTime,startBytes);

                           

                          function yourBarF(mc:MovieClip,startTime:Number,startBytes:Number):Void{

                          var timeN:Number = getTimer()/1000 - startTime;

                          // where yourBar is your display and it has a movieclip named, fill

                          yourBar.fill._xscale = Math.min( 100,100*(tl.getBytesLoaded()-startBytes)/(256*1024*timeN) )

                          }

                          1 person found this helpful