XML class
213
When
sendAndLoad()
is executed, the XML object property
loaded
is set to
false
. When
the XML data finishes downloading, the
loaded
property is set to
true
if the data
successfully loads and the
onLoad
event handler is invoked. The XML data is not parsed until
it is completely downloaded. If the XML object previously contained any XML trees, they are
discarded.
Example
The following example includes ActionScript for a simple e-commerce storefront application.
The
XML.sendAndLoad()
method transmits an XML element that contains the user’s name
and password and uses an
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 = myOnLoad;
my_xml.sendAndLoad("http://www.flash-mx.com/mm/login_xml.cfm",
myLoginReply_xml);
function myOnLoad(success) {
if (success) {
if ((myLoginReply_xml.firstChild.nodeName == "packet") &&
(myLoginReply_xml.firstChild.attributes.success == "true")) {
gotoAndStop("loggedIn");
} else {
gotoAndStop("loginFailed");
}
} else {
gotoAndStop("connectionFailed");
}
}
See also
XML.send()
,
XML.load()
,
XML.loaded
,
XML.onLoad
Содержание FLASH MEDIA SERVER 2
Страница 1: ...Server Side ActionScript Language Reference...
Страница 4: ...4 Contents...
Страница 228: ...228 Server Side ActionScript Language Reference...
Страница 234: ...234 Server Side Information Objects...