请问checkbox的label文字如何换行?
label字体改变后,一行太长,如何换行?
[解决办法]
我没找到简单的办法对应,自定义了一个组件。你看看对不对:
package{ import flash.text.TextLineMetrics; import mx.controls.CheckBox; public class MyCheckBox extends CheckBox { public function MyCheckBox() { super(); } override protected function createChildren():void { super.createChildren(); if (textField != null) { textField.multiline = true; textField.wordWrap = true; } } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth,unscaledHeight); var lineMetrics:TextLineMetrics = measureText(label); var textWidth:Number = lineMetrics.width + 6; var textHeight:Number = lineMetrics.height + 4; var paddingLeft:Number = textField.getStyle("paddingLeft") as Number; var paddingRight:Number = textField.getStyle("paddingRight") as Number; var paddingTop:Number = textField.getStyle("paddingTop") as Number; var paddingBottom:Number = textField.getStyle("paddingBottom") as Number; textHeight = (textWidth/(textField.width - paddingLeft - paddingRight))*(textHeight + paddingTop+paddingBottom); textField.height = textHeight; } }}