# setMask - Multiple Pictures, Functions

**URL:** https://forum.kirupa.com/t/setmask-multiple-pictures-functions/128716
**Category:** Uncategorized
**Created:** [November 15, 2004, 4:05pm UTC](https://forum.kirupa.com/t/setmask-multiple-pictures-functions/128716 "2004-11-15T16:05:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![TRPlace](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@TRPlace](https://forum.kirupa.com/u/TRPlace)
#### Post date: [November 15, 2004, 4:05pm UTC](https://forum.kirupa.com/t/setmask-multiple-pictures-functions/128716/1 "2004-11-15T16:05:20Z")

</div>

I am trying to make an image scrolling program…I had it so the first image worked fine, the mask did it’s job, then after that it didnt. Now I have it so you see the mask but it doesnt mask the images like it is supposed to. I have 4 images [image1\_mc,image2\_mc,image3\_mc,image4\_mc] I exported them to actionscript and the first frame…I have a mask that is reveal\_mc that is also exported to actionscript and the first frame. The reveal\_mc is just a simple rectangle growing from small to big.  
Here is my code:  
PHP Code:  
[left] [color=#000000] [color=#0000bb] [/color][color=#007700]var [/color][color=#0000bb]imagePosition[/color][color=#007700]=[/color][color=#0000bb]2[/color][color=#007700];  
function [/color][color=#0000bb]dynamicMask[/color]color=#007700{  
[/color][color=#ff8000]//unloadMovie(mask);  
[/color][color=#0000bb]toBeMasked[/color][color=#007700].[/color][color=#0000bb]setMask[/color]color=#007700;  
[/color][color=#0000bb]mask\_mc[/color][color=#007700]=[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]createEmptyMovieClip[/color][color=#007700]([/color][color=#dd0000]“mask”[/color][color=#007700], [/color][color=#0000bb]2[/color][color=#007700]);  
var [/color][color=#0000bb]spacing[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];  
for(var [/color][color=#0000bb]i[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]\<=[/color][color=#0000bb]5[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++){  
[/color][color=#0000bb]mask[/color][color=#007700].[/color][color=#0000bb]attachMovie[/color]color=#007700;  
[/color][color=#0000bb]mask[/color][color=#007700][[/color][color=#dd0000]“reveal\_mc”[/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]\_y[/color][color=#007700]=[/color][color=#0000bb]spacing[/color][color=#007700];  
[/color][color=#0000bb]spacing[/color][color=#007700]+=[/color][color=#0000bb]spaceInput[/color][color=#007700];  
}  
[/color][color=#0000bb]toBeMasked[/color][color=#007700].[/color][color=#0000bb]setMask[/color]color=#007700;  
}  
[/color][color=#ff8000]//images\_mc.attachMovie(“image1\_mc”,“image1\_mc”,2);  
//dynamicMask(25,images\_mc.image1\_mc);  
//imageToBack(images\_mc.image1\_mc);  
[/color][color=#0000bb]nextImage[/color]color=#007700;  
function [/color][color=#0000bb]imageToBack[/color]color=#007700{  
var [/color][color=#0000bb]temp[/color][color=#007700]=[/color][color=#dd0000]"\_level0.test."[/color][color=#007700]+[/color][color=#0000bb]mc[/color][color=#007700];  
var [/color][color=#0000bb]counter[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];  
[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]onEnterFrame[/color][color=#007700]=function(){  
if([/color][color=#0000bb]counter[/color][color=#007700]==[/color][color=#0000bb]50[/color][color=#007700]){  
[/color][color=#0000bb]back\_mc[/color][color=#007700].[/color][color=#0000bb]attachMovie[/color]color=#007700;  
[/color][color=#0000bb]nextImage[/color]color=#007700;  
}  
[/color][color=#0000bb]counter[/color][color=#007700]++;  
}  
}  
function [/color][color=#0000bb]nextImage[/color]color=#007700{  
var [/color][color=#0000bb]temp[/color][color=#007700]=[/color][color=#dd0000]"\_level0.test.images\_mc.image"[/color][color=#007700]+[/color][color=#0000bb]imagePosition[/color][color=#007700]+[/color][color=#dd0000]"\_mc"[/color][color=#007700];  
[/color][color=#0000bb]images\_mc[/color][color=#007700].[/color][color=#0000bb]attachMovie[/color]color=#007700;  
[/color][color=#0000bb]dynamicMask[/color]color=#007700;  
if([/color][color=#0000bb]imagePosition[/color][color=#007700]==[/color][color=#0000bb]4[/color][color=#007700]){  
[/color][color=#0000bb]imagePosition[/color][color=#007700]=[/color][color=#0000bb]1[/color][color=#007700];  
}else{  
[/color][color=#0000bb]imagePosition[/color][color=#007700]++;  
}  
[/color][color=#0000bb]imageToBack[/color]color=#007700;  
}  
[/color] [/color] [/left]

I keep track of the imagePosition, because I want it to continuously scroll thru…  
The first function is SUPPOSED to make 6 copies of the reveal\_mc and place them below each other, which is does that fine, but the part it doesn’t work fine is to mask the image…  
I call the nextImage(); function to start the whole rotation, I commented off some of the other lines I was trying also  
nextImage() is attaching the current image, ex image2\_mc [the number is derived from the imagePosition variable], then it sends it to the dynamicMask function for it to mask the image, the if statement is just to make sure it doesn’t try to load an image that is not there, and start at 1 once it gets to the end…  
Then my idea was the imageToBack(); function. I wanted to take the current loaded image (after it is masked and shown) to go to the back\_mc, so when I call up the nextImage it gets tranisitioned on top of the underlying image, the counter in the imageToBack() function acts as a clock, to give it some time before processing…I also put the back\_mc on level 1 and the other stuff one level 2…I have tested and tested and I ran out of ideas, so I HOPE someone can help me out! =)

Thanks for your help !!

Sincerely,  
-TJ
