[ Team LiB ] |
Recipe 19.13 Sending XML19.13.1 ProblemYou want to send XML data to a server-side script. 19.13.2 SolutionIn almost all cases, use XML.sendAndLoad( ), as discussed in Recipe 19.14. In some isolated cases, use the XML.send( ) method. 19.13.3 DiscussionXML 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 for those times when you wanted to send data and also receive a response from the server. However, the send( ) method seems to function other than expected. The send( ) method relies on a mechanism in the web browser to work. However, only one browser supports that functionality. Therefore, the send( ) method will not work in the Test Player, the Standalone Player, Projectors, or in many web browsers. For these reasons, it is suggested that you use the sendAndLoad( ) method even when you don't expect a server response. 19.13.4 See Also |
[ Team LiB ] |