# XML Menu - Add Click Event

**URL:** <https://forum.kirupa.com/t/xml-menu-add-click-event/290314>\
**Category:** flash\
**Created:** [June 12, 2009, 3:54pm UTC](https://forum.kirupa.com/t/xml-menu-add-click-event/290314 "2009-06-12T15:54:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gphilly77](https://avatars.discourse-cdn.com/v4/letter/g/5e9695/32.png) [@gphilly77](https://forum.kirupa.com/u/gphilly77)\
**Post date:** [June 12, 2009, 3:54pm UTC](https://forum.kirupa.com/t/xml-menu-add-click-event/290314/1 "2009-06-12T15:54:16Z")

</div>

I’m having a major brain fog right now…I’m trying to add a click event for each menu item that is loaded from an XML file.

See code below:

function xmlLoaded(event:Event):void  
{  
xml = XML(event.target.data);  
xmlList = xml.children();  
for (var i:int=0; i\<xmlList.length(); i++)  
{  
var logo:Logo= new Logo(xmlList\*.imgPath);  
arrayImg.push(thumb);  
thumb.buttonMode = true;

```
imgURL = xmlList*.imgURL.toString();
arrayImg*.addEventListener(MouseEvent.CLICK, logoOnClick);
arrayImg*.y = 70;
arrayImg*.x = (i*100)+45;
logoContainer.addChild(logo);

```

function logoOnClick(event:MouseEvent):void  
{  
trace(imgURL);  
}  
}  
}

So basically everytime a click event occurs on a menu item, the related url from the xml file will be called. However the trace(imgURL) only shows the last item loaded from the XML file which makes sense.

I just can’t see how to modify the code so the unique url is associated with each unique menu item click event.

Thx a million
