Как получить HSlider со скинами для каждой стороны большого пальца

I'd like to create an HSlider so that the skin of the track is different on either side of the thumb. So, for example, the track on the left side of the thumb is green, but red on the other.

Is this possible or will it take a custom component?

12.10.2009 21:33:26

You can do this via skinning. The entire scrollbar is customizable. You just need to set the trackSkin style for the HScrollBar to be a programmatic skin. Then your skin will be basically two rectangles. 0 to parent.scrollPosition. And the other from parent.scrollPosition to height. Here's an example that might work. I haven't tested. You might need to fiddle with some numbers.

  public class ScrollBarSkin extends Border
    //maybe needed as a hack for the flex internals. Values may need to be changed for specific cases
    override public function get measuredWidth():Number {return 16; }
    override public function get measuredHeight():Number {return 10;}   

    override protected function updateDisplayList(w:Number, h:Number):void {

      if(this.parent) {
        var g:Graphics = this.graphics;

        g.drawRoundRect(1,1, w, parent.scrollPosition);

        g.drawRoundRect(0, parent.scrollPosition, w, h);

14.10.2009 20:02:19