----- Original Message ----- From: "Alexander Farber" <alexander.far...@gmail.com>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Tuesday, December 23, 2008 10:02 AM
Subject: [Flashcoders] Scope of variables declared in for loop


Hello,

has anybody else noticed, that the code like:

stop();

for (var i:Number = 0; i < 10; i++) {
trace('1st loop: ' + i);
}

for (var i:Number = 0; i < 10; i++) {
trace('2nd loop: ' + i);
}

won't be accepted by compiler?

Yes.

Is there an explanation for that?

Flash doesn't scope the variables to the loop block, but to the code section.

The other languages wouldn't complain here
No, they wouldn't.

Paul


Regards
Alex

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

Reply via email to