declare variables in for-statement
this works , traces '2' 5 times:
for (var = 0; < 5; i++)
{
var d:int = 2;
trace(d);
}
i sort of understand why doesn't:
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);
since next error:
1151: conflict exists definition d in namespace internal
cause declare same variable 5 times.
the thing don't understand why work in for-loop, since in principle i'm doing same thing there. why isn't problem actionscript when let same variable declared on , on again when use for-loop?
one way @ declare variables compiler - not runtime. - compiler perspective if declare var in loop - single declaration statement.
More discussions in ActionScript 3
adobe
Comments
Post a Comment