All pastes #880030 Raw Edit

Someone

public text v1 · immutable
#880030 ·published 2008-01-29 18:58 UTC
rendered paste body
var items = _root.ifob_xml.firstChild.firstChild.childNodes;
if (items[1].attributes.name == "Features and Benefits") {
	//Page Variable Declarations
	var page = items[1].childNodes[0];// Page Title
	var docs = page.firstChild;// Doc Node
	var sidebar = page.childNodes[1];// Sidebar Node
	var bar = sidebar.childNodes;
	var footer = page.lastChild;
	
	// Count Nodes to help test and get direct variable paths
	var dcount:Number = docs.childNodes.length;
	var scount:Number = sidebar.childNodes.length;
	var fcount:Number = footer.childNodes.length;
	
	// MC Duplicating Paramters
	var item_count = 0;
	var side_spacing = 170;
	var side_count = 0;
	var footer_spacing = 15;
	var footer_count = 0;
	
	
	// Create the Document Loop
	for (var i = 0; i<dcount; i++) {
		var item_mc = mcDocs.attachMovie("MC_Docs", "item_mc"+item_count, item_count);
		item_mc._x = x;
		item_mc._y = item_count*curHeight;
		//curHeight = item_mc._y;
		item_count++;
		
		// Dynamic Symbols for Doc Loop
		item_mc.txtDocTitle.text = docs.childNodes[i].attributes.title;
		item_mc.iurl = docs.childNodes[i].attributes.file;
		item_mc.txtDocIntro.wordWrap = true;
		item_mc.txtDocIntro.width = 548;
		item_mc.txtDocIntro.autoSize = "center";
		
		// If a node is empty, it wont fill the text box with "null"
		if (docs.childNodes[i].firstChild.nodeValue == null){
			item_mc.txtDocIntro.text = "";
		} else {
			item_mc.txtDocIntro.text = docs.childNodes[i].firstChild;
		}
		
		// If a Doc item has Bullets, loop and create the MC
		if (docs.childNodes[i].hasChildNodes()){
			var list_count = 0;
			var list = docs.childNodes[i].childNodes[1];
			var lcount:Number = list.childNodes.length;
			
			for (var b = 0; b<lcount; b++) {
				var list_mc = this.item_mc.mcBullet.attachMovie("MC_Bullet", "list"+list_count, list_count);
				curBHeight = this.list_mc._height;
				list_mc._x = x;
				list_mc._y = list_count*curBHeight;
				list_count++;
			
				//Dynamic Text Box Assignments 
				list_mc.txtBullet.htmlText = list.childNodes[b].childNodes;
			}
		}
		curHeight = this.item_mc._height;
	}
	
	// Create the Sidebar Loop
	for (var s = 0; s<scount; s++) { 
		var side_mc = mcSide.attachMovie("MC_SideBar", "side"+side_count, side_count);
		side_mc._y = side_count*side_spacing;
		side_count++;
		
		// Dynamic Symbols for sidebar Loop
		side_mc.txtSBItem.text = bar[s].attributes.title;
		side_mc.mcSBGfx.loadMovie(bar[s].attributes.image);
		side_mc.url = bar[s].attributes.file;
		side_mc.onRelease = released;
		
		// Variables to execute On Click for PDF Links
		side_mc.onRelease = function(){
			getURL(this.url, "_blank");
			_root.mcFile.gotoAndPlay("Fadein");
		};
		
		// Activate Rollover for Tooltips
		side_mc.onRollOver = function() {
			mcToolTip.gotoAndStop(2);
		}
		side_mc.onRollOut = function() {// hide it again
			mcToolTip.gotoAndStop(1);
		}
	}
	
	// Check for a footer Node, if available, create the footer items
	if (page.lastChild.nodeName == "footer"){
		for (var f = 0; f<fcount; f++) {
			var footer_mc = mcFooter.attachMovie("MC_itemFooter", "footer"+footer_count, footer_count);
			//footer_mc._y = footer_count*footer_spacing;
			footer_mc._y = footer_count*footer_spacing;
			footer_count++;

			//Dynamic Text Box Assignments 
			footer_mc.txtfNum.text = footer.childNodes[f].attributes.number;
			footer_mc.txtfCopy.text = footer.childNodes[f].firstChild;
		}
	}
	//Dynamic Text Box Assignments  
	txtPageTitle.text = page.attributes.title;
	
	//Help Test Node references
	//trace("there are "+dcount+" entries in your XML");
	//trace("there are "+lcount+" entries in your XML");
	trace(curHeight);
}