Resizing HSlider thumb while skinning

The default thumb of a HSlider component is traingular in shape and the default size is 12×12. While skinning thumb it’s usually a problem if you need to have a thumb bigger than the default. So here is a quick solution for the above problem. Write down a small custom class to handle width and height of the thumb by extending the default mx.controls.sliderClasses.SliderThumb class.

  1. package customClasses {
  2.     import mx.controls.sliderClasses.SliderThumb;
  3.     import mx.core.mx_internal;
  4.  
  5.     use namespace mx_internal;
  6.  
  7.     public class ExtendedSliderThumb extends SliderThumb {
  8.  
  9.         override protected function measure():void {
  10.             super.measure();
  11.             measuredWidth = currentSkin.measuredWidth;
  12.             measuredHeight = currentSkin.measuredHeight;
  13.         }
  14.     }
  15. }

To get the effect of this class, you need to set the sliderThumbClass property as customClasses. ExtendedSliderThumb . Here is an example how you do it.

  1. <mx:HSlider x="37.7" y="374.65" width="220" height="12"
  2.                 tickInterval="1"
  3.                 maximum="9"
  4.                 minimum="1"
  5.                 snapInterval="1"
  6.                 tickValues="5"
  7.                 sliderThumbClass="{controls.sliderClasses.FlexibleSliderThumb}" />
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>