# Dynamic buttons

**URL:** <https://forum.kirupa.com/t/dynamic-buttons/252792>\
**Category:** Uncategorized\
**Created:** [February 23, 2008, 5:40pm UTC](https://forum.kirupa.com/t/dynamic-buttons/252792 "2008-02-23T17:40:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![panda00s](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@panda00s](https://forum.kirupa.com/u/panda00s)\
**Post date:** [February 23, 2008, 5:40pm UTC](https://forum.kirupa.com/t/dynamic-buttons/252792/1 "2008-02-23T17:40:52Z")

</div>

Hi all,

I’m trying to make dynamic buttons but can’t get the buttons to function like a button.

Here is the code:

```auto
var xPos = 105;
var xChange = 5;
var imgName = "img";

var myThumbs:Array = Array(4);
myThumbs[0] = "images/thumbs/TNvnspots.jpeg";
myThumbs[1] = "images/thumbs/TNvnspots.jpeg";
myThumbs[2] = "images/thumbs/TNvnspots.jpeg";
myThumbs[3] = "images/thumbs/TNdes.jpg";
myThumbs[4] = "images/thumbs/TNsimpsons.jpg";

for(var i = 0; i < myThumbs.length; i++){
    var mcc = createEmptyMovieClip(imgName, this.getNextHighestDepth());
    
        **imgName.onPress = function(){ //test on press for each image
            trace("afda");
        };**
        
    mcc._x = 30 + xChange;
    mcc._y = 350;
    
    imgName = "img" + i;
    
    mcc.loadMovie(myThumbs*);
    xChange +=102;

};

```

Thanks :bu:

nevermind, its solved

```auto
var xChange = 5;
var imgbtn = "img";

var myThumbs:Array = Array(4);
myThumbs[0] = "images/thumbs/TNvnspots.jpeg";
myThumbs[1] = "images/thumbs/TNvnspots.jpeg";
myThumbs[2] = "images/thumbs/TNvnspots.jpeg";
myThumbs[3] = "images/thumbs/TNdes.jpg";
myThumbs[4] = "images/thumbs/TNsimpsons.jpg";

for(var i = 0; i < myThumbs.length; i++){

    imgbtn = this.createEmptyMovieClip(imgbtn, this.getNextHighestDepth());
    imgbtn.onRelease = function() {
        trace(this.imageLoad._url);
    }
    
    imgbtn._x = 30 + xChange;
    imgbtn._y = 350;
    
    imageLoad = imgbtn.createEmptyMovieClip("imageLoad", imgbtn.getNextHighestDepth());
    imageLoad.loadMovie(myThumbs*);
    
    imgbtn = "img" + i;
    xChange +=102;

};

```
