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

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account