Resizing Scrollbars in Flex

I had to create bigger scrollbars, for a flex project which had to run on touchscreens. Their isn’t a real style or property which enables you to do this, but thanks to programmatic skinning, it is quite easy.

First of all, create a class which extends mx.skins.halo.ScrollTrackSkin. In this class, you override the measuredWidth() and updateDisplayList() functions:

override public function get measuredWidth():Number
{
	return 50;
}
 
override protected function updateDisplayList(w:Number, h:Number):void
{
	super.updateDisplayList(50, h);
}

After that, create a class which extends mx.skins.halo.ScrollThumbSkin. In this class, you have to provide the same methods:

override public function get measuredWidth():Number
{
	return 50;
}
 
override protected function updateDisplayList(w:Number, h:Number):void
{
	super.updateDisplayList(50, h);
}

The last class you have to create, is for the scrollbar arrows. This class extends mx.skins.halo.ScrollArrowSkin. Again, you have to override some methods: measuredWidth, measuredHeight and updateDisplayList:

override public function get measuredWidth():Number
{
	return 50;
}
 
override public function get measuredHeight():Number
{
	return 50;
}
 
override protected function updateDisplayList(w:Number, h:Number):void
{
	super.updateDisplayList(50, 50);
}

The final step, is to link these classes in your css file:

ScrollBar
{
    trackSkin: ClassReference("com.mydomain.BigScrollTrackSkin");
    downArrowDisabledSkin: ClassReference("com.mydomain.BigScrollArrowSkin");
    downArrowDownSkin: ClassReference("com.mydomain.BigScrollArrowSkin");
    downArrowOverSkin: ClassReference("com.mydomain.BigScrollArrowSkin");
    downArrowUpSkin: ClassReference("com.mydomain.BigScrollArrowSkin");
    thumbDownSkin: ClassReference("com.mydomain.BigScrollThumbSkin");
    thumbOverSkin: ClassReference("com.mydomain.BigScrollThumbSkin");
    thumbUpSkin: ClassReference("com.mydomain.BigScrollThumbSkin");
    upArrowDisabledSkin: ClassReference("com.mydomain.BigScrollArrowSkin");
    upArrowDownSkin: ClassReference("com.mydomain.BigScrollArrowSkin");
    upArrowOverSkin: ClassReference("com.mydomain.BigScrollArrowSkin");
    upArrowUpSkin: ClassReference("com.mydomain.BigScrollArrowSkin");
}

Programmatic skinning allows you to do even more, you can completely control the layout, and drawing of the components through code.

Good luck!

2 Responses to “Resizing Scrollbars in Flex”


  • Thanks for this great article, it helps me alot

  • Hi Wouter,
    thanks for your article.
    I have a question for you:
    I use Adobe Flex Builder 2 to build custom objects for Xcelsius 2008.
    I tried to set a different scrollbar’s Style in my custom “Panel” object.
    In Flex I see the right result,but in Xcelsius I see always classic Scrollbar.
    If you use Xcelsius and Flex (for custom objects), maybe know this problem and you can help me.
    Thanks for your help.
    Regards.
    Francesco

Leave a Reply