1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
/* Importation de la classe FormItem qui va être étendue */
import mx.containers.FormItem;
/* Définition du nouveau style "verticalAlign" absent par défaut du formItem */
[Style(name="verticalAlign", type="String", inherit="no")]
public class MyFormItem extends FormItem
{
public function MyFormItem()
{
super();
}
/* redéfinition de la méthode updateDisplayList appelée pour définir la taille et la position des enfants du formItem et ajout d'un comportement spécifique lors de l'appel de la propriété "verticalAlign" */
override protected function updateDisplayList(w:Number, h:Number):void {
super.updateDisplayList(w, h);
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);
}
}
} |
Partager