 # Hit Test problem

Pom tried this and couldn’t get it working, I wanna get some more opinions:\r\rI’ll try to explain it as best I can. I have a movie clip of a long bar shape that spins. I programed it to move up down left and right when the correct arrow keys are pressed. \r\rThen I have anohter movie clip that dosent move. I tried to use Hit test to make it tell me when the two touch. The problem is that it works too good. It says its touching when the bar gets close and when it really is covering. \r\rOK, i know this is really confusing, thats why I uploaded the FLA for any one who wants to help. \r\rhttp://www.angelfire.com/pokemon2/onlinepics/spin.html

I tried to do it, and it’s a real pain in the ass. Moreover, there’s no Shape flag when you do it like this, so I think the best solution is to create your own hitTest function. Easy. \r\rpom 0]

I can’t get it to work. Pisses me off.\r\rpom 0]

Closest I could get :in the first frame

`````` MovieClip.prototype.hitTest2 = function (largeur) {\r\r&nbsp &nbsp &nbsp &nbsp var distx = _root.circle._x - this._x ;\r\r&nbsp &nbsp &nbsp &nbsp var disty = _root.circle._y - this._y ;\r\r\r\r&nbsp &nbsp &nbsp &nbsp var distance = Math.sqrt(distx*distx+disty*disty);\r\r\r\r&nbsp &nbsp &nbsp &nbsp var angle = Math.atan2(disty,distx) ; //angle in radians\r\r&nbsp &nbsp &nbsp &nbsp angle *= 180/Math.PI ; //angle in degrees\r\r\r\r&nbsp &nbsp &nbsp &nbsp trace (distance - _root.circle._width/2 > largeur) ;\r\r&nbsp &nbsp &nbsp &nbsp if (distance - _root.circle._width/2 > largeur) {\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _root.texte = "No collision";\r\r&nbsp &nbsp &nbsp &nbsp } else {\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp a = this._rotation>angle-_root.circle._width/distance*180/Math.PI ;\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp b = this._rotation<angle+_root.circle._width/largeur*180/Math.PI ;\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp c = this._rotation-180<angle+_root.circle._width/largeur*180/Math.PI ;\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp d = this._rotation+180>angle-_root.circle._width/largeur*180/Math.PI\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if (a and b and c and d){\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _root.texte = "Collision" ;\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp }\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp else {\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _root.texte = "No collision";\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp }\r\r&nbsp &nbsp &nbsp &nbsp }\r\r}
``````

on the Line movie clip (has to be FLAT !!)

`````` onClipEvent (load) {\r\r&nbsp &nbsp &nbsp &nbsp // the line has to be flat !!\r\r&nbsp &nbsp &nbsp &nbsp large = this._width;\r\r}\r\r\r\ronClipEvent (enterFrame) {\r\r&nbsp &nbsp &nbsp &nbsp _rotation+=1 ;\r\r&nbsp &nbsp &nbsp &nbsp this.hitTest2(large);\r\r}
``````

This code slows my computer, so you better have a good computer.\r\rpom 0]

didnt work for me using either. (I just tried for grins)