A user e-mailed with an interesting question. He has a ColdFusion powered Flex application that uses lots of DateField controls. By default, DateField displays left and right buttons to change months, but no buttons to change years. Changing years is supported by specifying yearNavigationEnabled=”true”, but he wanted to know if there was a way to change the default behavior so as to not have to add that property over and over.
The solution is a very simple one, and is a nice demonstration of the simplest form of Flex custom components. This first code snippet is a new DateField2 component:
And here is the equivalent DateChooser2 component:
That’s all there is to it, just use DateField2 instead of DateField, and DateChooser2 instead of DateChooser, and you’re done.