# Do something after hittest " remove hittest after first collsion"

**URL:** <https://forum.kirupa.com/t/do-something-after-hittest-remove-hittest-after-first-collsion/304493>\
**Category:** Uncategorized\
**Created:** [February 8, 2010, 11:57pm UTC](https://forum.kirupa.com/t/do-something-after-hittest-remove-hittest-after-first-collsion/304493 "2010-02-08T23:57:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashman2006](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@flashman2006](https://forum.kirupa.com/u/flashman2006)\
**Post date:** [February 8, 2010, 11:57pm UTC](https://forum.kirupa.com/t/do-something-after-hittest-remove-hittest-after-first-collsion/304493/1 "2010-02-08T23:57:57Z")

</div>

[SIZE=“4”]hi there i am stuck and need help please

i am controlling a tractor mc with right and left keyboard keys and let the user move the tractor till it reach a certain point where it touch a mc

i want to go to a certain frame and stop the keyboard event listener and also the hit test listener

so finally the tractor is moved by user till it touches the mc then we will jump to a certain frame

this certain frame will not have both of the tractor and the mc

i used this code

```php
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.MovieClip;
import flash.events.*;

stop();

tractor.removeEventListener(Event.EXIT_FRAME, circleHit);
stage.removeEventListener(Event.EXIT_FRAME, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

function keyDownHandler(event:KeyboardEvent):void {
	
		
	
    if(event.keyCode == Keyboard.LEFT){
       tractor.w1.rotation -= 1 ;
	   tractor.w2.rotation -= 1.5 ;
	   var cartween : Tween = new Tween (tractor, "x", Regular.easeOut, tractor.x, tractor.x -1, 1, false);
    }
    if(event.keyCode == Keyboard.RIGHT){
        tractor.w1.rotation += 1 ;
	    tractor.w2.rotation += 1.5 ;;
		var cartween2 : Tween = new Tween (tractor, "x", Regular.easeOut, tractor.x, tractor.x +1, 1, false);
    }
    }

	tractor.addEventListener(Event.ENTER_FRAME, circleHit);
	function circleHit(event:Event) {
	if(tractor.hitTestObject(line)){
		trace ("hit");	
		gotoAndPlay ("tractor_play");
        
	}
	}

```

the flash jumps to the frame “tractor\_play”

but

i got this error

```php
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at site2_fla::main_2/circleHit()

```

[/SIZE]
