package
{
import flash.text.TextFieldAutoSize;
import mx.controls.Button;
public class WrappingButton extends Button
{
public function WrappingButton()
{
super();
}
override protected function createChildren():void
{
super.createChildren();
textField.multiline = true;
textField.wordWrap = true;
textField.autoSize = TextFieldAutoSize.CENTER;
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
textField.y = (this.height - textField.height) >> 1;
height = textField.height + getStyle("paddingTop") + getStyle("paddingBottom");
}
}
}
引用原文:http://stackoverflow.com/questions/1654403/adobe-flex-word-wrap-in-button-label
本文介绍了一个自定义Adobe Flex按钮类,该类支持按钮内的文本自动换行和居中显示。通过重写默认按钮行为,使得即使在按钮较窄时也能确保文本清晰可读。
4205

被折叠的 条评论
为什么被折叠?



