# Custom Event and variable parameters count

**URL:** https://forum.kirupa.com/t/custom-event-and-variable-parameters-count/306644
**Category:** flash
**Created:** [March 18, 2010, 9:32pm UTC](https://forum.kirupa.com/t/custom-event-and-variable-parameters-count/306644 "2010-03-18T21:32:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Talei](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@Talei](https://forum.kirupa.com/u/Talei)
#### Post date: [March 18, 2010, 9:32pm UTC](https://forum.kirupa.com/t/custom-event-and-variable-parameters-count/306644/1 "2010-03-18T21:32:05Z")

</div>

Hello,  
This is more a question then a problem, so excuse me if I post it in a wrong category.  
What I want to know is: is it possible to create custom event with variable arguments count? I ask this because currently I use anonymous functions on events with variable parameters count to pass arguments to appropriate function, i.e:

```auto
addEventListener( MouseEvent.ROLL_OVER, function(evt:MouseEvent):void{mTBGp( pX, pY, l_w, l_h, isDone )}, false, 0, false );
addEventListener( MouseEvent.ROLL_OUT, function(evt:MouseEvent):void{mTBGe( pX, pY, l_w, l_h )}, false, 0, false );

```

and I don’t want to do that because of weakReference.  
Please share You knowledge to this additions questions:

1. From what I know if I set weakReference to true with anonymous function on in addEventListener GarbageCollector will delete them (and indeed I can see that my code stops to work on random, due to GC “kickin in”)
2. When i delete my Object with addEventListener( weakReference = false ) the memory used by addEventListener is not freed ( unconfirmed, please elaborate on that subject also)  
That’s why, from My point of view, usage of custom event is best, but unfortunately I use many addEventListeners with variable parameters count so (in above example 2 listeners. one 5 arg, second 4 arg) is there a way to do something like this? To write event that will take x parameters of any type?

Thank You far any advise or info.  
Best regards
