Here is a simple application incorporating your code snippet. As I click in the TextArea, I don't get any errors. So you'll need to post your exact code and the exact sequence of user interactions that lead to your problem. What is the value of caretIndex when you get the error?

 

- Gordon

 

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

           

            <mx:Script>

                        <![CDATA[

                                   

                                   

                                    use namespace mx_internal;

                                   

                                    private function initializeHandler(event:Event):void

                                    {

                                                textArea.text = "Line 1\nLine 2";

                                    }

                                   

                                    private function clickHandler(event:MouseEvent):void

                                    {

                                                var caretIndex:int = textArea.getTextField().caretIndex;

                                                var beginIndex:int = textArea.getTextField().getFirstCharInParagraph(caretIndex);

                                                var endIndex:int = textArea.getTextField().getParagraphLength(caretIndex);

                                                trace(caretIndex, beginIndex, endIndex);

                                    }

 

                        ]]>

            </mx:Script>

           

            <mx:TextArea id="textArea" initialize="initializeHandler(event)" click="clickHandler(event)"/>

 

</mx:Application>

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Branko
Sent: Thursday, October 19, 2006 7:23 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] getParagraphLength method error!!!!

 

var caretIndex:int = textArea.getTextField().caretIndex;
var beginIndex:int =
textArea.getTextField().getFirstCharInParagraph(caretIndex);
var endIndex:int = textArea.getTextField().getParagraphLength(caretIndex);

and I'm getting error like "The supplied index is out of bounds."

And here is the deffinitoin of getParagraphLength property:

getParagraphLength () method

public function getParagraphLength(charIndex:int):int

Parameters charIndex:int — The zero-based index value of the
character (for example, the first character is 0, the second character
is 1, and so on).

Returns int — Returns the number of characters in the paragraph.

Please tell me what is wrong with my code?

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to