A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Weird bug in ActionScript envolving Array. Please help.

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Posts
    185

    Weird bug in ActionScript envolving Array. You gotta try this!

    I'm using Flash MX 6.0 and Flash MX 2004 Professional

    Try this:

    Code:
    normal = new Array(01,02,03,04,05,06,07,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60);
    Now check syntax.
    It should appear "This script contains no errors".

    Now try this:
    Code:
    normal = new Array(01,02,03,04,05,06,07,08,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60);
    Now check syntax. It says ERROR.
    Code:
    Scene=Scene 1, Layer=ac, Frame=1: Line 3: ')' or ',' expected
         	normal = new Array("01","02","03",04,05,06,07,08,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60); 
    
    Scene=Scene 1, Layer=ac, Frame=1: Line 15: Unexpected '}' encountered
         }
    The only diference is that I have a "08" instead of "8" in the Array. Is that a Flash bug or an error in my code?

    Thanks.
    Last edited by joaomiguel33; 09-10-2004 at 05:38 PM.
    - J.Miguel

  2. #2
    Member
    Join Date
    Sep 2004
    Posts
    78
    Funny Bug

  3. #3
    Senior Member
    Join Date
    Nov 2000
    Posts
    185
    I just check it with the newest Flash Version MX 2004 Professional and the error still occours!!!
    - J.Miguel

  4. #4
    Member
    Join Date
    Sep 2004
    Posts
    78
    If you build up the array with a loop, its no problem

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Posts
    185
    Yeah, I kinda figured that out. But it's still weird that it doesn't work in the conventional way, huh?
    - J.Miguel

  6. #6
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    In most C-like languages (including more recent versions of actionscript), when you put leading zeros in front of a number, it is assumed to be in Octal (a number base which uses the digits 0-7).

    The equivalent of 8 in octal is "010".

    "08" is an illegal octal number, thus the error. And yes, Flash is doing a crappy job of telling you what's wrong with the code.

    To avoid the error, leave off the leading zeros.

    * * *

    In my opinion, Octal is a historical holdover that should be removed from modern languages. I pretty much stick to decimal or hexadecimal in all my code. For example, you used to encode arbitrary ASCII characters in strings using "\OOO" in which OOO is a 3-digit octal number, but these days you can almost always use the easier-to-read "\xHH" in which HH is hexadecimal. Then again, I'll probably be *****ing and moaning about ASCII in 10 years time...
    Last edited by jbum; 09-10-2004 at 07:07 PM.

  7. #7
    Senior Member
    Join Date
    Nov 2000
    Posts
    185
    Thanks for the input!
    - J.Miguel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center