# Scope/organization problem

**URL:** <https://forum.kirupa.com/t/scope-organization-problem/196017>\
**Category:** flash\
**Created:** [August 4, 2006, 4:52pm UTC](https://forum.kirupa.com/t/scope-organization-problem/196017 "2006-08-04T16:52:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akilah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/akilah/32/1544_2.png) [@Akilah](https://forum.kirupa.com/u/Akilah)\
**Post date:** [August 4, 2006, 4:52pm UTC](https://forum.kirupa.com/t/scope-organization-problem/196017/1 "2006-08-04T16:52:15Z")

</div>

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 = i_item\_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]
