Running function from a string with unlimited parameters in as3

This is useful if you need to run a lot of different functions that are stored as strings:
 

var myFuncName:String = "myFunc";
var unlimitedParams:Array = new Array("a", "b", 1, 2);
 
 
function myFunc(... params):void
{
    trace(params.length + ": " + params);
}
 
 
this[myFuncName].apply(this, unlimitedParams);//this will run the function

Leave a Reply


× seven = 21

Resources
Running function from a string with …
Modo Scripts – Join and Separate
Modo Custom Toolbar I
Knife Screen in Modo
Wallpaper Set I
Move/scale on two axes in Blender
Set Draw Mode on multiple objects in…
Texture Set 1
Joy No.4 Wallpaper
Joy No.3 Wallpaper
Joy No. 2 Wallpaper
Joy No.1 Wallpaper
Tileable Bark Texture
Glow and DOF with nodes in Blender -…
Yafaray not showing in Blender – Sol…
Tutorials
Running function from a string with …
Move/scale on two axes in Blender
Set Draw Mode on multiple objects in…
Glow and DOF with nodes in Blender -…
Yafaray not showing in Blender – Sol…