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.
2 comments
Comments feed for this article
April 5, 2010 at 5:37 pm
Tweets that mention Multiline buttons in flex 3 « FlexNotes -- Topsy.com
[…] This post was mentioned on Twitter by Joseph Burchett, CT and topsy_top20k, topsy_top20k_en. topsy_top20k_en said: Flex News: Multiline buttons in flex 3: Here is the code for creating multiline buttons in flex 3. After a lot of … http://bit.ly/cj8vCj […]
May 29, 2010 at 9:20 am
Bette Neal
Hehe I’m honestly the first reply to your great writing?!