Bijoy Thangaraj
Bijoy Thangaraj

Reputation: 5546

Size of the thumb graphic on a Flash scrollbar

I am trying to customise the built-in scrollbar component in flash. Specifically, I need to customise the scrollbar's thumb to have a fixed height and width.

This is what I have right now. The thumb height adjusts itself. I need to fix the height of the thumb.

current state

What I'm trying to achieve (a fixed-height thumb):

what I'm trying to achieve

Any pointers towards how I can set the size of the thumb in Flash will be appreciated.

Upvotes: 1

Views: 696

Answers (1)

fsbmain
fsbmain

Reputation: 5267

There isn't easy way to do this, I mean that Flash CS6 ScrollBar doesn't support this feature. The height of thumb updates in the protected method fl.controls.ScrollBar:

    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 = Math.max(13,_pageSize / per * track.height);
            thumb.y = track.y+(track.height-thumb.height)*((_scrollPosition-_minScrollPosition)/(_maxScrollPosition-_minScrollPosition));
            thumb.visible = enabled;
        }
    }

and as you can see there isn't any flag to skip setting of thumb.height in else block. The possible solution can be to extends the ScrollPane and override the configUI method - and add your custom CustomScrollPane (that extends ScrollBar and overrides the updateThumb method) instead of created _verticalScrollBar:ScrollBar.

Another solution can be to replace the original fl ScrollPane class with your own with the same name fl.controls.ScrollPane in the main ApplicationDomain of your swf. But to do this you will have to organize the class loading in a such way that your own class loaded before the fl ones that is you have to load all classes dynamically in external swfs.

Upvotes: 3

Related Questions