Assigning onPress functions in a loop

is that possible? i’m a complete beginner when it comes to flash and actionscript… so if it sounds like i dont know what i’m talking about… it’s because i don’t!

let me describe my situation…

I have about 20 boxes… and on each box i want to assign the onPress to trace the value corresponding to an Array at element “i” in the console…

instead of doing:

box1.onPress = function() {
  trace("the value is: "+hypotheticalArray[1]);
}

from 1 to 20… i’d like to loop these assignments.

like this:

function myTrace(i) {
  trace("the value is: "+hypotheticalArray*);
}

//assume that there are as many textboxes as there are elements in the array.
for (var i=0; i<hypotheticalArray.length; i++) {
  set("box"+i+".onPress",myTrace(i));
}

ANY suggestions would be greatly appreciated!