Strike Through text component
Recently it was asked on the HOF Flex list how to display text with a strike through. I suggested extending label and using the graphics API, though I had no time at that time to produce the example. While another (Daniel Grace) has provided a mxml based example, here I provide a AS based one that allows for turning the strikethrough on/off at runtime, great for bound data. I’ve attached the component file as well as a simple application example.

Looks like the link to ZIP file is broken.
Jabby, thanks and sorry about that. Seems I found a wordpress bug.
DK
Good approach with extending Label component with text “strike-through” functionality, I was thinking of similar approach to use Flash Drawing API to actually draw a line.
Thumb up!
This component is useful when you need a label with all its text strikethrough.
But how can I specify only a portion of the text to be strikethrough?
It would be great if the htmltext methods will support the html tag
Great job. I extended your method. I use it for button.
import mx.controls.Button;
import mx.events.StyleEvent;
[Style(name=”textDecoration”, type=”String”, enumeration=”none,underline,strike”, inherit=”no”)]
public class ExtendedButton extends Button
{
public function ExtendedButton()
{
super();
}
override protected function updateDisplayList(unscaledWidth: Number, unscaledHeight: Number): void
{
super.updateDisplayList (unscaledWidth, unscaledHeight);
this.graphics.clear();
drawStrike();
}
override public function styleChanged(styleProp:String):void
{
super.styleChanged(styleProp);
if (styleProp == “textDecoration”)
{
this.invalidateDisplayList();
}
}
private function drawStrike():void
{
if (getStyle(”textDecoration”) == “strike”)
{
this.graphics.lineStyle(1, this.getStyle(”color”));
this.graphics.moveTo((width - textField.textWidth) / 2, height/2);
this.graphics.lineTo((width + textField.textWidth) / 2, height/2);
}
else
{
this.graphics.clear();
}
}
}
How can I create a strikeout itemRenderer component. I want to be able to select a checkbox and thereby applying a strikeout to the entire row.