3 Replies Latest reply on Jul 8, 2009 5:56 AM by logeye

    F8as2 - Headscratcher!  += incrementation stops for no apparent reason

    logeye Level 1

      F8as2

       

      Background:

       

      In trying to respond to a question I wrote a bit of code that just adds 0.01 to a number.  It is displayed in a dynamic text field.  If I start counting from 0 it only counts to 0.06.  The counting stops but the onEnterFrame keeps running.

       

      The Code:

       

      var num:Number = 0;
      this.onEnterFrame = function() {
            num += .01;
            trace(num);
            num = Math.floor(num*100)/100;
            trace("           "+num);
      };

       

      The Output:

       

      0.01

              0.01

      0.02

              0.02

      0.03

              0.03

      0.04

              0.04

      0.05

              0.05

      0.06

              0.06

      0.07

              0.06

      0.07

             0.06

      repeats 0.07

                            0.06

       

       

      The Question:

       

      Why did the code stop incrementing after 0.07??

       

       

      Thanks,