03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

onLoad (XML.onLoad h<strong>and</strong>ler)<br />

onLoad = function(success:Boolean) {}<br />

Invoked by Flash Player when an XML document is received from the server. If the XML<br />

document is received successfully, the success parameter is true. If the document was not<br />

received, or if an error occurred in receiving the response from the server, the success<br />

parameter is false. The default, implementation of this method is not active. To override the<br />

default implementation, you must assign a function that contains custom actions.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 5<br />

Parameters<br />

success:Boolean - A Boolean value that evaluates to true if the XML object is successfully<br />

loaded with a XML.load() or XML.sendAndLoad() operation; otherwise, it is false.<br />

Example<br />

The following example includes <strong>ActionScript</strong> for a simple e-commerce storefront application.<br />

The sendAndLoad() method transmits an XML element that contains the user's name <strong>and</strong><br />

password, <strong>and</strong> uses an XML.onLoad h<strong>and</strong>ler to process the reply from the server.<br />

var login_str:String = "";<br />

var my_xml:XML = new XML(login_str);<br />

var myLoginReply_xml:XML = new XML();<br />

myLoginReply_xml.ignoreWhite = true;<br />

myLoginReply_xml.onLoad = function(success:Boolean){<br />

};<br />

if (success) {<br />

if ((myLoginReply_xml.firstChild.nodeName == "packet") &&<br />

(myLoginReply_xml.firstChild.attributes.success == "true")) {<br />

gotoAndStop("loggedIn");<br />

} else {<br />

gotoAndStop("loginFailed");<br />

}<br />

} else {<br />

gotoAndStop("connectionFailed");<br />

}<br />

my_xml.sendAndLoad("http://www.flash-mx.com/mm/login_xml.cfm",<br />

myLoginReply_xml);<br />

1326 <strong>ActionScript</strong> classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!