Help with simple for loop problem

Hi, i’m trying to program a for loop to make the following code occur four times:

b1.onRelease = function():Void {
ID=1;
}

so that when you press on b2, ID=2 etc…

for (i=1;i<=3;i++) {
this[“b”+i].onRelease = function():Void {
ID=i;
}
}
unfortunately this keeps returning the same number for each button (b1=3,b2=3), not 1,2,3. Any ideas?

thanks in advance,
Adam