# Passing a function as an argument

**URL:** <https://forum.kirupa.com/t/passing-a-function-as-an-argument/39869>\
**Category:** flash\
**Created:** [January 12, 2004, 9:19am UTC](https://forum.kirupa.com/t/passing-a-function-as-an-argument/39869 "2004-01-12T09:19:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daw0lverine](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@daw0lverine](https://forum.kirupa.com/u/daw0lverine)\
**Post date:** [January 12, 2004, 9:19am UTC](https://forum.kirupa.com/t/passing-a-function-as-an-argument/39869/1 "2004-01-12T09:19:00Z")

</div>

Hi everybody,

My question is slightly complicated : I have a global function that does some stuff with a LoadVars in it.  
I 90% of the cases, the onLoad reference of the LoadVars is the same, but I sometimes need to do something else when the LoadVars is loaded.

Is there a way to pass a function reference to a function so that I could do something like that :

[AS]  
\_global.function myFunction(maybeFunction)  
{  
myLoadVars = new LoadVars();  
if (maybeFunction != undefined)  
myLoadVars.onLoad = maybeFunction;  
else  
myLoadVars.onLoad = function(ok)  
{  
[…]  
}

myLoadVars.load("…");  
}  
[/AS]

If not, any other Idea ?
