4 Replies Latest reply on Oct 24, 2010 8:31 AM by allen.brown

    How to access minimum and maximum in Slider skin

    allen.brown

      I've created a custom skin for a HSlider because the client has been very precise about how they want the ticks to be displayed.  All fine so far but I can't see how to access the minimum and maximum values that are attributes of HSlider.  Parent-dot and Hostcomponent-dot seemed the way to go but neither give me those parameters.

       

      I'm missing something aren't I?

       

      Can anyone point me in the right direction?

       

      Thanks

        • 1. Re: How to access minimum and maximum in Slider skin
          ratnawe Level 1

          Hi Allen,

           

          I have a few ideas/questions:

           

          Which IDE are you using?

          Are you extending SparkSkin or a different component?

          Did you add [HostComponent("spark.components.HSlider")] to the meta-data portion of your skin file?

           

          When I try to create a skin for HSlider with Flash Builder 4 it works and the code completion shows me hostComponent.minimum and hostComponent.maximum as suggestions.

           

          The only issue I see here is that the minimum and maximum properties are not bindable. So if they change during runtime your skin won't be able to reflect that. But in most cases these values don't change. If you need to reflect updates on those properties in your skin I think you have to override the updateDisplayList function.

           

          Kind regards,

          Thilo

           

          If you find this post useful please mark it as such.

          1 person found this helpful
          • 2. Re: How to access minimum and maximum in Slider skin
            allen.brown Level 1

            Hi Thilo

             

            Thanks for your answer.

             

            I am using Flash Builder 4.0.1 Standard.

             

            Yes, I did add [HostComponent("spark.components.HSlider")]

             

            The HSliderSkin itself is ok and yes, I do get hostComponent.minimum on code completion but the place I need the minimum is inside the track skin which appears as a Button in the HSlider skin that I'm using. 

             

            The Button can't receive a minimum so it's not seen inside the skin.  I can work around it by passing to through as depth (actually as negative depth or the thumb appears behind the track!) but I have two problems with this:

            1. I get two warnings about bindings

            2. It's nasty.

             

            Is there a better way?

             

            Kind regards

            Allen

            • 3. Re: How to access minimum and maximum in Slider skin
              ratnawe Level 1

              Allen, what if you create a custom button class that enhances the plain Spark button and use that in your HSlider skin? You could add a minimum property there. Like so:

               

              package
              {
                  import spark.components.Button;
                 
                  public class MyButton extends Button
                  {
                      private var _minimum:Number;

               

                      public function get minimum():Number { return _minimum; }
                      public function set minimum(value:Number):void { _minimum = value; }

               

                      public function MyButton() { super(); }
                  }
              }

               

              In your HSlider skin file you add this (note the id property):

               

              <local:MyButton id="track" minimum="{hostComponent.minimum}" />

               

              Of course that doesn't prevent the warnings because the minimum isn't bindable but at least you could transport the initial value through to the skin. In the track skin you would access the minimum value via (hostComponent as MyButton).minimum.

               

              Best regards,

              Thilo

              1 person found this helpful
              • 4. Re: How to access minimum and maximum in Slider skin
                allen.brown Level 1

                Nice solution! 

                 

                It gets rid of one of my problems but I'm still not comfortable having compiler warnings.  It would be nice if there was a way to flag something to say that you don't care if it can't bind.