Search code examples
actionscript-3apache-flexlinkbutton

How do I get the LinkButton in flex to underline on mouse over


I am new to using flex. I have a linkButton and I need it to underline when I hover the mouse over. I think it can be done by setstyle() but I don't know the syntax and how it works. I looked around but it quite find anything useful related to this.

Any help is much appreciated.


Solution

  • The syntax to use is:

    buttonObject.setStyle("property", "value");
    

    A complete example:

    <fx:Script> 
        <![CDATA[
            import mx.controls.Alert;
    
            protected function linkbutton1_clickHandler(event:MouseEvent):void
            {
                Alert.show('LinkButton selected!');
            }
    
            protected function linkbutton1_mouseOverHandler(event:MouseEvent):void
            {
                btn.setStyle("textDecoration", "underline");
            }
    
            protected function linkbutton1_mouseOutHandler(event:MouseEvent):void
            {
                btn.setStyle("textDecoration", "none");
    
            }
    
        ]]>
    
    </fx:Script>
    
    <mx:LinkButton id="btn" label="LinkButton control" color="#0000FF" fontWeight="bold" rollOverColor="#FFFFFF"
           mouseOver="linkbutton1_mouseOverHandler(event)"
           mouseOut="linkbutton1_mouseOutHandler(event)"
           click="linkbutton1_clickHandler(event)"/>
    

    See more at Display text as hyperlink in Flex and http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/LinkButton.html