Use delete instead of removeNode() in AS3 -- was (Having trouble with removeNode() in AS3 preview)
I'm working on a little app that tracks user activity and saves the data locally, so the user can go back and resume where they left off. To keep track of where they position various movieclips, I'm using an xml object with a node for each movieclip and it's position. Fairly simple, really.
What's been frustrating me, though, is the removeNode method of the XML class. I have yet to successfully get it to work for me. I've also had trouble finding much documentation on removeNode() in AS3. In the end, I've resorted to delete, which works like a charm.
So, instead of
myXML.myNode.removeNode();
I'm using
delete myXML.mynode;
Comments
You're not finding documentation on it because it does not exist. removeNode was a method of the original XML(Node) class (now flash.xml.XMLDocument and flash.xml.XMLNode). For E4X you use delete. http://livedocs.adobe.com/flex/201/langref/operators.html#delete_(XML)
Posted by: senocular | April 13, 2007 02:26 PM
Ah! That would explain it. I was beginning to wonder if the docs I was reading for AS3 hadn't been updated...and I was right :-)
removeNode() was listed in the methods, but without any details, in the docs for AS3 I was reading.
Posted by: Kristin | April 13, 2007 02:29 PM
:) Currently the Flex docs are the best place to keep up to date with AS3. Once Flash CS3 is released, that will have its own set of livedocs for AS3 (which will also cover FL-specific classes etc.)
Posted by: senocular | April 13, 2007 03:02 PM
Unfortunately, it's in the CS3 docs, that shipped with today's download:
Quote:
removeNode () method
public function removeNode():void
Language version: ActionScript 3.0
Player version: Flash Player 9
Removes the specified XML object from its parent. Also deletes all descendants of the node.
Posted by: Kristin | April 17, 2007 12:46 AM