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

Create successful ePaper yourself

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

// <br />

// <br />

// <br />

// <br />

// <br />

firstChild (XMLNo<strong>de</strong>.firstChild, propriété)<br />

public firstChild : XMLNo<strong>de</strong> [lecture seule]<br />

Evalue l'objet XML spécifié et fait référence au premier enfant dans la liste <strong>de</strong>s enfants <strong>de</strong><br />

nœud parent. Cette propriété est null si le nœud n'a pas d'enfants. Cette propriété est<br />

un<strong>de</strong>fined si le nœud est un nœud <strong>de</strong> texte. Il s'agit d'une propriété en lecture seule qui ne<br />

peut pas être utilisée pour manipuler les nœuds enfants ; utilisez les métho<strong>de</strong>s<br />

appendChild(), insertBefore() et removeNo<strong>de</strong>() pour manipuler les nœuds enfants.<br />

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

Exemple<br />

L'exemple suivant indique comment utiliser XML.firstChild pour parcourir les enfants d'un<br />

nœud :<br />

// create a new XML document<br />

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

// create a root no<strong>de</strong><br />

var rootNo<strong>de</strong>:XMLNo<strong>de</strong> = doc.createElement("rootNo<strong>de</strong>");<br />

// create three child no<strong>de</strong>s<br />

var ol<strong>de</strong>st:XMLNo<strong>de</strong> = doc.createElement("ol<strong>de</strong>st");<br />

var middle:XMLNo<strong>de</strong> = doc.createElement("middle");<br />

var youngest:XMLNo<strong>de</strong> = doc.createElement("youngest");<br />

// add the rootNo<strong>de</strong> as the root of the XML document tree<br />

doc.appendChild(rootNo<strong>de</strong>);<br />

// add each of the child no<strong>de</strong>s as children of rootNo<strong>de</strong><br />

rootNo<strong>de</strong>.appendChild(ol<strong>de</strong>st);<br />

rootNo<strong>de</strong>.appendChild(middle);<br />

rootNo<strong>de</strong>.appendChild(youngest);<br />

// use firstChild to iterate through the child no<strong>de</strong>s of rootNo<strong>de</strong><br />

for (var aNo<strong>de</strong>:XMLNo<strong>de</strong> = rootNo<strong>de</strong>.firstChild; aNo<strong>de</strong> != null; aNo<strong>de</strong> =<br />

aNo<strong>de</strong>.nextSibling) {<br />

trace(aNo<strong>de</strong>);<br />

}<br />

XMLNo<strong>de</strong> 1365

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

Saved successfully!

Ooh no, something went wrong!