4 Replies Latest reply on Nov 17, 2006 4:52 AM by rohai

    sending to and receiving data from server side script

      Back to theory...I want to send variables (values) to server side script. Server side script receives them as querystrings.It uses them to collect the right data from database and then creates XML. Flash then reads the XML

      In Flash the values are sent from one swf and xml is loaded into other swf, which is loaded into the swf, from which the values are sent.

      I'd appriciate if someone could tell me, how to do that? Do there have to be involved any event handlers? I don't need a code, just a short summary. THX.

      ps-i'm working on that now for 7 days and no progress. PLEASE, help
        • 1. sending to and receiving data from server side script
          Calwen Level 1
          Hi Rohai,

          You need to use the method sendAndLoad in order to do that, and yes you will need an event handler to be able to detect when the data is sent back and loaded in your listener LodVars object. Just check "sendAndLoad" in the help file of Flash 8 it should put you on the good track.
          • 2. Re: sending to and receiving data from server side script
            rohai Level 1
            Hi, Calwen,

            THX for your reply. So far I did all that. I know how to send values to server side script (SSS). I know how to recieve and load xml into flash. The problem is I don't know how to combine those two actions. I have one main swf into which all others are loaded. This main swf sends values to SSS and new loaded swf loads the xml, created by SSS. The problem is the XML doesn't get loaded. In loaded swf I use a standard XML actions (creating a xml object, onLoad function, etc.). Is there an event handler, listener, which checks when the SSS prepares the XML and sends it to Flash?
            • 3. Re: sending to and receiving data from server side script
              Yeah, it's the sendAndLoad method of a loadVars object. This method both sends and receives data from a server-side script. It can even load that data directly into an XML object. I know you didn't ask for code, but it's the easiest way to illustrate.

              // Create your XML and loadVars objects
              var senderObj:loadVars = new loadVars();
              var _xml:XML = new XML();

              //Set the values of the variables you want to send as properties of loadVars
              senderObj.Variable1 = Value1;
              senderObj.Variable2 = Value2;
              senderObj.Variable3 = Value3;

              //Now send and receive data, using _xml as target
              senderObj.sendAndLoad(_url_of_script, _xml, "POST");
              ....more code...

              At this point, the XML sent by the SSS is stored in the _xml variable. You can setup an .onLoad event handler for senderObj to pass that data to your other SWF - it triggers once the data has been received and verified (in this case, as XML, since it's trying to put it in an XML object).
              • 4. Re: sending to and receiving data from server side script
                rohai Level 1
                RemyR, THX for your reply. One more question. If I have a XML object in loaded swf, then the target to xml in sendAndLoad should be mc._xml? I did try something like you suggested but I always did get the unsuccessful onLoad function result. I send values from main swf and load it into loaded swf. Can I send/show you the code for inspection?THX again