quarta-feira, 4 de abril de 2012

Texto tachado

Blz?! Não sei se isso será surpresa para vocês ou não mas só hoje eu descobri que o componente Label por default não sabe oque é um texto tachado (aquela linha que corta o texto ao meio na horizontal). Pois bem, sendo assim nada que uma boa googada não me ajuda-se. Segue o componente com a propriedade "LineThrough"

Source da classe
package KC {
  import flash.text.TextLineMetrics;
  
  import mx.controls.Label;

  public class KLabel extends Label {
    [Bindable]
    private var
      FLineThrough: Boolean = true;
       
    [Inspectable(
      category = "eduarmstrong", 
      enumeration = "true,false",
      defaultValue = "false"
    )]
    public function get LineThrough(): Boolean {
      return(FLineThrough);
    }
    public function set LineThrough(ALineThrough: Boolean): void {
      FLineThrough = ALineThrough;
    }
        
    public function KLabel() {
      super();
    }

    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number): void {
      var 
        _rTxtWidth: TextLineMetrics = textField.getLineMetrics(0),
        _rPosY: int = (_rTxtWidth.ascent * 0.66 ) + 2;
        
      super.updateDisplayList( unscaledWidth, unscaledHeight );

      if(textField && FLineThrough) {
        graphics.clear();
        graphics.lineStyle(1, getStyle("color"), 1 );
        graphics.moveTo(0, _rPosY);
        graphics.lineTo(_rTxtWidth.width, _rPosY);
      }
    }
  }
}


Exemplo



Bons estudos e bom trabalho a todos.

Abraços

0 comentários:

Postar um comentário

Twitter Delicious Facebook Digg Stumbleupon Favorites More