Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

root.as

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// adds a root property that references the document root
// element of an XML instance through any of its nodes
XMLNode.prototype.root = function(){
	var r = this;
	while(r.parentNode) r = r.parentNode;
	return r.firstChild;
}
XMLNode.prototype.addProperty("root",
	function(){
		return this.root();
	},
	function(n){
		r = this.root();
		r.parentNode.appendChild(n);
		r.removeNode();
	}
);