Whoops, sorry, looking at your code, your are headed in the right
direction.  Maybe debug to see what is resetting the slider value?

Also, best practice is to store the data vlue in a local var, and call
invalidateProperties().  Do the work in commitProperties().  Set data
gets called very often, but the call to commitProperties is optimized by
the framework.

Tracy

-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Tracy Spratt
Sent: Tuesday, June 24, 2008 2:35 PM
To: [email protected]
Subject: RE: [flexcomponents] Slider in a Datagrid resets when Datagrid
is scrolled.

Item renderers are recycled, so all row-level state must be data-driven.

Your slider must obtain its value from a property on the dataProvider
item, and set that value in the commitProperties or updateDisplayList
methods. 

It must also update that same dataProvider item property value when a
user interacts with the control.

Find an example of a working itemRenderer and modify that to fit your
needs, rather than attempt to create one from scratch.

Tracy

-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of gbkpicasso
Sent: Monday, June 23, 2008 12:19 PM
To: [email protected]
Subject: [flexcomponents] Slider in a Datagrid resets when Datagrid is
scrolled.

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>



------------------------------------

Yahoo! Groups Links






------------------------------------

Yahoo! Groups Links





Reply via email to