Webdevotion.be

Developer for the Flash Platform

Binding between a DateField and a Button label at runtime

When creating a runtime component to use as a popup I wanted to bind a DateField’s selectedDate property to a Button label. Because I never used bindings ( and a labelFunction ) using pure Actionscript before I had to come up with a solution.

This is what worked for me:

bt being a Button instance
df being a DateField instance
dateLabelFunction returns a formatted date as a string

BindingUtils.bindProperty( bt, "label", df, {name:"selectedDate",getter:function(df:DateField):String{return dateLabelFunction(df.selectedDate)}});

What we are doing here is:
- Bind bt.label to df.selectedDate ( that’s the name:”selectedDate” part )
- When retrieving the value of df.selectedDate use the ‘getter’ function
- The getter function returns a formatted date string



Tagged as , , + Categorized as Uncategorized

Leave a Reply