User Guide

Coding conventions 105
In this case, the counter variable on the main timeline is overwritten by the counter variable
within the function. The following is the corrected code, which uses the keyword
counter to
declare both of the variables:
var counter = 7;
function loopTest(){
trace(counter);
for(var counter = 0; counter < 5; counter++){
trace(counter);
}
}
trace(counter);
loopTest();
trace(counter);