# Mask Duplicated MC not working

**URL:** <https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274>\
**Category:** Uncategorized\
**Created:** [June 16, 2004, 2:34pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274 "2004-06-16T14:34:23Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlLife](https://avatars.discourse-cdn.com/v4/letter/r/eb8c5e/32.png) [@rlLife](https://forum.kirupa.com/u/rlLife)\
**Post date:** [June 16, 2004, 2:34pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/1 "2004-06-16T14:34:23Z")

</div>

How come when I take a shape and make it duplicate with actionscript.

```auto
for (var i = 0; i<50; i++) {
	box.duplicateMovieClip(i, i);
}
for (var i = 0; i<25; i++) {
	box2.duplicateMovieClip(i, i);
}

```

the mask that i had over that shape stops working? Has anyone else had this happen. I could just put all the shapes on the stage and it works under the mask. But i think it is better to not have to lay out all the shapes so that is why i wanted to make them duplicate. C:-)

---

<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:** [June 16, 2004, 3:36pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/2 "2004-06-16T15:36:52Z")

</div>

> [@rlLife](#):
>
> [size=1]How come when I take a shape and make it duplicate with actionscript.
> 
> ```auto
> ...
> 
> ```
> 
> the mask that i had over that shape stops working? Has anyone else had this happen. I could just put all the shapes on the stage and it works under the mask. But i think it is better to not have to lay out all the shapes so that is why i wanted to make them duplicate. C:-)[/size]

I don’t think you can have masks on Duplicated Movie Clips. Each one is on a level, and I don’t think masks work like that… I thought they had to be on the stage.

---

<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:** [June 16, 2004, 3:44pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/3 "2004-06-16T15:44:08Z")

</div>

A mask can only mask :lol: one movie clip at one time . the work around your problem is to do the duplication ‘inside’ a parent movie clip which is the masked one.

---

<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:** [June 16, 2004, 3:46pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/4 "2004-06-16T15:46:10Z")

</div>

you know i never thought of that , you are right. I guess i am stuck using the version were i lay out all of the shapes first. I had one more question if you had time to check it out. I have random shapes that are moving from the tut on this site. I also wanted some of the shapes to randomly expand and then go back, to give the apperance that they are comeing tward the screen then going back here is the code i am using

```auto
onClipEvent (enterFrame) {
	// generating movement
	location = this._x;
	var i;
	i = 1+_root._xmouse/150;
	if (this, hitTest(_root.thegotoguy)) {
		this._x = -1000;
	} else {
		this._x = location+i++;
	}
	// take this out if you want to add the ablility to scale the squares, 
	//this._xscale = 100+_root._ymouse;
	//this._yscale = 100+_root._ymouse;
}

```

---

<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:** [June 16, 2004, 3:46pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/5 "2004-06-16T15:46:39Z")

</div>

```auto
for (var i = 0; i<50; i++) {
        box.duplicateMovieClip("box"+i, i);
}

```

and you can use

```auto
myMovieClip.setMask(maskMovieClip)

```

for dynamic masking;)

scotty(-:

---

<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:** [June 16, 2004, 3:56pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/6 "2004-06-16T15:56:01Z")

</div>

> [@scotty](#):
>
> ```auto
> for (var i = 0; i<50; i++) {
> box.duplicateMovieClip("box"+i, i);
> }
> 
> ```
> 
> and you can use
> 
> ```auto
> myMovieClip.setMask(maskMovieClip)
> 
> ```
> 
> for dynamic masking;)
> 
> scotty(-:

My point was:

```auto
for (var i = 0; i<50; i++) {
        boxesContainer.box.duplicateMovieClip("box"+i, i);
}
boxesContainer.setMask(maskMovieClip)

```

---

<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:** [June 16, 2004, 3:59pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/7 "2004-06-16T15:59:57Z")

</div>

Nice one, eki=)

scotty(-:

---

<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:** [June 16, 2004, 4:00pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/8 "2004-06-16T16:00:59Z")

</div>

here is my file so you can see what i am doing. I cant seem to get the dynamic mask to work.

---

<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:** [June 16, 2004, 4:04pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/9 "2004-06-16T16:04:46Z")

</div>

```auto

onClipEvent (enterFrame) {
	// generating movement
	location = this._x;
	var i;
	i = 1+_root._xmouse/150;
	if (this, hitTest(_root.thegotoguy)) {
		this._x = -1000;
	} else {
		this._x = location+i++;
	}
	if(!temp){
                  var myScale = random(400);
                  temp = 1;
             }
              this._xscale += (myScale-this._xscale)*0.3;
             if(Math.ceil(this._xscale)>=(myScale-1)){
                 this._xscale = myScale;
                 temp = 0;
              }
}

```

---

<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:** [June 16, 2004, 4:07pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/10 "2004-06-16T16:07:34Z")

</div>

cool! :cool:

---

<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:** [June 16, 2004, 4:09pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/11 "2004-06-16T16:09:26Z")

</div>

Can’t open that file!

---

<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:** [June 16, 2004, 6:33pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/12 "2004-06-16T18:33:06Z")

</div>

Here you go, with eki’s code;)

scotty(-:

---

<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:** [June 16, 2004, 6:48pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/13 "2004-06-16T18:48:43Z")

</div>

very cool, thanks. It looks like what i might have been doing wrong was that i had the layer masked and should have taken that off since eki’s code was for a dynamic mask. Thanks so much for helping me work through that.

rL:::…

---

<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:** [June 16, 2004, 6:58pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/14 "2004-06-16T18:58:18Z")

</div>

Welcome:)  
Yep, it was the making layer **and** mc box is now in mc called boxContainer;)

scotty(-:

---

<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:** [June 17, 2004, 5:12pm UTC](https://forum.kirupa.com/t/mask-duplicated-mc-not-working/113274/15 "2004-06-17T17:12:29Z")

</div>

hey i started to add some more stuff to the action script today, i have the cubes moving in and out. If you have a chance to look at the code, could you tell me how i might add random to the in and out movement. Right now the way it is all of the shapes at one time move in and out. It would be cool if there was a way to say for it to be random some move in and out sometimes. here is the code

```auto
for (var i = 0; i<50; i++) {
	boxContainer.box.duplicateMovieClip("box"+i, i);
}
boxContainer.setMask(maskMovieClip);
origin = new Object();
origin.x = 150;
origin.y = 150;

focalLength = 300;

boxContainer.x = -50;
boxContainer.y = 0; 
boxContainer.z = 0;
boxContainer.dir = 1;

speed = 20;

move = function(){
	this.z += speed*this.dir;
	if (this.z > 500){
		this.z = 500;
		this.dir = -1;
	}else if (this.z < 0){
		this.z = 0;
		this.dir = 1;
	}

	var scaleRatio = focalLength/(focalLength + this.z);
	this._x = origin.x + this.x * scaleRatio;
	this._y = origin.y + this.y * scaleRatio;
	this._xscale = this._yscale = 100 * scaleRatio;
	this.swapDepths(-this.z);
};
boxContainer.onEnterFrame = move;

```

if you dont have time no problem, i will keep working through it.

:::::rL
