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

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

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

Example<br />

The following example shows how the namespaceURI property is affected by the use of<br />

prefixes. A directory contains a SWF file <strong>and</strong> an XML file. The XML file, named<br />

SoapSample.xml contains the following tags.<br />

<br />

<br />

<br />

<br />

San Francisco<br />

<br />

<br />

<br />

The source for the SWF file contains the following script (note the comments for the Output<br />

strings). For tempNode, which represents the w:GetTemperature node, the value of<br />

namespaceURI is defined in the soap:Body tag. For soapBodyNode, which represents the<br />

soap:Body node, the value of namespaceURI is determined by the definition of the soap<br />

prefix in the node above it, rather than the definition of the w prefix that the soap:Body node<br />

contains.<br />

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

xmlDoc.load("SoapSample.xml");<br />

xmlDoc.ignoreWhite = true;<br />

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

{<br />

var tempNode:XMLNode = xmlDoc.childNodes[0].childNodes[0].childNodes[0];<br />

trace("w:GetTemperature namespaceURI: " + tempNode.namespaceURI);<br />

// Output: ... http://www.example.com/weather<br />

}<br />

trace("w:GetTemperature soap namespace: " +<br />

tempNode.getNamespaceForPrefix("soap"));<br />

// Output: ... http://www.w3.org/2001/12/soap-envelope<br />

var soapBodyNode:XMLNode = xmlDoc.childNodes[0].childNodes[0];<br />

trace("soap:Envelope namespaceURI: " + soapBodyNode.namespaceURI);<br />

// Output: ... http://www.w3.org/2001/12/soap-envelope<br />

The following example uses XML tags without prefixes. It uses a SWF file <strong>and</strong> an XML file<br />

located in the same directory. The XML file, named NoPrefix.xml contains the following<br />

tags.<br />

<br />

<br />

<br />

<br />

<br />

<br />

1350 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!