You are correct Jonathan, but loop blocks are delimited by brackets, so
the for ( ... ) declaration is outside of the loop block.
jonathan howe wrote:
I had always thought that the scope of variables declared in the
initialization part of the for loop were local to the loop block
Jonathon:
In any other language, the scope would be as you describe. AS3 doesn't
have block-level scoping -- the most local scope is always the
function. Declaring a variable anywhere but the first line of a
function is a lie -- the VM declares all variables as the first set of
operations after
besides, the compiler only warns you that you're about the overwrite the
variable, by
re-assigning it. In case of 2 loops(where the variable is only used within
the loop),
it doesn't have any real consequences.
On Mon, Mar 24, 2008 at 4:56 PM, Cory Petosky [EMAIL PROTECTED]
wrote:
Jonathon:
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
4 matches
Mail list logo