Skip to content

Extend the DateField component to include BorderStyles

I was just recently working with the DateField component and much to my surprise, the typical styles that can be applied to a core Text component are not available by default. The work around is to extend the DateField class and include the [Style] tags of the BorderStyles class. Unfortunately you just can’t include the entire BorderStlyes class. If you do, Flex throws the error: “[Style] must annotate a class.” To get around this minor annoyance you simply copy all the [Style] tags inline of your extended DateField class.

package {

import mx.controls.DateField;

[Style(name="backgroundAlpha", type="Number", inherit="no")]
[Style(name="backgroundColor", type="uint", format="Color", inherit="no")]
[Style(name="backgroundDisabledColor", type="uint", format="Color", inherit="yes")]
[Style(name="backgroundImage", type="Object", format="File", inherit="no")]
[Style(name="backgroundSize", type="String", inherit="no")]
[Style(name="borderColor", type="uint", format="Color", inherit="no")]
[Style(name="borderSides", type="String", inherit="no")]
[Style(name="borderSkin", type="Class", inherit="no")]
[Style(name="borderStyle", type="String", enumeration="inset,outset,solid,none", inherit="no")]
[Style(name="borderThickness", type="Number", format="Length", inherit="no")]
[Style(name="cornerRadius", type="Number", format="Length", inherit="no")]
[Style(name="dropShadowEnabled", type="Boolean", inherit="no")]
[Style(name="dropShadowColor", type="uint", format="Color", inherit="yes")]
[Style(name="shadowDirection", type="String", enumeration="left,center,right", inherit="no")]
[Style(name="shadowDistance", type="Number", format="Length", inherit="no")]

public class CustomDateField extends DateField {

public function CustomDateField() {
super();
}
}
}

Categories: Flex.

Tags: , ,

My first REAL post

So here I am. After 7 years of working with Flash, I have finally decided that its time to give back to the community that has helped me get to this somewhat successful point in my career. Better late than never, right?

Categories: Misc..