2 Replies Latest reply on Aug 28, 2006 8:29 AM by SashMan79

    Slider component change event

    SashMan79
      Hello flexers,

      i am pretty new to Flex2 and need to get into it the next months for a full screen flex application.
      In my research i often found certain bugs/features that arent yet implemented or fixed, so i am
      unsure if i dont understand the event model in flex or if it is a bug.

      I have this example code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" viewSourceURL="srcview/index.html">
      <mx:Script>
      <![CDATA[
      import mx.events.SliderEvent;
      private function eventSliderChange(event:SliderEvent):void
      {
      var newColorCode:int = Math.round(colorSlider.value);
      var newColorS:String = newColorCode.toString() + newColorCode.toString() + newColorCode.toString();

      panel1.setStyle('borderColor', newColorS);
      panel1.setStyle('backgroundColor', newColorS);
      }
      ]]>
      </mx:Script>
      <mx:Panel width="100%" height="100%" layout="absolute" alpha="1.0" backgroundColor="#ff8000" borderColor="#ff8000" backgroundAlpha="1.0" cornerRadius="20" borderStyle="solid" x="0" y="0">
      <mx:HSlider id="colorSlider" showDataTip="false" minimum="0" maximum="255" y="345" change="eventSliderChange(event);" height="20" horizontalCenter="0"/>
      <mx:Panel id="panel1" title="Panel1" width="178" height="232" backgroundColor="#ff8040" borderColor="#0080ff" top="0" left="10" borderStyle="solid">
      </mx:Panel>
      <mx:Label y="319" text="Drag slider to change color!" textAlign="center" horizontalCenter="0"/>
      </mx:Panel>
      </mx:Application>

      Now i was expecting that by sliding the slider, the panel's background color would change
      immediately - though it only changes when releasing the slider. I was thinking that this would
      be done by either mouseRelease or ThumbRelease; if I use the Thumb_Drag event, slider.value
      would always be NaN.

      Any idea what the problem here is ?

      Very kind regards,
      Sascha