Dynamic buttons

Hi all,

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

Here is the code:

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

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;

};