1 Reply Latest reply on Aug 24, 2010 11:59 PM by Shongrunden

    How to get the value of a slider immediately after action is performed in SDK 4.0?

    pgpradeep Level 1

      Hi,

       

      I am using ActionScript to set the value of a VSlider/HSlider.

      I want to immediately cross-check whther the slider value has changed.

      For this, I am immediately (as soon as I set the slider value through code) checking VSlider.value or HSlider.value.

      But this is not giving me the values that have been set.

       

      Is there any other way that I can get the values as soon as I exceute slider change?

       

      Thanks,

      Pradeep.

        • 1. Re: How to get the value of a slider immediately after action is performed in SDK 4.0?
          Shongrunden Adobe Employee

          Does listening for the change or valueCommit events get you what you need?

           

          For example:

          <s:Application
              xmlns:s="library://ns.adobe.com/flex/spark"
              xmlns:fx="http://ns.adobe.com/mxml/2009">
              <fx:Script>
                  <![CDATA[
                      import mx.events.FlexEvent;
                     
                      // valueCommit gets fired any time the value of the slider changes
                      private function mySlider_valueCommitHandler(event:FlexEvent):void {
                          trace("valueCommit", event.target.value);
                      }

                      // change gets fired only when the slider is changed via the UI
                      private function mySlider_changeHandler(event:Event):void {
                          trace("change", event.target.value);
                      }

                  ]]>
              </fx:Script>

              <!-- interacting with this will fire both valueCommit and change events -->
              <s:HSlider id="mySlider" valueCommit="mySlider_valueCommitHandler(event)" change="mySlider_changeHandler(event)" />
             
              <!-- clicking this will only fire valueCommit events -->
              <s:Button label="programmatically change" x="200" click="mySlider.value += 1" />
             
          </s:Application>