19.13. Sending XML
Problem
You want to send XML data to a server-side script.
Solution
In almost all cases,
use XML.sendAndLoad( )
,
as discussed in Recipe 19.14. In some
isolated cases, use
the XML.send( )
method.
Discussion
XML is normally used to transfer data to and from applications, and in this case, Flash movies. Therefore, it is quite unusual that you would want to create XML objects in your Flash movies for use within Flash alone. Instead, you generally load XML data from another source, create XML data in Flash for the purposes of sending to another application, or both. In this recipe, we want to look at sending XML data from Flash to another application. There are lots of reasons to do this. For example, in a Flash game you might want to use XML to send the user’s name and score to the server. At other times, you might want to send XML packets to a server-side script to invoke server-side functionality. This is a process that is sometimes called a remote procedure call (RPC), and it can use XML to send the function invocation information (function name, parameters, etc.) to the server. So as you can see, the possibilities for sending XML to the server are quite diverse.
ActionScript actually includes two methods for sending XML data:
send( )
and sendAndLoad( )
.
The original idea was that send( )
would be for
sending data in which no response was necessarily expected or in
which the response would be opened in a new browser window. The
sendAndLoad( )
method was intended ...
Get Actionscript Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.