
XMLNode 1325
insertBefore (XMLNode.insertBefore method)
public insertBefore(newChild:XMLNode, insertPoint:XMLNode) : Void
Inserts a
newChild
node into the XML object's child list, before the
insertPoint
node. If
insertPoint
is
not
a child of the XMLNode object, the insertion fails.
Availability:
ActionScript 1.0; Flash Player 5
Parameters
newChild
:XMLNode
- The XMLNode object to be inserted.
insertPoint
:XMLNode
- The XMLNode object that will follow the
newChild
node after the
method is invoked.
Example
The following inserts a new XML node between two existing nodes:
var my_xml:XML = new XML("<a>1</a>\n<c>3</c>");
var insertPoint:XMLNode = my_xml.lastChild;
var newNode:XML = new XML("<b>2</b>\n");
my_xml.insertBefore(newNode, insertPoint);
trace(my_xml);
See also
XML
,
cloneNode (XMLNode.cloneNode method)
lastChild (XMLNode.lastChild property)
public lastChild : XMLNode [read-only]
An XMLNode value that references the last child in the node's child list. The
XML.lastChild
property is
null
if the node does not have children. This property cannot be used to
manipulate child nodes; use the
appendChild()
,
insertBefore()
, and
removeNode()
methods to manipulate child nodes.
Availability:
ActionScript 1.0; Flash Player 5
Example
The following example uses the
XML.lastChild
property to iterate through the child nodes
of an XML node, beginning with the last item in the node's child list and ending with the first
child of the node's child list:
// create a new XML document
var doc:XML = new XML();
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...