# Arguments to eventListener?

**URL:** <https://forum.kirupa.com/t/arguments-to-eventlistener/252975>\
**Category:** Uncategorized\
**Created:** [February 26, 2008, 2:04am UTC](https://forum.kirupa.com/t/arguments-to-eventlistener/252975 "2008-02-26T02:04:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrickjv](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@patrickjv](https://forum.kirupa.com/u/patrickjv)\
**Post date:** [February 26, 2008, 2:04am UTC](https://forum.kirupa.com/t/arguments-to-eventlistener/252975/1 "2008-02-26T02:04:37Z")

</div>

I have xml with button list info, name and link

```auto
 
<?xml version="1.0" encoding="utf-8"?>
<menulist>
<menuitem main="true" >
<itemname>home</itemname>
<link>test1.swf</link>
</menuitem>
<menuitem>
<itemname>about</itemname>
<link>test2.swf</link>
</menuitem>
</menulist>

```

I’ve managed to generate a list with buttons. Using a for loop. While generating them I’m also adding an eventlistener

```auto
 
for each(var value:XML in myXML.menuitem) {
obj[j] = new listmenuitem();
menucontainer.addChild(obj[j]);
obj[j].y = j*itemheight;
obj[j].button.addEventListener(MouseEvent.CLICK, onClick);
j++;
}

```

which nicely performs it. At this moment however the onclick function uses one link only…

```auto
 
public var externalswf:URLRequest;
public var dolink:String = "[http://www.somedomain.com](http://www.somedomain.com/)";
 
public function onClick(event:MouseEvent):void{
externalswf = new URLRequest(dolink);
navigateToURL(externalswf, "_top");
}

```

Is there a way to pass the xml value to the function, sort of like “delegate”?  
Or an eays alernative?

P.
