# Initial call for a Function

**URL:** https://forum.kirupa.com/t/initial-call-for-a-function/298936
**Category:** Uncategorized
**Created:** [October 27, 2009, 1:45pm UTC](https://forum.kirupa.com/t/initial-call-for-a-function/298936 "2009-10-27T13:45:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![CayoHueso](https://avatars.discourse-cdn.com/v4/letter/c/8e8cbc/32.png) [@CayoHueso](https://forum.kirupa.com/u/CayoHueso)
#### Post date: [October 27, 2009, 1:45pm UTC](https://forum.kirupa.com/t/initial-call-for-a-function/298936/1 "2009-10-27T13:45:07Z")

</div>

Hi,

I have the following code:

```auto

for(var i:int = 0; i<buttons.length; i++){
  buttons*.addEventListener(MouseEvent.CLICK, myFunction);
}

function myFunction(e:MouseEvent):void{
 if(e.target.parent == btnContainerArray*)){
  trace("does something");
 }
}

```

I would like to add a code that would add an initial call to the function myFunction, but because it is listening for a MouseEvent, it has to wait until a MouseEvent happens (CLICK)

I thought that I could add a parameter to a function call like this:

```auto

myFunction(e:Event, buttons[0]);

```

but that did not work.

Could you please share some advice? Thanks
