all groups > flash (macromedia) > april 2005 >
You're in the

flash (macromedia)

group:

Dynamic function call


Dynamic function call steamboy
4/10/2005 8:10:40 PM
flash (macromedia): Hi, Is there a way to call a function using a variable? I have an array full
of strings like so: 0:hello 1:bonjour 2:konnichiwa 3:gutentag etc. I want to
then recurse through this list and if there is a function with that name, call
it. thanks in advance, Owen
Re: Dynamic function call NSurveyor
4/10/2005 9:04:15 PM
func_array = ['hello','bonjour','konnichiwa','gutentag'];
for(var i = 0;i<func_array.length;i++){
if(typeof(this[func_array[ i ]])=='function'){
this[func_array[ i ]]();
}
}

If you want me to explain it, feel free to ask! :)
AddThis Social Bookmark Button