Hello,
I have a HSlider custom component that is used as a column in a 
datagrid. If I change the value of a slider and then scroll the 
datagrid so that row does not appear, the value of the slider is 
reset to it's original value. It does not trigger a change event, it 
only visually moves the slider.
This does not happen to rows that are still viewable in the datagrid. 
It only happens to rows that are not seen after the datagrid is 
scrolled.
How can I keep the sliders from changing back to their original value?

Thanks
Greg

I have included my Application code and the custom component code 
below.

//-------------------------------------
// Application code:
//-------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="absolute">

<mx:Script>
        <![CDATA[
                import mx.collections.ArrayCollection;
                
                [Bindable]
                private var dataLayers:ArrayCollection = new 
ArrayCollection(
                [ {name:'Data 1',value:'1'},
                                  {name:'Data 2',value:'1'},
                                  {name:'Data 3',value:'1'},
                                  {name:'Data 4',value:'1'},
                                  {name:'Data 5',value:'1'},
                                  {name:'Data 6',value:'1'},
                                  {name:'Data 7',value:'1'},
                                  {name:'Data 8',value:'1'},
                                  {name:'Data 9',value:'1'},
                                  {name:'Data 10',value:'1'}]); 
                
        ]]>
</mx:Script>
        <mx:DataGrid dataProvider="{dataLayers}" width="221">
                        <mx:columns>
                                        <mx:DataGridColumn 
headerText="Name" dataField="name" width="95" />
                                        <mx:DataGridColumn 
headerText="Value" dataField="volumn" itemRenderer="MySlider"/> 
                                                                
                                                                
                                
                        </mx:columns>
        </mx:DataGrid>
</mx:Application>

//-------------------------------------
// Custom Component code in a file called MySlider.mxml:
//-------------------------------------
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"; width="100%" 
height="100%">
<mx:Script>
        <![CDATA[
                import mx.events.SliderEvent;
                
                private function slideChanged(event:SliderEvent):void
                {
                        trace("Slider Changed: " + mySlider.name + ", 
Value: " + event.value);
                        var myEvent:SliderEvent = new SliderEvent
(SliderEvent.CHANGE,true,event.cancelable, event.thumbIndex, 
event.value,event.triggerEvent, event.clickTarget,event.keyCode);
                        dispatchEvent(myEvent); 
                }
                
                override public function set data(myVal:Object):void
                {
                        mySlider.value = myVal.volumn;
                        mySlider.name = myVal.name;
                }
        ]]>
</mx:Script>
        <mx:HSlider id="mySlider" width="100" minimum="0" 
maximum="1.25" liveDragging="true" change="slideChanged(event)" />
</mx:VBox>


Reply via email to