# \[AS1\] Problem with hittest and instances of a class \[renamed\]

**URL:** <https://forum.kirupa.com/t/as1-problem-with-hittest-and-instances-of-a-class-renamed/218233>\
**Category:** flash\
**Created:** [March 6, 2007, 2:29am UTC](https://forum.kirupa.com/t/as1-problem-with-hittest-and-instances-of-a-class-renamed/218233 "2007-03-06T02:29:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarface](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@Tarface](https://forum.kirupa.com/u/Tarface)\
**Post date:** [March 6, 2007, 2:29am UTC](https://forum.kirupa.com/t/as1-problem-with-hittest-and-instances-of-a-class-renamed/218233/1 "2007-03-06T02:29:52Z")

</div>

alright, well im making a game and for some reason im faced with this problem.

i have a class

a = function () {  
};  
a.prototype.a = false;  
a.prototype.b = false;  
a.prototype.c = false;  
a.prototype.d = false;

in part of the code i use a for loop to attach some movie clips that are to be hittested by the main character

for (i=0; i\<=a; i++) {  
\_root.attachMovie(“x”, “x”+y, y+1000000000);  
\_root[“x”+y].\_x = something;  
\_root[“x”+y].\_y = something;  
\_root[“x”+y] = new a();  
\_root[“x”+y].a = true;  
}

at the end of the code i run another for loop to cycle through the movie clips i attached and in that for loop i hittest the character against them

for (i=0; i\<=numberofmovieclips; i++) {  
if (\_root.char.hitTest(moveiclips) == true){  
trace(“test”)  
}

now, if i leave out the line

\_root[“x”+y] = new a();

then the hittests work fine and result in a test being traced, but if i leave it in the hittests wont work…

that is my problem… why the hell doesnt it work.

oh, and if i put the class declaring line in before the x and y properties of the movieclips are set, then the movieclips x and y properties wont get set, like so

for (i=0; i\<=a; i++) {  
\_root.attachMovie(“x”, “x”+y, y+1000000000);  
\_root[“x”+y] = new a();  
\_root[“x”+y].a = true;  
\_root[“x”+y].\_x = something;  
\_root[“x”+y].\_y = something;  
}

so someone please explain what im doing wrong, thanks
