EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 657

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
About XML 657
loginXML.sendAndLoad("http://www.flash-mx.com/mm/main.cfm",
loginReplyXML);
};
You can test this code by using a user name of JeanSmith and the password VerySecret. The
first section of the script generates the following XML when the user clicks the login button:
<login username="JeanSmith" password="VerySecret" />
The server receives the XML, generates an XML response, and sends it back to the SWF file.
If the password is accepted, the server responds with the following:
<LOGINREPLY STATUS="OK" SESSION="4D968511" />
This XML includes a session attribute that contains a unique, randomly generated session
ID, which is used in all communications between the client and server for the rest of the
session. If the password is rejected, the server responds with the following message:
<LOGINREPLY STATUS="FAILURE" />
The loginreply XML node must load into a blank XML object in the SWF file. The
following statement creates the XML object
loginreplyXML to receive the XML node:
// Construct an XML object to hold the server's reply
var loginReplyXML:XML = new XML();
loginReplyXML.onLoad = function(success:Boolean) {
The second statement in this ActionScript defines an anonymous (inline) function, which is
called when the
onLoad event triggers.
The login button (
login_btn instance) is used to send the user name and password as XML
to the server and to load an XML response back into the SWF file. You can use the
sendAndLoad() method to do this, as shown in the following example:
loginXML.sendAndLoad("http://www.flash-mx.com.com/mm/main.cfm",
loginReplyXML);

Table of Contents

Related product manuals