# Flex dynamic functions? EventDispatchers?

**URL:** <https://forum.kirupa.com/t/flex-dynamic-functions-eventdispatchers/247817>\
**Category:** flash\
**Created:** [December 30, 2007, 9:23am UTC](https://forum.kirupa.com/t/flex-dynamic-functions-eventdispatchers/247817 "2007-12-30T09:23:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Z11](https://avatars.discourse-cdn.com/v4/letter/z/97f17d/32.png) [@Z11](https://forum.kirupa.com/u/Z11)\
**Post date:** [December 30, 2007, 9:23am UTC](https://forum.kirupa.com/t/flex-dynamic-functions-eventdispatchers/247817/1 "2007-12-30T09:23:14Z")

</div>

I have noticed that in flex you can have something and setup a

\<object click=“runthisfunction()”\> and onclick it will run the function, however you can also pass variables like.

\<object click=“runthisfunction(‘hey there’)”\>

Right now, I have is so my custom event dispatcher runs a function, and that function tries to run a dynamic function like.

onClose:Function = functionname;

public function clicked(e:Event):void  
{  
onClose();  
}

And it works fine, however I would really like to be able to pass variables into it, the same way flex does. It’s so much smoother.

so somewhere In My code I would do

onClose = functionname(‘variable’);

(Though I know that would theoretically ‘RUN’ the function name, how would I acheive the same effect?)

The best I could think of so far was to do an  
onClose = functionname;  
params = parameters;

and later

event{  
onClose(params);  
}
