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);
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...