3 Replies Latest reply on Dec 1, 2008 10:00 AM by GeorgeWS

    Slider and date

    GeorgeWS Level 1
      I have a slider like so:

      <mx:HSlider id="myslider" width="245" allowThumbOverlap="true" thumbCount="1" snapInterval="1" tickInterval="1"
      values="[11]" labels="['Jan', 'Dec']" minimum="1" maximum="12" change="sliderChangeTwo(event)" dataTipFormatFunction="getSliderLabel" themeColor="#73B9B9"/>

      every month I go in and change the values to the current month like November is 11. How can I have it shoe this month automatically. I have been looking at the date stuff but there is an error because dates are strings and the slider acceps numbers. Any thoughts?

        • 1. Re: Slider and date
          Gregory Lafrance Level 6
          This works:
          • 2. Re: Slider and date
            rtalton Level 4
            ..and here's another way to do it...
            View source at:

            Main difference is I'm using arithmetic on the current date to get you a date one month out, and using the formatted result as a bindable in the slider labels property. Since the "futureDate" var contains today's date + one month, you could also use this var anywhere else in your code where you need the entire future date. This is useful at the end of the current year, where you might want to add two months to today's date, and get a date in 2009, for instance.

            I included the use of the Date formatter class to get you started on returning just a portion of a date, formatted as you wish (M="1", MM="01", MMM= "Jan", MMMM= "January"). Simply change the formatter's format string and the slider's labels will also be updated.

            On more thing...if you are planning on using the slider's retun value to get a month's number, remember that in actionscript the month numbering starts at 0 (you are specifying 1-12; AS uses 0-11).

            Complete code:

            • 3. Re: Slider and date
              GeorgeWS Level 1
              Thanks alot. I have it working to select the current month. I cannot seem to get it to start out that way. when the app loads it brings in the data, All months are shown in my chart, and the correct month (Dec) is where the thumbs is (so thats good) when I move the thumb to November it changes the chart perfect. But when it loads there are all 12 months how can I get it to just have December to start? When I move the thumb back to December it looks perfect. Thanks for all your help.