Help needed with variables!

what i want, is the value of a variable at a specific point in time.

to explain further, i have a for loop, with a variable k, and in the for loop there is an if statement, which, if true, adds an on release handler to a duplicated mc calling a function:

mc.onRelease = function(){
creategrid(“p”+(k+1)+“pics”)
}

now by using traces, i have determined that this is doing what i want

BUT
k changes!(rather obvious i know)
cos at the end of the loop its equal to 5, so when you click the mc it goes to p6pics which isn’t what i want

is there anyway i can use the value of k at that specific point in time, and not change afterwards when k does?

thanks for your help

chris