# I MIGHT HAVE SOLVED THE SCROLLING PROB!...kinda

**URL:** <https://forum.kirupa.com/t/i-might-have-solved-the-scrolling-prob-kinda/106691>\
**Category:** Uncategorized\
**Created:** [April 8, 2004, 12:07am UTC](https://forum.kirupa.com/t/i-might-have-solved-the-scrolling-prob-kinda/106691 "2004-04-08T00:07:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RadioactveChimp](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@RadioactveChimp](https://forum.kirupa.com/u/RadioactveChimp)\
**Post date:** [April 8, 2004, 12:07am UTC](https://forum.kirupa.com/t/i-might-have-solved-the-scrolling-prob-kinda/106691/1 "2004-04-08T00:07:36Z")

</div>

Well now that you are pumped…jk. I found a really nice component where all it is is a minimalistic scrollbar, but I can’t get it to work! The only things you can customize are: Target text field and colors…thats it.

here’s the code to the component if you really want it 🙂  
Thanks a bundle, hope this solves other peoples probs too!

// \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
// zMinimalTextSlider  
// No-bull-\*\*\*\* text slider. Clean, simple, minimal.  
// Intended to be used with the zMinimalTextButton component.  
//  
// Version 1.0.2  
// Last update April 4th  
//  
// By zeh - [zeh@fatorcaos.com.br](mailto:zeh@fatorcaos.com.br)  
// \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

// PS: Some variable names are in brazilian portuguese

// Needed functions \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

// Rule of three  
rot = function (a, b, x) {  
return ((x \* b) / a);  
};

// Resets the deal: reads the maximum number of visible lines  
function reset() {  
tx.scroll = 1;  
if (tx.maxscroll \> 1) numlinhas = tx.bottomScroll - tx.scroll;  
}

// Update: called when the scroll has to be redraw  
function update() {  
if (!foreground.dragando) {  
if (tx.maxscroll \> 1) {  
if (numlinhas == undefined) numlinhas = tx.bottomScroll - tx.scroll;  
// Enables  
\_alpha = 100;  
if (tx.scroll \> tx.maxscroll) tx.scroll = tx.maxscroll; // fixes a weird error of not updating .scroll when a part of the text is deleted from the end of the string  
foreground.\_height = rot(tx.maxscroll+numlinhas,tx.bottomScroll-tx.scroll+1, background.\_height);  
foreground.\_y = rot(tx.maxscroll-1,tx.scroll-1,background.\_height-foreground.\_height);  
foreground.onRollover = background.onRollover = function() {  
// Hello! function!!!1 Please do nothing! Thanks!!!111  
}  
foreground.useHandCursor = useHand;  
background.useHandCursor = useHand;  
} else {  
// Disables  
\_alpha = disAlpha;  
foreground.\_y = 0;  
foreground.\_height = background.\_height;  
delete (foreground.onRollover);  
delete (background.onRollover);  
foreground.useHandCursor = false;  
background.useHandCursor = false;  
}  
}  
}

// Scroller functions \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

foreground.onLoad = function () {  
this.dragando = false;  
this.offset = 0;  
};

foreground.onMouseDown = function () {  
// Checks if a drag should start  
if (this.hitTest (\_root.\_xmouse, \_root.\_ymouse, false)) {  
this.dragando = true;  
this.offset = this.\_y - \_parent.\_ymouse;  
}  
};

foreground.onMouseUp = function () {  
// Ends drag, if any  
this.dragando = false;  
};

foreground.onMouseMove = function () {  
// Move and update, if being dragged  
if (this.dragando) {  
this.\_y = \_parent.\_ymouse + this.offset;  
if (this.\_y \< 0) this.\_y = 0;  
// this.\_parent = explicit reference to the object’s parent from a function scope  
if ((this.\_y + this.\_height) \> this.\_parent.background.\_height) this.\_y = this.\_parent.background.\_height - this.\_height;  
tx.scroll = rot(this.\_parent.background.\_height, this.\_y, tx.maxScroll+numlinhas)+1;  
}  
}

// Background functions \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
background.onMouseDown = function () {  
// Verifies if the background has been clicked  
if (this.hitTest (\_root.\_xmouse, \_root.\_ymouse, false) && !this.\_parent.foreground.hitTest (\_root.\_xmouse, \_root.\_ymouse, false)) {  
if (this.\_parent.\_ymouse \< this.\_parent.foreground.\_y) {  
// Big scroll up  
this.contador = 0;  
this.onEnterFrame = function () {  
if (this.contador % 5 == 0) tx.scroll -= numlinhas;  
this.contador++;  
if (this.\_parent.\_ymouse \>= this.\_parent.foreground.\_y) delete (this.onEnterFrame);  
}  
} else if (this.\_parent.\_ymouse \> this.\_parent.foreground.\_y+this.\_parent.foreground.\_height) {  
// Big scroll down  
this.contador = 0;  
this.onEnterFrame = function () {  
if (this.contador % 5 == 0) tx.scroll += numlinhas;  
this.contador++;  
if (this.\_parent.\_ymouse \<= this.\_parent.foreground.\_y+this.\_parent.foreground.\_height) delete (this.onEnterFrame);  
}  
}  
}  
};

background.onMouseUp = function () {  
delete (this.onEnterFrame);  
};

// Mousewheel functions \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

this.onEnterFrame = function() {  
// Checks to see if it’s inside this textfield’s bounding box

```
// I can't use a object watch event because there might be different
// textfields on the same screen - an object property can't have
// two different watchers.
var mx = tx._parent._xmouse;
var my = tx._parent._ymouse;
if (mx &gt;= tx._x && mx &lt;= tx._x + tx._width && my &gt;= tx._y && my &lt;= tx._y + tx._height) {
	// It's IN
	
	// Mouse wheel movement is expressed in ticks, which are bigger
	// than simple line movements - they depend on the current mouse
	// wheel speed set on the user's system. This calculation is done
	// to reach a reasonable rate of line movement according to the
	// user's mouse wheel movement.
	ticksPerLine = 60;
	if ((_level0.__wheelDelta + 0) != 0) {
		tx.scroll -= (_level0.__wheelDelta/ticksPerLine);
		_level0.__wheelDelta = 0;
	}
}

```

};

// Initializes \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

// Shortcuts  
tx = \_parent[textfield\_name];

// Reset size to 1:1  
background.\_height = this.\_height;  
this.\_yscale = 100;

// Sets colors  
clr = new Color(foreground);  
clr.setRGB (fgColor);  
foreground.\_alpha = fgAlpha;

clr = new Color(background);  
clr.setRGB (bgColor);  
background.\_alpha = bgAlpha;

delete (clr);

// Sets text update functions and initializes  
tx.reset = reset;  
tx.reset();  
tx.onChanged = tx.onScroller = update;  
tx.onChanged();

// End: sit down and wait \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

stop();

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 8, 2004, 9:23am UTC](https://forum.kirupa.com/t/i-might-have-solved-the-scrolling-prob-kinda/106691/2 "2004-04-08T09:23:12Z")

</div>

> Well now that you are pumped…jk. I found a really nice component where all it is is a minimalistic scrollbar, but I can’t get it to work! The only things you can customize are: Target text field and colors…thats it

Well, what more do you want to change then?  
I’ve tested it and the component works just fine…  
Please explain the problem more clearly or provide us with a .fla.
