Hi There,
I am trying to get a movie clip to pop up when i press a button, when the clip pops up it displays certain information taken from an xml document. I want to be able to display the info held in the first part of the xml to display when i press the 1st button, the info in the 2nd part of the xml to display when i press the 2nd button and so on. However it always seems to loop to the last item in the xml list. I have attached a simplified version of my problem to this posting, please help me someone I am going mad trying to get it to work. I have also posted my actionscript code below:
import mx.xpath.XPathAPI;
var popup_xml:XML = new XML();
var popupArray:Array = new Array;
var popupNames:Array = new Array;
popup_xml.ignoreWhite = true;
popup_xml.onLoad = popUpFunction;
popup_xml.load(“xml/popup.xml”);
var popupPath:String = “/content/products/pop”;
function popUpFunction(success:Boolean) {
if (success) {
popupArray = XPathAPI.selectNodeList(this.firstChild, popupPath);
popupBuilder(popupArray);
} else {
trace(“Error: XML not successfully loaded”);
}
};
function popupBuilder(popupArray) {
for (var i:Number = 0; i<popupArray.length; i++) {
var imageName:String;
imageName = popupArray*.childNodes[0].firstChild;
var titleName:String;
titleName = popupArray*.childNodes[1].firstChild;
var mainBody:String;
mainBody = popupArray*.childNodes[2].firstChild;
image_mc.loadMovie(imageName);
title_txt.htmlText = titleName;
body_txt.htmlText = mainBody;
}
}
Thanks
James