[LEFT]Hello everybody…
I’m working on a project in which viewers can see a map with state parks highlighted as buttons. onRollOver a caption pops up displaying the name of the park, acreage and feet of shoreline. onRelease a movie clip is loaded into a holder. The data is being stored in an XML file integrated with a content management system… The AS for displaying the caption works fine, but I cannot get the XML data to display in the dynamic text fields contained within the caption MC. There are 37 buttons that need to display the popup and I am looking for some advice on how I can effectively navigate the XML nodes and display the data accordingly in the text fields. Below is my current code, I have not yet added the onRelease function because, I’m pretty sure that i’m going to run into the same issue that i’m having with the caption popup… The last obstacle will be that the caption is only displaying 3 of the child nodes, while the MC loaded into the holder will be displaying 7 of the child nodes. I’m guessing that using the attributes property and modifying my XML would be the easiest… but i’m relatively new to integrating XML data into Flash and am trying to minimize the work that I create for myself. If anybody could point me in the right direction, i would be immensly appreciative. Pura Vida. ~Anthony
//1st frame AS for the first button, and loading XML
var xmlPath = (“xml_mapinfo.xml”);
/////////////////////////////////////
var locID:Number = 0;
/////////////////////////////////////
startDrag(this.caption, true);
/////////////////////////////////////
btn_1.onRollOver = function (){
set (“locID”, 1);
RollOver();
ShowData();
}
btn_1.onRollOut = function (){
RollOut();
}
/////////////////////////////////////
function RollOver (){
trace(“rollOver occured”);
_root.x = 1;
this.caption.words = “Word!”;
trace ("Location ID = " + locID);
}
function RollOut (){
trace(“rollOut occured”);
set (“locID”, 0);
_root.x = 0;
this.caption.words= " ";
trace ("Location ID = " + locID);
}
/////////////////////////////////////
function ShowData(){
this.caption.location_txt.text=contentMain.owner[‘1’];
this.caption.acreage_txt.text=contentMain.acreage[‘1’];
this.caption.acreage_txt.text=contentMain.shorelin e[‘1’];
}
/////////////////////////////////////
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
owner = [];
interest = [];
town = [];
established = [];
acreage = [];
shoreline = [];
thumbnail = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
owner* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
interest* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
town* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
established* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
acreage* = xmlNode.childNodes*.childNodes[4].firstChild.nodeValue;
shoreline* = xmlNode.childNodes*.childNodes[5].firstChild.nodeValue;
thumbnail* = xmlNode.childNodes*.childNodes[6].firstChild.nodeValue;
}
} else {
content = “file not loaded!”;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(this.xmlPath);
//AS on actual caption MC
//////////////////////////////
onClipEvent (enterFrame) {
if (_root.x==1) {
this._alpha = 80;
} else {
this._alpha = 0;
}
}
_[/LEFT]