Multiple Masks with for Multiple MC's

I want to be able to dynamically create multiple masks as movieclips and them apply those masks to other movieclips using actionScript. My code is below, it’s still in the logic phase though. I want to be able to loop over this code for as many movieclips is as neccessary. (I realize that the instance names would be the same as it is currently written)

mc1 is a blank containerMC

var depth = mc1.getNextHighestDepth();

mc1.createEmptyMovieClip(“picClip”, depth);
mc1.picClip.createEmptyMovieClip(“maskClip”, 1);
with(mc1.picClip.maskClip){
lineStyle(0,0xFFFFFF,100);
beginFill(0x000000,30);
moveTo(0,0);
lineTo(100,0);
lineTo(100,100);
lineTo(0,100);
lineTo(0,0);
endFill();
}
mc1.picClip.setMask(mc1.picClip.maskClip);