# Scripted dynamic button problem

**URL:** https://forum.kirupa.com/t/scripted-dynamic-button-problem/83467
**Category:** flash
**Created:** [March 19, 2005, 4:52am UTC](https://forum.kirupa.com/t/scripted-dynamic-button-problem/83467 "2005-03-19T04:52:12Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mprzybylski](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mprzybylski/32/613_2.png) [@mprzybylski](https://forum.kirupa.com/u/mprzybylski)
#### Post date: [March 19, 2005, 4:52am UTC](https://forum.kirupa.com/t/scripted-dynamic-button-problem/83467/1 "2005-03-19T04:52:12Z")

</div>

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

```auto
// 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!
