Flex中button可自动换行的label
程序员文章站
2022-05-14 12:50:35
...
package { import flash.text.TextFieldAutoSize; import mx.controls.Button; public class WrappingButton extends Button { public function WrappingButton() { super(); } override protected function createChildren():void { super.createChildren(); textField.multiline = true; textField.wordWrap = true; textField.autoSize = TextFieldAutoSize.CENTER; } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); textField.y = (this.height - textField.height) >> 1; height = textField.height + getStyle("paddingTop") + getStyle("paddingBottom"); } } }
引用时:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*"> <local:WrappingButton label="The quick brown fox jumped over the lazy dog." width="100" paddingTop="10" paddingBottom="10" /> </mx:Application>
参考文档:
http://*.com/questions/1654403/adobe-flex-word-wrap-in-button-label
上一篇: historyManagementEnabled设为false
下一篇: 全键盘快捷键说明