Products
Technologies

Developer resources

Truncating text with the Spark RichText control in Flex Gumbo

Avg. Rating 3.5

Problem

You need to truncate some text in your Flex application.

Solution

The following example shows how you can truncate text in the Spark RichText control in Flex Gumbo by setting the truncation property and specifying the maximum number of visible lines.

Detailed explanation

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/05/27/truncating-text-with-the-spark-richtext-control-in-flex-gumbo/ -->
<s:Application name="Spark_RichText_truncation_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library://ns.adobe.com/flex/halo"
        xmlns:s="library://ns.adobe.com/flex/spark">

    <mx:ApplicationControlBar width="100%" cornerRadius="0">
        <mx:Form styleName="plain">
            <mx:FormItem label="truncation:">
                <s:HSlider id="slider"
                        minimum="-1"
                        maximum="22"
                        liveDragging="true" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <s:RichText id="richText"
            truncation="{slider.value}"
            width="200"
            horizontalCenter="0" verticalCenter="0">
        <s:text><fx:String source="dummy.txt" /></s:text>
    </s:RichText>

</s:Application>

For more information, see the original post (as well as many others) on FlexExamples.com.

Report abuse

Related recipes