As far as I've seen the label on 
FormItem's are always vertically aligned at the top.  I have no idea why the Adobe guys didn't add the expected "
verticalAlign" style to let the programmer choose where the label is positioned.
Anyways, I've extended the default 
mx.containers.FormItem control to add support for this style:
      | public class FormItemVerticalAlign extends FormItem {
 override protected function updateDisplayList(w:Number, h:Number):void {
 super.updateDisplayList(w, h);
 // vertically align (top by default)
 var verticalAlign:String = getStyle("verticalAlign");
 if (verticalAlign == "middle") {
 itemLabel.y = Math.max(0, (h - itemLabel.height) / 2);
 } else if (verticalAlign == "bottom") {
 var padBottom:Number = getStyle("paddingBottom");
 itemLabel.y = Math.max(0, h - itemLabel.height - padBottom);
 }
 }
 }
 | 
E.g.
Thanks very much! This saved me a lot of time.
ReplyDeleteWow, this is fantastic. Probably simple for experienced developers but it was exactly what I was looking for and gave me a great entrance into creating my own classes.
ReplyDeleteGood one. Thanks Much.
ReplyDeleteThanks, this is cool
ReplyDeleteThanks this is what i was looking for!!!
ReplyDeleteThanks mate! Saved me a lot of banging my head against the wall.
ReplyDeleteHow retarded is that of Adobe to not implement that? - It was driving me nuts. I thought I was going mental. LOL
Thanks anyways!
this may be looong overdue, but adobe didnt actually left this out. set labelStyleName to some style selector say: formLabelStyle
ReplyDeletethen in the css declaration:
.formLabelStyle {
vertical-align:top;
}
or middle .. or bottom
doesnt work :P
ReplyDeleteWorks like a charm! I've been searching for hours for this, thank you!
ReplyDeleteYou should have added
ReplyDelete[Style(name="verticalAlign", type="String", enumeration="bottom,middle,top",
inherit="no")]
before the class