attachMovie() problem

Hi , i’m new to actionscript. I use this code to get a button instance from my library several times into stage. The problem is that although the code should add 9 buttons to stage, it loads only the last one correctly. It also adds a button at 0,0 (top left of the movie) but with no functionality.

the code used is:
for (var i=1 ; i <= loader.num ; i++) { //my for loop

var elementtodisplay = new LoadVars();
elementtodisplay.onLoad = function(success) {
if(success) {

root.attachMovie(“lampon”, "button"+i, _root.getNextHighestDepth());

root["button"+i]._x=elementtodisplay.detx;
root["button"+i]._y=elementtodisplay.dety;
root["button"+i].id=elementtodisplay.id;
root["button"+i].onPress=function(){

getURL(“http://www.oneurl.com”+root["button"+i].id);

} // end onpress
root["button"+i].play();
} //end if success
}; // end function success

var sender = new LoadVars();
sender.n = i;
sender.f=floortodisplay.num;
sender.sendAndLoad(“elementtoshow.php”, elementtodisplay, “post”);