2 Replies Latest reply on Jun 16, 2006 7:09 AM by Newsgroup_User

    Text compression

    Level 7
      I am sending text data between movies over the internet via the MUS.xtra.
      Most of the time the data is small. There are potential situations where it
      could be relatively larger, say 13KB. In the interest of optimization, I am
      wondering if there is a way to compress this data prior to sending it. Note
      that this data is not in a file, it is in a global variable.

      As a test of sorts, I took a sample 13K text message and put it an a text
      file and zipped it, it was about 2k then. If I could achieve something
      similar in via applying a function to my global variable, then I would be
      able to speed up the transfer of data.

      Any ideas? Thanks.


        • 1. Re: Text compression
          Lukewig Level 1
          Hi,

          There are a couple of different 'compression' techniques you could try (depending on the nature of the data, some might be more effective than others). For example, 'Run Length Encoding' (RLE) is useful if the data string contains lots of repetitive characters. For some general info on RLE, see http://www.compression-links.info/RLE. For an example Lingo implementation, check out some of the scripts at http://www.lingoworkshop.com/Codelib/pixelfonts.php (RLE is used to encode 'pixel maps'). You might be able to google for a Javascript implementation which will work in DMX2004

          -- Luke
          • 2. Re: Text compression
            Level 7
            I don't have DMX2004, so that's out. I don't think that RLE will help me (If
            I understand it correctly) as there are not a many repeated characters. I
            probably should have given a clue about the type of text data, but I do
            appreciate the suggestions.

            The data is a list of vertexLists from one or more vector shapes. In the end
            I wrote a simple "search and replace" type function, which eliminates all
            spaces and replaces some strings which I expect the list to have with a
            single character that should never be in the list. A decompress function
            does the same thing in reverse. A few preliminary test shows that the string
            gets reduced to about 25% of it's original size, which is better than
            nothing.

            Thanks again.