? about movieClip.duplicateMovieClip with (for) loop

my question is tha why some values of duplicated movie clips trace back as UNDIFINED if the trace
is assigned to a onPress function, but if its outside of the function than it traces back normaly.
Im trying generate bottons for pictures depending on a number from a variable and I need to number the buttons so they will pull out the right
Well, here is the script:

[FONT=Lucida Console]
c = 1;
function btnDup() {
for (v=1; v<pics; v++) {
p_btn.duplicateMovieClip(“p”+c+"_btn", v);
setProperty(“p”+v+"_btn", _x, _root.p_btn._x += 18);
_level0[“p”+v+"_btn"].tmb = v;
if (c>=pics) {
valuesAssigned = true;
picGal_mc.onRelease = function() {
if (picsLoaded) {
if (valuesAssigned) {
for (v=1; v<pics; v++) {

	_level0["p"+v+"_btn"].onPress = function() {