开发者

Databinding in AS3 to a slider

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 trie开发者_如何学Pythond it with a bindable function, and assign the function result to the column, but it did not work. Any ideas? Thx,

Martin


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;
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜