Load pictures and give each of them a onPress function

I’m loading pictures from an array, each picture gets his own onPress function:

while(arrayLengthLast <= arrayLength)
{
    tmp = _root.theBar.createEmptyMovieClip(namesArray[arrayLengthLast]+"v", j);
    tmp2 = tmp.createEmptyMovieClip("holder", 1);
    tmp2.loadMovie("../"+namesArrayPath[arrayLengthLast]+".jpg");
    tmp._x = xDistance;
    temp[arrayLengthLast] = tmp;
    tmp.onPress = function()
    {    
              trace(namesArrayPath[arrayLengthLast]+".php");
    }
    arrayLengthLast++;
    j++;
    xDistance = xDistance + 90;
}

the problem is that each pictures gets the same function, the namesArrayPath[10]