Skip to main content
Known Participant
September 2, 2011
Answered

Why does 01->07 work and 08 & 09 don't???

  • September 2, 2011
  • 1 reply
  • 404 views

Flash8 AS2

In attempt to remove leading 0's from an input text field I tested for 01 through 07 and everything seemed to work OK.

When I get to 08 and 09 it doesn't work.

Here's a portion of the code:

// this works

if (kids == 07) {
kids = 7;
}

// this does not work unless 08 is changed to 8
if (kids == 08) {
    // kids = 8;
}

This checks OK and auto formats OK, but when I make the 8 to 08 in the if statement, I get an error message.  Same with 09.

The = and == do not seem to make any difference, just the 08 and 09.

It's got to be me messed up, but I can't see any logical reasoning for this.

This topic has been closed for replies.
Correct answer Rothrock

Because a zero before a number tells flash that the number is octal (base 8). So you count like this,

0,1,2,3,4,5,6,7,10,11,12,13,14,15,16,17,20,...

There is no such thing as 08 in octal.

Instead of trying to remove the zeros using if than statments use something like:

kids=parseInt(myTextField.text);

You shouldn't be using the vars property of a textfield anyways.

1 reply

RothrockCorrect answer
Inspiring
September 2, 2011

Because a zero before a number tells flash that the number is octal (base 8). So you count like this,

0,1,2,3,4,5,6,7,10,11,12,13,14,15,16,17,20,...

There is no such thing as 08 in octal.

Instead of trying to remove the zeros using if than statments use something like:

kids=parseInt(myTextField.text);

You shouldn't be using the vars property of a textfield anyways.

logeyeAuthor
Known Participant
September 2, 2011

F8 AS2

Thanks Rothrock,

I seem to remember now about the 0 and octal numbers.

Don't get old.  The older you get the more new things you repeat.

Thanks