
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
139
XML.onLoad()
my_xml.onLoad = function (success) {}
Invoked when an XML document is received from the server. If the XML document is received successfully, the
success parameter is true. If the document was not received, or if an error occurred in receiving the response from
the server, the
success parameter is false. The default implementation of this method is not active. To override
the default implementation, you must assign a function that contains custom actions.
Availability
Flash Media Server 2
Parameters
success A boolean value; true if the XML object successfully loads with an XML.load() or XML.sendAndLoad()
operation; otherwise,
false.
Example
The following example includes ActionScript for a simple e-commerce storefront application. The
sendAndLoad()
method transmits an XML element that contains the user’s name and password and uses an
XML.onLoad() handler
to process the reply from the server.
var login_str = "<login username=\""+username_txt.text+"\"
password=\""+password_txt.text+"\" />";
var my_xml = new XML(login_str);
var myLoginReply_xml = new XML();
myLoginReply_xml.ignoreWhite = true;
myLoginReply_xml.onLoad = function(success){
if (success) {
if ((myLoginReply_xml.firstChild.nodeName == "packet") &&
(myLoginReply_xml.firstChild.attributes.success == "true")) {
gotoAndStop("loggedIn");
} else {
gotoAndStop("loginFailed");
}
} else {
gotoAndStop("connectionFailed");
}
};
my_xml.sendAndLoad("http://www.flash-mx.com/mm/login_xml.cfm", myLoginReply_xml);
See also
XML.load(), XML.sendAndLoad()
XML.parentNode
my_xml.parentNode
Read-only; an XMLNode value that references the parent node of the specified XML object or returns null if the
node has no parent. This property cannot be used to manipulate child nodes; use the
appendChild(),
insertBefore(), and removeNode() methods instead.
Availability
Flash Media Server 2
Example
The following example creates an XML packet and writes the parent node of the
username node to the log file:
Commenti su questo manuale