1 Reply Latest reply on Jun 6, 2006 7:36 PM by kglad

    Flash counting bug?

    matpat
      This is part of a bigger project, but I've tried to simplify the problem.

      My basic logic is:

      Start with a variable (_root.lapZ) and set it to 0
      Action 1: If the decimal point is 0.0 then add 0.2 to it.
      Action 2: If the decimal point is 0.8 then add 0.2 to it.
      Action 3: If the decimal point is 0.6 then add 0.2 to it.
      Action 4: If the decimal point is 0.4 then add 0.2 to it.
      Action 5: If the decimal point is 0.2 then add 0.2 to it.
      Action 6: Go back to action 1

      In theory, this should continually add 0.2 to the variable lapZ forever BUT it doesn't!

      If you start at 0, it fails to add any more after 0.6! If you start at 1.8 if fails to add more after 2.4

      Below is a simplified version of the script I'm using to calculate the decimal point and the loop of if/then statements:

      decimalP = _root.lapZ-Math.floor(_root.lapZ);
      decimalP == 0 ? _root.lapZ += 0.2 : null;
      decimalP == 0.8 ? _root.lapZ += 0.2 : null;
      decimalP == 0.6 ? _root.lapZ += 0.2 : null;
      decimalP == 0.4 ? _root.lapZ += 0.2 : null;
      decimalP == 0.2 ? _root.lapZ += 0.2 : null;

      I found this making a small flash game a year ago while detecting how far around a track the car had travelled (5 hit tests) and having just purchased Studio 8, the bug still appears to be there.

      Any ideas? Is my logic wrong, or is it a bug?