How can I extend a LinkButton to allow HTML text in Flex?

Posted by John Isaacks on Stack Overflow See other posts from Stack Overflow or by John Isaacks
Published on 2009-05-26T13:27:13Z Indexed on 2011/06/23 0:22 UTC
Read the original article Hit count: 292

Filed under:
|

I am feeding the label to my LinkButton directly from a string I receive from a Google API that puts html to format the label.

I want to extend linkbutton to allow this. I wrote a class myself to allow html text for the label and that aspect of it works but now the background that appears when you hover is way too big. I tried to override measure() to fix this but I didn't have a clue how. Here is the class I wrote:

package com.kranichs.components
{
    import mx.controls.LinkButton;

    public class HTMLLinkButton extends LinkButton
    {
    	protected var _isHTML:Boolean;

    	public function HTMLLinkButton()
    	{
    		super();
    	}

    	[Bindable]
    	public function set isHTML(value:Boolean):void
    	{
    		_isHTML = value;
    	}
    	public function get isHTML():Boolean
    	{
    		return _isHTML;
    	}

    	override protected function updateDisplayList(unscaledWidth:Number,
                                                  unscaledHeight:Number):void
        {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            if(_isHTML)
            {
            	textField.htmlText = label;
            }
        }



    }
}

© Stack Overflow or respective owner

Related posts about flex

Related posts about linkbutton