This works and traces '2' five times:
I sort of understand why this doesn't:Code:for (var i = 0; i < 5; i++) { var d:int = 2; trace(d); }
Since I get the next error:Code:var d:int = 2; trace(d); var d:int = 2; trace(d); var d:int = 2; trace(d); var d:int = 2; trace(d); var d:int = 2; trace(d);
cause I declare the same variable five times.1151: A conflict exists with definition d in namespace internal
The thing I don't understand is why it does work in the for-loop, since in principle I'm doing the same thing there. Why isn't it a problem for actionscript when I let the same variable be declared over and over again when I use a for-loop?