29 Replies Latest reply on Jul 31, 2010 7:50 PM by Ansury

    Poor performance using TextArea

    Ansury Level 3
      I'm working on a wordpad-like editor AIR application. (I'm posting here because TextArea isn't just an AIR component, and AIR probably doesn't effect this issue.) No, I'm not doing something stupid like implementing WordPad in Flex - I'm creating a text editor for a specific type of large text file, adding some features to make editing them easier. Call it a huge configuration file if you want.

      I'm having two problems:

      1) Loading the files works fine (they're about 5 to 6 MB text files), but setting the file's text in the textarea takes awhile, maybe a few seconds. Also, using the page down key is pretty slow, especially as you get further down the TextArea's content. This would be acceptable...I guess (although pretty bad), but see #2 below...

      2) These text files have both a newline and carriage return at the end of each line. Since TextArea considers both of these a "newline", I end up with what appears to be double spacing. I've attempted to remove the extra carriage returns using this:

      private static const windowsCRLF:RegExp = /\r\n/gm;
      ...
      fileText.replace(windowsCRLF, "\n");

      But apparently, the file is so big that it takes FOREVER to execute this. (In debug mode this call never returns and is using 99% CPU, so I can only assume that it is "working on it".) During this time the UI is completely unresponsive of course, and I've given it at least a minute or two to TRY and finish. (Which is way too slow anyway.) It'd be nice to be able to tell TextArea to treat new line+carriage return as one line return, but it doesn't appear possible.

      So, I'm trying to find a way around these two issues.

      The only thing I've been able to think of so far is to load/display only small sections of the large files at a time, so Flex can handle the required parsing and such. Do I have any other options? Would it be difficult to extend TextArea and possibly override some functions to provide the functionality and/or speed increases that I need? Or do I pretty much have no choice but to segment these files into smaller managable chunks? I also have to be able to save changes back to disk when they're finished, so for obvious reasons segmenting the files makes that a little harder.

      (BTW - my reasoning for calling this performance "poor" despite the fact that my expectations seem very high showing these huge files is just that WordPad manages to outperform Flex here pretty easily. )