Warning: 3596: Duplicate variable definition and Adobe Bug Tracking system.
I've recently switched to CS4 and AS3. There is a couple of nice features in AS3. However, the more I do hacking (certainly you can't call it programming) the more frustrated I'm with AS3.
Here is the most stupid thing I found so far.
Put this code in:
for (var i:Number=0; i<10; i++)
{
trace("i exists and equals: "+i);
}
for (var i:Number=0; i<10; i++)
{
trace("new for loop; new i: "+i);
}
This is the basic of programming. You create 'for' loop and a variable. Loop ends. Variable should be destroyed. You create another 'for' loop and declare new i variable. Simple. If you publish the SWF movie and select AS2, it will work. But change it to AS3 and "fun" begins! You get "Warning: 3596: Duplicate variable definition" error. I honestly can't understand why Adobe made this kind of a "feature".
I looked up this error in the Internet and found this comment from 2007!
http://curtismorley.com/2007/06/21/flash-cs3-flex-2-as3-warning-3596-duplicate-variable-definition/
So either you can use different variable name or you should omit variable declaration in the second loop. That's "great". Completely in opposition to all modern programming languages. Nice. What's even more bizarre is the fact that this "feature" exists for at least two years!
I wanted to check if somebody have reported this bug already. I went to Adobe Bug System: https://bugs.adobe.com/asc/
As it is written: "Search (Browse without registration)". So I want to browse... where are all bugs? "You are not logged in, and do not have the permissions required to browse projects as a guest." Great! Another "nice feature". I created an account and have been waiting for confirmation e-mail for around an hour. Once I get it, I'll report it. But still... so many nice things were added to AS3 and so many basic things were broken... and the software is more and more expensive!
PS I know I can use var i:int in AS3. I used Number for backward compatibility. Still doesn't make any change that such a basic thing like a for loop behaves in a such a strange way.