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");
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"layout="absolute"xmlns:local="*">
<local:WrappingButton label="The quick brown fox jumped over the lazy dog."width="100"paddingTop="10"paddingBottom="10"/>
</mx:Application>