A reader commented on my ScrollPane article, saying “why wouldn’t they just say that?”
I’ve found myself asking this question more and more as I’ve been diving into Flex and ActionScript 3.
For example, here is how to get the name of the root node of an XML object:
AS2:
myXML.childNodes[0].nodeName;
AS3:
myXML.name();
In AS3, nodeName has mysteriously disappeared, and the Migration Guide makes no mention of name() as its new equivalent.
In fact, the XML Class Definition for ActionScript 3 describes name() as “Gives the qualified name for the XML object.”, which led me to believe it was relevant only namespace-qualified XML tags and not useful for getting a root node’s name.
Splitting hairs, perhaps, but a good little tip nonetheless.

2 comments
Comments feed for this article
January 26, 2007 at 5:01 pm
Dan Wilday
I don’t have anything on my machine here at work to test it so I’ll just ask:
is myXML.name() actually a method or is .name a property of the XML Object?
So, am I correct in assuming that you no longer have to navigate through root node but can jump right into the child nodes of the XML?
For example to get the fourth childNode of an XML object is AS2 you’d do the following:
myXML.firstChild.childNode[3];
Am I correct in assuming they’ve killed this in AS3 allowing you to use just the following:
myXML.childNode[3];
January 29, 2007 at 10:50 am
admin
myXML.name() is a built-in method for getting the root node’s name, regardless of whether it’s namespace-qualified or not.
your assumption is almost corrected but the syntax is different in AS3:
myXML.children()[3];
There are code zealots out there who would take issue with having () and [] right next to each other, but meh, I just need this to work.