Relax Breath of Solution.Community tech blog of Sameera Thilakasiri - Consultant UI, UX, RWD Specialist/ Interactive Designer

Just I wanted.. Do you?…

Truncating text using the Spark SimpleText control in Flex 4 – TruncationOptions

Posted on September 18, 2010 | No Comments

The following example shows how you can truncate text using the Spark SimpleText control in Flex 4 by setting the truncation property and specifying the maximum number of lines allowed.

<?xml     version="1.0"   encoding="UTF-8"?>
<s:Application     name="Spark_SimpleText_truncation_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/halo">

        <fx:Script>
          <![CDATA[
                import flashx.textLayout.factory.TruncationOptions;
          ]]>
      </fx:Script>

      <mx:ApplicationControlBar     width="100%" cornerRadius="0">
            <mx:Form styleName="plain">
              <mx:FormItem label="truncation:">
                <s:HSlider id="slider1"
                          minimum="{TruncationOptions.NO_LINE_COUNT_LIMIT}"
                          maximum="8"
                          value="-1"
                        liveDragging="true" />
            </mx:FormItem>
              <mx:FormItem label="width:">
                    <s:HSlider id="slider2"
                        minimum="100"
                        maximum="300"
                          value="300"
                              liveDragging="true"     />
            </mx:FormItem>
          </mx:Form>
      </mx:ApplicationControlBar>

    <s:Group horizontalCenter="0"   verticalCenter="0">
        <s:Rect width="100%" height="100%">
            <s:fill>
                    &lt;s:SolidColor <a href="http://jtc-enterprises.com/images/">buy cialis tadalafil</a>  color=&quot;red&quot; alpha=&quot;0.1&quot; /&gt;
              &lt;/s:fill&gt;
        &lt;/s:Rect&gt;
        &lt;s:SimpleText id=&quot;simpleTxt&quot;
                text=&quot;The quick brown fox jumps     over the lazy dog.&quot;
                fontSize=&quot;24&quot;
                truncation=&quot;{slider1.value}&quot;
                  width=&quot;{slider2.value}&quot; /&gt;
    &lt;/s:Group&gt;

&lt;/s:Application&gt;

Incoming search terms:

Author
Sameera Thilakasiri By Sameera Thilakasiri
,is a front-end developer based in Colombo, is a blogger and a lifestyle photographer.
Follow him Twitter and Google+. Check out him.

Comments

Leave a Reply

You must be logged in to post a comment.