Masking "i" depth movies

Do you know these “duplicateMovie/random” animations? Like:
[AS]
i = 0;
onEnterFrame = function () {
i++;
duplicateMovieClip(root.mymovie, "mymovie"+i, i);
if (i>1000) {
i = 0;
}
};
[/AS]
How to mask them? Each movie has a higher depth.