It seems Flex 3 controls don't allow their text labels to be multiline. For some reason this feature wasn't implemented.


Thanks to Alex's Multiline buttons example I created a custom class to that extend the CheckBox to allow more than one line of text.


1. package packageName
2. {
3. import flash.text.TextLineMetrics;
4.
5. import mx.controls.CheckBox;
6.
7. public class MultilineCheckbox extends CheckBox
8. {
9. public var myLineMetric:TextLineMetrics;
10.
11. public function MultilineCheckbox()
12. {
13. super();
14. }
15.
16. override protected function createChildren():void
17. {
18. super.createChildren();
19.
20. textField.multiline = true;
21. textField.wordWrap = true;
22. textField.width = this.explicitWidth - 20;
23. }
24.
25. override protected function measure():void
26. {
27.
28. if (!isNaN(explicitWidth))
29. {
30. var w:Number = explicitWidth;
31. w -= getStyle("horizontalGap") + getStyle("paddingLeft") + getStyle("paddingRight");
32. textField.width = w;
33. textField.y = 0;
34. }
35.
36. if (this.myLineMetric == null)
37. super.measure();
38. this.height = myLineMetric.height + 4;
39. }
40.
41. override public function measureText(s:String):TextLineMetrics
42. {
43. textField.text = s;
44. var lineMetrics:TextLineMetrics = textField.getLineMetrics(0);
45. lineMetrics.width = textField.textWidth;
46. lineMetrics.height = textField.textHeight;
47.
48. if (this.myLineMetric == null)
49. this.myLineMetric = lineMetrics;
50. this.height = myLineMetric.height + 4;
51. return this.myLineMetric;
52. }
53. }
54. }
55.
Generated by FlexWebFormater

Make sure you specify the width and don't specify the height to allow it to resize properly.

Usage example :

1. <packageName:MultilineCheckbox id="MultiCheckBox"
2. label="LLLLLLLLLL OOOOOOO NNNNNNNN GGGGGGG TTTTTT EEEEEEEE XXXXXX TTTTT"
3. width="110">
4. </packageName:MultilineCheckbox>
Generated by FlexWebFormater

UPDATE 8/24/2010
It seems this isn't supported in Flex 4 either, but there is a very clean solution for it. You can just skin the spark Checkbox and set the label's maxDisplayedLines property to -1
For more information on this and to see how flexible the solution is check out: http://spy6.blogspot.com/2010/09/spark-multiline-checkbox-with-word-wrap.html