Code problem with a mouse trailer

hi,

I have inserted a code found on the web to create a mouse trailer. all works just fine until I inserted the code found in the fading grid effect. then the mouse trailing effect no longer works.
don’t know if it is a depth problem or what? don’t really know too much about as, trying to learn…

here is the code on frame 1:

Text = "art";
letters = Text.split("");
letterformat = new TextFormat();
letterformat.font = "Verdana";
letterformat.align = "center";
letterformat.size = "10";
spacing = 8;
speed = 3;
for (L=0; L<letters.length; L++) {
	_root.createEmptyMovieClip(letters[L], L);
	_root[letters[L]].createTextField(letters[L]+"t", L, L*spacing, 10, 20, 20);
	with (_root[letters[L]][letters[L]+"t"]) {
		text = letters[L];
		setTextFormat(letterformat);
		selectable = false;
	}
	if (L>0) {
		_root[letters[L]].id = L;
		_root[letters[L]].onEnterFrame = function() {
			this._x += (_root[letters[this.id-1]]._x-this.lastX+5)/speed;
			this._y += (_root[letters[this.id-1]]._y-this.lastY)/speed;
			this.lastX = this._x;
			this.lastY = this._y;
		};
	} else {
		_root[letters[L]].onEnterFrame = function() {
			this._x += (_root._xmouse-this.lastX+10)/speed;
			this._y += (_root._ymouse-this.lastY)/speed;
			this.lastX = this._x;
			this.lastY = this._y;
		};
	}
}

then here is the code on frame 20 for the fade grid effect:

//Declare variables
xspacing = box._width;
yspacing = box._height;
depth = 0;
box._visible = 0;
azcount = 0;
smoothness = 900;
//Calculate positions and values
amH = Math.ceil(image._width/box._width);
amV = Math.ceil(image._height/box._height);
border._height = image._height+1;
border._width = image._width+1;
border._x = image._x-0.5;
border._y = image._y-0.5;
//Create grid

	for (var k = 0; k<amV; k++) {
		for (i=0; i<amH; i++) {
		box.duplicateMovieClip("box"+depth, depth);
		cur = this["box"+depth];
		cur._x = image._x+(xspacing*i);
		cur._y = image._y+(yspacing*k);
		depth++;
	}
}
// 
// 
// End of grid
// 
// 
function fadeOut(startboxnr, speed) {
	fadeMC(startboxnr, speed);
}
function fadeMC(mcnr, speed) {
	azcount++;
	_root["box"+mcnr].onEnterFrame = function() {
		_root["box"+mcnr]._alpha -= speed;
		if (_root["box"+mcnr]._alpha<=smoothness) {
			_root["box"+mcnr].onEnterFrame = null;
			continueFade(_root["box"+mcnr], speed);
			mcnr += 1;
			fadeOut(mcnr, speed);
		}
	};
}
function continueFade(mc, speed) {
	mc.onEnterFrame = function() {
		mc._alpha -= speed;
		if (mc._alpha<=0) {
			delete mc.onEnterFrame;
		}
	};
}
fadeOut(0, 5);

Any help is greatly appreciated
thanks

wow,

thank you very much… It worked!! But why?
if you don’t mind explaining.

ty

I think with the code you were using, the new movie clips were overwriting other clips on the lower levels… giving it a level of L +100 makes it less likely you will be overwriting clips on the lower levels.

I did that to avoid having 2 movie clips being created in the same depth. If that happens, the second will replace the first one.