Titus
Titus

Reputation: 4627

How do I make strikethrough text programatically in Flex?

I know I can do this in MXML:

<s:CheckBox label="Some Text" lineThrough="true" />

But how can I do the same thing programatically? The following doesn't work:

var newCheckBox:CheckBox = new CheckBox;
newCheckBox.label = "Some Text";
newCheckBox.lineThrough = "true"; // Flex code help doesn't see "lineThrough"
dummyContainer.addElement(newCheckBox); // Just some dummy container to add the element to.

Upvotes: 0

Views: 1027

Answers (1)

Jason Sturges
Jason Sturges

Reputation: 15955

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               minWidth="955"
               minHeight="600"
               creationComplete="creationCompleteHandler(event)">

    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;
            import spark.components.CheckBox;

            protected function creationCompleteHandler(event:FlexEvent):void
            {
                var checkBox:CheckBox = new CheckBox();
                checkBox.label = "Some text";
                checkBox.setStyle("lineThrough", true);

                addElement(checkBox);
            }
        ]]>
    </fx:Script>

</s:Application>

Upvotes: 1

Related Questions