All pastes #981191 Raw Edit

Untitled

public text v1 · immutable
·published 2008-04-11 16:32 UTC
rendered paste body
var items = _root.ifob_xml.firstChild.firstChild.childNodes;
var myClipsArray = new Array(); //New array to hold all the clips you create
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_count = 0;
	var side_spacing = 170;
	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);
		myClipsArray.push(item_mc); //add each item created to the array
		item_mc._x = x;
		item_mc._y = curHeight;
		
		// Dynamic Symbols for Doc Loop
		item_mc.txtDocTitle.wordWrap = true;
		item_mc.txtDocTitle.autoSize = "center";
		item_mc.txtDocTitle.width = 548;
		item_mc.txtDocTitle.antiAliasType = "advanced";
		item_mc.txtDocTitle.gridFitType = "subpixel";
		item_mc.txtDocTitle.sharpness = 100;
		item_mc.txtDocTitle.font = "Arial";
		item_mc.txtDocTitle.text = docs.childNodes[i].attributes.title;
		item_mc.iurl = docs.childNodes[i].attributes.file;

		// Format Settings for Intro Copy
		item_mc.txtDocIntro.wordWrap = true;
		item_mc.txtDocIntro.width = 548;
		item_mc.txtDocIntro.autoSize = "center";
		item_mc.txtDocIntro.html = true;
		item_mc.txtDocIntro.antiAliasType = "advanced";
		item_mc.txtDocIntro.gridFitType = "subpixel";
		item_mc.txtDocIntro.sharpness = 100;
		item_mc.txtDocIntro.font = "Arial";
		item_mc.txtDocIntro._y = item_mc.txtDocTitle._y+item_mc.txtDocTitle._height;
		
		// If a node is empty, it wont fill the text box with "null"
		if (docs.childNodes[i].firstChild.nodeValue == null) {
			item_mc.txtDocIntro.htmlText = "";
		} else {
			item_mc.txtDocIntro.htmlText = 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;
			var curBHeight:Number = 0;
			item_mc.mcBullet._y = item_mc.txtDocIntro._height;
			
			for (var b = 0; b<lcount; b++) {
				var list_mc = item_mc.mcBullet.attachMovie("MC_Bullet", "list_mc"+list_count, list_count);
				myClipsArray.push(list_mc);
				list_mc._x = x;
				list_mc._y = curBHeight;
				list_mc.txtBullet.wordWrap = true;
				list_mc.txtBullet.width = 528;
				list_mc.txtBullet.autoSize = "center";
				list_mc.txtBullet.antiAliasType = "advanced";
				list_mc.txtBullet.gridFitType = "subpixel";
				list_mc.txtBullet.sharpness = 100;
				list_mc.txtBullet.font = "Arial";
				list_mc.txtBullet.html = true;
				list_mc.txtBullet.htmlText = list.childNodes[b].childNodes;
				curBHeight = list_mc._y+list_mc._height;
				list_count++;
			}
		} else {
			list_mc._height = 0;
		}
		curHeight = item_mc._y+item_mc._height;
		item_count++;
	}
	// Check for the a Sidebar node
	if (page.childNodes[1].nodeName == "sidebar") {
		
		// Create the Sidebar Loop if found
		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() {
				mcToolTip.gotoAndStop(1);
			};
		}
	} else {
		removeMovieClip(this.mcSide);
	}
	
	// Check for a footer Node, if available, create the footer items
	if (page.lastChild.nodeName == "footer") {
		var curFHeight:Number = 0;
		for (var f = 0; f<fcount; f++) {
			var footer_mc = item_mc.mcFooter.attachMovie("MC_itemFooter", "footer_mc"+footer_count, footer_count);
			footer_mc._x = 0;
			footer_mc._y = curFHeight;
			
			//Dynamic Text Box Assignments
			footer_mc.txtfNum.text = footer.childNodes[f].attributes.number;
			footer_mc.txtfCopy.html = true;
			footer_mc.txtfCopy.autoSize = "Center";
			footer_mc.txtfCopy.width = 528;
			footer_mc.txtfCopy.htmlText = footer.childNodes[f].firstChild;
			curFHeight = footer_mc._y+footer_mc._height;
			footer_count++;
		}
	} else {
		curFHeight = 0;
	}
	
	//Dynamic Text Box Assignments
	txtPageTitle.autoSize = "Center";
	txtPageTitle.width = 548;
	txtPageTitle.text = page.attributes.title;
	//Help Test Node and Var references
	//trace("there are "+dcount+" entries in your XML");
	//trace("there are "+lcount+" entries in your XML");
	//trace("curHeight ="curHeight);
	//trace("curFHeight ="+curFHeight);
	//trace(sidebar);
}

// Increase-Decrease the Title and Intro Copy
var myPlusSize:TextFormat = new TextFormat();
myPlusSize.size = 14;
var myNegSize:TextFormat = new TextFormat();
myNegSize.size = 12;

// Increase-Decrease the Bullet points
var myPBulletSize:TextFormat = new TextFormat();
myPBulletSize.size = 12;
var myNBulletSize:TextFormat = new TextFormat();
myNBulletSize.size = 11;

// Add Relaases for each click so it can reactivate
fSize.fontPlus.onRelease = released;
fSize.fontMinus.onRelease = released;

// Click Actions for Font Settings
fSize.fontPlus.onRelease = function() {
	changeFontSize(myPlusSize);
	changeBulletSize(myPBulletSize);
	updatePos();
	_root.scrollPane.invalidate();
};
fSize.fontMinus.onRelease = function() {
	changeFontSize(myNegSize);
	changeBulletSize(myNBulletSize);
	updatePos();
	_root.scrollPane.invalidate();
};

// Function that gets new height assignemtns, and repositions MC's
function updatePos(){
    //item_mc._x = item_mc._x;
    //item_mc._y = item_mc.txtDocIntro._y + item_mc.txtDocIntro._height;
	//item_mc._y = item_mc.txtDocIntro._y + item_mc.txtDocIntro._height;
	//item_mc._y = item_mc._y + item_mc.txtDocIntro._height;
	//list_mc._y = list_mc.txtBullet._y + list_mc.txtBullet._height;
	//item_mc._y = curHeight + curBHeight;
	//list_mc._y = curBHeight;
	//item_mc._y = curHeight;
}

function getHeight(){
	for (u:Number=0; u<myClipsArray.length;u++) {;
    	myClipsArray[u].txtDocIntro._height;
		//trace("item_mc height = "+myClipsArray[u]);
	}
}
getHeight();

// Function which recieves the new TextFormat for Font settings
function changeFontSize(newTF:TextFormat) {
	for (z:Number=0; z<myClipsArray.length;z++) {;
		myClipsArray[z].txtDocIntro.setTextFormat(newTF);
		myClipsArray[z].txtDocTitle.setTextFormat(newTF);
	}
}

// Function which recieves the new TextFormat for Font settings
function changeBulletSize(newTBF:TextFormat) {
	for (w:Number=0; w<myClipsArray.length;w++) {;
		myClipsArray[w].txtBullet.setTextFormat(newTBF);
	}
}

// Re-initialize the Scrollpane per MovieClip
_root.scrollPane.invalidate();