# Function arguments with Listeners?

**URL:** <https://forum.kirupa.com/t/function-arguments-with-listeners/230737>\
**Category:** flash\
**Created:** [June 28, 2007, 4:29pm UTC](https://forum.kirupa.com/t/function-arguments-with-listeners/230737 "2007-06-28T16:29:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lonerhino](https://avatars.discourse-cdn.com/v4/letter/l/45deac/32.png) [@lonerhino](https://forum.kirupa.com/u/lonerhino)\
**Post date:** [June 28, 2007, 4:29pm UTC](https://forum.kirupa.com/t/function-arguments-with-listeners/230737/1 "2007-06-28T16:29:54Z")

</div>

Yikes, Sorry but I’m **really** having problems migrating to AS3 :puzzled:

A big conceptual hole I can’t seem to wrap my head around is how do you pass parameter arguments with listeners? Forget classes for right now - baby steps - I cannot even figure out the basics in calling functions on the timeline! All code on frame 1 of main.

Here’s my old style function with sample call

```auto
// Function to load items
function gearLoader(sItem,nSide):Void{

	this["btn" + sItem].onRelease = function(){
		mcItem.loadMovie(sItem + ".swf");
		mcItem._x = nSide;
		tDesc.text=lvItemDesc[sItem];
		tTitle.text=lvItemTitle[sItem];
		tTitle.setTextFormat(tfTitleFormat);
		mcProducts._alpha=30;
	}

}

//sample call
gearLoader(“goggles”, 244);

```

So now, in AS3, I set up my loader instance and register my button listeners.

[AS]var swfLoader:Loader = new Loader();  
var sRequest:URLRequest = new URLRequest(“boots.swf”);

//add to display list  
addChild(swfLoader);

//event handling - subscribe listeners  
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,handleImage);

btnRod.addEventListener(MouseEvent.CLICK, gearLoader);  
btnVest.addEventListener(MouseEvent.CLICK, gearLoader);  
btnWadeBoots.addEventListener(MouseEvent.CLICK, gearLoader);  
btnHat.addEventListener(MouseEvent.CLICK, gearLoader);  
btnHelmet.addEventListener(MouseEvent.CLICK, gearLoader);  
btnBoots.addEventListener(MouseEvent.CLICK, gearLoader);  
btnGoggles.addEventListener(MouseEvent.CLICK, gearLoader);  
btnGloves.addEventListener(MouseEvent.CLICK, gearLoader);

function handleImage(evtObj:Event):void{  
//set initial position onstage  
swfLoader.y = 56;  
swfLoader.x = 244;  
}[/AS]

So how do I pass the necessary parameters to the function below in a reasonably simple way? I’ve used _event.target.name_ of a listener event object in other AS3 Projects to determine button clicked. . .but again, that does not help me with parameters.

New Function  
[AS]function gearLoader(sItem:String, nSide:Number):void{

```
//dim Bitmap
mcProducts.alpha = 30;

//position clip
swfLoader.x = 244;

//fetch a swf
swfLoader.load(new URLRequest(sItem + ".swf"));

```

}[/AS]

I’ve looked through help files & articles but I’m certain I’m missing something simple here. Thanks Much!
