# Functions passed as arguments to other functions

**URL:** https://forum.kirupa.com/t/functions-passed-as-arguments-to-other-functions/168739
**Category:** Uncategorized
**Created:** [November 9, 2005, 5:03pm UTC](https://forum.kirupa.com/t/functions-passed-as-arguments-to-other-functions/168739 "2005-11-09T17:03:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jwopitz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jwopitz/32/1556_2.png) [@jwopitz](https://forum.kirupa.com/u/jwopitz)
#### Post date: [November 9, 2005, 5:03pm UTC](https://forum.kirupa.com/t/functions-passed-as-arguments-to-other-functions/168739/1 "2005-11-09T17:03:02Z")

</div>

FLASH MX 2004 - AS2.0

I have a function with 4 necessary arguments (aka parameters) in order to perform the actions. I would like to have the ability to pass the same function to itself as an argument (sort of like a recursive function) along with its arguments. Basically I want to “base” to engage an onMotionFinished event handler if there is another function passed as an argument. Something like…

```php
   function base (arg1, arg2, arg3 arg4, {arg5:another function, arg6:arg5's arg).....}){
  //do the stuff
  instructions = blahblahblah
  if (arg5 is present){
     instructions.onEventHandler = function(){
         //perform function which is arg5...argN
     }
  }
 }

```

Would there be a way to use listeners to do this or the AsBroadcaster? Thanks
