# squirrelFinder + header

**URL:** <https://forum.kirupa.com/t/squirrelfinder-header/142212>\
**Category:** Uncategorized\
**Created:** [March 26, 2005, 3:49pm UTC](https://forum.kirupa.com/t/squirrelfinder-header/142212 "2005-03-26T15:49:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Macro\_design](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Macro\_design](https://forum.kirupa.com/u/Macro_design)\
**Post date:** [March 26, 2005, 3:49pm UTC](https://forum.kirupa.com/t/squirrelfinder-header/142212/1 "2005-03-26T15:49:23Z")

</div>

Hi,

I’m trying to modify the squirrelFinder, by adding a header. So I’ve added a new textbox with the instanceName: “header\_txt” in the: “infobox\_mc” movieClip. So now theres two textboxes in the: “infobox\_mc” movieClip: “header\_txt” and “content\_txt”.

The problem is, that it loads the text in my: “content\_txt” textbox, and not my: “header\_txt” textbox.

Anybody got a solution to this?

My AS:  
[AS]// DisplayInfo is used when an item is pressed  
// it hides the menu\_mc (and the buttons) and shows the  
// infobox\_mc, assigning the text of the selected button  
// to the textbox within.  
function DisplayInfo(){  
menu\_mc.\_visible = false;  
infobox\_mc.\_visible = true;  
infobox\_mc.content\_txt.text = this.location\_text;  
infobox\_mc.content\_txt.text = this.header\_text;  
}  
// close\_btn is in infobox\_mc ands restores  
// the menu (clearing the info text and hiding itself as well)  
infobox\_mc.close\_btn.onRelease = function(){  
menu\_mc.\_visible = true;  
infobox\_mc.\_visible = false;  
infobox\_mc.content\_txt.text = “”;  
infobox\_mc.header\_txt.text = “”;  
}  
infobox\_mc.\_visible = false; // start the info box hidden

// define basic variables for setting up the menu  
var item\_spacing = 28; // how far menu items are spaced veritcally  
var item\_count = 0; // counts menu items as they are added from the XML  
// CreateMenu creates a menu based on the XML object passed.  
// It loops through all the items with a for loop adding clips to the menu\_mc  
// movieclip on the timeline, defining the appropriate text where needed  
function CreateMenu(menu\_xml){  
// start with the first item in the XML  
var items = menu\_xml.firstChild.firstChild.childNodes; // menu -\> menuitems -\> child nodes array  
for (var i=0; i\<items.length; i++) {  
// only continue if the type of this item is a squirrel  
if (items\*.attributes.type == “squirrel”) {  
// create variables for our elements  
var species = items\*.firstChild; // same as items\*.childNodes[0]  
var location = items\*.childNodes[1]; // second child node  
var header = items\*.childNodes[2];

// Create a menu item movie clip in the menu\_mc instance on the main timeline  
// for each item element offsetting each additional further down the screen  
var item\_mc = menu\_mc.attachMovie(“menu\_item”,“item”+item\_count, item\_count);  
item\_mc.\_y = item\_count \* item\_spacing;  
item\_count++;

// assign text using nodeValue to get the text  
// from the text nodes and CDATA sections  
item\_mc.species\_txt.text = species.firstChild.nodeValue;  
item\_mc.main\_btn.location\_text = location.firstChild.nodeValue;  
item\_mc.main\_btn.header\_text = header.firstChild.nodeValue;  
// set the onRelease of the item button to the DisplayInfo function  
item\_mc.main\_btn.onRelease = DisplayInfo;  
}  
}  
}  
// CreateMenu2 uses nextSibling and a do-while loop to  
// access all the items in the XML. It functions exactly the  
// same as CreateMenu, just with a different technique (NOT USED)  
function CreateMenu2(menu\_xml){  
// start with the first item in the XML  
var currItem = menu\_xml.firstChild.firstChild.firstChild; // menu -\> menuitems -\> first item  
do {  
// only continue if the type of this item is a squirrel  
if (items\*.attributes.type == “squirrel”) {  
// create variables for our elements  
var species = currItem.firstChild;  
var location = species.nextSibling;  
var header = species.nextSibling;

// Create a menu item movie clip in the menu\_mc instance on the main timeline  
// for each item element offsetting each additional further down the screen  
var item\_mc = menu\_mc.attachMovie(“menu\_item”,“item”+item\_count, item\_count);  
item\_mc.\_y = item\_count \* item\_spacing;  
item\_count++;

// assign text using nodeValue to get the text  
// from the text nodes and CDATA sections  
item\_mc.species\_txt.text = species.firstChild.nodeValue;  
item\_mc.main\_btn.location\_text = location.firstChild.nodeValue;  
item\_mc.main\_btn.header\_text = header.firstChild.nodeValue;  
// set the onRelease of the item button to the DisplayInfo function  
item\_mc.main\_btn.onRelease = DisplayInfo;  
}

} while (currItem = currItem.nextSibling); // continue loop if more items exist after current  
}

// manage XML  
// create new XML object instance, remembering to ignore white space  
var squirrel\_xml = new XML();  
squirrel\_xml.ignoreWhite = true;  
// define an onLoad to create our location menu when the XML has successfully loaded.  
squirrel\_xml.onLoad = function(success){  
if (success) CreateMenu(this);  
else trace(“Error loading XML file”); // no success? trace error (wont be seen on web)  
}  
// load the xml file!  
squirrel\_xml.load(“squirrel\_finder.xml”);[/AS]my XML file:

```auto
<?xml version="1.0" ?>
<menu>
<menuitems sourceurl="[http://spot.colorado.edu/~halloran/sqrl.html](http://spot.colorado.edu/~halloran/sqrl.html)">
<item type="squirrel">
<species>Cybercitys investors sell out</species>
<location>
	<![CDATA[The newspaper Borsen, wrote last day, that Cybercitys investors was planning to sell out, big shares of their stocks in Cybercity]]>
</location>
<tester>This is my header text</tester>
</item type="squirrel">........

```

Just some stupid, and NON real news
