8/8/2010 11:40:59 PM
Title:
Multiline Label
Can we have a multiline label?
Rayan
Points: 700
Posts:0
8/9/2010 1:39:17 AM
extend you label component to add this functionality, here is the extended class code to make a label multiline
package components
{
import mx.core.UITextField;
import flash.text.TextFieldAutoSize;
import mx.controls.Label;
import flash.display.DisplayObject;
public class MultiLineLabel extends Label
{
override protected function createChildren() : void
{
// Create a UITextField to display the label.
if (!textField)
{
textField = new UITextField();
textField.styleName = this;
addChild(DisplayObject(textField));
}
super.createChildren();
textField.multiline = true;
textField.wordWrap = true;
textField.autoSize = TextFieldAutoSize.LEFT;
}
}
}
8/11/2010 12:55:28 AM
Yes, we can have multi line label.
Try this example : Hope this is what you were loooking for.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.controls.Label;
import mx.controls.Alert;
import mx.containers.FormItem;
private function init3(evt:FlexEvent):void {
// var lbl:Label = FormItem(evt.currentTarget).itemLabel as Label;
label3.htmlText = "<b>" + label3.text + "</b>" + "\n" + "Street Name";
label3.selectable = true;
label3.height = 100;
// label3.addEventListener(TextEvent.LINK, label_link);
}
]]>
</mx:Script>
<mx:Form minWidth="1000" height="100%">
<mx:FormItem id="formItem3"
>
<mx:Label id="label3" width="100%" text="Multi line Label Multi line Label "
creationComplete="init3(event);"/>
</mx:FormItem>
</mx:Form>
</mx:Application>