PDA

View Full Version : Passing a function as an argument



daw0lverine
January 12th, 2004, 04:19 AM
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 :


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

myLoadVars.load("...");
}


If not, any other Idea ?

daw0lverine
January 12th, 2004, 04:36 AM
works. sometimes I ought to try before talking :D