<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Truncating text in the Flex Label control using the truncateToFit property</title>
	<link>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Thu, 08 Jan 2009 12:10:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Dinesh Copoosamy</title>
		<link>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-16874</link>
		<author>Dinesh Copoosamy</author>
		<pubDate>Mon, 24 Nov 2008 22:27:34 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-16874</guid>
		<description>Is there a way to get truncated text to move left and right periodically so you can read the entire label?</description>
		<content:encoded><![CDATA[<p>Is there a way to get truncated text to move left and right periodically so you can read the entire label?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mregert</title>
		<link>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-14494</link>
		<author>mregert</author>
		<pubDate>Tue, 05 Aug 2008 15:49:11 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-14494</guid>
		<description>&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&#62;
	&#60;mx:Script&#62;
		&#60;![CDATA[
		import mx.utils.StringUtil;
		[Bindable]
		private var longString:String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
		private var maxStringLength:int = 50;	
		private function truncatedString(source:String):String {
			var shortString:String = StringUtil.trim(source);
			shortString = shortString.substr(0, maxStringLength);
			if (source.length != 0 &#38;&#38; source.length &#62; maxStringLength) {
				shortString += "...";
			}
			return shortString;
		} 
		]]&#62;
	&#60;/mx:Script&#62;
	&#60;mx:Panel layout="absolute" left="10" right="10" bottom="10" top="10"&#62;
		&#60;mx:TextArea x="10" y="10" maxWidth="200" maxHeight="50" text="{truncatedString(longString)}" id="lblLongText" height="65" wordWrap="true"/&#62;
	&#60;/mx:Panel&#62;
	
&#60;/mx:Application&#62;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[
		import mx.utils.StringUtil;
		[Bindable]
		private var longString:String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
		private var maxStringLength:int = 50;
		private function truncatedString(source:String):String {
			var shortString:String = StringUtil.trim(source);
			shortString = shortString.substr(0, maxStringLength);
			if (source.length != 0 &amp;&amp; source.length &gt; maxStringLength) {
				shortString += "...";
			}
			return shortString;
		}
		]]&gt;
	&lt;/mx:Script&gt;
	&lt;mx:Panel layout="absolute" left="10" right="10" bottom="10" top="10"&gt;
		&lt;mx:TextArea x="10" y="10" maxWidth="200" maxHeight="50" text="{truncatedString(longString)}" id="lblLongText" height="65" wordWrap="true"/&gt;
	&lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: mregert</title>
		<link>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-14492</link>
		<author>mregert</author>
		<pubDate>Tue, 05 Aug 2008 15:47:19 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-14492</guid>
		<description>One possible solution would be:
&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&#62;
	&#60;mx:Script&#62;
		&#60;![CDATA[
		import mx.utils.StringUtil;
		[Bindable]
		private var longString:String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
		private var maxStringLength:int = 50;	
		private function truncatedString(source:String):String {
			var shortString:String = StringUtil.trim(source);
			shortString = shortString.substr(0, maxStringLength);
			if (source.length != 0 &#38;&#38; source.length &#62; maxStringLength) {
				shortString += "...";
			}
			return shortString;
		} 
		]]&#62;
	&#60;/mx:Script&#62;
	&#60;mx:Panel layout="absolute" left="10" right="10" bottom="10" top="10"&#62;
		&#60;mx:TextArea x="10" y="10" maxWidth="200" maxHeight="50" text="{truncatedString(longString)}" id="lblLongText" height="65" wordWrap="true"/&#62;
	&#60;/mx:Panel&#62;
	
&#60;/mx:Application&#62;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>One possible solution would be:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[
		import mx.utils.StringUtil;
		[Bindable]
		private var longString:String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
		private var maxStringLength:int = 50;
		private function truncatedString(source:String):String {
			var shortString:String = StringUtil.trim(source);
			shortString = shortString.substr(0, maxStringLength);
			if (source.length != 0 &amp;&amp; source.length &gt; maxStringLength) {
				shortString += "...";
			}
			return shortString;
		}
		]]&gt;
	&lt;/mx:Script&gt;
	&lt;mx:Panel layout="absolute" left="10" right="10" bottom="10" top="10"&gt;
		&lt;mx:TextArea x="10" y="10" maxWidth="200" maxHeight="50" text="{truncatedString(longString)}" id="lblLongText" height="65" wordWrap="true"/&gt;
	&lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat Long</title>
		<link>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-14432</link>
		<author>Pat Long</author>
		<pubDate>Fri, 01 Aug 2008 11:04:15 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-14432</guid>
		<description>Is there a way of using truncateToFit AND getting the Label to wrap? It seems the only way to get truncateToFit is to set a MaxWidth but the only way I have found to get wrapping to work is to set width=100%</description>
		<content:encoded><![CDATA[<p>Is there a way of using truncateToFit AND getting the Label to wrap? It seems the only way to get truncateToFit is to set a MaxWidth but the only way I have found to get wrapping to work is to set width=100%</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brind</title>
		<link>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-12906</link>
		<author>Chris Brind</author>
		<pubDate>Fri, 23 May 2008 09:43:50 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-12906</guid>
		<description>@rob there's a couple of ways I can think of.  Inline:
&lt;pre class="code"&gt;
&#60;mx:Label id="_alabel" text="hello" toolTip="{_alabel.text}" /&#62;
&lt;/pre&gt;

secondly, you could subclass label and override the setter for the text property and assigning the text being set to the tooltip.  i haven't tried this, so this code is off the top of my head:
&lt;pre class="code"&gt;
public class TippedLabel extends Label {

  override public function set text(o:String) : void {
    super.text = o;
    super.toolTip = o;
  }

}
&lt;/pre&gt;

Hope that helps.

Cheers,
Chris</description>
		<content:encoded><![CDATA[<p>@rob there&#8217;s a couple of ways I can think of.  Inline:</p>
<pre class="code">
&lt;mx:Label id="_alabel" text="hello" toolTip="{_alabel.text}" /&gt;
</pre>
<p>secondly, you could subclass label and override the setter for the text property and assigning the text being set to the tooltip.  i haven&#8217;t tried this, so this code is off the top of my head:</p>
<pre class="code">
public class TippedLabel extends Label {

  override public function set text(o:String) : void {
    super.text = o;
    super.toolTip = o;
  }

}
</pre>
<p>Hope that helps.</p>
<p>Cheers,<br />
Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rob</title>
		<link>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-12390</link>
		<author>rob</author>
		<pubDate>Wed, 30 Apr 2008 14:05:58 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-12390</guid>
		<description>Hey folks, would anyone know how to extend the Label class, so that the tooltip is always shown when you hover over it? whether or not the label is truncated..</description>
		<content:encoded><![CDATA[<p>Hey folks, would anyone know how to extend the Label class, so that the tooltip is always shown when you hover over it? whether or not the label is truncated..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Quentin</title>
		<link>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-6841</link>
		<author>Quentin</author>
		<pubDate>Sun, 10 Feb 2008 13:00:16 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/01/26/truncating-text-in-the-flex-label-control-using-the-truncatetofit-property/#comment-6841</guid>
		<description>A quick comment to add that 'truncateToFit' won't show the '...' ending string on HTML Labels. They only get truncated.

Here what you can find in Label.as :
&lt;code&gt;
// Plain text gets truncated with a "...".
// HTML text simply gets clipped, because it is difficult
// to skip over the markup and truncate only the non-markup.
// But both plain text and HTML text gets an automatic tooltip
// if the full text isn't visible.
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>A quick comment to add that &#8216;truncateToFit&#8217; won&#8217;t show the &#8216;&#8230;&#8217; ending string on HTML Labels. They only get truncated.</p>
<p>Here what you can find in Label.as :<br />
<code><br />
// Plain text gets truncated with a "...".<br />
// HTML text simply gets clipped, because it is difficult<br />
// to skip over the markup and truncate only the non-markup.<br />
// But both plain text and HTML text gets an automatic tooltip<br />
// if the full text isn't visible.<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
