I would set the textfield's props in createChildren after super.createChildren. Calling measure from updateDisplayList is too late. The framework should have called it for you especially if invalidateSize got called.
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Giles Roadnight Sent: Wednesday, April 04, 2007 9:46 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Extending LinkButton - please help, no hair left! Hi Guys I've been trying to extend the LinkButton class to let the text wrap onto 2 lines rather than always be on one line. I have the code working but when it initially appears the second line is hidden by an element below the button, it then updates and the size is reported correctly but this isn't good enough. The problem is that the measure function doesn't correctly report the height of the button until there is some text in the textField. when measure is first caleld there is no text there but when updateDisplayList is called there is text there so measure reports the correct height (I call this my self). I would really appreciate it if someone could help me out with this, it's been doing my head in for hours! My code is below: [code] package com.company.util { import mx.controls.LinkButton; import mx.events.FlexEvent; import flash.text.TextLineMetrics; import mx.core.mx_internal; import mx.controls.ButtonLabelPlacement; import flash.events.Event; use namespace mx_internal; public class TextLinkButton extends LinkButton { public function TextLinkButton() { super(); } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth,unscaledHeight); trace("updateDisplayList"); this.textField.autoSize = "left"; this.textField.wordWrap = true; this.textField.text = this.label; this.toolTip = null; this.measure(); } override protected function measure():void { trace("measure: " + this + " : " + this.textField); super.measure(); var textHeight:Number = 8; textHeight += this.textField.textHeight; viewIcon(); viewSkin(); var iconHeight:Number = currentIcon ? currentIcon.height : 0; var h:Number = 0; if (labelPlacement == ButtonLabelPlacement.LEFT || labelPlacement == ButtonLabelPlacement.RIGHT) { h = Math.max(textHeight, iconHeight); } else { if (label && label.length > 0) h = textHeight + iconHeight; else h = iconHeight; if (iconHeight != 0) h += getStyle("verticalGap"); } h = Math.max(14, h); measuredMinHeight = measuredHeight = h; } } } [/code]