views:

66

answers:

1

Hi,

I am creating a datagrid in AS3, and want to pass the value of a slider to an item renderer

var column : MyDataGridColumn = new MyDataGridColumn();
column.sliderValue = mySlider.value;
...

This works fine initially, but when I move the slider, I would like the datagrid to assign the new value to the column.

This worked fine when I created the datagrid in MXML and bound the slider value like this

<local:MyDataGridColumn
 sliderValue="{mySlider.value}"/>

This gets re-evaluated and re-assigned everytime the slider changes. The AS3 version not.

I tried it with a bindable function, and assign the function result to the column, but it did not work. Any ideas? Thx,

Martin

+2  A: 

You will need to set a change event handler on the slider and manually update the column.sliderValue when the change event is dispatched. Something like:

mySlider.addEventListener(SliderEvent.CHANGE, function(event:SliderEvent):void {
  column.sliderValue = mySlider.value;
});
James Ward
So I would need to loop through all the created columns of this datagrid to update this value?In the end I went again for the MXML solution - is not so nice because its more sparse, but the data binding is just a lot more flexible.Thanks!
martin