# AS2 mask several images in a loop

**URL:** https://forum.kirupa.com/t/as2-mask-several-images-in-a-loop/331226
**Category:** flash
**Created:** [June 17, 2013, 5:18pm UTC](https://forum.kirupa.com/t/as2-mask-several-images-in-a-loop/331226 "2013-06-17T17:18:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![capdetrons](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@capdetrons](https://forum.kirupa.com/u/capdetrons)
#### Post date: [June 17, 2013, 5:18pm UTC](https://forum.kirupa.com/t/as2-mask-several-images-in-a-loop/331226/1 "2013-06-17T17:18:30Z")

</div>

I’m completely confused here and would appreciate any help with this code where I’m trying to mask some images loaded into a container clip and distributed horizontally along the gallery but I can’t manage to achieve it. I think i have tried almost everything besides looking for similar examples. I know I have the masks there from a trace, but I just can’t find the way to mask the loaded images. Thanks…

```auto
myGalleryXML.onLoad = function():Void {
    images = myGalleryXML.firstChild.childNodes;
    thumbs = images;
    callThumbs();
};

function callThumbs():Void {
_root.createEmptyMovieClip("container_mc", getNextHighestDepth());
container_mc._x = 50;
container_mc._y = 50;
    var clipLoader = new MovieClipLoader();
    var preloader = new Object();
    clipLoader.addListener(preloader);
    for (i=0; i<12; i++) {
        thumbURL = thumbs*.attributes.thumb_url;
        myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth());
        myThumb_mc._x = 200*i;
        myThumbMask_mc = container_mc.createEmptyMovieClip("thumbMask_mc"+i, container_mc.getNextHighestDepth());
        myThumb_mc.setMask(myThumbMask_mc);
        clipLoader.loadClip("images/"+thumbURL, myThumb_mc);
    }
}

```
