Here is the code for creating multiline buttons in flex 3. After a lot of trial and error and googling the following seems to be working.

package
{
 import mx.controls.Button;
 import flash.display.DisplayObject;
 import flash.text.TextLineMetrics;
 import mx.core.UITextField;
 import flash.text.TextFieldAutoSize;

 import mx.core.IFlexDisplayObject;
 import mx.core.mx_internal;
 use namespace mx_internal;

 public class MultiLineButton extends Button
 {
  public function MultiLineButton()
  {
   super();
  }
  override protected function createChildren():void
  {
  super.createChildren();
  textField.multiline = true;
  textField.wordWrap = true;
  textField.autoSize = TextFieldAutoSize.LEFT;
  }

  override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
  {
  super.updateDisplayList(unscaledWidth, unscaledHeight);
  textField.y = (this.height-textField.height)>>1;
  }
  
 }
}

Try it in case you need it.

Advertisements