# Extend UIScrollBar to set thumb to not scale

**URL:** <https://forum.kirupa.com/t/extend-uiscrollbar-to-set-thumb-to-not-scale/229214>\
**Category:** Uncategorized\
**Created:** [June 14, 2007, 10:01pm UTC](https://forum.kirupa.com/t/extend-uiscrollbar-to-set-thumb-to-not-scale/229214 "2007-06-14T22:01:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbagg](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@mbagg](https://forum.kirupa.com/u/mbagg)\
**Post date:** [June 14, 2007, 10:01pm UTC](https://forum.kirupa.com/t/extend-uiscrollbar-to-set-thumb-to-not-scale/229214/1 "2007-06-14T22:01:56Z")

</div>

(I cross-posted to Sephiroth as well…)

Extend the functionality of the UIScrollBar class and override the function where the thumb skin is scaled proportionate to the track.

The attached files are based on the Adobe Flash\_ActionScript3.0\_samples\>LoadText.

In your .fla, you will have:

import UIScrollBar\_thumb;  
//Handle the UIScrollBar - instance in library  
var my\_sb:UIScrollBar\_thumb = new UIScrollBar\_thumb();  
addChild(my\_sb);

So instead of using “UIScrollBar” you are using the new subclass “UIScrollBar\_thumb” that is defined in UIScrollBar.as which should be in the folder where your .fla is…or you can put it somewhere else and make sure you change the import path and the package path.

UIScrollBar.as contains:

package  
{  
import fl.controls.ScrollBar;  
import fl.controls.UIScrollBar;  
public class UIScrollBar\_thumb extends fl.controls.UIScrollBar  
{

public function UIScrollBar\_thumb()  
override protected function updateThumb():void {  
var per:Number = maxScrollPosition - minScrollPosition + pageSize;  
if (track.height \<= 12 || maxScrollPosition \<= minScrollPosition || (per == 0 || isNaN(per))) {  
thumb.height = 12;  
thumb.visible = false;  
} else {  
thumb.height = 12;  
// thumb.height = Math.max(13,pageSize / per \* track.height);  
thumb.y = track.y+(track.height-thumb.height)\*((scrollPosition-minScrollPosition)/(maxScrollPosition-minScrollPosition));  
thumb.visible = enabled;  
}  
}  
}  
}
