# \[xml\] array not recognized in function

**URL:** <https://forum.kirupa.com/t/xml-array-not-recognized-in-function/195861>\
**Category:** programming\
**Created:** [August 3, 2006, 4:57pm UTC](https://forum.kirupa.com/t/xml-array-not-recognized-in-function/195861 "2006-08-03T16:57:46Z")\
**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 3, 2006, 4:57pm UTC](https://forum.kirupa.com/t/xml-array-not-recognized-in-function/195861/1 "2006-08-03T16:57:46Z")

</div>

Could someone please explain to me why my array is not working? imgurl[]; is an array that is used in the menu function, but it seems that the variable i cannot be recognized outside the CreateMenu function… how come?

```php

var item_spacing = 25;
var item_count = 0;
var img = [];
var imgfldr = [];
var imgurl = [];
var work_id = [];
var menulist = [];
var i = 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") {
            var title = works*.firstChild.firstChild;
            menulist* = menu.attachMovie("projects_list", "item"+i, i);
            menulist*._y = i*item_spacing;
            menulist*.project_name.text = title;
            var images = works*.childNodes[1].childNodes;
            var imgtotal = images.length;
            var q = 0;
            img[q] = q+1;
            work_id* = portfolio_xml.firstChild.firstChild.childNodes*;
            imgfldr[q] = work_id*.childNodes[1].attributes.puc;
            imgurl* = "images/"+imgfldr+"/image"+img+".jpg";
        }
        trace (imgurl[0]);
//HERE IS MY PROBLEM.
        menulist*.onRelease = function() {
            imageholder.loadMovie(imgurl*, 1);  
        }
    }
    //end of condition of going through all works 

}
//end of condition of generating the portfolio
function firstImage() {
    imageholder.loadMovie(imgurl[0], 1);
// desctop.text = desc[0];
}

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");

```
