<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; truncate</title>
	<atom:link href="http://blog.flexexamples.com/tag/truncate/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Determining if a Spark SimpleText control is truncated in Flex 4</title>
		<link>http://blog.flexexamples.com/2009/06/15/determining-if-a-spark-simpletext-control-is-truncated-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2009/06/15/determining-if-a-spark-simpletext-control-is-truncated-in-flex-4/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 06:49:05 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta1]]></category>
		<category><![CDATA[SimpleText (Spark)]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[isTruncated()]]></category>
		<category><![CDATA[truncate]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/06/15/determining-if-a-spark-simpletext-control-is-truncated-in-flex-4/</guid>
		<description><![CDATA[<p>The following example shows how you can determine if a Spark SimpleText control is truncated in Flex 4 by using the isTruncated() method.</p> <p>Full code after the jump.</p> <p></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2009/06/15/determining-if-a-spark-simpletext-control-is-truncated-in-flex-4/ --&#62; &#60;s:Application name="Spark_SimpleText_isTruncated_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"&#62; &#60;s:layout&#62; &#60;s:VerticalLayout gap="8" /&#62; &#60;/s:layout&#62; &#60;fx:Script&#62; &#60;![CDATA[ import mx.events.FlexEvent; private function group1_updateComplete(evt:FlexEvent):void { checkBox.selected = [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can determine if a Spark SimpleText control is truncated in Flex 4 by using the <code>isTruncated()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-1111"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/06/15/determining-if-a-spark-simpletext-control-is-truncated-in-flex-4/ --&gt;
&lt;s:Application name="Spark_SimpleText_isTruncated_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"&gt;
    &lt;s:layout&gt;
        &lt;s:VerticalLayout gap="8" /&gt;
    &lt;/s:layout&gt;

    &lt;fx:Script&gt;
        &lt;![CDATA[
            import mx.events.FlexEvent;

            private function group1_updateComplete(evt:FlexEvent):void {
                checkBox.selected = simpleTxt.isTruncated();
            }
        ]]&gt;
    &lt;/fx:Script&gt;

    &lt;mx:ApplicationControlBar width="100%" cornerRadius="0"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="truncation:"&gt;
                &lt;s:HSlider id="slider"
                        minimum="0"
                        maximum="3"
                        liveDragging="true" /&gt;
            &lt;/mx:FormItem&gt;
            &lt;mx:FormItem label="isTruncated():"&gt;
                &lt;mx:CheckBox id="checkBox" enabled="false" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;s:Group updateComplete="group1_updateComplete(event);"
            width="100%"
            height="100%"&gt;
        &lt;s:SimpleText id="simpleTxt"
                truncation="{slider.value}"
                textAlign="justify"
                fontSize="24"
                width="200"
                horizontalCenter="0"
                verticalCenter="0"&gt;
            &lt;s:text&gt;The quick brown fox jumps over the lazy dog&lt;/s:text&gt;
        &lt;/s:SimpleText&gt;
    &lt;/s:Group&gt;

&lt;/s:Application&gt;
</pre>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/06/15/determining-if-a-spark-simpletext-control-is-truncated-in-flex-4/ --&gt;
&lt;s:Application name="Spark_SimpleText_isTruncated_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"
        initialize="init();"&gt;
    &lt;s:layout&gt;
        &lt;s:VerticalLayout gap="8" /&gt;
    &lt;/s:layout&gt;

    &lt;fx:Script&gt;
        &lt;![CDATA[
            import flashx.textLayout.formats.TextAlign;
            import mx.containers.ApplicationControlBar;
            import mx.containers.Form;
            import mx.containers.FormItem;
            import mx.events.FlexEvent;
            import spark.components.CheckBox;
            import spark.components.Group;
            import spark.components.HSlider;
            import spark.primitives.SimpleText;

            private var slider:HSlider;
            private var checkBox:CheckBox;
            private var simpleTxt:SimpleText;

            private function init():void {
                slider = new HSlider();
                slider.minimum = 0;
                slider.maximum = 3;
                slider.setStyle("liveDragging", true);
                slider.addEventListener(Event.CHANGE, slider_change);

                checkBox = new CheckBox();
                checkBox.enabled = false;

                var formItem1:FormItem = new FormItem();
                formItem1.label = "truncation:";
                formItem1.addElement(slider);

                var formItem2:FormItem = new FormItem();
                formItem2.label = "isTruncated():";
                formItem2.addElement(checkBox);

                var form:Form = new Form();
                form.styleName = "plain";
                form.addElement(formItem1);
                form.addElement(formItem2);

                var appControlBar:ApplicationControlBar = new ApplicationControlBar();
                appControlBar.percentWidth = 100;
                appControlBar.setStyle("cornerRadius", 0);
                appControlBar.addElement(form);
                addElementAt(appControlBar, 0);

                simpleTxt = new SimpleText();
                simpleTxt.truncation = slider.value;
                simpleTxt.setStyle("textAlign", TextAlign.JUSTIFY);
                simpleTxt.setStyle("fontSize", 24);
                simpleTxt.width = 200;
                simpleTxt.horizontalCenter = 0;
                simpleTxt.verticalCenter = 0;
                simpleTxt.text = "The quick brown fox jumps over the lazy dog";

                var group1:Group = new Group();
                group1.percentWidth = 100;
                group1.percentHeight = 100;
                group1.addEventListener(FlexEvent.UPDATE_COMPLETE, group1_updateComplete);
                group1.addElement(simpleTxt);
                addElement(group1);
            }

            private function slider_change(evt:Event):void {
                simpleTxt.truncation = slider.value;
            }

            private function group1_updateComplete(evt:FlexEvent):void {
                checkBox.selected = simpleTxt.isTruncated();
            }
        ]]&gt;
    &lt;/fx:Script&gt;

&lt;/s:Application&gt;
</pre>
<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Determining if a Spark SimpleText control is truncated in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/06/15/determining-if-a-spark-simpletext-control-is-truncated-in-flex-4/',contentID: 'post-1111',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'Gumbo,isTruncated(),truncate',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2009/06/15/determining-if-a-spark-simpletext-control-is-truncated-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

