Sending XML in Flash

Written on January 19, 2007 – 8:33 pm | by John |

So you want to send XML in flash? There are some things that you need to watch out for.

ONE: We're working with the XML object.

Actionscript:
  1. var myXML:XML = new XML();
  2. var theXML:String = "";
  3. myXML.parseXML(theXML);

TWO: If you are are expecting a response, use the sendAndLoad() method. You will need to create an XML object to catch the response from your server. The sendAndLoad() method takes 3 parameters:

url - where to send the XML

target - The XML object that receives the downloaded data (this can also be a LoadVars object depending on the data that is returned from the service)

method - GET or POST HTTP protocol. This parameter is optional.

Actionscript:
  1. var responseXML:XML;
  2. myXML.sendAndLoad("http://www.realeyesmedia.com/", responseXML, "POST");

Now what happens if you don't expect a response from the server? Do you use send()? Not if you don't want the page to redirect.

The send() method can GET or POST your XML data to a page, but your Flash piece page is expected to redirect. So, what do you do. Well, just use sendAndLoad() and create a dummy XML object for the 2nd parameter. You won't receive a response, but the XML will be sent to the server just the same.

powered by performancing firefox

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • description
  • ThisNext
  • MisterWong
  • Wists
  • Facebook
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Related Posts

Put your related posts code here
Find entries :

Want to subscribe?

  Subscribe in a reader or,
Subscribe via email:

About me

I'm a senior developer at RealEyes Media, Adobe Certified Instructor and Adobe Certified Professional. Here you'll get my ideas and experience Flex, Flash, ColdFusion and related technologies as well as some generally off the wall stuff.