You are currently browsing the category archive for the ‘Flex 3 code snippets’ category.

One way to achieve this is to extend the Link Button class to display underline on mouse over event.

// code begins

package

{
 import flash.events.MouseEvent;
 
 import mx.controls.LinkButton;

 public class ULinkButton extends LinkButton
 {
  
  public function ULinkButton()
  {
   super();
   this.addEventListener(MouseEvent.MOUSE_OVER, showUnderline)
   this.addEventListener(MouseEvent.MOUSE_OUT, clearUnderline);
  }
  
  
  private function showUnderline(evt:MouseEvent):void
    {
     this.setStyle(“textDecoration”, “underline”);
    }
    
   private function clearUnderline(evt:MouseEvent):void
    {
     this.setStyle(“textDecoration”, “none”);
    }
 }
}

// code ends

The above class extends the the link button component and makes it to listen for mouse over and mouse out events and then sets the textDecoration property to either display underline or not.

Cheers!

Advertisements

Here is the code for creating multiline buttons in flex 3. After a lot of trial and error and googling the following seems to be working.

package
{
 import mx.controls.Button;
 import flash.display.DisplayObject;
 import flash.text.TextLineMetrics;
 import mx.core.UITextField;
 import flash.text.TextFieldAutoSize;

 import mx.core.IFlexDisplayObject;
 import mx.core.mx_internal;
 use namespace mx_internal;

 public class MultiLineButton extends Button
 {
  public function MultiLineButton()
  {
   super();
  }
  override protected function createChildren():void
  {
  super.createChildren();
  textField.multiline = true;
  textField.wordWrap = true;
  textField.autoSize = TextFieldAutoSize.LEFT;
  }

  override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
  {
  super.updateDisplayList(unscaledWidth, unscaledHeight);
  textField.y = (this.height-textField.height)>>1;
  }
  
 }
}

Try it in case you need it.

Twitter Updates

October 2017
M T W T F S S
« Dec    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Blog Stats

  • 78,509 hits