# Unload scroller returns error

**URL:** <https://forum.kirupa.com/t/unload-scroller-returns-error/306150>\
**Category:** flash\
**Created:** [March 10, 2010, 3:13pm UTC](https://forum.kirupa.com/t/unload-scroller-returns-error/306150 "2010-03-10T15:13:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![felipegm](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@felipegm](https://forum.kirupa.com/u/felipegm)\
**Post date:** [March 10, 2010, 3:13pm UTC](https://forum.kirupa.com/t/unload-scroller-returns-error/306150/1 "2010-03-10T15:13:29Z")

</div>

I’m using a scroller with the bellow code:

```auto

//scroller

function scroller():void {
import com.greensock.*;
import com.greensock.easing.*;

	var yOffset:Number;
	var yMin:Number = 0;
	var yMax:Number = sb.track.height - sb.thumb.height;

	sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
	stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);
	sb.thumb.buttonMode = true;
	function thumbDown(e:MouseEvent):void {
		stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
		yOffset = mouseY - sb.thumb.y;
	}

	function thumbUp(e:MouseEvent):void {
		stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
	}

	function thumbMove(e:MouseEvent):void {
		sb.thumb.y = mouseY - yOffset;
		if (sb.thumb.y <= yMin) {
			sb.thumb.y = yMin;
		}
		if (sb.thumb.y >= yMax) {
			sb.thumb.y = yMax;
		}
		var sp:Number = sb.thumb.y / yMax;
		TweenLite.to(content.content,1, {y:(-sp*(content.content.height-content.masker.height))});
		e.updateAfterEvent();
	}
}

stop();

```

the scroller and it’s code is inside a swf that’s being loaded into the main movie.  
When I unload the swf that contains the scroller, the listeners are still active to the stage and/or the scroller component.

the error I’m getting is:

_TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at MethodInfo-1094()_

How can I remove the listeners so the error does not happens? I noticed that after unloading the swf, if I click anywhere the stage, the error happens.

Thanks
