|
-
SaphuA
[AS2/3] Duplicate variable definition in for-loop?
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:
code: 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
-
Senior Member
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)
-
Senior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|