Mask Duplicated MC not working

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

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:-)

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.

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.

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

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;
}
for (var i = 0; i<50; i++) {
        box.duplicateMovieClip("box"+i, i);
}

and you can use

myMovieClip.setMask(maskMovieClip)

for dynamic masking;)

scotty(-:

My point was:

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

Nice one, eki=)

scotty(-:

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


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;
              }
}

cool! :cool:

Can’t open that file!

Here you go, with eki’s code;)

scotty(-:

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:::…

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

scotty(-:

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

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