Scope/organization problem

I’m trying to make a portfolio that has two “layers”. The first layer is that you select a work on a menu which is generated by xml/AS. The second layer is that once a work has been selected, there are five images under one piece of work that users can flip and browse through. The problem is that I can’t get the navigation of the imagebrowser to realise which work has been selected!
Could someone tell me how I can tap in to the current variable selected by the user?

The code:
[actionscript]
var item_spacing = 25;
var item_count = 0;
var img = [];
var imgfldr = [];
var imgurl = [];
var work_id = [];
var menulist = [];
var frstdesc = [];
var frstimgurl = [];
var desc = [];
var i = 0;
var q = 0;
var p = 0;
function CreateMenu() {
//below: the condition that makes the repetition of going through all works
works = portfolio_xml.firstChild.firstChild.childNodes;
for (i=0; i<works.length; i++) {
//MENU LOOP
if (works*.parentNode.attributes.cup == “UrbDes”) {
//note to self: works here light look like array, but is actually xml string.
menulist* = menu.attachMovie(“projects_list”, “item”+i, i);
menulist*._y = iitem_spacing;
var imgtotal = works
.childNodes[1].childNodes.length;
work_id* = portfolio_xml.firstChild.firstChild.childNodes*;
imgfldr* = work_id*.childNodes[1].attributes.puc;
for (q=0; q<imgtotal; q++) {
img[q] = q+1;
frstdesc* = work_id*.childNodes[1].childNodes[0].firstChild;
desc[q] = work_id*.childNodes[1].childNodes[q].firstChild;
frstimgurl* = “images/”+imgfldr*+"/image"+img[0]+".jpg";
}
imgurl* = “images/”+imgfldr*;
// imgurl doesn’t work, lists all arrays instead of only the currently selected one.
menulist*.firstdesc = frstdesc*;
menulist*.firstimg = frstimgurl*;
menulist*.project_name.text = works*.firstChild.firstChild;
}
menulist*.onRelease = function() {
imageholder.loadMovie(this.firstimg, 1);
desctop.text = this.firstdesc;
titletop.text = this.project_name.text;
};
prev_btn.onRelease = function() {
if (p>0) {
p–;
imageholder.loadMovie(imgurl+"/image"+(p+1)+".jpg");
//imgurl error reflects here
desctop.text = “prev”+(p+1);
//to be solved when menu/browse communication is better
}
};
next_btn.onRelease = function() {
if (p<(imgtotal-1)) {
p++;
imageholder.loadMovie(imgurl+"/image"+(p+1)+".jpg");
//imgurl error reflects here
desctop.text = “next”+(p+1);
//to be solved when menu/browse communication is better
}
};
}
//end of condition of going through all works
firstImage();
}
//end of condition of generating the portfolio
// prev-nextImage functions not in use.
function prevImage() {
if (p>0) {
p–;
imageholder.loadMovie(“images/”+imgfldr*+"/image"+p+".jpg");
desctop.text = “prev”+p;
}
}
function nextImage() {
if (p<4) {
p++;
imageholder.loadMovie(“images/”+imgfldr*+"/image"+p+".jpg");
desctop.text = “next”+p;
}
}
function firstImage() {
imageholder.loadMovie(this.frstimgurl[0], 1);
desctop.text = this.frstdesc[0];
titletop.text = menulist[0].project_name.text;
}
//---------------------------------------
var portfolio_xml = new XML();
portfolio_xml.ignoreWhite = true;
portfolio_xml.onLoad = function(success) {
if (success) {
CreateMenu();
} else {
trace(“Error loading XML file”);
}
};
portfolio_xml.load(“portfolio.xml”);
//---------------------------------------
[/actionscript]