I've got this project with a simple draggable custom scrollbar, my client wants to also incorporate mousewheel functionality. So I added that and it works fine, but I can't figure out how make the scrollbar move the correct distance while using the scrollwheel on the mouse. I've tried a couple things but I'm not quite getting the math or the logic to make it work right.

If anyone can help me before my head explodes, I'd appreciate it!

This is what I have for my code:

//This part works the scrollbar by dragging - txt is the content that scrolls

scrollbar.onMouseDown = function() {
	if (this.hitTest(_root._xmouse, _root._ymouse) && txt._height>mask._height) {
		this.startDrag(false, scrollbarBG._x, scrollbarBG._y, scrollbarBG._x, scrollbarBG._height-this._height)
		txt.onEnterFrame = scrollThumbs;
		dragging = true
scrollbar.onMouseUp = function() {
	dragging = false
	delete this.onEnterFrame;
function scrollThumbs() {
	var funkyVar = -this._parent.scrollbar._y*(((this._height-this._parent.scrollbar._height)/(this._parent.scrollbarBG._height-this._parent.scrollbar._height))-1)
	this.Y = (funkyVar-this._y)*.2;
	this._y += this.Y;
	if(Math.abs(funkyVar-this._y)<1 && !dragging){
		delete this.onEnterFrame


//This is for the mousewheel, that part works fine
//But how do I code the variable barmove? 

var barmove:????

var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta) {
	if (delta>0 && txt._y < 0) {
		txt._y +=(delta*5);
		scrollbar._y -= barmove ;
	} else if (delta<-1 && txt._y>0-txt._height+mask._height) {
		txt._y +=(delta*5);
		scrollbar._y += barmove ;