Using array data as button list

hoping this has a simple solution, basically i have an array that holds MC names and i want to use a loop so when i click on any of these buttons they will perform a function. for the testing i basically get them to trace a message, heres what i got:

there a loop that pushes data from another ‘generator’ into an array called ‘randomButton’
but basically its like:
randomButton[0] = “_root.rightgrid_1”
…etc…etc… there are only 5 items in this array.
but heres what i got:


var randomButton:Array = new Array()

for (var i=0;i<randomButton.length;i++){
     randomButton*.onRelease = function(){
            trace("PING")
     }
}


it doesn’t work, but when i test if the buttons will work with the following it code, it works.


_root.rightgrid_1.onRelease = function(){
trace("PING")
}

what am i doing wrong?