Question
reading XML in AS 3.0
Hello, i have some trouble finding information in the
'migration section' about the replacement command's
for reading XML in actionscript 3.0.
For example, the firstChild, childNodes commands don't work anymore.
I find it hard to understand the help files about xml and don't know how to do it the proper way.
If i would read this xml (for building a drop down menu) example from kirupa.com
<?xml version="1.0"?>
<menu name="links">
<menu name="macromedia">
<item name="flash" action="gotoURL" variables=" http://www.macromedia.com/software/flash"/>
<item name="dreamweaver" action="gotoURL" variables=" http://www.macromedia.com/software/dreamweaver"/>
<item name="fireworks" action="gotoURL" variables=" http://www.macromedia.com/software/fireworks"/>
</menu>
<menu name="kirupa">
<item name="home" action="gotoURL" variables=" http://www.kirupa.com"/>
<item name="forums" action="gotoURL" variables=" http://www.kirupaforum.com/forums/index.php"/>
<menu name="tutorials">
<item name="actionscript" action="gotoURL" variables=" http://www.kirupa.com/developer/actionscript/index.htm"/>
<item name="photoshop" action="gotoURL" variables=" http://www.kirupa.com/photoshop/index.htm"/>
<item name="web" action="gotoURL" variables=" http://www.kirupa.com/web/index.htm"/>
</menu>
</menu>
<item name="google" action="gotoURL" variables=" http://www.google.com"/>
</menu>
I have this so far..:
var myXML:XML = new XML();
var XML_URL:String = "menu1.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(event:Event):void
{
myXML = XML(myLoader.data);
trace(myXML.children());
trace("Data loaded.");
}
Is there some more clear information about the new way of reading XML ?
Or do i also need to rewrite the xml code to a different format?
for reading XML in actionscript 3.0.
For example, the firstChild, childNodes commands don't work anymore.
I find it hard to understand the help files about xml and don't know how to do it the proper way.
If i would read this xml (for building a drop down menu) example from kirupa.com
<?xml version="1.0"?>
<menu name="links">
<menu name="macromedia">
<item name="flash" action="gotoURL" variables=" http://www.macromedia.com/software/flash"/>
<item name="dreamweaver" action="gotoURL" variables=" http://www.macromedia.com/software/dreamweaver"/>
<item name="fireworks" action="gotoURL" variables=" http://www.macromedia.com/software/fireworks"/>
</menu>
<menu name="kirupa">
<item name="home" action="gotoURL" variables=" http://www.kirupa.com"/>
<item name="forums" action="gotoURL" variables=" http://www.kirupaforum.com/forums/index.php"/>
<menu name="tutorials">
<item name="actionscript" action="gotoURL" variables=" http://www.kirupa.com/developer/actionscript/index.htm"/>
<item name="photoshop" action="gotoURL" variables=" http://www.kirupa.com/photoshop/index.htm"/>
<item name="web" action="gotoURL" variables=" http://www.kirupa.com/web/index.htm"/>
</menu>
</menu>
<item name="google" action="gotoURL" variables=" http://www.google.com"/>
</menu>
I have this so far..:
var myXML:XML = new XML();
var XML_URL:String = "menu1.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(event:Event):void
{
myXML = XML(myLoader.data);
trace(myXML.children());
trace("Data loaded.");
}
Is there some more clear information about the new way of reading XML ?
Or do i also need to rewrite the xml code to a different format?