# Removing enterframe events

**URL:** <https://forum.kirupa.com/t/removing-enterframe-events/295559>\
**Category:** flash\
**Created:** [September 1, 2009, 9:51am UTC](https://forum.kirupa.com/t/removing-enterframe-events/295559 "2009-09-01T09:51:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![romit\_2034](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@romit\_2034](https://forum.kirupa.com/u/romit_2034)\
**Post date:** [September 1, 2009, 9:51am UTC](https://forum.kirupa.com/t/removing-enterframe-events/295559/1 "2009-09-01T09:51:07Z")

</div>

Hi Note my code below

```auto

this.addEventListener(Event.ENTER_FRAME,follow);
function follow(evt:Event):void {
	addChild(mouseThing_mc);
	var xMouse:Number=(stage.mouseX);
	var yMouse:Number=(stage.mouseY);
	var xH:Number=mouseThing_mc.x;
	var yH:Number=mouseThing_mc.y;

	mouseThing_mc.x=xMouse;
	mouseThing_mc.y=yMouse;

}
// SOME OTHER STUFF HAPPENS IN HERE AND FINALLY

var menuItem11:ContextMenuItem=new ContextMenuItem("Home");
menuItem11.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, home1);

function home1(event:ContextMenuEvent):void {
	this.removeEventListener(Event.ENTER_FRAME,follow);
	MovieClip(root).gotoAndPlay("out_point2");
}

```

So when I navigate out of this movieclip once the function home1 is fired, I get the following error

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at home\_fla::mc\_content\_13/follow()

I know it is the function looking for that mouseThing\_mc that is not there. Any ideas?
