1 Reply Latest reply on Jul 15, 2009 7:33 AM by flashharry!

    copy & paste in textarea, shows correct but one long string, no returns?

    flashharry! Level 1

      I have a text area, I copy from an email a list of names, or I copy from a text file a list of names.

       

      They display in the text area correctly, i.e. they look like they have newlines.

       

      but if I split them they appear to be just one line of text

       

      var searchText:Array = new Array();

      searchText = textSearchBox.text.split(/\r|\n/);

      trace(ObjectUtil.toString(searchText));

       

      results

      (Array)#0

        [0] "00013.TIF00008.TIF00021.TIF844.mov00013.TIF00008.TIF00021.TIF844.mov00013.TIF00008.TIF00 021.TIF844.mov"

       

      if I edit the text and backspace/add return, it looks the same in the gui, but the results are what I want.

       

      results

      (Array)#0

        [0] "00013.TIF"

        [1] "00008.TIF"

        [2] "00021.TIF"

        [3] "844.mov"

        [4] "00013.TIF"

        [5] "00008.TIF"

        [6] "00021.TIF"

        [7] "844.mov"

        [8] "00013.TIF"

        [9] "00008.TIF"

        [10] "00021.TIF"

        [11] "844.mov"

       

      Question, what do I need to split on from a copy & paste without needing to edit list

       

      TIA

      Dean

        • 1. Re: copy & paste in textarea, shows correct but one long string, no returns?
          flashharry! Level 1

          found a thread with the same issue..

           

          http://forums.adobe.com/thread/424273

           

          this pointed to a fix

           

           

          http://bugs.adobe.com/jira/browse/FP-780

           

           

          basically this only affects flashplayer 10 on the Mac.

           

          in the script block of your code add this

           

          private function cleanCRLF(event:TextEvent): void {

               event.preventDefault();

               var textField:TextArea = event.target as TextArea;

               var currentText:String = textField.text;

               var insertionPrefix:String = currentText.substr(0, textField.selectionBeginIndex);

              var insertionSuffix:String = currentText.substr(textField.selectionEndIndex, currentText.length);

              textField.text = insertionPrefix + event.text + insertionSuffix;

              var caretIndex:int = insertionPrefix.length + event.text.length;

              textField.setSelection(caretIndex, caretIndex);

          }

           

          add the function call to you text area's textInput event

          <TextArea width="600" height="300" id="textSearchBox" text="" textInput="cleanCRLF(event)"/>      

           

          flash