# Problem with HitTestPoint

**URL:** <https://forum.kirupa.com/t/problem-with-hittestpoint/307080>\
**Category:** flash\
**Created:** [March 27, 2010, 7:08pm UTC](https://forum.kirupa.com/t/problem-with-hittestpoint/307080 "2010-03-27T19:08:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeteWaugh](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@PeteWaugh](https://forum.kirupa.com/u/PeteWaugh)\
**Post date:** [March 27, 2010, 7:08pm UTC](https://forum.kirupa.com/t/problem-with-hittestpoint/307080/1 "2010-03-27T19:08:39Z")

</div>

Hey,  
I have been having a problem with the below script.The script assumes that there is a MovieClip with the instance name “char”(I used a 32x32 square) and a MovieClip with the instance name BG on stage(I used the brush tool to create a bumpy fill/landscape roughly 1000x300.)As the script stands at the moment it moves the “BG” to create the effect that the “char” is moving along a scrolling landscape, the problem that I have is with the ‘while’ statement instead of stopping adding to the y value when the points are no longer touching it continues until the char is at the edge of it’s hit box.If I change it so that the “char” is moving and the “BG” is stationary the script runs as expected.Can anyone tell me why this is happening and possibly offer a soloution to my problem?Many thanks!

```auto
const gravity:Number = 1;
var yspeed:Number = 0;
BG.addEventListener(Event.ENTER_FRAME, begin);
function begin(event:Event):void {
	BG.y -= yspeed;
	while (BG.hitTestPoint(char.x, char.y-1, true)) {
		BG.y++
		yspeed=0;
	}
		
	if (! BG.hitTestPoint(char.x,char.y+1,true) ) {
			yspeed+=gravity;
	}
}

```
