1 Reply Latest reply on Jul 9, 2007 4:56 AM by Greg Dove

    Loading large volumes of arbitrary binary data to a clip

      It is easy to download external data in XML format to a movie clip. However, what I need is to load really large volumes of readonly binary data. In my case, textual representation is not an option. Is it possible to download an arbitrary array of bytes into memory then seek this array to read individual bytes?

      I don't think that ActionsScript arrays like this one
      var data:Array = [1,2,3,...];
      could be solution fro my problem either. The reason is that virtual machine associates so much extra information with every array member.

      The only solution I came so far is to pack binary data as strings,
      var data:String = "\u0000\u1234\uabcd";
      two byte per character. There should not be any storage overhead, and seeking for an individual data member is trivial.

      But I doubt is there any better solution?
        • 1. Re: Loading large volumes of arbitrary binary data to a clip
          Greg Dove Level 4
          For as2 I don't believe there's any other option other than to load it in as an encoded string and then decode it internally. So if you have \u0000 as in the above example you will find it doesn't work.
          var data:String = "\u0000\u1234\uabcd";
          trace(data.length) //traces 0 (zero) because the first character is a string terminator

          I think you need an encoding method like base64 in the source string and an equivalent decoder class for decoding to binary inside flash. I'm not expert on this stuff... others may know more or it could be a starting point for your research.

          In the past I've used the meychi.com classes for this type of thing. Couldn't see them online now... but there's something else here that may be useful:

          With as3 - as I understand it - there's no problem because you can load binary data.