Scope of a variable?

Hi every1! I got this code:

cycle for 1<i<10:
_root["containter"+i].onRelease = function () {
	_root.play();
	_root.blackout.gotoAndPlay(1);
	_root.media2load = "works/" + myVars["media"+i];
}
end of cycle

So, when I check then “_root.media2load” after I click on the container1 (for example) it says “undefined”. So, I guess the cycle doesn’t go into this function and work it out only when the flash is playing and when I click on that container. But then the variable “i” has the its last value = 10.
What should I do?