-
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
-
Funny Bug
-
I just check it with the newest Flash Version MX 2004 Professional and the error still occours!!!
-
If you build up the array with a loop, its no problem
-
Yeah, I kinda figured that out. But it's still weird that it doesn't work in the conventional way, huh?
-
Senior Member
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.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|