Problem with attachMovie in for loop - flash 8 (as2)

Hello everyone,

I seem to be having a bit of trouble with my code- specifically the attachMovie line in the for loop below. I have a series of movieclips with identifiers named “loc_1”, “loc_2”, “loc_3” … which are supposed to load inside the scrollPane which is located on the root timeline.

I think I have the problem narrowed down to the first parameter in attachMovie :
mcMain.attachMovie(“loc_”+i, “loc_”+i, mcMain.getNextHighestDepth());

If I change it to “loc_1” instead of “loc_”+i, it loads the movie clip…

Here’s what the AS looks like:


stop();

var mcMain:MovieClip;
var i:Number=0;

function init() {
    scrollPane.contentPath = "scrollMovieClip";
    mcMain = scrollPane.content;
    //trace(mcMain);
}

init();

for( i = 1; i <= 9; i++) {
    _root["loc_" + i].onRelease = function (){
    mcMain.attachMovie("loc_"+i, "loc_"+i, mcMain.getNextHighestDepth());
    scrollPane.invalidate();
    }
}

Any help is greatly appreciated :slight_smile:

Thanks