452
Chapter 6: ActionScript Core Classes
Parameters
deep
A Boolean value; if set to
true
, the children of the specified XML object will be
recursively cloned.
Returns
An XMLNode object.
Description
Method; constructs and returns a new XML node of the same type, name, value, and attributes as
the specified XML object. If
deep
is set to
true
, all child nodes are recursively cloned, resulting in
an exact copy of the original object’s document tree.
The clone of the node that is returned is no longer associated with the tree of the cloned item.
Consequently,
nextSibling
,
parentNode
, and
previousSibling
all have a value of
null
. If the
deep
parameter is set to
false
, or the
my_xml
node has no child nodes,
firstChild
and
lastChild
are also
null
.
Example
The following example shows how to use the
XML.cloneNode()
method to create a copy of a
node:
// create a new XML document
var doc:XML = new XML();
// create a root node
var rootNode:XMLNode = doc.createElement("rootNode");
// create three child nodes
var oldest:XMLNode = doc.createElement("oldest");
var middle:XMLNode = doc.createElement("middle");
var youngest:XMLNode = doc.createElement("youngest");
// add the rootNode as the root of the XML document tree
doc.appendChild(rootNode);
// add each of the child nodes as children of rootNode
rootNode.appendChild(oldest);
rootNode.appendChild(middle);
rootNode.appendChild(youngest);
// create a copy of the middle node using cloneNode()
var middle2:XMLNode = middle.cloneNode(false);
// insert the clone node into rootNode between the middle and youngest nodes
rootNode.insertBefore(middle2, youngest);
trace(rootNode);
// output (with line breaks added):
// <rootNode>
// <oldest />
// <middle />
// <middle />
// <youngest />
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...