# Passing variables from eventListener to function AS3

**URL:** <https://forum.kirupa.com/t/passing-variables-from-eventlistener-to-function-as3/227507>\
**Category:** Uncategorized\
**Created:** [May 30, 2007, 10:06pm UTC](https://forum.kirupa.com/t/passing-variables-from-eventlistener-to-function-as3/227507 "2007-05-30T22:06:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mediashock](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mediashock](https://forum.kirupa.com/u/Mediashock)\
**Post date:** [May 30, 2007, 10:06pm UTC](https://forum.kirupa.com/t/passing-variables-from-eventlistener-to-function-as3/227507/1 "2007-05-30T22:06:23Z")

</div>

hey guys,

I am stuck in AS3

I got a function with For loop… that created instances of a button… … now when i press one of these buttons i want to load up an image… so i used the code below to call the function when you click on the menu item.

```auto
portMenu.addEventListener(MouseEvent.CLICK, displayPort);

```

the for loop also includes var Title:String = mainXML…item\*…IMAGE.text();

then here is the function that gets called when the button is pressed…

```auto
function displayPort(event:MouseEvent){
	 var ldr:Loader = new Loader();
	 var urlReq:URLRequest = new URLRequest(" I WANT TO INSERT IMAGE VALUE HERE ");
	 ldr.load(urlReq);
	 displayMC.addChild(ldr); 
	 ldr.x = 20;
	 ldr.y = 100;
}

```

can anyone help thanks
