How can I use strikethrough in a Label or text in flex 3 ?
A:
You can use a TextGraphic
from the Flex Gumbo SDK (Using the beta Gumbo SDK in Flex Builder 3).
Samuel
2009-03-30 16:00:03
A:
Depending on your exact needs, you might be able to subclass label, override the updateDisplayList, and just draw a line through the middle of the text.
rogueg
2009-03-31 02:01:13
+2
A:
I needed the same, and ended up simplifying the mediagreenhouse solution somewhat:
package
{ import flash.text.TextLineMetrics; import mx.core.mx_internal; import mx.controls.Label;
use namespace mx_internal;
public class StrikeLabel extends Label
{
public function StrikeLabel()
{
super();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList( unscaledWidth, unscaledHeight );
if( textField )
{
var metrics : TextLineMetrics = textField.getLineMetrics( 0 );
var y : int = ( metrics.ascent * 0.66 ) + 2;
graphics.clear();
graphics.lineStyle( 1, getStyle( "color" ), 1 );
graphics.moveTo( 0, y );
graphics.lineTo( metrics.width, y );
}
}
}
}
Ward
2009-05-14 05:37:03
This works great until the text is multi-line, then it only strikesthrough the top line.
invertedSpear
2010-03-03 20:46:42
I fixed it with this copy everything below and format it and you'll see what I'm doing: `copy below this`var nLines:uint = super.mx_internal::getTextField().numLines; var yPos:int = 0; for(var i:int = 0; i<nLines;i++){var metrics:TextLineMetrics = super.getLineMetrics(i);var y:int = Number(metrics.ascent * .66)+2;yPos += y; graphics.lineStyle( 1, getStyle( "color" ), 1 ); graphics.moveTo( 0, yPos );graphics.lineTo( metrics.width, yPos ); yPos -= y; yPos+=metrics.height;} copy that and format it and you'll see what I'm doing.
invertedSpear
2010-03-03 21:58:28