# Dynamic Masking on loadmovies

**URL:** <https://forum.kirupa.com/t/dynamic-masking-on-loadmovies/26855>\
**Category:** flash\
**Created:** [July 27, 2003, 11:39am UTC](https://forum.kirupa.com/t/dynamic-masking-on-loadmovies/26855 "2003-07-27T11:39:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alimirza](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@alimirza](https://forum.kirupa.com/u/alimirza)\
**Post date:** [July 27, 2003, 11:39am UTC](https://forum.kirupa.com/t/dynamic-masking-on-loadmovies/26855/1 "2003-07-27T11:39:57Z")

</div>

I want to have a same dynamic mask on my each load movie when it is called.  
Actually I am trying to have duplicate movieclip which build a grid step by step and act as a dynamic mask and whenever movie loads it plays and reverses itself on new movieload do the same again.  
Help is always appreciated:)

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2003, 5:56am UTC](https://forum.kirupa.com/t/dynamic-masking-on-loadmovies/26855/2 "2003-07-29T05:56:22Z")

</div>

This isn’t the best prototype for you needs or the most optimized. Just place the proto in the first frame of your movie, make a mask movieclip around 10px by 10px + export for Actionscript as ‘masker’) and call like so:

//(10,10 is the size of your mask movieclip).  
myMovieClip.setGridTrans(10,10);

This proto will add grid masking functionality to any movieclip – also, it is set for radnom postitioning right now – alter away.

Code:  
MovieClip.prototype.setGridTrans = function(gridX, gridY) {  
if(this.active) return;  
this.active = true;  
var count = 1;  
var numX = Math.ceil(this.\_width/gridX);  
var numY = Math.ceil(this.\_height/gridY);  
maskObj = this.createEmptyMovieClip(“masker”, 1000);  
maskObj.base = this;  
maskObj.tmpArr = [];  
maskObj.alterPlay = function(){  
var tmpNum = random(this.tmpArr.length);  
tmpClip = this.tmpArr[tmpNum];  
tmpClip.play();  
if(this.tmpArr.length==0) clearInterval(this.base.loop), this.active = false, removeMovieClip (this);  
this.tmpArr.splice(tmpNum,1);  
}  
for (var n = 0; n\<=numY; n++) {  
for (var i = 0; i\<=numX; i++, count++) {  
var clip = maskObj.attachMovie(“box2”, “b”+count, count+100, {\_x:i_gridX, \_y:n_gridY});  
maskObj.tmpArr.push(clip);  
}  
}  
this.loop = setInterval(maskObj,‘alterPlay’,10);  
this.setMask(maskObj);  
};

by  
neue  
WH Flasher  
California

P.S: I couldn’t make it work? any help how to use it fully and properly??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2003, 9:56am UTC](https://forum.kirupa.com/t/dynamic-masking-on-loadmovies/26855/3 "2003-07-29T09:56:13Z")

</div>

I’ve tried alot but still couldn’t figure out how to make it work  
my debug Object list shows  
Level #0: Frame=1  
Movie Clip: Frame=1 Target="\_level0.pic"  
Shape:  
Button: Target="\_level0.instance1"  
Shape:  
my debug Variable list shows  
Level #0:  
Variable \_level0.$version = “WIN 6,0,79,0”  
Movie Clip: Target="\_level0.pic"  
Button: Target="\_level0.instance1"  
Variable \_level0.instance1.tabIndex = [getter/setter] undefined

Now the picMC does appear after a mint or so but without any effect.  
\_root.pic.setGridTrans(10, 10);  
aint working on button or clipevent.  
it is a test file all independent.

Please tell me where I am wrong or how to make it work for me.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2003, 10:05am UTC](https://forum.kirupa.com/t/dynamic-masking-on-loadmovies/26855/4 "2003-07-29T10:05:17Z")

</div>

My debug Variable list shows  
Variable \_level0.maskObj = [movieclip:\<broken\>]  
Variable \_level0.tmpClip = [object #1, class ‘Array’] []  
Movie Clip: Target="\_level0.pic"  
Variable \_level0.pic.active = true  
Variable \_level0.pic.loop = 1  
Button: Target="\_level0.instance1"  
Variable \_level0.instance1.tabIndex = [getter/setter] undefined

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2003, 6:37am UTC](https://forum.kirupa.com/t/dynamic-masking-on-loadmovies/26855/5 "2003-08-02T06:37:44Z")

</div>

PLEASE HELP!!!  
Or atleast let me know how I can apply my single animated mask on all my loaded movies when they are called?  
Or just how to reuse my MCmask each time I need it?
