Collisions between dynamically attached clips

I’m working on this site www.promoaps.com and I’m trying to solve collision issues between those small rectangle clips, and of course, it’s not working :slight_smile:

I’ve got two arrays, one of possible texts and one with 0/1 to know which texts are shown and which not. Basically each time i add a movie i check how many i have on stage and then use hitTest for collisions but it’s all screwed up, i get that lovely “256 levels of recursion” message after a while.

here is the relevant code i’ve got, if anyone can tell what’s wrong after a quick look i’d really appreciate it.

faTextu = function () {
	care = randRange(0, 10);
	if (msgAct[care] == 0) {
		msgAct[care] = 1;
		_root.cateIs++;
		if (_root.cateIs>4) {
			if (_root.ju == 0) {
				_root.ju++;
				//trace("mata");
				clearInterval(faTextuInt2);
				scotAstaInt = setInterval(scotAsta, 8200, randRange(0, 10));
			}
		}
		_root.Nou = care;
		_root.tot.attachMovie("textu", "textu_"+care, care+20);
		unde = _root.tot["textu_"+care].tot;
		IlPun(care);
		//trace(care);
		unde.alphu = randRange(35, 65);
		unde._alpha = unde.alphu;
		unde.blurTo((100-unde.alphu)/10, 5, 0.3, "easeOutSine");
		//trace(_root.msgPath[care]);
		//unde.txt = _root.msgPath[care];
		//_level0.tot["textu_"+care].txt.txt.pushOver(_root.msgPath[care], 100.000000E-001);
		_root.tot["textu_"+care].onRollOver = function() {
			this.tot.Act = 1;
			this.tot.alphaTo(100, 0.3, "easeOutSine");
			this.tot.blurTo(0, 5, 0.3, "easeOutSine");
			this.tot.scaleTo(100, 0.3, "easeOutSine");
		};
		_root.tot["textu_"+care].onRollOut = function() {
			this.tot.Act = 0;
			this.tot.alphaTo(this.tot.alphu, 0.3, "easeOutSine");
			this.tot.blurTo((100-this.tot.alphu)/10, 5, 0.3, "easeOutSine");
			this.tot.scaleTo(this.tot.alphu, 0.3, "easeOutSine");
		};
	} else {
		faTextu();
	}
};
bagaTexte = function () {
	clearInterval(bagaTexteInt);
	faTextuInt2 = setInterval(faTextu, randRange(1000, 1500));
	faTextuInt = setInterval(faTextu, 8200);
};
//.hitTest 
bagaTexteInt = setInterval(bagaTexte, 2000);
aranjeazaTexte = function () {
	for (i=0; i<=msgPath.length; i++) {
		_root.tot["textu_"+care];
	}
};
IlPun = function (care) {
	_level0.tot.textu.tot.txt.updateLongTxt(_root.msgPath[care], 0, false, ["FFFFFF", "3BB7D0", "E1E4EA"], -1);
	resizeAst = function () {
		clearInterval(resizeAstaIntu);
		//trace("res");
		unde = _root.tot["textu_"+care].tot;
		_root.tot.textu.tot.shape._height = unde.txt._height+8;
		_root.tot.textu.tot.masca._height = unde.shape._height+8;
		_root.tot.textu.tot.masa._height = unde.shape.height;
		_root.tot.textu.rotRand = randRange(-35, 35)
		_root.tot.textu.rotateTo(rotRand, 0);
		undeIlPun(care);
		undeIlPun = function (care) {
			//trace("iar");
			stgDrp = randRange(0, 1);
			if (_root.sectActiva == 0) {
				margineStg = -400;
				margineDrp = 150;
			} else if (_root.sectActiva == 1) {
				margineStg = -400;
				margineDrp = 300;
			}
			if (stgDrp == 0) {
				_root.tot.textu._x = randRange(-(Stage.width/2-150), margineStg);
			} else {
				_root.tot.textu._x = randRange(margineDrp, (Stage.width/2-180));
			}
			_root.tot.textu._y = randRange(-(Stage.height/2-100), (Stage.height/2-150));
			if (_root.inceput == 1) {
				//trace("inc");
				amGatat(care);
				_root.inceput = 0;
			}
			for (i=0; i<=msgPath.length; i++) {
				if (i<>care) {
					if (msgAct* == 1) {
						trace(i+"_"+"_"+care+"_"+msgPath.length+"_"+msgAct*);
						if (_root.tot.textu.hitTest(_root.tot["textu_"+i])) {
							trace("hit");
							undeIlPun(care);
						} else if (i == msgPath.length-1) {
							amGatat(care);
						}
					}
				}
			}
		};
	};
	resizeAstaIntu = setInterval(resizeAst, 40);
};
///////////////////////
/////////////////////
amGatat = function (care) {
	unde = _root.tot["textu_"+care].tot;
	_root.tot["textu_"+care]._x = _root.tot.textu._x;
	_root.tot["textu_"+care]._y = _root.tot.textu._y;
	//trace("capat");
	_level0.tot["textu_"+care].tot.txt.updateLongTxt(_root.msgPath[care], 0, false, ["FFFFFF", "3BB7D0", "E1E4EA"], -1);
	resizeAsta = function () {
		clearInterval(resizeAstaInt);
		unde.shape._height = unde.txt._height+8;
		unde.masca._height = unde.shape._height+8;
		_root.tot["textu_"+care].masa._height = unde.shape.height;
		_root.tot["textu_"+care].rotateTo(_root.tot.textu.rotRand, 0);
	};
	resizeAstaInt = setInterval(resizeAsta, 40);
	unde.scala = randRange(35, 65);
	unde.scaleTo(unde.alphu, 0);
	unde.Act = 0;
	Clr = randRange(0, 1);
	if (Clr == 0) {
		unde.shape.colorTo(0x993333, 0);
	}
	stgDrp = randRange(0, 1);
	if (_root.sectActiva == 0) {
		margineStg = -400;
		margineDrp = 150;
	} else if (_root.sectActiva == 1) {
		margineStg = -400;
		margineDrp = 300;
	}
	unde.masca.resizeTo(280, undefined, 0.3, "easeOutSine");
};