Jul 15
Pretty straightforward. If is a multiline button what you need, then a multiline button is what you have!
Check also: http://flexrays.wordpress.com/2007/04/24/multilined-label-for-a-button/ and http: blogs.adobe.com/aharui/2007/04/multiline_buttons.html
Both are great references.
MultilineButton .as
[code lang="actionscript"] package com.multilineButton{import flash.text.TextField;
import mx.controls.Button;
import flash.text.TextLineMetrics;
//check also: http://flexrays.wordpress.com/2007/04/24/multilined-label-for-a-button/
//and also: http://blogs.adobe.com/aharui/2007/04/multiline_buttons.html
//great stuff!!
public class MultilineButton extends Button {
//private var _textField:UITextField;
public function MultilineButton(){
super();
}
override protected function createChildren():void{
if (!textField){
textField = new NoTruncationUITextField();
textField.styleName = this;
addChild(TextField(textField));
}
super.createChildren();
textField.multiline = true;
textField.wordWrap = true;
}
override public function measureText(s:String):TextLineMetrics{
textField.text = s;
var lineMetrics:TextLineMetrics = textField.getLineMetrics(0);
lineMetrics.width = textField.textWidth + 4;
lineMetrics.height = textField.textHeight + 4;
return lineMetrics;
}
}
}[/code]
NoTruncationUITextField.as
[code lang="actionscript"]package com.multilineButton{
import mx.core.UITextField;
public class NoTruncationUITextField extends UITextField{
public function NoTruncationUITextField(){
super();
}
override public function truncateToFit(s:String = null):Boolean{
return false;
}
}
}[/code]




July 27th, 2008 at 11:33 pm
Hi Gabriela,
I am new to Flex and I’ve got a newbie question. How do I reference the package within a component? I know for a fact I can’t nest it as into a block.
Thanks for your help.
July 28th, 2008 at 8:27 am
Hi.
Im not sure which pakage youre talking about, but this ii is not that important at all (only woukd make the example more concrete).
Lets say your thinking of using this multiline button.
You should hava a folder named “com” and another one (inside it) named “multilineButton”. This class should be inside this last folder.
August 19th, 2008 at 3:14 am
this is not a problem now
http://flexlib.googlecode.com/svn/trunk/docs/flexlib/controls/CanvasButton.html
Very simple
November 1st, 2008 at 8:01 am
Thanks for the post, I have been having the same problems.
May 23rd, 2011 at 2:20 am
your submit is damn intriguing to read!