jonathan howe wrote:
> I was hoping someone could explain why I get "Warning: 3596: Duplicate
> variable definition." warnings when I reuse an iterator variable.
> Example:
>
> for (var i:int = 0; i < someArray.length; i ++) {
> // do something cool
> }
>
> for (var i:int = 0; i < someOtherArray.length; i ++) {
> // do something even cooler
> }
The first time you declare the var i, it is in scope for the rest of the
function, not the loop. Think of it this way:
function someFunc():void
{
.
.
.
var i:int;
for (i = 0; i < someArray.length; i ++) {
// do something cool
}
for (i = 0; i < someOtherArray.length; i ++) {
// do something even cooler
}
}
Make sense?
Cordially,
Kerry Thompson
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders