;

PDA

Click to See Complete Forum and Search --> : [AS2/3] Duplicate variable definition in for-loop?


SaphuA
08-03-2006, 10:37 AM
Hi there,

I'm currently learning AS3 (and 2 aswell I guess). Now i'm having a little 'problem' with duplicated variables.

I'm having a function with two for-loops:
for(var i:int=0; i<10; i++) {
var m:Boolean = false;
}

for(var i:int=0; i<10; i++) {
var m:Boolean = false;
}
Why do i get the warning of duplicated variables? I always thought that both variables 'i' and 'm' would get removed at the end of the loop. Doesn't this happen anymore since AS2/3 ?

Thanks,
~Sph

UnknownGuy
08-03-2006, 11:01 AM
No, they don't get removed if declared in a loop, its when they are declared in a function.

(Eg, at the end of the function all local variables declared are erased)

tonypa
08-08-2006, 07:09 AM
Moved to AS3 forum.