# \[AS3\] Pass variable with addEventListener

**URL:** https://forum.kirupa.com/t/as3-pass-variable-with-addeventlistener/216887
**Category:** flash
**Created:** [February 21, 2007, 10:18am UTC](https://forum.kirupa.com/t/as3-pass-variable-with-addeventlistener/216887 "2007-02-21T10:18:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Knorcedger](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/knorcedger/32/1244_2.png) [@Knorcedger](https://forum.kirupa.com/u/Knorcedger)
#### Post date: [February 21, 2007, 10:18am UTC](https://forum.kirupa.com/t/as3-pass-variable-with-addeventlistener/216887/1 "2007-02-21T10:18:02Z")

</div>

I want to pass a variable to a function called by an addEventListener, but when i try to do it, it doesnt pass the event itself to the function. For example, i have

```auto
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, me);

and...

private function me(event:ContextMenuEvent):void {

```

and i try something like that, but it says that it expected 2 variables

```auto
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, me(fire));

and...

private function me(event:ContextMenuEvent, fire:Number):void {

```

so, i try this one

```auto
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, me(ContextMenuEvent, fire));

and...

private function me(event:ContextMenuEvent, fire:Number):void {

```

but is says “Type Coercion failed: cannot convert flash.events::ContextMenuEvent$ to flash.events.ContextMenuEvent.”

I dont know what else to try. Can somebody please help me?

Thanx
