I’m using Flash builder, with flex 4 sdk and am trying to create a DateField in which the TextInput component has rounded corners.
I have tried the following code that doesn’t work:
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"
xmlns:components="components.*">
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/halo";
@namespace components "components.*";
.roundedTI
{
corner-radius: 10;
borderStyle: solid;
}
</fx:Style>
<mx:DateField textInputStyleName="roundedTI"/>
</s:Application>
Can the community help me rectify any visible errors in my code or point me to a alternative guide or tutorial that demonstrates how to do this?
With Flex 4, everything is in the Skins. CSS is used largely just to apply one skin to a component or class of components, whereas in Flex 3 it was used to set tons of properties. The cool thing is, however, that you can define any arbitrary style property value in CSS and it will be accessible via
getStylein the Skin!As such, they don’t have the
cornerRadiusproperty anymore. Instead, you have to create a “DateFieldSkin”, and apply it to your component via a css selector. The default DateField skin uses theDropDownSkin. Here’s the code to solve this:DateFieldSkin:
Sample App:
You can also hardcode radius values into the skin, or do something even more dynamic and optimized. This is just a start.
Let me know if that works,
Lance