That's easy.....only after busting my asss for an hour figuring it out..
...Variables are only local to the function
Jonathan try using j in your second for statement....not the letter i twice

Hope that helps...
Sent via BlackBerry from T-Mobile

-----Original Message-----
From: "jonathan howe" <[EMAIL PROTECTED]>

Date: Sun, 23 Mar 2008 20:00:41 
To:flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] Variable scope within for loops: reusing iterator
        variables


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
}

I had always thought that the scope of variables declared in the
initialization part of the for loop were local to the loop block, not the
block containing the loop. So I guess that is not true... does this mean the
second time I use the loop I have to omit the declaration? Or is there a
keyword I can use to keep the instantiation local to the for block? Seems
like it would be clunky if I was cutting and pasting blocks of code in
different orders, I'd have to keep track of who was the first for loop of
any code block (an admittedly minor annoyance, since I don't have stacks and
stacks of loops, but still...)

Thanks in advance,
-jonathan



-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to