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>
<s:SolidColor <a href="http://jtc-enterprises.com/images/">buy cialis tadalafil</a> color="red" alpha="0.1" />
</s:fill>
</s:Rect>
<s:SimpleText id="simpleTxt"
text="The quick brown fox jumps over the lazy dog."
fontSize="24"
truncation="{slider1.value}"
width="{slider2.value}" />
</s:Group>
</s:Application>
Incoming search terms:
Comments
Leave a Reply
You must be logged in to post a comment.
Sameera at LinkedIn
