// *************************************************** // AUTHOR: Mike Golding // TITLE: XML File Import // DATE: 16/3/2003 // *************************************************** // *************************************************** // Recurse and return node depth within the tree // *************************************************** function XMLNode_getDepth() { var count = 1; if (this.parentNode != null) { return count + this.parentNode.getDepth(); } else{ return count; } } // *************************************************** // Recurse and duplicate the movie clip to disply node values // *************************************************** function XMLNode_displayNodeClips(){ //INCREASE NUMBER var vNodeCount = _root.vNodeCount++; //DUPLICATE MOVIE _root.nodeClip.duplicateMovieClip("nodeClip" + vNodeCount, vNodeCount); //POSITION NODE CLIP _root["nodeClip" + vNodeCount]._x = 55 + this.getDepth() * 18; _root["nodeClip" + vNodeCount]._y = 1 + _root.vNodeCount * 20; //CHECK NODE TYPE FOR NODE OR TEXT if (this.nodeType == 1) { _root["nodeClip" + vNodeCount].titlefield = "<" + this.nodeName + ">"; _root["nodeClip" + vNodeCount].bulletfield = ">"; } else { _root["nodeClip" + vNodeCount].titlefield = this.nodeValue; _root["nodeClip" + vNodeCount].bulletfield = "#"; } //RECURSE IF MORE CHILD NODES EXIST if (this.childNodes.length > 0) { for (var i = 0; i < this.childnodes.length; i++) { this.childnodes[i].displayNodeClips(); } } } // *************************************************** // Function that runs when the XML file has loded // *************************************************** function onLoad(vResult) { this.firstChild.displayNodeClips(); } // *************************************************** // Main // *************************************************** //GLOBAL VARIABLES _root.vNodeCount = 0; _root.getDepth = 0; //PROTOTYPES XMLNode.prototype.getDepth = XMLNode_getDepth; XMLNode.prototype.displayNodeClips = XMLNode_displayNodeClips; //CREATE XML OBJECT XMLdata = new XML(); //FORCE WHITE SPACE TO BE IGNORED XMLdata.ignoreWhite = true; //ASSIGN FUNCTION TO RUN WHEN FILE IS LOADED XMLdata.onLoad = onLoad; //LOAD XML FILE XMLdata.load("mg1.xml"); fscommand("allowscale", "false"); stop ();