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.

Valeur renvoyée<br />

String - Préfixe associé au nom d'espace spécifié.<br />

Exemple<br />

L'exemple suivant crée un objet XML très simple et renvoie le résultat <strong>de</strong> l'appel à la métho<strong>de</strong><br />

getPrefixForNamespace(). Le nœud XML Outer, représenté par la variable xmlDoc, définit<br />

un URI d'espace <strong>de</strong> nom et l'affecte au préfixe exu. Le fait d'appeler la métho<strong>de</strong><br />

getPrefixForNamespace() avec l'URI <strong>de</strong> l'espace <strong>de</strong> nom défini (« http://<br />

www.example.com/util ») renvoie le préfixe exu, mais l'appel <strong>de</strong> cette métho<strong>de</strong> avec un URI<br />

non défini ("http://www.example.com/other") renvoie null. Le premier nœu<strong>de</strong>xu:Child,<br />

représenté par la variable child1, définit aussi un URI d'espace <strong>de</strong> nom (« http://<br />

www.example.com/child »), mais ne l'affecte pas à un préfixe. Le fait d'appeler cette métho<strong>de</strong><br />

sur un URI d'espace <strong>de</strong> nom défini mais non affecté, renvoie une chaîne vi<strong>de</strong>.<br />

function createXML():XMLNo<strong>de</strong> {<br />

var str:String = ""<br />

+ ""<br />

+ ""<br />

+ ""<br />

+ "";<br />

return new XML(str).firstChild;<br />

}<br />

var xmlDoc:XMLNo<strong>de</strong> = createXML();<br />

trace(xmlDoc.getPrefixForNamespace("http://www.example.com/util")); //<br />

output: exu<br />

trace(xmlDoc.getPrefixForNamespace("http://www.example.com/other")); //<br />

output: null<br />

var child1:XMLNo<strong>de</strong> = xmlDoc.firstChild;<br />

trace(child1.getPrefixForNamespace("http://www.example.com/child")); //<br />

output: [empty string]<br />

trace(child1.getPrefixForNamespace("http://www.example.com/other")); //<br />

output: null<br />

Voir également<br />

getNamespaceForPrefix (XMLNo<strong>de</strong>.getNamespaceForPrefix, métho<strong>de</strong>), namespaceURI<br />

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

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

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

Saved successfully!

Ooh no, something went wrong!