im simply trying to load in the first xml item on start-up. The xml has title, description and image paths…heres the code for those who are interested:
imagetextbox_txt._visible=false;
imagetextbox2_txt._visible=false;
imagetextbox3_txt._visible=false;
// define basic variables for setting up the menu
var item_spacing = 16; // 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 == "advertising") {
// create variables for our elements
var itemtitle = items*.firstChild; // same as items*.childNodes[0]
var description = items*.childNodes[1]; // second child node
var imagepath = items*.childNodes[2]; // third child node
var imagepath2 = items*.childNodes[3]; // third child node
var imagepath3 = items*.childNodes[4]; // third child node
var firstitem = items[0].childNodes[2]; // first item
// 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.textclip.species_txt.text = itemtitle.firstChild.nodeValue;
item_mc.main_btn.location_text = description.firstChild.nodeValue;
item_mc.main_btn.imagepath_txt = imagepath.firstChild.nodeValue;
item_mc.main_btn.imagepath2_txt = imagepath2.firstChild.nodeValue;
item_mc.main_btn.imagepath3_txt = imagepath3.firstChild.nodeValue;
firstitem_txt = firstitem.firstChild.nodeValue;
trace (imagepath.firstChild.nodeValue);
// set the onRelease of the item button to the DisplayInfo function
item_mc.main_btn.onRelease = DisplayInfo;
}
}
}
// manage XML
// create new XML object instance, remembering to ignore white space
var portfolio_xml = new XML();
portfolio_xml.ignoreWhite = true;
// define an onLoad to create our location menu when the XML has successfully loaded.
portfolio_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!
portfolio_xml.load(“portfolio.xml”);
// 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(){
imageHolder.gotoAndPlay(1);
fadeOutAndBack();
menu_mc._visible = true;
infobox_mc._visible = true;
infobox_mc.content_txt.text = this.location_text;
imagetextbox_txt.text=this.imagepath_txt;
imagetextbox2_txt.text=this.imagepath2_txt;
imagetextbox3_txt.text=this.imagepath3_txt;
//
imagetextbox_txt._visible=false;
imagetextbox2_txt._visible=false;
imagetextbox3_txt._visible=false;
imageHolder.morphContainer.loadMovie(imagetextbox_txt.text);
imageHolder.morphContainer2.loadMovie(imagetextbox2_txt.text);
imageHolder.morphContainer3.loadMovie(imagetextbox3_txt.text);
bannerMC._alpha=0;
}
function loadFirstItem(){
menu_mc._visible = true;
infobox_mc._visible = true;
infobox_mc.content_txt.text = this.location_text;
imagetextboxfirst_txt.text=firstitem_txt;
imageHolder.morphContainer.loadMovie(imagetextboxfirst_txt.text);
imageHolder.gotoAndPlay(1);
}
//loadFirstItem();
function fadeOutAndBack(){
imageHolder.alphaTo(0,1,“linear”);
imageHolder.onTweenComplete=function(){
if (imageHolder.alpha<1){
imageHolder.alphaTo(100,1,"linear");
}
}
}
stop();