<?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"
	>
<channel>
	<title>Comments on: Find Cursor Position in a HtmlText Object (RichTextEditor, TextArea, TextField) - UPDATE</title>
	<atom:link href="http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/</link>
	<description>flex developers web corner</description>
	<pubDate>Thu, 28 Aug 2008 08:35:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Andrei Ionescu</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-483</link>
		<dc:creator>Andrei Ionescu</dc:creator>
		<pubDate>Fri, 04 Jul 2008 12:40:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-483</guid>
		<description>JBI, thank for clarifying it out. I restored your comment.</description>
		<content:encoded><![CDATA[<p>JBI, thank for clarifying it out. I restored your comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei Ionescu</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-482</link>
		<dc:creator>Andrei Ionescu</dc:creator>
		<pubDate>Thu, 03 Jul 2008 13:25:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-482</guid>
		<description>JBI, I'm sorry but the tag you mentioned and parts of the code was stripped away. So please send it by email. Thanks.</description>
		<content:encoded><![CDATA[<p>JBI, I&#8217;m sorry but the tag you mentioned and parts of the code was stripped away. So please send it by email. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JBI</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-481</link>
		<dc:creator>JBI</dc:creator>
		<pubDate>Thu, 03 Jul 2008 12:54:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-481</guid>
		<description>Hi. This is a great piece of code. I have one small 'fix' though.
I have the following tag:
&lt;code&gt;
&#60;span class="charo_u68" id="txsr_a:2:{s:4:&#38;quot;bnlt&#38;quot;;s:6:&#38;quot;e_LTnm&#38;quot;;s:4:&#38;quot;bncp&#38;quot;;s:3:&#38;quot;b_f&#38;quot;;}"&#62;&lt;/code&gt;

Don't ask why, it's a complicated story ;)

But this tag gets broken off, in the middle. Why? Because the code it recognizes a new tag and focuses on that.. So I've added two lines of code;
&lt;code&gt;
public function calculateHtmlPosition(htmlstr:String, pos:int):int
{
&#160;&#160;// we return -1 (not found) if the position is bad
&#160;&#160;if (pos &lt;= -1)
&#160;&#160;&#160;&#160;return -1;
&#160; 
&#160;&#160;// characters that appears when a tag starts
&#160;&#160;var openTags:Array = ["&lt;","&#038;"];
&#160;&#160;// characters that appears when a tag ends
&#160;&#160;var closeTags:Array = ["&gt;",";"];
&#160;&#160;// the tag should be replaced with
&#160;&#160;// ex: &#38; is &#038; and has 1 as length but normal 
&#160;&#160;// tags have 0 length
&#160;&#160;var tagReplaceLength:Array = [0,1];
&#160;&#160;// flag to know when we are inside a tag
&#160;&#160;var isInsideTag:Boolean = false;
&#160;&#160;var cnt:int = 0;
&#160;&#160;// the id of the tag opening found
&#160;&#160;var tagId:int = -1;
&#160;&#160;var tagContent:String = "";
&#160; 
&#160;&#160;for (var i:int = 0; i &lt; htmlstr.length; i++)
&#160;&#160;{
&#160;&#160;&#160;&#160;// if the counter passes the position specified
&#160;&#160;&#160;&#160;// means that we reach the text position
&#160;&#160;&#160;&#160;if (cnt&gt;=pos) 
&#160;&#160;&#160;&#160;&#160;&#160;break;
&#160;&#160;&#160;&#160;// current char	
&#160;&#160;&#160;&#160;var currentChar:String = htmlstr.charAt(i);
&#160;&#160;&#160;&#160;// checking if the current char is in the open tag array
&#160;&#160;&#160;&#160;if(!isInsideTag)
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;for (var j:int = 0; j &lt; openTags.length; j++)
&#160;&#160;&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (currentChar == openTags[j])
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// set flag
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;isInsideTag = true;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// store the tag open id
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tagId = j;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;}
&#160;
&#160;&#160;&#160;&#160;if (!isInsideTag)
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;// increment the counter
&#160;&#160;&#160;&#160;&#160;&#160;cnt++;
&#160;&#160;&#160;&#160;} else {
&#160;&#160;&#160;&#160;&#160;&#160;// store the tag content
&#160;&#160;&#160;&#160;&#160;&#160;// needed afterwards to find new lines
&#160;&#160;&#160;&#160;&#160;&#160;tagContent += currentChar;
&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;if (currentChar == closeTags[tagId]) {
&#160;&#160;&#160;&#160;&#160;&#160;// we ad the replace length 
&#160;&#160;&#160;&#160;&#160;&#160;if (tagId &gt; -1) cnt += tagReplaceLength[tagId];
&#160;&#160;&#160;&#160;&#160;&#160;// if we encounter the &lt;/P&gt; tag we increment the counter
&#160;&#160;&#160;&#160;&#160;&#160;// because of new line character
&#160;&#160;&#160;&#160;&#160;&#160;if (tagContent == "&lt;/P&gt;") cnt++;
&#160;&#160;&#160;&#160;&#160;&#160;// set flag 
&#160;&#160;&#160;&#160;&#160;&#160;isInsideTag = false;
&#160;&#160;&#160;&#160;&#160;&#160;// reset tag content
&#160;&#160;&#160;&#160;&#160;&#160;tagContent = "";
&#160;&#160;&#160;&#160;}
&#160;&#160;}
&#160;&#160;// return de position in html text
&#160;&#160;return i;
}&lt;/code&gt;

This fixed my problem. My case is very rare (won't probably occur in normal HTML), but there are other cases in which my fix might help :)</description>
		<content:encoded><![CDATA[<p>Hi. This is a great piece of code. I have one small &#8216;fix&#8217; though.<br />
I have the following tag:<br />
<code><br />
&lt;span class="charo_u68" id="txsr_a:2:{s:4:&amp;quot;bnlt&amp;quot;;s:6:&amp;quot;e_LTnm&amp;quot;;s:4:&amp;quot;bncp&amp;quot;;s:3:&amp;quot;b_f&amp;quot;;}"&gt;</code></p>
<p>Don&#8217;t ask why, it&#8217;s a complicated story <img src='http://www.flexer.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>But this tag gets broken off, in the middle. Why? Because the code it recognizes a new tag and focuses on that.. So I&#8217;ve added two lines of code;<br />
<code><br />
public function calculateHtmlPosition(htmlstr:String, pos:int):int<br />
{<br />
&nbsp;&nbsp;// we return -1 (not found) if the position is bad<br />
&nbsp;&nbsp;if (pos < = -1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;return -1;<br />
&nbsp;<br />
&nbsp;&nbsp;// characters that appears when a tag starts<br />
&nbsp;&nbsp;var openTags:Array = ["<","&#038;"];<br />
&nbsp;&nbsp;// characters that appears when a tag ends<br />
&nbsp;&nbsp;var closeTags:Array = [">&#8220;,&#8221;;&#8221;];<br />
&nbsp;&nbsp;// the tag should be replaced with<br />
&nbsp;&nbsp;// ex: &amp; is &#038; and has 1 as length but normal<br />
&nbsp;&nbsp;// tags have 0 length<br />
&nbsp;&nbsp;var tagReplaceLength:Array = [0,1];<br />
&nbsp;&nbsp;// flag to know when we are inside a tag<br />
&nbsp;&nbsp;var isInsideTag:Boolean = false;<br />
&nbsp;&nbsp;var cnt:int = 0;<br />
&nbsp;&nbsp;// the id of the tag opening found<br />
&nbsp;&nbsp;var tagId:int = -1;<br />
&nbsp;&nbsp;var tagContent:String = &#8220;&#8221;;<br />
&nbsp;<br />
&nbsp;&nbsp;for (var i:int = 0; i < htmlstr.length; i++)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;// if the counter passes the position specified<br />
&nbsp;&nbsp;&nbsp;&nbsp;// means that we reach the text position<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (cnt>=pos)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;// current char<br />
&nbsp;&nbsp;&nbsp;&nbsp;var currentChar:String = htmlstr.charAt(i);<br />
&nbsp;&nbsp;&nbsp;&nbsp;// checking if the current char is in the open tag array<br />
&nbsp;&nbsp;&nbsp;&nbsp;if(!isInsideTag)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (var j:int = 0; j < openTags.length; j++)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (currentChar == openTags[j])<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// set flag<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isInsideTag = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// store the tag open id<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tagId = j;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (!isInsideTag)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// increment the counter<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cnt++;<br />
&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// store the tag content<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// needed afterwards to find new lines<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tagContent += currentChar;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (currentChar == closeTags[tagId]) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// we ad the replace length<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (tagId > -1) cnt += tagReplaceLength[tagId];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// if we encounter the  tag we increment the counter<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// because of new line character<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (tagContent == &#8220;&#8220;) cnt++;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// set flag<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isInsideTag = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// reset tag content<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tagContent = &#8220;&#8221;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;// return de position in html text<br />
&nbsp;&nbsp;return i;<br />
}</code></p>
<p>This fixed my problem. My case is very rare (won&#8217;t probably occur in normal HTML), but there are other cases in which my fix might help <img src='http://www.flexer.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei Ionescu</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-260</link>
		<dc:creator>Andrei Ionescu</dc:creator>
		<pubDate>Thu, 05 Jun 2008 06:45:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-260</guid>
		<description>Rob I don't know is I understand well what you mean. &lt;b&gt;Norm Pos&lt;/b&gt; is correct to be 1 and also for &lt;b&gt;Pos&lt;/b&gt; it should be 118 if you place the cursor after the first "a". If you take the string "&#60;TEXTFORMAT LEADING=&#34;2&#34;&#62;&#60;P ALIGN=&#34;LEFT&#34;&#62;&#60;FONT FACE=&#34;Verdana&#34; SIZE=&#34;13&#34; COLOR=&#34;#555555&#34; LETTERSPACING=&#34;0&#34; KERNING=&#34;0&#34;&#62;a" and put it in a document editor like Microsoft Word or OpenOffice Writer and do the word count command you will find that the string has 118 characters as it should (but be careful to delete the last space that is added automatically at the end of the string when pasting).

Maybe I don't understand what you mean in you comment and if so please give me more info.</description>
		<content:encoded><![CDATA[<p>Rob I don&#8217;t know is I understand well what you mean. <b>Norm Pos</b> is correct to be 1 and also for <b>Pos</b> it should be 118 if you place the cursor after the first &#8220;a&#8221;. If you take the string &#8220;&lt;TEXTFORMAT LEADING=&quot;2&quot;&gt;&lt;P ALIGN=&quot;LEFT&quot;&gt;&lt;FONT FACE=&quot;Verdana&quot; SIZE=&quot;13&quot; COLOR=&quot;#555555&quot; LETTERSPACING=&quot;0&quot; KERNING=&quot;0&quot;&gt;a&#8221; and put it in a document editor like Microsoft Word or OpenOffice Writer and do the word count command you will find that the string has 118 characters as it should (but be careful to delete the last space that is added automatically at the end of the string when pasting).</p>
<p>Maybe I don&#8217;t understand what you mean in you comment and if so please give me more info.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-259</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Wed, 04 Jun 2008 15:25:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-259</guid>
		<description>From what I can tell the values for norm pos and pos are incorrect. Maybe I'm interpreting these incorrectly?

If you place your cursor after the first "a" you will see pos is "1" and norm pos is "118", now turn on HTML view and count the number of characters including whitespace.

Am I missing something?</description>
		<content:encoded><![CDATA[<p>From what I can tell the values for norm pos and pos are incorrect. Maybe I&#8217;m interpreting these incorrectly?</p>
<p>If you place your cursor after the first &#8220;a&#8221; you will see pos is &#8220;1&#8243; and norm pos is &#8220;118&#8243;, now turn on HTML view and count the number of characters including whitespace.</p>
<p>Am I missing something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei Ionescu</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-258</link>
		<dc:creator>Andrei Ionescu</dc:creator>
		<pubDate>Wed, 04 Jun 2008 06:41:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-258</guid>
		<description>For &lt;b&gt;najier&lt;/b&gt;: You can drag and drop UI controls onto RTE, you can add UIs with &lt;b&gt;addChild&lt;/b&gt; method, but it will never layer it in the text as you expect (no text wrap, no formating, nothing). The text area of the RTE knows to render just a small part of HTML tags (&lt;a href="http://www.flexer.info/2008/05/08/html-tags-and-attributes-supported-by-flash-player/" rel="nofollow"&gt;see here&lt;/a&gt;). 

For &lt;b&gt;Justin&lt;/b&gt;: As you can see in the source file you cand use &lt;b&gt;selection.beginIndex&lt;/b&gt; property of the RTE like this:

&lt;code&gt;RTE.selection.beginIndex&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>For <b>najier</b>: You can drag and drop UI controls onto RTE, you can add UIs with <b>addChild</b> method, but it will never layer it in the text as you expect (no text wrap, no formating, nothing). The text area of the RTE knows to render just a small part of HTML tags (<a href="http://www.flexer.info/2008/05/08/html-tags-and-attributes-supported-by-flash-player/"  rel="nofollow">see here</a>). </p>
<p>For <b>Justin</b>: As you can see in the source file you cand use <b>selection.beginIndex</b> property of the RTE like this:</p>
<p><code>RTE.selection.beginIndex</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-252</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Tue, 03 Jun 2008 22:08:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-252</guid>
		<description>I'm just beginning my Flex experience, and was curious as to how you calculated the normal position?  I'm working in a TextArea, not a RichTextEditor if that makes a difference.  Thanks in advance.</description>
		<content:encoded><![CDATA[<p>I&#8217;m just beginning my Flex experience, and was curious as to how you calculated the normal position?  I&#8217;m working in a TextArea, not a RichTextEditor if that makes a difference.  Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: najier</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-237</link>
		<dc:creator>najier</dc:creator>
		<pubDate>Thu, 29 May 2008 13:10:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-237</guid>
		<description>Can u drag a UI control such as a Grid or canvas...etc and drop it in the RTE?</description>
		<content:encoded><![CDATA[<p>Can u drag a UI control such as a Grid or canvas&#8230;etc and drop it in the RTE?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei Ionescu</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-102</link>
		<dc:creator>Andrei Ionescu</dc:creator>
		<pubDate>Tue, 08 Apr 2008 06:47:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-102</guid>
		<description>mooksa did find an easier way to get the cursor position. Though I didn't test it I'll post here his code:
&lt;code&gt;public static function getHtmlCaretPosition( target:UIComponent, caret:int ):int
{
&#160;&#160;&#160;&#160;var range:TextRange = new TextRange( target, false, 0, caret );
&#160;&#160;&#160;&#160;var pattern:RegExp = /(.*?)(&lt;\/([^&lt;&gt;]*&gt;&lt;\/[^&lt;&gt;]*)*&gt;)/gm;
&#160;&#160;&#160;&#160;var cleanHtml:String = range.htmlText.replace( pattern, "$1");
&#160;&#160;&#160;&#160;var htmlLength:int = cleanHtml.length-1;
&#160;&#160;&#160;&#160;return htmlLength;
}&lt;/code&gt;
His original comment is &lt;a href="http://www.flexer.info/2008/03/18/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield/#comment-100" rel="nofollow"&gt;here&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>mooksa did find an easier way to get the cursor position. Though I didn&#8217;t test it I&#8217;ll post here his code:<br />
<code>public static function getHtmlCaretPosition( target:UIComponent, caret:int ):int<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;var range:TextRange = new TextRange( target, false, 0, caret );<br />
&nbsp;&nbsp;&nbsp;&nbsp;var pattern:RegExp = /(.*?)(< \/([^<>]*>< \/[^<>]*)*>)/gm;<br />
&nbsp;&nbsp;&nbsp;&nbsp;var cleanHtml:String = range.htmlText.replace( pattern, &#8220;$1&#8243;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;var htmlLength:int = cleanHtml.length-1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;return htmlLength;<br />
}</code><br />
His original comment is <a href="http://www.flexer.info/2008/03/18/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield/#comment-100"  rel="nofollow">here</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrei Ionescu</title>
		<link>http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-96</link>
		<dc:creator>Andrei Ionescu</dc:creator>
		<pubDate>Tue, 01 Apr 2008 06:43:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.flexer.info/2008/03/26/find-cursor-position-in-a-htmltext-object-richtexteditor-textarea-textfield-update/#comment-96</guid>
		<description>Will, thanks for comment and I'm looking forward to see your function posted here if you would like to post it. Thanks.</description>
		<content:encoded><![CDATA[<p>Will, thanks for comment and I&#8217;m looking forward to see your function posted here if you would like to post it. Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
