Scripted dynamic button problem

my problem is that the button which i name through the loop does not work.

// function that executes gallery commands 
function chooseGallery(whichOne) {
    var currentGallery = xmlGallery.firstChild.childNodes[whichOne];
    
    // array that holds the galleries
    //var galleries = xmlGallery.firstChild.childNodes;
    
    // fill text box with the name of the gallery
    var galleryTitle:String = xmlGallery.firstChild.childNodes[whichOne].attributes.title;
    gallery_txt.text = galleryTitle;
    
    // make array for images
    var images = xmlGallery.firstChild.childNodes[whichOne].childNodes;
    for (i = 0; i < images.length; i++) {
        var largeIMG = images*.attributes.image;
        var thumbnail = images*.attributes.thumb;
        var imgButton = "image" + i + "_btn";
        imgButton.id = i;
        imgButton.onRelease = function() {
            trace("button clicked");
            _root.onEnterFrame = function() {
                _root.containerMC.loadPic(xmlGallery.firstChild.childNodes[whichOne].childNodes[2].attributes.image);
            };
        };
    }
}

as you can see the onRelease of imgButton doesn’t work (ignore the loadPic i’m going to make that dynamic later) but i cant even get the trace command to come out of it. when i trace imgButton it lists the buttons as they should be, image1_btn, imgae2_btn, and so on, but that doesn’t work. anyone have any ideas why? thanks in advance!