# Removing Event

**URL:** https://forum.kirupa.com/t/removing-event/282882
**Category:** Uncategorized
**Created:** [February 27, 2009, 2:21pm UTC](https://forum.kirupa.com/t/removing-event/282882 "2009-02-27T14:21:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Beebs](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Beebs](https://forum.kirupa.com/u/Beebs)
#### Post date: [February 27, 2009, 2:21pm UTC](https://forum.kirupa.com/t/removing-event/282882/1 "2009-02-27T14:21:56Z")

</div>

This code is nested in the movieclip.

```auto

import caurina.transitions.*;

var yOffset:Number;
var yMin:Number;
var yMax:Number;

function ScrollBar():void
		{
			sb.thumb.buttonMode = true;
			yMin = 0;
			yMax = sb.track.height - sb.thumb.height;
			sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
			addEventListener(MouseEvent.MOUSE_UP, thumbUp);
			
		}

function thumbDown(e:MouseEvent):void
{
	addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
	yOffset = mouseY - sb.thumb.y;
}

function thumbUp(e:MouseEvent):void
{
	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;
	Tweener.addTween(body_txt, {y:(-sp*(body_txt.height-masker.height)), time:1});
	e.updateAfterEvent();
}

ScrollBar();

```

The problem is that, after several scroll, the event for “sb.thumb” cannot be removed. So, it always listening where the mouse on the stage move.

Thanks
