Random+duplicate+width.. help please?

hi… i have a little problem with a script i found…


for (i=0; i<30; i++) {
	newBall = mask_mc.duplicateMovieClip("mask_mc"+i, i);
	newBall._x = Math.random*600;

	newBall.targX = Math.random()*600;

	newBall.i = 0;
	newBall.rand = Math.random()*50;
	newBall.onEnterFrame = function() {
		this.i++;
		if (this.i>this.rand) {
			this.targX = Math.random()*600;

			this.i = 0;
			this.rand = Math.random()*50;
		}
		this._x -= (this._x-this.targX)/5;

	};
}

Problem is this does’nt seem to work in a mc with a mask… it works i know that cos if i unmask my layer it starts perfectly but as soon as i make the layer mask again it stops working…

how come and how do i fix this?

Ps, and wile your at it… how do i add a random width section to this script?

Use setMask.
Make your mask a mc an give it the instancename “mask”.
Place it where you want it and put the code below
(btw the random width is also in it)
[AS]for (i=0; i<30; i++) {
mask._visible = 0;
mask_mc._visible = 0;
newBall = mask_mc.duplicateMovieClip(“mask_mc”+i, i);
newMask = mask.duplicateMovieClip(“mask”+i, 40+i);
newBall._x = Math.random()*600;
newBall._width = Math.random()*100;//randomly setting width
newBall.setMask(newMask);//masking
newBall.targX = Math.random()*600;
newBall.i = 0;
newBall.rand = Math.random()*50;
newBall.onEnterFrame = function() {
this.i++;
if (this.i>this.rand) {
this.targX = Math.random()*600;
this.i = 0;
this.rand = Math.random()*50;
}
this._x -= (this._x-this.targX)/5;
};
[/AS]

scotty(-:

Thx the width section… PERFECT works fine but the mask is still no work… explain to me how i must set the instance cos we have 2 now?

explain the script a little…?

PS. LOL did know you where from Holland “ouwe reus” :):smiley:

LOL hé jochie:)

It worked here, but I think I misunderstood you.
You want your duplicated movies to be a mask?

scotty(-:

okay i’ll explain in more detail…

i have main time with 2 layers… 1 is my background 2 is my animation layer…

in layer 2 i have a movieClip called mask…
that movieclip has 3 layers 3 = action 2 = mask 1 = a colored bar…

the colored bar is what need tobe masked…

Hope I’ve understood you right this time.
The actions are now on a mc in the mc in the mask layer.
In case you don’t get me anymore, I made a little fla:)

scotty(-:

seem to work on your fla… thx… i’ll fiddel a little with it

mosho thx… :stuck_out_tongue: Maatje

graag gedaan:)

Ok i had to redo the _width a little but it works fine now…

for the ppl that like this code… here is the final code… all credits go to SCOTTY… (script guru)


for (i=0; i<50; i++) { // duplication factor
	newBall = mask.duplicateMovieClip("mask_mc"+i, i); // instance name
	newBall._x = Math.random*800;
	newBall._width = Math.random()*30;// random width in pixels 
	newBall.targX = Math.random()*650; // width in pixels
	newBall.i = 0;
	newBall.rand = Math.random()*50;
	newBall.onEnterFrame = function() {
		this.i++;
		if (this.i>this.rand) {
			this.targX = Math.random()*800;
			this.i = 0;
			this.rand = Math.random()*800; // speed movement
		}
		this._x -= (this._x-this.targX)/10;
	};
}