4 Replies Latest reply on Feb 27, 2007 7:01 AM by stevebakh

    Array data between Flash and PHP

    stevebakh
      As the title suggests, I'm trying to find a good way of getting an ActionScript/Flash dynamic array into PHP, so I can serialize it and store it in a DB, then simply give back that same array when it's called. Are there any popular techniques? The array will always be a different size, containing different values - which is why I'd like to keep the array in tact, to minimise the amount of parameter transfers. If there's no good solution, I suppose I could pass in parameters and read them in, create an array and serialize that... but I'd much rather find a way of having my flasher serialize his own array and pass me the byte-code. Is this possible?

      PHP doesn't need to read the contents of the array, simply store it in a DB, so if there's some kind of flash method for serializing an array into bytecode that it can unserialize and read back later, that would be awesome.

      Thanks. =]

      [edit]
      I found this: http://sourceforge.net/projects/serializerclass/ a serializer class. Is this the best method?
        • 1. Re: Array data between Flash and PHP
          Pal_w_G
          I am not an expert in PHP ... but the most common way to communicate from flash to any server side script is by using loadVars object .... have a look at it.....hope that will solve your problem


          cheers
          • 2. Re: Array data between Flash and PHP
            shikozel Level 1
            The way i do it:
            PHP to flash- de-construct the array to aong string where the "|" character seperates each element in the array. than in flash i String.slice("|") the string and constract the array again. I dont know if thats the best way.
            • 3. Re: Array data between Flash and PHP
              MajiDfn
              Hi;
              I strongly recommend you to use XML for data transfer instead of array.
              You just need to make a simple xml parser and then send and load data in XML format.
              parsing xml with php is also easy.

              regards
              MajiD
              • 4. Re: Array data between Flash and PHP
                stevebakh Level 1
                Sorry, I should have explained, we already use XML for data transfers (though I personally find JSON much nicer with less overhead). So, in this project, we use XML for data transfer between flash and PHP/Database. The reason I wanted this functionality, is because the flash array, in this one case, will be completely dynamic and the PHP doesn't need to know the contents of the array at all. In fact, in this instance, PHP is just the mechanism used for storing the data. Becuase of the nature of the data, I wanted to serialize the flash array, store it in the database as Bytecode, then when the flash needs that information again, I can pass back the same bytecode, which can then be unserialized back into the original array.

                I think I've found the solution, the one I linked in the original post. I should know if it's as effective as I want it to be in the next couple of days when my flasher gives it a try. =]

                Thanks for the responses. If anyone has any other ideas, please throw them in here.