I have a strange problem regarding Flash error 1151: A conflict exists with definition i in namespace internal.
Here is the problematic code:
for(var i:Number=dt.getFullYear(); i >= dt.getFullYear()-90; i--)
{
dtYear.addItem( {label:i, data:i} );
} //for
//-*-*-* Month
for(var i:Number=0; i < months.length; i++)
{
dtMonth.addItem( {label:i, data:i} );
} //for
Or a more blatant example:
for(var i:Number=0; i < 12; i++)
{
trace(i);
} //for
//-*-*-* Month
for(var i:Number=0; i < 12; i++)
{
} //for
Adobe gives an explanation:
You cannot declare more than one variable with the same identifier name within the same scope unless all such variables are declared to be of the same type. In ActionScript 3.0, different code blocks (such as those used in two for loops in the same function definition) are considered to be in the same scope.
What the friggin hell is this? I mean the i variable is all the time exists as a Number, typecasted as a Number, why the hell would the above code then fail?
If I modify it this way, it works, BUT THATS UGLY AND WHY IS THIS NEEDED? AAARGGGHHHH...Flash development makes me crazy. Gimme a gun :). Someone explain this one to me please.
Working code:
for(var i:Number=dt.getFullYear(); i >= dt.getFullYear()-90; i--)
{
dtYear.addItem( {label:i, data:i} );
} //for
//-*-*-* Month
for(i=0; i < months.length; i++)
{
dtMonth.addItem( {label:i, data:i} );
} //for