PDA

View Full Version : hittest 1st mc problem



vintage
April 4th, 2005, 09:14 PM
i have a problem with hitTest.
after making a movieclip (some kind of labyrinth), build with mc's called "m", i tried the following code

onClipEvent (enterFrame) {
if (_root.muur["m"].hitTest(_root.lijf)) {
_root.txt += 1;
}
}
now this works fine, except for one stupid thing, only the FIRST mc i drag on the "muur" MC, works.(the rest is there, same name etc, but not add 1 to txt)
im sure i did something stupīd, i watched the tutorial 30 times, but i cant find what i am doing wrong.
any help would be nice.
thx in advance

frost_oni
April 4th, 2005, 09:41 PM
use eval() to check for all instances.

vintage
April 5th, 2005, 06:52 AM
thx for the reply frost_oni, but i am not shure how to use eval().
I looked at the "example" flas provides in its help function, but i dont understand how to use this on my fla.
the example was :
piece3 = "dangerous";
x = 3;
y = eval("piece" + x);
trace(y);
// Output: dangerous

so i tried variations like this
onClipEvent (enterFrame) {
raak = eval(this["m"]);
if (_root.muur["raak"].hitTest(_root.lijf)) {
_root.txt += 1;
}
}
but still the hittest is working only on the first mc that i dragged on the muur mc.
Can u give me a little more hints please ?

frost_oni
April 5th, 2005, 09:26 AM
for example, if you duplicate like this;




for(n=0;n<100;n++){
duplicateMovieClip("thingy", "thingy"+n,n);
}



you use eval like this:




if(eval("thingy"+n).hitTest(obj)){
trace(eval("thingy"+n)+" hit "+obj);
}