Assigning same action in a multiple buttons

numOfPlaylist = 11;
for (var i = 1; i<=numOfPlaylist; i++) {
_root[“list”+i].onRollOver = function() {
_root[“playlist”+i].gotoAndPlay(“over”);
};
_root[“list”+i].onRollOut = function() {
_root[“playlist”+i].gotoAndPlay(“out”);
};
_root[“list”+i].onPress = function() {
_root.gotoAndStop(i);
};
}

i have a buttons name list1, list2, list3 … and movieclips so on and playlist1 , playlist2 … and so on basically what i want to do is assign same action on it the code above is what i did and it doesn’t work … can anyone tell me whats wrong…