hitTestPoint Help

I’m trying to set up a collision so that when a bullet hits a wall it is destroyed. Here is the snippet of code I am using:


while (_root.newWall.hitTestPoint(x, y+radius, true)) {
y-=Math.sin(angle);
deleteMe=true;
}
while (_root.newWall.hitTestPoint(x, y-radius, true)) {
y+=Math.sin(angle);
deleteMe=true;
}
while (_root.newWall.hitTestPoint(x-radius, y, true)) {
x+=Math.cos(angle);
deleteMe=true;
}
while (_root.newWall.hitTestPoint(x+radius, y, true)) {
x-=Math.cos(angle);
deleteMe=true;
}
if (deleteMe) {
deleteMe=false;
removeEventListener(Event.ENTER_FRAME, eFrame);
_root.removeChild(this);
}

This method works great for when detecting a collision between other moving instances and the walls, but for some reason with the bullets I get this error message when they almost touch the wall and Flash freezes and I usually have to restart it:


Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at Bullet/eFrame()

I attempted to debug it and it said that the problems were at the four lines beginning the while loop. Can someone help me please? Thanks :smiley: