首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

请教checkbox的label文字怎么换行

2012-03-20 
请问checkbox的label文字如何换行?label字体改变后,一行太长,如何换行?[解决办法]我没找到简单的办法对应,

请问checkbox的label文字如何换行?
label字体改变后,一行太长,如何换行?

[解决办法]
我没找到简单的办法对应,自定义了一个组件。你看看对不对:

JScript code
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;        }            }} 

热点排行