03.07.2013 Views

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Exemple<br />

L'exemple suivant montre l'emploi <strong>de</strong> la métho<strong>de</strong> onHTTPStatus d'ai<strong>de</strong> au débogage.<br />

L'exemple rassemble <strong>de</strong>s co<strong>de</strong>s <strong>de</strong> statut HTTP et affecte leur valeur et type à une instance <strong>de</strong><br />

l'objet XML (notez que cet exemple crée les membres this.httpStatus <strong>de</strong> l'instance et<br />

this.httpStatusType au cours <strong>de</strong> l'exécution). La métho<strong>de</strong> onData les emploie pour<br />

retracer les informations sur la réponse HTTP qui pourrait être utile au débogage.<br />

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

myXml.onHTTPStatus = function(httpStatus:Number) {<br />

this.httpStatus = httpStatus;<br />

if(httpStatus < 100) {<br />

this.httpStatusType = "flashError";<br />

}<br />

else if(httpStatus < 200) {<br />

this.httpStatusType = "informational";<br />

}<br />

else if(httpStatus < 300) {<br />

this.httpStatusType = "successful";<br />

}<br />

else if(httpStatus < 400) {<br />

this.httpStatusType = "redirection";<br />

}<br />

else if(httpStatus < 500) {<br />

this.httpStatusType = "clientError";<br />

}<br />

else if(httpStatus < 600) {<br />

this.httpStatusType = "serverError";<br />

}<br />

}<br />

myXml.onData = function(src:String) {<br />

trace(">> " + this.httpStatusType + ": " + this.httpStatus);<br />

if(src != un<strong>de</strong>fined) {<br />

this.parseXML(src);<br />

this.loa<strong>de</strong>d = true;<br />

this.onLoad(true);<br />

}<br />

else {<br />

this.onLoad(false);<br />

}<br />

}<br />

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

}<br />

myXml.load("http://weblogs.macromedia.com/mxna/xml/<br />

rss.cfm?query=byMostRecent&languages=1");<br />

1348 Chapitre 2: Classes <strong>ActionScript</strong>

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

Saved successfully!

Ooh no, something went wrong!