<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Determining the number of lines in a TextArea control in Flex</title>
	<atom:link href="http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: yuki</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-10372</link>
		<dc:creator>yuki</dc:creator>
		<pubDate>Wed, 08 Feb 2012 09:21:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-10372</guid>
		<description>Hi,

That&#039;s cool! Thanks.
May I know how to limit characters per line instead in a textarea and to be able to save the value entered as it is, meaning the space and empty lines are included in the array? 
Been trying to figure that out. 
Thanks.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>That&#8217;s cool! Thanks.<br />
May I know how to limit characters per line instead in a textarea and to be able to save the value entered as it is, meaning the space and empty lines are included in the array?<br />
Been trying to figure that out.<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nuwan</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-10323</link>
		<dc:creator>Nuwan</dc:creator>
		<pubDate>Mon, 16 Jan 2012 19:06:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-10323</guid>
		<description>how to get number of lines in spark text area?</description>
		<content:encoded><![CDATA[<p>how to get number of lines in spark text area?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-9518</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sun, 21 Aug 2011 17:21:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-9518</guid>
		<description>private function removeExcessLines():void
		{
			var numLines:int = this.textField.numLines;
			
			if( numLines &gt; numLinesAllowed )
			{
				var lines:Array = ObjectUtil.copy( this.textField.text ) .split(&quot;\r&quot;);
				var lineCount:int = 0;
				var lineIndex:int = 0;
				var currentLine:String;
				this.textField.text = &#039;&#039;;
				
				while( lineCount  0  ) {
						this.textField.text += currentLine;
						lineCount++;
						
						if( lineCount == 1 ) {
							this.textField.text += &#039;\r&#039;;
						}
						
						if( lineCount == 2 ) {
							this.selectionBeginIndex = this.length;  
							this.selectionEndIndex = this.length;				
						}
					}
					lineIndex++;
				}
			}
		}</description>
		<content:encoded><![CDATA[<p>private function removeExcessLines():void<br />
		{<br />
			var numLines:int = this.textField.numLines;</p>
<p>			if( numLines &gt; numLinesAllowed )<br />
			{<br />
				var lines:Array = ObjectUtil.copy( this.textField.text ) .split(&#8220;\r&#8221;);<br />
				var lineCount:int = 0;<br />
				var lineIndex:int = 0;<br />
				var currentLine:String;<br />
				this.textField.text = &#8221;;</p>
<p>				while( lineCount  0  ) {<br />
						this.textField.text += currentLine;<br />
						lineCount++;</p>
<p>						if( lineCount == 1 ) {<br />
							this.textField.text += &#8216;\r&#8217;;<br />
						}</p>
<p>						if( lineCount == 2 ) {<br />
							this.selectionBeginIndex = this.length;<br />
							this.selectionEndIndex = this.length;<br />
						}<br />
					}<br />
					lineIndex++;<br />
				}<br />
			}<br />
		}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kaushal</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-5217</link>
		<dc:creator>kaushal</dc:creator>
		<pubDate>Tue, 18 Aug 2009 07:12:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-5217</guid>
		<description>Really helpful example, I can end my search here. But I want to find a string of particular line, I am using TextArea, and have wordWrap=true, so using above code I can find number of line, but not the string contain each line.

Please help me.

Thanks</description>
		<content:encoded><![CDATA[<p>Really helpful example, I can end my search here. But I want to find a string of particular line, I am using TextArea, and have wordWrap=true, so using above code I can find number of line, but not the string contain each line.</p>
<p>Please help me.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ole Simon</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-3195</link>
		<dc:creator>Ole Simon</dc:creator>
		<pubDate>Mon, 06 Apr 2009 13:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-3195</guid>
		<description>Hi - im working on a project where i have to determin the number of lines and find the best fontsize in a multiline textarea.
When i try to get the number of lines as you show above, I somethimes get wrong values. I can se in flex that its 2 lines, and numLines give me 3 lines.
Any help of why this is happening? It happens even if a use callater after textchange or fontchange.</description>
		<content:encoded><![CDATA[<p>Hi &#8211; im working on a project where i have to determin the number of lines and find the best fontsize in a multiline textarea.<br />
When i try to get the number of lines as you show above, I somethimes get wrong values. I can se in flex that its 2 lines, and numLines give me 3 lines.<br />
Any help of why this is happening? It happens even if a use callater after textchange or fontchange.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sascha/hdrs</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-3197</link>
		<dc:creator>sascha/hdrs</dc:creator>
		<pubDate>Sat, 28 Mar 2009 09:32:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-3197</guid>
		<description>Flex 3 has the textHeight property now which does the same. However it is still not correct when using HTML Text. I suppose it&#039;s because of the html tags used in the text which are not part of the visible text. It would be great if there was a solution to solve that problem!</description>
		<content:encoded><![CDATA[<p>Flex 3 has the textHeight property now which does the same. However it is still not correct when using HTML Text. I suppose it&#8217;s because of the html tags used in the text which are not part of the visible text. It would be great if there was a solution to solve that problem!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-3193</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Tue, 03 Feb 2009 16:31:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-3193</guid>
		<description>Karthik,

Try something like the following:
&lt;pre class=&quot;code&quot;&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application name=&quot;TextArea_tabStops_test&quot;
        xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function init1():void {
                var tf:TextFormat = new TextFormat();
                tf.tabStops = [100, 200, 300, 400];

                textArea1.mx_internal::getTextField().setTextFormat(tf);
            }

            private function init3():void {
                textArea3.htmlText = &quot;&lt;TEXTFORMAT TABSTOPS=&#039;100,200,300,400&#039;&gt;&lt;P&gt;The quick&lt;TAB/&gt;brown fox&lt;TAB/&gt;jumps over&lt;TAB/&gt;the lazy&lt;TAB/&gt;dog.&lt;/P&gt;&lt;P&gt;The&lt;TAB/&gt;quick brown&lt;TAB/&gt;fox jumps&lt;TAB/&gt;over the&lt;TAB/&gt;lazy dog.&lt;/P&gt;&lt;/TEXTFORMAT&gt;&quot;;
            }

            private function init4():void {
                var tf:TextFormat = new TextFormat();
                tf.tabStops = [100, 200, 300, 400];

                textArea4.mx_internal::getTextField().defaultTextFormat = tf;
                textArea4.text = &quot;The quick\\tbrown fox\\tjumps over\\tthe lazy\\tdog.\\nThe\\tquick brown\\tfox jumps\\tover the\\tlazy dog.&quot;;

                textArea4.validateNow();
                trace(textArea4.htmlText);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:TextArea id=&quot;textArea1&quot;
            condenseWhite=&quot;true&quot;
            width=&quot;500&quot;
            creationComplete=&quot;init1();&quot;&gt;
        &lt;mx:htmlText&gt;
            &lt;![CDATA[
                &lt;p&gt;The quick&lt;tab/&gt;brown fox&lt;tab/&gt;jumps over&lt;tab/&gt;the lazy&lt;tab/&gt;dog.&lt;/p&gt;&lt;p&gt;The&lt;tab/&gt;quick brown&lt;tab/&gt;fox jumps&lt;tab/&gt;over the&lt;tab/&gt;lazy dog.&lt;/p&gt;
            ]]&gt;
        &lt;/mx:htmlText&gt;
    &lt;/mx:TextArea&gt;

    &lt;mx:TextArea id=&quot;textArea2&quot;
            condenseWhite=&quot;true&quot;
            width=&quot;500&quot;&gt;
        &lt;mx:htmlText&gt;
            &lt;![CDATA[
                &lt;TEXTFORMAT TABSTOPS=&quot;100,200,300,400&quot;&gt;&lt;P&gt;The quick&lt;TAB/&gt;brown fox&lt;TAB/&gt;jumps over&lt;TAB/&gt;the lazy&lt;TAB/&gt;dog.&lt;/P&gt;&lt;P&gt;The&lt;TAB/&gt;quick brown&lt;TAB/&gt;fox jumps&lt;TAB/&gt;over the&lt;TAB/&gt;lazy dog.&lt;/P&gt;&lt;/TEXTFORMAT&gt;
            ]]&gt;
        &lt;/mx:htmlText&gt;
    &lt;/mx:TextArea&gt;

    &lt;mx:TextArea id=&quot;textArea3&quot;
            condenseWhite=&quot;true&quot;
            width=&quot;500&quot;
            initialize=&quot;init3();&quot; /&gt;

    &lt;mx:TextArea id=&quot;textArea4&quot;
            width=&quot;500&quot;
            initialize=&quot;init4();&quot; /&gt;

&lt;/mx:Application&gt;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>Karthik,</p>
<p>Try something like the following:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application name="TextArea_tabStops_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function init1():void {
                var tf:TextFormat = new TextFormat();
                tf.tabStops = [100, 200, 300, 400];

                textArea1.mx_internal::getTextField().setTextFormat(tf);
            }

            private function init3():void {
                textArea3.htmlText = "&lt;TEXTFORMAT TABSTOPS='100,200,300,400'&gt;&lt;P&gt;The quick&lt;TAB/&gt;brown fox&lt;TAB/&gt;jumps over&lt;TAB/&gt;the lazy&lt;TAB/&gt;dog.&lt;/P&gt;&lt;P&gt;The&lt;TAB/&gt;quick brown&lt;TAB/&gt;fox jumps&lt;TAB/&gt;over the&lt;TAB/&gt;lazy dog.&lt;/P&gt;&lt;/TEXTFORMAT&gt;";
            }

            private function init4():void {
                var tf:TextFormat = new TextFormat();
                tf.tabStops = [100, 200, 300, 400];

                textArea4.mx_internal::getTextField().defaultTextFormat = tf;
                textArea4.text = "The quick\\tbrown fox\\tjumps over\\tthe lazy\\tdog.\\nThe\\tquick brown\\tfox jumps\\tover the\\tlazy dog.";

                textArea4.validateNow();
                trace(textArea4.htmlText);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:TextArea id="textArea1"
            condenseWhite="true"
            width="500"
            creationComplete="init1();"&gt;
        &lt;mx:htmlText&gt;
            &lt;![CDATA[
                &lt;p&gt;The quick&lt;tab/&gt;brown fox&lt;tab/&gt;jumps over&lt;tab/&gt;the lazy&lt;tab/&gt;dog.&lt;/p&gt;&lt;p&gt;The&lt;tab/&gt;quick brown&lt;tab/&gt;fox jumps&lt;tab/&gt;over the&lt;tab/&gt;lazy dog.&lt;/p&gt;
            ]]&gt;
        &lt;/mx:htmlText&gt;
    &lt;/mx:TextArea&gt;

    &lt;mx:TextArea id="textArea2"
            condenseWhite="true"
            width="500"&gt;
        &lt;mx:htmlText&gt;
            &lt;![CDATA[
                &lt;TEXTFORMAT TABSTOPS="100,200,300,400"&gt;&lt;P&gt;The quick&lt;TAB/&gt;brown fox&lt;TAB/&gt;jumps over&lt;TAB/&gt;the lazy&lt;TAB/&gt;dog.&lt;/P&gt;&lt;P&gt;The&lt;TAB/&gt;quick brown&lt;TAB/&gt;fox jumps&lt;TAB/&gt;over the&lt;TAB/&gt;lazy dog.&lt;/P&gt;&lt;/TEXTFORMAT&gt;
            ]]&gt;
        &lt;/mx:htmlText&gt;
    &lt;/mx:TextArea&gt;

    &lt;mx:TextArea id="textArea3"
            condenseWhite="true"
            width="500"
            initialize="init3();" /&gt;

    &lt;mx:TextArea id="textArea4"
            width="500"
            initialize="init4();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karthik</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-3194</link>
		<dc:creator>Karthik</dc:creator>
		<pubDate>Tue, 03 Feb 2009 03:08:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-3194</guid>
		<description>Hi,

Can you please give me an example of how to assign &quot;tabStops&quot; format property to textarea control?

Thanks,
Karthik</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Can you please give me an example of how to assign &#8220;tabStops&#8221; format property to textarea control?</p>
<p>Thanks,<br />
Karthik</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mikek</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-3196</link>
		<dc:creator>mikek</dc:creator>
		<pubDate>Wed, 22 Oct 2008 15:56:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-3196</guid>
		<description>Looks like you extended TextArea so, should be able to use just &quot;this.textField.numLines&quot;</description>
		<content:encoded><![CDATA[<p>Looks like you extended TextArea so, should be able to use just &#8220;this.textField.numLines&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/comment-page-1/#comment-3192</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Fri, 12 Sep 2008 06:39:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/08/determining-the-number-of-lines-in-a-textarea-control-in-flex/#comment-3192</guid>
		<description>Johan,

You can file an enhancement request to make the property public at &lt;a href=&quot;http://bugs.adobe.com/flex/&quot; rel=&quot;nofollow&quot;&gt;http://bugs.adobe.com/flex/&lt;/a&gt;. That won&#039;t guarantee that it will happen, but it will at least show Adobe there is interest.

It may possibly have been made internal if it was &quot;expensive&quot; to calculate, so they didn&#039;t want to expose it too easily. You could also try extending the TextArea control and making this value public in your custom component.

Peter</description>
		<content:encoded><![CDATA[<p>Johan,</p>
<p>You can file an enhancement request to make the property public at <a href="http://bugs.adobe.com/flex/" rel="nofollow">http://bugs.adobe.com/flex/</a>. That won&#8217;t guarantee that it will happen, but it will at least show Adobe there is interest.</p>
<p>It may possibly have been made internal if it was &#8220;expensive&#8221; to calculate, so they didn&#8217;t want to expose it too easily. You could also try extending the TextArea control and making this value public in your custom component.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
</channel>
</rss>

