Looking for a new hitTest

I have been using the "single line hitTest " method for a LONG while:td:, and I was wondering if anyone could teach me a better hitTest method. But please teach it to me in onClipHandlers (I dont like functions :wink: ). Thanks in advance.

peace

Well, I made one just now, but it is REALLY messed and I dont know why…


onClipEvent (enterFrame) {
	if (_root.b.hitTest(_x+x+b.xmin+5, _y+y+b.ymin+5, true)) {
		_x -= 5;
	}
	if (_root.b.hitTest(_x+x+b.xmax-5, _y+y+b.ymin+5, true)) {
		_x += 5;
	}
	if (_root.b.hitTest(_x+x+b.xmin+5, _y+y+b.ymax-5, true)) {
		_y -= 6;
	}
	if (_root.b.hitTest(_x+x+b.xmax-5, _y+y+b.ymax-5, true)) {
		_y += 6;
	}
}

Okay, I made one of my own, but it is REALLY messed and I dont know why… Anyone know?

 
onClipEvent (enterFrame) { 
b = this.getBounds(this);
if (_root.limits.hitTest(_x+x+b.xmin+5, _y+y+b.ymin+5, true)) {
_x += 6;
}
if (_root.limits.hitTest(_x+x+b.xmax-5, _y+y+b.ymin+5, true)) {
_x -= 6;
} 
if (_root.limits.hitTest(_x+x+b.xmin+5, _y+y+b.ymax-5, true)) {
_y -= 6;
}
if (_root.limits.hitTest(_x+x+b.xmax-5, _y+y+b.ymax-5, true)) {
_y += 6;
}
}
 

You’re forgetting the first curly brackets after the conditions.

:slight_smile:

I have those, but I think you have to scroll the coding box to see the curly brackets

You cant scroll it left or right… double check to see if you put them

Here, I put it on regular:

onClipEvent (enterFrame) {
b = this.getBounds(this);
if (_root.limits.hitTest(_x+x+b.xmin+5, _y+y+b.ymin+5, true)) {
_x += 6;
}
if (_root.limits.hitTest(_x+x+b.xmax-5, _y+y+b.ymin+5, true)) {
_x -= 6;
}
if (_root.limits.hitTest(_x+x+b.xmin+5, _y+y+b.ymax-5, true)) {
_y -= 6;
}
if (_root.limits.hitTest(_x+x+b.xmax-5, _y+y+b.ymax-5, true)) {
_y += 6;
}
}