[F8/FMX] Functions on "attachMovie()" clip instances

Okay, here is what I am trying to do, and I have attempted it several different ways…

I would like to generate a grid of squares (movieclip clip_Square with Export for AS Linkage). The grid generates just fine 10x10, as expected. However, in addition to having this grid, I would like to be able to reference properties of each individual square when they are clicked on. Unfortunately, the function only references the last movieclip, not the movieclip being clicked (onMouseUp).

And if you replace txtDebug.text = “Square_”+i; with trace(this._name);, the output window displays the names of every square when you click one.

What am I doing wrong? Is there a tutorial someone could point me towards…? Any help would be greatly appreciated.

Thank you very much in advance!

PS: Happy Halloween! :link:

function init_Game() {
    x = 0;
    y = 0;
    
    for (i = 1; i <= grid; i++) {
        attachMovie("clip_Square", "Square_" + i, i);
        _root["Square_" + i]._x = x * 65 + 50;
        _root["Square_" + i]._y = y * 65 + 50;
        _root["Square_"+i].onMouseUp = function() {
            txtDebug.text = "Square_"+i;
        }
        ++x;
        if (x >= 10) {
            x = 0;
            y++;
        }
    }
}

init_Game();
stop();