2 Replies Latest reply on May 29, 2009 10:49 PM by hoantv

    Hslider

    hoantv

      I have a question about Hslider.

      i have a Hslider with id="myhslider", a combobox to choose "ONE", "TWO", THREE"(default is "TWO") and a function getminmax() to get maximum and mininum of myhslider .

      At the beginning,  My program display the Combobox(defalut is "TWO") and hslider with min=0, max=10.

      at the begining, the component will display with main component, and boundMetric = null. So Hslider [min,max] = [0;10],

      after I do something with main component, the boundMetric will be an array. I wanna Hslider change min,max value according to boundMetric, but it not work, because "initialize" attribute perform beforing receiving boundMetric. If i change "initialize" to "activate", it works but i can freeze webrowser because it perform getBound() unlimitly.
      can u give me an idea?

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="50%" minHeight="40" title="Customize">
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;
      import com.tsdv.infovis.vo.BoundMetric;
      import com.tsdv.infovis.util.MetricNames;
      import com.tsdv.infovis.model.InfoVisModelLocator;


      private function getBound():void
      {
      var metricFilter:String = rMetric.selectedLabel;
      var boundMetrics:ArrayCollection = modelLocator.selectedPj.boundMetrics;
      rSlide.minimum = getBoundValue(metricFilter, boundMetrics, 0);
      rSlide.maximum = getBoundValue(metricFilter, boundMetrics, 1);
      }

      private function getBoundValue(metricType:String, metricBounds:ArrayCollection, boundType:int):Number
      {
      var boundValue:Number = 0;
      var boundMetric:BoundMetric;
      for (var i:int = 0; i < metricBounds.length; i++)
      {
      boundMetric = metricBounds[i] as BoundMetric;
      if((boundMetric.metricType == metricType) && (boundMetric.type == boundType))
      {
      boundValue = boundMetric.value;
      }
      }
      return boundValue
      }
      <mx:HBox>
      <mx:Label text="Metric"/>
      <mx:ComboBox id="rMetric" dataProvider="{MetricNames.METRIC_LIST}" selectedIndex="0" change="getBound();">
      </mx:ComboBox>
      </mx:HBox>

      <mx:HSlider id="rSlide" initialize = "getBound"/>

        • 1. Re: Hslider
          _Natasha_ Level 4

          Hi,

          accourding to your code you should listen initialization of your modelLocator and after this set values to your HSlider or init any variables with binding to HSlider.

          • 2. Re: Hslider
            hoantv Level 1

            I did it, If blind max, min value it wont still work. Because the value max, min are compute after display Hslider, The event for Hslider will occur when I interact with Hslider. After that, max and min are compute. I use caingorm to resolve it. Add a attribute min,max to model. the model is global variable in whole program. Show that, I can compute min, max without any event.