# Passing variables in event listeners

**URL:** <https://forum.kirupa.com/t/passing-variables-in-event-listeners/235739>\
**Category:** flash\
**Created:** [August 14, 2007, 11:53am UTC](https://forum.kirupa.com/t/passing-variables-in-event-listeners/235739 "2007-08-14T11:53:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlowenberg](https://avatars.discourse-cdn.com/v4/letter/r/8491ac/32.png) [@rlowenberg](https://forum.kirupa.com/u/rlowenberg)\
**Post date:** [August 14, 2007, 11:53am UTC](https://forum.kirupa.com/t/passing-variables-in-event-listeners/235739/1 "2007-08-14T11:53:45Z")

</div>

Hey guys,

I’m aware that there has been a bunch of discussion on this already here and on other forums, but I just don’t see how the custom AS3 events can help me with this one. I’m probably missing something obvious.

I have a function that says this:

```auto

objectToSearchIn = myMovieClip;
pixelColour = 0xff0000;
position = myRectangle;
searchPixel(objectToSearchIn, pixelColour, position);

```

Then, in the searchPixel function:

```auto

public function searchPixel (myMovieClip:pixelRing, colour:uint, position:Point):void {
     myMovieClip.addEventListener(Event.ENTER_FRAME, myEnterFrameFunction);
}

```

My understanding is that in order to pass the variables that need to get to the function myEnterFrameFunction, I need to create a custom event handler. But in order to call this custom event handler onEnterFrame, I need to use a standard ENTER\_FRAME to call my custom handler. Because the ENTER\_FRAME cannot take variables, I lose my parameters during that step.

Have I missed something big here? Is there a simple but elegant way to get those variables into my enterframe function? I’d rather not start using class level variables if I can help it.

Thanks!

Rich.
