
Код:
package eu.orangeflash.controls
{
import mx.controls.LinkButton;
import mx.controls.Button;
import mx.core.UIComponent
import flash.text.TextField
import mx.core.mx_internal;;
public class MultilineLink extends LinkButton
{
public function MultilineLink()
{
}
protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var h:Number = calculateMultilineHeight(label);
textField.height = h;
textField.y = (height-h)/2;
}
protected override function measure():void
{
super.measure();
var textHeight:Number = 8;
if(label)
{
textHeight += calculateMultilineHeight(label);
}
mx_internal::viewIcon();
mx_internal::viewSkin();
var iconHeight:Number = mx_internal::currentIcon ? mx_internal::currentIcon.height : 0;
var h:Number = 0;
if (labelPlacement == "left" ||
labelPlacement == "right")
{
h = Math.max(textHeight, iconHeight);
}
else
{
if (label && label.length > 0)
h = textHeight + iconHeight;
else
h = iconHeight;
if (iconHeight != 0)
h += getStyle("verticalGap");
}
trace(textField.x);
this.measuredMinHeight = this.measuredHeight = h;
textField.y = (h - textHeight)/2;
}
protected function calculateMultilineHeight(multilineText:String):Number
{
var tf:TextField = new TextField();
tf.autoSize = "left";
tf.text = multilineText;
return tf.height;
}
}
}